/* QPA design tokens — the single source of truth for colour/theme.
 *
 * To rebrand: edit the TIER 1 primitives. To retheme: edit the TIER 2 alias mapping.
 * To add a third theme: copy the dark block under a new [data-theme="x"] selector.
 * Served at /theme.css and injected into every view's <head> by scripts/serve_ui.py.
 *
 * Two tiers:
 *   TIER 1  primitives   raw values; the ONLY place hex literals should live.
 *   TIER 2  aliases      semantic names the views consume (var(--bg) etc.); mapped per theme.
 *
 * LIGHT is the default (bare :root). DARK overrides the chrome aliases AND the risk/chart aliases (they
 * pick their -d step); only primitives (--hue-*, the -l/-d risk steps) are theme-invariant.
 */

/* ---- TIER 1 — primitive tokens ------------------------------------------- */
:root {
  /* neutral ramp (light -> dark) */
  --n-0:#ffffff;  --n-50:#f6f8fb;  --n-100:#eef3f9; --n-200:#d9e1ec;
  --n-700:#1f2a3a; --n-750:#13203a; --n-800:#0f1a2e; --n-850:#101a2e; --n-900:#0b1220;
  /* light-chrome ink */
  --ink-700:#1f2a3a; --ink-500:#5b6b82;
  /* dark-chrome ink */
  --ink-100:#cbd5e1; --ink-300:#7e8aa0;
  /* accent ramp */
  --sky-400:#38bdf8; --sky-600:#0b7fc7;
  /* semantic hues (theme-invariant) */
  --hue-red:#E74C3C; --hue-orange:#E67E22; --hue-green:#2ECC71;
  --hue-purple:#8E44AD; --hue-grey:#95A5A6;
  /* risk-bucket + chart primitives (validated; see header of the dashboard token change) */
  --risk-red-l:#B3261E;  --risk-orange-l:#E07B00; --risk-teal-l:#00897B;
  --risk-red-d:#D6363F;  --risk-orange-d:#C98300; --risk-teal-d:#1A9E8F;
  --slate-strong-l:#3E5673; --slate-weak-l:#8FA3BF;
  --slate-strong-d:#9FB3CE; --slate-weak-d:#5E7391;
  /* categorical identity primitives (--cat-1..6: algorithm segments, no risk meaning). Kept off the risk red,
     orange, teal and the grey hatch (OKLab dE >= 14 in each theme) and ordered so every donut neighbour, the
     wrap included, keeps protan/deutan dE >= 11 (light) / 7.8 (dark); pair each with a text label. */
  --cat-1-l:#C8B400; --cat-2-l:#2A78D6; --cat-3-l:#C2408F; --cat-4-l:#5046C8; --cat-5-l:#E0689F; --cat-6-l:#7A4FD1;
  --cat-1-d:#D4C24A; --cat-2-d:#3987E5; --cat-3-d:#CF5AB8; --cat-4-d:#6C63E0; --cat-5-d:#E07AA8; --cat-6-d:#9A6AE8;
  /* non-color tokens (seeded; adopt incrementally across pages) */
  --radius:8px; --radius-lg:12px;
  --font-sans:-apple-system,'Segoe UI',Roboto,sans-serif;
}

/* ---- TIER 2 — semantic aliases. LIGHT = default -------------------------- */
:root {
  --bg:var(--n-50);  --bg2:var(--n-0);  --line:var(--n-200);
  --text:var(--ink-700); --muted:var(--ink-500); --accent:var(--sky-600);
  --chip:var(--n-100); --scrim:#0006;
  /* semantic risk aliases (constant in both themes) */
  --red:var(--hue-red); --orange:var(--hue-orange); --green:var(--hue-green);
  --purple:var(--hue-purple); --grey:var(--hue-grey);
  /* status-badge tints (bg + on-tint fg) — LIGHT: pale tint + darkened hue for contrast */
  --ok-bg:#e3f6ea;     --ok-fg:#1a7a43;
  --warn-bg:#fbeed8;   --warn-fg:#955800;
  --bad-bg:#fbe1dd;    --bad-fg:#b3261e;
  --info-bg:#dceffb;   --info-fg:#0b6aa6;
  --violet-bg:#efe3f8; --violet-fg:#6b2f9c;
  /* risk buckets, named by meaning, in colour language option B (QScope D6, DOC-ARCH-0095 D-8,
     decided 2026-11-07); remap here, nowhere else. Hue is always paired with a text label and a
     position or pattern; grey is a FILL only — grey text uses --muted. */
  --risk-vulnerable:var(--risk-orange-l); /* quantum-vulnerable (Shor-class): orange */
  --risk-broken:var(--risk-red-l);       /* classically broken today: red */
  --risk-hybrid:var(--risk-teal-l);      /* hybrid-PQ negotiated or configured; never "done" */
  --risk-unknown:var(--hue-grey);        /* unknown / not classified / not collected: fill + hatch */
  --chart-count:var(--slate-strong-l);   /* neutral count, strong step */
  --chart-count-2:var(--slate-weak-l);   /* neutral count, weak step */
  --cell-unknown:repeating-linear-gradient(45deg, var(--risk-unknown) 0 2px, transparent 2px 6px);
  --cell-inferred:repeating-linear-gradient(135deg, var(--risk-vulnerable) 0 2px, transparent 2px 6px);
  /* categorical identity hues, in fixed order (never cycled; a 7th group folds into "other") */
  --cat-1:var(--cat-1-l); --cat-2:var(--cat-2-l); --cat-3:var(--cat-3-l);
  --cat-4:var(--cat-4-l); --cat-5:var(--cat-5-l); --cat-6:var(--cat-6-l);
}

/* ---- DARK — override chrome aliases + badge tints ------------------------ */
:root[data-theme="dark"] {
  --bg:var(--n-900); --bg2:var(--n-800); --line:#1f2d45;
  --text:var(--ink-100); --muted:var(--ink-300); --accent:var(--sky-400);
  --chip:var(--n-750); --scrim:#0008;
  /* DARK badges: deep tint + bright hue (the original look) */
  --ok-bg:#10331f;     --ok-fg:var(--hue-green);
  --warn-bg:#3a2a10;   --warn-fg:var(--hue-orange);
  --bad-bg:#3a1414;    --bad-fg:var(--hue-red);
  --info-bg:#10293a;   --info-fg:var(--sky-400);
  --violet-bg:#2a1f3a; --violet-fg:#b794f4;
  --risk-vulnerable:var(--risk-orange-d); --risk-broken:var(--risk-red-d);
  --risk-hybrid:var(--risk-teal-d);
  --chart-count:var(--slate-strong-d); --chart-count-2:var(--slate-weak-d);
  --cat-1:var(--cat-1-d); --cat-2:var(--cat-2-d); --cat-3:var(--cat-3-d);
  --cat-4:var(--cat-4-d); --cat-5:var(--cat-5-d); --cat-6:var(--cat-6-d);
}
