/* ============================================================================
   Issue #151 (refonte T3) — LES TOKENS COMMUNS.
   Spec : REFONTE-SPEC.md §3. Un seul fichier de tokens pour la coquille `/`,
   l'accueil, v1 et v2 ; les trois palettes divergentes (coquille `#0b0f17`,
   accueil `#0e1014`+`#6f7787`, v1 `#6c768f`) y disparaissent.

   Sombre = rôles actuels (valeurs héritées de static_v2/index.html, issue #20).
   Clair  = spec §3.1. Seul écart mesuré : le texte d'accent clair est
   #8f5c00 et non #a96d00 — #a96d00 tombe à 4,05:1 sur --bg clair (calcul WCAG
   collé dans rapports/issue-151.md) et ferait échouer le gate axe
   (« 0 violation serious »). Le fond de bouton principal reste #f4b73d.

   Bascule : @media (prefers-color-scheme: light) par défaut ; le choix manuel
   ☾ (static_v2/theme.js, clé localStorage littérale "ns.theme") l'emporte via
   l'attribut data-theme posés sur <html>. Le bloc clair est écrit deux fois
   (média + attribut) volontairement : sans JS, prefers-color-scheme fonctionne
   encore (le thème suit le système).
   ========================================================================== */
:root {
  color-scheme: dark;
  /* Couleurs (rôles) — spec §3.1, colonne sombre */
  --bg: #0b0f17;
  --bg-2: #0f1421;
  --panel: #121929;
  --panel-2: #192238;
  --line: rgba(255,255,255,.07);
  --line-2: rgba(255,255,255,.13);
  --hair: rgba(255,255,255,.04);
  --text: #e8ecf4;
  --text-2: #a4adc2;
  /* Issue #20 (mesuré) : #6c768f tombait à 3,87:1 — sous AA. #949db3 = 6,46:1. */
  --text-3: #949db3;
  --accent: #f4b73d;
  --accent-fg: #f4b73d;
  --accent-soft: rgba(244,183,61,.14);
  --accent-line: rgba(244,183,61,.35);
  --accent-hi: #ffc94a;
  --primary-ink: #1a1408;
  /* Encre du glyphe ✓ des cases personnalisées (v1 .chk) : fond = --accent. */
  --check-ink: #1a1408;
  /* Encre du glyphe des cases EXO (.chk:checked, fond --exo) — round 3 :
     en clair, #1a1408 sur #6d28d9 = 2,58:1 (coche invisible). Sombre :
     6,72:1 sur #a78bfa (mesuré). --check-ink reste l'encre de .chk.amber. */
  --check-ink-exo: #1a1408;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --ok-soft: rgba(52,211,153,.10);
  --ok-line: rgba(52,211,153,.3);
  --warn-soft: rgba(251,191,36,.08);
  --warn-line: rgba(251,191,36,.35);
  --err-soft: rgba(248,113,113,.12);
  --err-line: rgba(248,113,113,.35);
  /* Rôles dérivés partagés (barres collantes, champs, survols) : la valeur
     était recopiée par page avec des nuances différentes — elle est unique ici. */
  --bar-bg: rgba(15,20,33,.92);
  --field-bg: rgba(255,255,255,.03);
  --hover: rgba(255,255,255,.04);
  /* Sémantique v2 (rôles chips/exo) — mêmes noms dans les deux thèmes. */
  --exo: #a78bfa;
  --con: #5c9eff;
  --max: #f4b73d;
  /* Rôle « Panoplies » (v1 : badge + carte Panoplies actives) — issue #151
     round 3 : #60a5fa n'avait AUCUNE valeur claire (v1 la redéfinissait en
     local, sombre seulement → badge clair mesuré 2,29:1). Sombré = rôle
     actuel ; clair = #1d4ed8 (comme --con) : 5,92:1 sur son fond lavé. */
  --pano: #60a5fa;
  --pano-soft: rgba(96,165,250,.12);
  --exo-soft: rgba(167,139,250,.14);
  --exo-line: rgba(167,139,250,.45);
  --gold: var(--accent);
  --gold-soft: rgba(244,183,61,.08);
  --gold-line: rgba(244,183,61,.35);
  /* Échelle typographique (issue #20 §2.6) : six rôles, rien sous 12 px utile. */
  --t-display: 22px;
  --t-titre: 16px;
  --t-corps: 14px;
  --t-champ: 13px;
  --t-notule: 12px;
  --t-marque: 11px;
  /* Rayons (spec §3.3) : 12 carte, 8 contrôle, 999 puce. */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
}

/* Choix manuel ☾ = clair : l'emporte sur le système. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8fa;
  --bg-2: #eef1f6;
  --panel: #ffffff;
  --panel-2: #eef1f6;
  --line: rgba(15,23,42,.10);
  --line-2: rgba(15,23,42,.18);
  --hair: rgba(15,23,42,.04);
  --text: #111827;
  --text-2: #374151;
  --text-3: #5b6474;
  --accent: #f4b73d;
  --accent-fg: #8f5c00;
  --accent-soft: rgba(244,183,61,.18);
  --accent-line: rgba(143,92,0,.35);
  --accent-hi: #ffc94a;
  --primary-ink: #1a1408;
  /* Encre du glyphe ✓ des cases personnalisées (v1 .chk) : fond = --accent. */
  --check-ink: #1a1408;
  /* Encre du glyphe des cases EXO (fond --exo clair #6d28d9) : blanche. */
  --check-ink-exo: #ffffff;
  --ok: #047857;
  --warn: #b45309;
  --err: #b91c1c;
  --ok-soft: rgba(4,120,87,.10);
  --ok-line: rgba(4,120,87,.3);
  --warn-soft: rgba(180,83,9,.08);
  --warn-line: rgba(180,83,9,.35);
  --err-soft: rgba(185,28,28,.10);
  --err-line: rgba(185,28,28,.35);
  --bar-bg: rgba(255,255,255,.92);
  --field-bg: rgba(15,23,42,.03);
  --hover: rgba(15,23,42,.05);
  --exo: #6d28d9;
  --con: #1d4ed8;
  --max: #8f5c00;
  /* Rôle « Panoplies » clair : #1d4ed8 = 5,92:1 sur son fond lavé (mesuré). */
  --pano: #1d4ed8;
  --pano-soft: rgba(29,78,216,.08);
  --exo-soft: rgba(109,40,217,.08);
  --exo-line: rgba(109,40,217,.35);
  --gold: var(--accent);
  --gold-soft: rgba(180,83,9,.07);
  --gold-line: rgba(180,83,9,.30);
}

/* Sans choix manuel, le système décide. Écrit en dup (pas en @media imbriqué)
   pour rester actif même si theme.js ne s'exécute pas. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f7f8fa;
    --bg-2: #eef1f6;
    --panel: #ffffff;
    --panel-2: #eef1f6;
    --line: rgba(15,23,42,.10);
    --line-2: rgba(15,23,42,.18);
    --hair: rgba(15,23,42,.04);
    --text: #111827;
    --text-2: #374151;
    --text-3: #5b6474;
    --accent: #f4b73d;
    --accent-fg: #8f5c00;
    --accent-soft: rgba(244,183,61,.18);
    --accent-line: rgba(143,92,0,.35);
    --accent-hi: #ffc94a;
    --primary-ink: #1a1408;
    --check-ink: #1a1408;
    --check-ink-exo: #ffffff;
    --ok: #047857;
    --warn: #b45309;
    --err: #b91c1c;
    --ok-soft: rgba(4,120,87,.10);
    --ok-line: rgba(4,120,87,.3);
    --warn-soft: rgba(180,83,9,.08);
    --warn-line: rgba(180,83,9,.35);
    --err-soft: rgba(185,28,28,.10);
    --err-line: rgba(185,28,28,.35);
    --bar-bg: rgba(255,255,255,.92);
    --field-bg: rgba(15,23,42,.03);
    --hover: rgba(15,23,42,.05);
    --exo: #6d28d9;
    --con: #1d4ed8;
    --max: #8f5c00;
    --pano: #1d4ed8;
    --pano-soft: rgba(29,78,216,.08);
    --exo-soft: rgba(109,40,217,.08);
    --exo-line: rgba(109,40,217,.35);
    --gold: var(--accent);
    --gold-soft: rgba(180,83,9,.07);
    --gold-line: rgba(180,83,9,.30);
  }
}

/* Bouton ☾ injecté par theme.js sur les pages sans en-tête propre (coquille,
   accueil, v1). Sur v2 c'est le Header React qui rend le bouton (classe
   .ns-inline : même look, mais dans le flux de l'en-tête). */
[data-ns-theme-toggle] {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-2);
  background: var(--bar-bg);
  color: var(--accent-fg);
  font: inherit;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
[data-ns-theme-toggle]:hover { border-color: var(--accent-line); }
[data-ns-theme-toggle]:not(.ns-inline) {
  position: fixed;
  top: 8px;
  right: 10px;
  z-index: 999;
}
@media (max-width: 767px) {
  [data-ns-theme-toggle]:not(.ns-inline) { top: 4px; right: 6px; }
}

/* Focus visible obligatoire (spec §1.4 / refonte §2.7), une fois pour toutes
   les pages qui incluent les tokens. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
