/* ═══════════════════════════════════════════════════════════════════
   SAPISAPI — CHARTE (tokens + composants partagés hors surface de jeu)
   De l'encre à l'ocre. Le fond est l'indigo de ce qu'on ignore ; l'ocre
   est le pigment de la paroi — la couleur du moment où l'on sait.
   Source de vérité : charte-graphique.html
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --ink:      #14172B;   /* fond — l'indigo de l'inconnu           */
  --ink-2:    #1E2340;   /* surface levée (cartes, options)        */
  --ink-3:    #2C3358;   /* bordures, séparateurs                  */
  --ink-4:    #3A4368;   /* bordure survolée                       */
  --bone:     #E8E2D4;   /* texte — os, parchemin                  */
  --bone-dim: #948FA6;   /* texte secondaire                       */

  --ochre:    #E6A23C;   /* LE pigment — juste, primaire           */
  --ochre-lo: #F0B255;
  --cyan:     #4CC9C0;
  --wrong:    #C4574E;   /* faux — terre de Sienne brûlée          */

  --display: 'Fraunces', Georgia, serif;
  --body:    'Public Sans', system-ui, sans-serif;

  --t-brand:  clamp(40px, 9vw, 68px);
  --t-streak: clamp(64px, 18vw, 108px);
  --t-h:      clamp(24px, 5vw, 36px);
  --t-body:   16px;
  --t-lg:     18px;
  --t-sm:     14px;
  --t-label:  11px;

  --step: 8px;
  --r: 4px;
  --r-lg: 8px;
  --read: 640px;
  --wide: 1080px;
  --tap: 52px;
  --step-side: 20px;

  --focus: 0 0 0 2px var(--ink), 0 0 0 4px var(--ochre);
}
@media (min-width: 640px)  { :root { --step-side: 32px; } }
@media (min-width: 1024px) { :root { --step-side: 48px; } }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--body);
  font-size: var(--t-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* La lueur de torche — le seul geste atmosphérique. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(120% 60% at 50% -10%, rgba(230,162,60,0.10), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.page { position: relative; z-index: 1; max-width: var(--wide); margin: 0 auto;
        padding: calc(var(--step) * 3) var(--step-side) calc(var(--step) * 10); }
.page.narrow { max-width: var(--read); }
/* ⚠️ Le gabarit COMMUN à toute page authentifiée (derrière le menu du haut) —
   une seule largeur, pour que la barre de nav se comporte pareil partout. */
.page.app { max-width: 960px; }

/* ═══ Typo ═══ */
.brand {
  font-family: var(--display);
  font-variation-settings: 'SOFT' 60, 'WONK' 1, 'opsz' 144;
  font-weight: 700; line-height: 0.95; letter-spacing: -0.03em;
}
.brand em { font-style: normal; color: var(--ochre); }

h1.section, h2.section {
  font-family: var(--display);
  font-variation-settings: 'SOFT' 40, 'WONK' 1, 'opsz' 72;
  font-weight: 600; font-size: var(--t-h); letter-spacing: -0.02em;
}

.eyebrow {
  font-size: var(--t-label); font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-dim);
}
.lede  { color: var(--bone-dim); font-size: var(--t-lg); }
.muted { color: var(--bone-dim); }

/* ═══ Topbar ═══ */
/* ⚠️ UNE seule définition — trois pages la redéfinissaient chacune un peu
   différemment (bordure, alignement, retour à la ligne). Résultat : le menu
   ne se comportait pas pareil d'une page à l'autre. Tout vit ici désormais. */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: calc(var(--step) * 5);
  border-bottom: 1px solid var(--ink-3); padding-bottom: 14px;
}
.topbar .brand { font-size: 26px; text-decoration: none; color: var(--bone); }
.topbar nav {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 18px; row-gap: 6px; flex-wrap: wrap;
}
.topbar a, .topbar button {
  color: var(--bone-dim); font-family: var(--body); font-size: var(--t-sm);
  background: none; border: 0; cursor: pointer; text-decoration: none;
  white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center;
}
.topbar a:hover, .topbar button:hover { color: var(--bone); }

/* Le bouton "menu" — masqué sur grand écran, où la nav tient sur la barre. */
.topbar .nav-toggle {
  display: none; width: 44px; height: 44px; flex: 0 0 auto;
  align-items: center; justify-content: center;
  border: 1px solid var(--ink-3); border-radius: var(--r);
  background: none; color: var(--bone); font-size: 20px; cursor: pointer;
}

/* ⚠️ En dessous de 720px, 9 liens ne tiennent plus sur une ligne : ils
   repoussaient tout le contenu utile (streak, "Défier quelqu'un"…) hors de
   l'écran. La nav se replie derrière le bouton, en liste verticale. */
@media (max-width: 720px) {
  .topbar .nav-toggle { display: inline-flex; }
  .topbar { flex-wrap: wrap; }
  .topbar nav {
    display: none; width: 100%; flex-basis: 100%;
    flex-direction: column; align-items: stretch; gap: 2px;
    margin-top: 14px; order: 3;
  }
  .topbar nav.open { display: flex; }
  .topbar nav a, .topbar nav button {
    width: 100%; justify-content: flex-start;
    padding: 0 4px; border-radius: var(--r);
  }
  .topbar nav a:hover, .topbar nav button:hover { background: var(--ink-2); }
  .topbar nav form { width: 100%; }
}

/* ═══ Boutons ═══ */
.btn {
  min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--body); font-size: var(--t-lg); font-weight: 600;
  border-radius: var(--r); border: 1px solid transparent;
  padding: 0 24px; cursor: pointer; text-decoration: none;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary { background: var(--ochre); color: var(--ink); }
.btn-primary:hover { background: var(--ochre-lo); }
.btn-ghost { background: transparent; color: var(--bone-dim); border-color: var(--ink-3); }
.btn-ghost:hover { border-color: var(--bone-dim); color: var(--bone); }
.btn-row { display: grid; gap: 10px; }
@media (min-width: 560px) { .btn-row.two { grid-template-columns: 1fr 1fr; } }

/* ═══ Formulaires ═══ */
.field { display: block; margin-bottom: 18px; }
.field label {
  display: block; font-size: var(--t-sm); color: var(--bone-dim); margin-bottom: 6px;
}
.field input:not([type="checkbox"]):not([type="radio"]) {
  min-height: var(--tap); width: 100%;
  background: var(--ink-2); border: 1px solid var(--ink-3); border-radius: var(--r);
  color: var(--bone); font-family: var(--body); font-size: var(--t-body); padding: 0 14px;
}
.field input:not([type="checkbox"]):not([type="radio"]):focus { outline: none; border-color: var(--ochre); }
.field input[type="checkbox"], .field input[type="radio"] {
  width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--ochre);
}
.field-error { color: var(--wrong); font-size: var(--t-sm); margin-top: 6px; }
.field-note { font-size: 12px; color: var(--bone-dim); margin-top: 4px; }
.form-actions { display: flex; align-items: center; gap: 16px; margin-top: 8px; flex-wrap: wrap; }
.status-ok { color: var(--cyan); font-size: var(--t-sm); }
.link { color: var(--bone-dim); font-size: var(--t-sm); text-decoration: underline; text-underline-offset: 3px; font-family: var(--body); }
.link:hover { color: var(--bone); }
.btn-danger { background: var(--wrong); color: var(--bone); }
.btn-danger:hover { background: #D2695F; }

/* ═══ Modale (confirmation destructrice) ═══ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,12,24,0.7); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-panel {
  background: var(--ink-2); border: 1px solid var(--ink-3); border-radius: var(--r-lg);
  padding: calc(var(--step) * 3); max-width: 420px; width: 100%;
}

/* ═══ Cartes / streak ═══ */
.card {
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r-lg);
  padding: calc(var(--step) * 3);
}
.streak {
  text-align: center;
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r-lg);
  padding: calc(var(--step) * 4);
}
.streak .flame { font-size: clamp(40px, 10vw, 60px); line-height: 1; }
.streak .n {
  font-family: var(--display);
  font-variation-settings: 'SOFT' 40, 'WONK' 1, 'opsz' 144;
  font-weight: 700; font-size: var(--t-streak);
  line-height: 1; color: var(--ochre); letter-spacing: -0.04em;
}
.streak .unit { color: var(--bone-dim); font-size: var(--t-sm); margin-top: 4px; }

/* ═══ Le carnet d'erreurs ═══ */
.mistake {
  border-left: 2px solid var(--ink-3);
  padding-left: 14px;
  margin-bottom: calc(var(--step) * 3);
}
.mistake .stmt { font-size: var(--t-lg); }
.mistake .key { color: var(--ochre); font-weight: 600; }
.mistake .said { color: var(--bone-dim); font-size: var(--t-sm); }
.mistake a { color: var(--bone-dim); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.mistake a:hover { color: var(--ochre); }

/* La mini-carte du carnet : la bonne position, en ocre. Lecture, pas jeu. */
.mistake .minimap {
  position: relative;
  max-width: 380px;
  aspect-ratio: 2 / 1;
  border: 1px solid var(--ink-3);
  border-radius: var(--r);
  overflow: hidden;
  margin-top: 10px;
}
.mistake .minimap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
/* Le repère doit se voir sur n'importe quel fond de carte : point ocre,
   liseré blanc, halo sombre — et une pulsation discrète pour accrocher l'œil. */
.mistake .minimap .pin {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; background: #E6A23C;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.55), 0 0 14px 4px rgba(230,162,60,0.9);
  animation: pin-pulse 1.6s ease-in-out infinite;
}
@keyframes pin-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(0,0,0,0.55), 0 0 10px 2px rgba(230,162,60,0.85); }
  50%      { box-shadow: 0 0 0 2px rgba(0,0,0,0.55), 0 0 18px 7px rgba(230,162,60,0.95); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
