/* ═══════════════════════════════════════════════════════════════════
   SÉRAGONE — Design System Forge-Haute
   ═══════════════════════════════════════════════════════════════════
   Doctrine 18/06 : esthétique noble, gradient noir-or, Cinzel pour titres.
   Règle perf : aucune animation infinie sur élément hors viewport.
   Règle perf : backdrop-filter réservé aux overlays uniquement.
   ═══════════════════════════════════════════════════════════════════ */

/* — Polices — */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&display=swap');

/* — Design tokens — */
:root {
  /* Fonds */
  --bg-1: #1a0a0a;
  --bg-2: #2a1210;
  --bg-card: rgba(212,168,83,0.08);
  --bg-card-strong: rgba(212,168,83,0.15);

  /* Or */
  --gold: #d4a853;
  --gold-soft: #e8d5b0;
  --cream: #a89878;
  --dim: #9b8e6e;

  /* Texte */
  --text: #e8d5b0;
  --text-strong: #f5d790;
  --text-soft: #a89878;

  /* Sémantique */
  --success: #22c55e;
  --alert: #e87a78;
  --info: #7cf;
  --cosmos: #a87cf5;
  --btc: #f7931a;

  /* Bordures */
  --border-soft: rgba(212,168,83,0.2);
  --border: rgba(212,168,83,0.4);
  --border-strong: #d4a853;

  /* Tailles */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  /* Espacements */
  --gap-1: 0.4rem;
  --gap-2: 0.8rem;
  --gap-3: 1.2rem;
  --gap-4: 1.8rem;
}

/* — Reset — */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  background: linear-gradient(165deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: clamp(0.95rem, 2.6vw, 1.15rem);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* — Layout principal — */
main#page-content {
  padding: 0.8rem 0.7rem calc(5.5rem + env(safe-area-inset-bottom)) 0.7rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
@media (min-width: 600px) {
  main#page-content { padding: 1rem 0.9rem calc(5.5rem + env(safe-area-inset-bottom)) 0.9rem; }
}

/* — Header noble — (corrigé 21/06 : cadrage smartphone) */
.page-header {
  text-align: center;
  padding: 1rem 0.9rem 0.7rem;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}
.page-header .eyebrow {
  font-family: "Cinzel", serif;
  font-size: clamp(0.78rem, 2.3vw, 1.05rem);
  letter-spacing: 0.18em;
  background: linear-gradient(135deg, var(--gold), var(--text-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-transform: uppercase;
  overflow-wrap: break-word;
  word-wrap: break-word;
  display: block;
  padding: 0 0.3rem;
}
.page-header .title {
  font-family: "Cinzel", serif;
  font-size: clamp(1.15rem, 5vw, 1.8rem);
  color: var(--gold);
  margin-top: 0.4rem;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: break-word;
  word-wrap: break-word;
  padding: 0 0.3rem;
}
.page-header .subtitle {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  color: var(--cream);
  margin-top: 0.3rem;
  font-size: clamp(0.85rem, 2.5vw, 1.05rem);
  padding: 0 0.5rem;
  overflow-wrap: break-word;
  word-wrap: break-word;
  line-height: 1.45;
}

/* — Section h2 — */
h2.section {
  font-family: "Cinzel", serif;
  font-size: clamp(1.05rem, 4vw, 1.35rem);
  color: var(--gold);
  margin: 1.4rem 0 0.7rem;
  letter-spacing: 0.04em;
  font-weight: 600;
}

/* — Bloc chiffre noble — */
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 1.2rem 1rem;
  text-align: center;
  margin: 0.8rem 0;
}
.kpi .kpi-label {
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  color: var(--cream);
  text-transform: uppercase;
}
.kpi .kpi-value {
  font-family: "Cinzel", serif;
  font-size: clamp(1.5rem, 7vw, 2.2rem);
  font-weight: 700;
  color: var(--gold);
  margin-top: 0.4rem;
  line-height: 1.15;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.kpi .kpi-value.big {
  font-size: clamp(2rem, 10vw, 3.2rem);
  background: linear-gradient(135deg, var(--gold), var(--text-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.kpi .kpi-hint {
  color: var(--cream);
  font-size: 0.9rem;
  margin-top: 0.3rem;
  font-style: italic;
}

/* — Cascade Capital — */
.cascade {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 1.2rem;
  margin: 1rem 0;
}
.cascade-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed rgba(212,168,83,0.18);
  font-size: clamp(0.92rem, 2.5vw, 1.05rem);
  flex-wrap: wrap;
}
.cascade-row:last-of-type { border-bottom: none; }
.cascade-row .label {
  color: var(--text-soft);
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}
.cascade-row .value {
  font-family: "Cinzel", serif;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex: 0 0 auto;
}
.cascade-row.add .value { color: var(--success); }
.cascade-row.sub .value { color: var(--alert); }
.cascade-row.total {
  border-top: 2px solid var(--gold);
  border-bottom: none;
  margin-top: 0.6rem;
  padding-top: 1rem;
  font-size: 1.2rem;
}
.cascade-row.total .label { color: var(--gold); font-weight: 600; }
.cascade-row.total .value {
  font-size: 1.6rem;
  color: var(--gold);
}
.cascade-total-final {
  text-align: center;
  margin-top: 1.4rem;
  padding: 1.4rem;
  border-top: 2px solid var(--gold);
}
.cascade-total-final .label {
  font-family: "Cinzel", serif;
  font-size: 0.95rem;
  letter-spacing: 0.3em;
  color: var(--gold);
  text-transform: uppercase;
}
.cascade-total-final .value {
  font-family: "Cinzel", serif;
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold), var(--text-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-top: 0.4rem;
  white-space: nowrap;
  line-height: 1.15;
  word-wrap: break-word;
}

/* — Cartes — */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 0.9rem 0.85rem;
  margin: 0.6rem 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
@media (min-width: 600px) {
  .card { padding: 1rem; margin: 0.8rem 0; }
}
.card-title {
  font-family: "Cinzel", serif;
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 0.6rem;
  font-weight: 600;
}
.card-hint {
  font-size: 0.9rem;
  color: var(--cream);
  font-style: italic;
  margin-top: 0.4rem;
}

/* — Grille de cartes — */
.grid {
  display: grid;
  gap: 0.6rem;
}
.grid > * { min-width: 0; }   /* empêche débordement des flex/grid items */
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* — Liens contextuels — */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1.4rem 0;
  justify-content: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card-strong);
  border: 2px solid var(--border-strong);
  color: var(--gold);
  font-family: "Cinzel", serif;
  font-size: clamp(0.82rem, 2.4vw, 0.95rem);
  letter-spacing: 0.06em;
  padding: 0.55rem 0.9rem;
  border-radius: var(--r-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
  text-align: center;
}
.btn:hover { background: rgba(212,168,83,0.3); }
.btn.btn-soft {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--cream);
}

/* — Sémantique — */
.text-success { color: var(--success); }
.text-alert { color: var(--alert); }
.text-info { color: var(--info); }
.text-cosmos { color: var(--cosmos); }
.text-btc { color: var(--btc); }
.text-dim { color: var(--dim); }
.text-gold { color: var(--gold); }
.italic { font-style: italic; }
.center { text-align: center; }
.mt-2 { margin-top: 0.8rem; }
.mt-4 { margin-top: 1.6rem; }

/* — Tags — */
.tag {
  display: inline-block;
  background: var(--bg-card-strong);
  border: 1px solid var(--border);
  color: var(--gold);
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--r-sm);
}
.tag.tag-success { color: var(--success); border-color: var(--success); }
.tag.tag-alert { color: var(--alert); border-color: var(--alert); }
.tag.tag-info { color: var(--info); border-color: var(--info); }

/* — Pastille live — */
.live-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  background: var(--success);
  border-radius: 50%;
  margin-right: 0.3rem;
  animation: live-pulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(100, 180, 150, 0.7);
}
@keyframes live-pulse {
  0%   { opacity: 1;   box-shadow: 0 0 0 0   rgba(100, 180, 150, 0.7); }
  50%  { opacity: 0.55; box-shadow: 0 0 0 5px rgba(100, 180, 150, 0); }
  100% { opacity: 1;   box-shadow: 0 0 0 0   rgba(100, 180, 150, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

/* — Nav fixe en bas — Raphaël 21/06 : plus visible, icônes, indicateur de scroll — */
#nav-mount {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(26,10,10,0.985);
  border-top: 1px solid rgba(212,168,83,0.35);
  box-shadow: 0 -8px 25px rgba(0,0,0,0.55);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
/* Gradient fade gauche/droite : signale que la nav scrolle horizontalement */
#nav-mount::before,
#nav-mount::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: env(safe-area-inset-bottom);
  width: 24px;
  pointer-events: none;
  z-index: 2;
}
#nav-mount::before {
  left: 0;
  background: linear-gradient(90deg, rgba(26,10,10,0.95), transparent);
}
#nav-mount::after {
  right: 0;
  background: linear-gradient(-90deg, rgba(26,10,10,0.95), transparent);
}
#nav-mount nav {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
}
#nav-mount nav::-webkit-scrollbar { display: none; }
#nav-mount nav a {
  flex: 0 0 auto;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.6rem 0.85rem 0.5rem;
  color: var(--text-soft);
  text-decoration: none;
  font-family: "Cinzel", serif;
  letter-spacing: 0.05em;
  text-align: center;
  border-top: 3px solid transparent;
  text-transform: uppercase;
  min-width: 76px;
  min-height: 60px;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
#nav-mount nav a .nav-icon {
  font-size: 1.15rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}
#nav-mount nav a .nav-label {
  font-size: clamp(0.66rem, 2.1vw, 0.74rem);
  line-height: 1;
  font-weight: 600;
}
#nav-mount nav a:hover,
#nav-mount nav a:active {
  color: var(--gold);
  background: rgba(212,168,83,0.08);
}
#nav-mount nav a.active {
  color: var(--gold);
  border-top-color: var(--gold);
  background: linear-gradient(180deg, rgba(212,168,83,0.18), rgba(212,168,83,0.02));
}
#nav-mount nav a.active .nav-icon {
  filter: drop-shadow(0 1px 4px rgba(212,168,83,0.5));
}
/* Padding-bottom global pour que la nav ne cache pas le contenu */
body { padding-bottom: 80px; }

/* — Encart Liens avec les autres pages (Raphaël 21/06) — */
.liens-pages {
  background: rgba(168, 124, 245, 0.06);
  border-left: 3px solid var(--cosmos);
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.2rem;
  margin: 0 0 1.5rem 0;
}
.liens-pages .liens-titre {
  font-family: "Cinzel", serif;
  font-size: 0.82rem;
  letter-spacing: 0.2em;
  color: var(--text-soft);
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
.liens-pages .pourquoi {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.6;
  margin: 0.3rem 0 0.9rem;
}
.liens-pages .liens-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.liens-pages .liens-grid a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  background: rgba(212,168,83,0.09);
  border: 1px solid rgba(212,168,83,0.22);
  border-radius: 18px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.liens-pages .liens-grid a:hover,
.liens-pages .liens-grid a:active {
  background: rgba(212,168,83,0.22);
  border-color: var(--gold);
  color: var(--gold);
}
.liens-pages .liens-grid .pill-icon {
  font-size: 1rem;
}

/* — Header simple (sur chaque page) — */
#header-mount {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, var(--bg-1) 80%, transparent);
  padding: env(safe-area-inset-top) 0 0.4rem 0;
}
#header-mount .brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  gap: 0.5rem;
}
#header-mount .brand-name {
  font-family: "Cinzel", serif;
  font-size: 1.1rem;
  letter-spacing: 0.3em;
  background: linear-gradient(135deg, var(--gold), var(--btc));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}
#header-mount .brand-eye {
  font-size: 1.2rem;
  filter: drop-shadow(0 0 4px rgba(212,168,83,0.4));
}
#header-mount .brand-mode-switch {
  font-size: 1rem;
  text-decoration: none;
  color: var(--text-soft);
  background: rgba(212,168,83,0.12);
  border: 1px solid rgba(212,168,83,0.25);
  border-radius: 50%;
  width: 1.8rem;
  height: 1.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.4rem;
  transition: background 0.2s, color 0.2s;
}
#header-mount .brand-mode-switch:hover,
#header-mount .brand-mode-switch:active {
  background: rgba(212,168,83,0.28);
  color: var(--gold);
}

/* — Widget readiness sticky (Raphaël 21/06) — capacité passage réel — */
.readiness-sticky {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.9rem;
  margin: 0 0.6rem 0.4rem;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(212,168,83,0.2);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background 0.2s, border-color 0.3s;
}
.readiness-sticky:hover, .readiness-sticky:active {
  background: rgba(0,0,0,0.5);
}
.readiness-bar {
  flex: 1 1 auto;
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
}
.readiness-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--alert);
  border-radius: 4px;
  transition: width 0.8s ease, background 0.5s;
}
.readiness-fill.r-vert      { background: var(--success); }
.readiness-fill.r-vert_jaune{ background: linear-gradient(90deg, var(--success) 60%, #d4a853); }
.readiness-fill.r-orange    { background: #e29c4a; }
.readiness-fill.r-rouge     { background: var(--alert); }
.readiness-text {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex: 0 0 auto;
  font-family: "Cinzel", serif;
}
.readiness-text #readiness-pct {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-strong);
}
.readiness-text #readiness-statut {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-soft);
}

/* — Listes en encart — */
ul.clean {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.clean li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px dashed rgba(212,168,83,0.15);
  flex-wrap: wrap;
}
ul.clean li > * { min-width: 0; }
ul.clean li > :first-child {
  flex: 1 1 auto;
  word-break: break-word;
}
ul.clean li > :last-child {
  flex: 0 0 auto;
  text-align: right;
}
ul.clean li:last-child { border-bottom: none; }

/* — Code / mono — */
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92rem; }
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(0.55rem, 2vw, 0.85rem);
  line-height: 1.35;
  margin: 0;
  padding: 0.4rem 0;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  text-align: left;
  white-space: pre;
  color: var(--gold);
}
.card pre {
  display: block;
  margin: 0 auto;
}

/* — Paragraphes texte — */
p { margin: 0.5rem 0; }
p.intro {
  color: var(--cream);
  font-style: italic;
  font-size: 1.05rem;
  text-align: center;
  margin: 0.5rem auto 1rem;
  max-width: 50ch;
}

/* — Accessibilité réduction de mouvement — */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
