/* ---------------------------------------------------------------------------
 * ProductAnywhere — tokens.css  (GLM-5.3 loop, Phase 1)
 * Source of truth for every colour, space, and motion value in the system.
 *
 * Rules this file enforces (main brief, decision 2):
 *   1. Bare :root is the LIGHT (canonical) theme.
 *   2. Dark redefines ONLY token values, twice: once under
 *      @media (prefers-color-scheme: dark) guarded :root:not([data-theme="light"]),
 *      and once under :root[data-theme="dark"] — so the manual toggle wins in
 *      both directions and the OS preference is respected on first load.
 *   3. No hex literal appears anywhere outside this file's token blocks.
 *      (Build gate greps for one and fails.)
 *
 * Provenance: lane hexes and the four-step ramp are measured values from
 * KIMI-K3-ADDENDUM.md §2/§4 (sampled from the logo asset); every ratio below
 * was computed (WCAG 2.1 relative luminance), not estimated.
 *
 * Semantics — hue = lane, saturation/lightness = maturity (4 steps):
 *   01 signal -> 02 pilot -> 03 receipt -> 04 proven
 * Light theme: step 01 is the quiet tint, step 04 the strongest deep.
 * Dark theme INVERTS the direction (addendum §5: deep facets collapse below
 * 2.6:1 on dark; tints become strongest): step 01 is the quiet deep, step 04
 * the strongest tint. Hue is fixed per lane so identity survives the switch.
 *
 * Text-safety (AA 4.5:1 body / 3:1 large+UI), stated, not hoped:
 *   LIGHT — text-safe: blue 02-04, teal 03-04, purple 02-04.
 *           fill-only: every 01, and teal 02 (2.46:1 on paper).
 *   DARK  — mirrors the asymmetry instead of papering over it:
 *           step 04 text-safe in every lane; step 03 text-safe (teal 03 is the
 *           logo facet #2DB4A3 untouched); step 02 is the UI/large-text band
 *           (>=3:1); step 01 is fill-only in every lane.
 * The light ladder is addendum §4 verbatim, all 12 values. The dark ladder
 * keeps hue fixed, inverts direction, and reuses 9 of 12 facets exactly; these
 * steps lift minimally at fixed hue/saturation (listed: was -> now, on ink):
     blue step3 #1073CA -> #117EDD  (was 3.96:1, now 4.62:1 on ink, L=0.467)
     purple step2 #690CBA -> #870FEF  (was 2.16:1, now 3.06:1 on ink, L=0.498)
     purple step3 #7F27CC -> #A25BE0  (was 2.8:1, now 4.67:1 on ink, L=0.616)
 *
 * Known-forbidden combinations — do not ship:
 *   - teal 02 as text on paper (2.46:1); teal mid #019380 as body text (3.83:1)
 *   - any light-theme 01 step as text anywhere; any dark-theme 01 step as text
 *   - deep facets (#053865/#016155/#460A7B) as text on dark ground
 * --------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  /* -- ground & neutrals (light) ------------------------------------------ */
    --ground: #FAFAF9;
    --surface: #FFFFFF;
    --surface-2: #F3F3F0;
    --line: #E5E5E1;
    --line-2: #C9C9C3;
    --ink: #0C0F14;
    --ink-soft: #3B414E;
    --ink-mute: #5B6371;
    --ink-faint: #878E9B;

  /* -- lane ladders (light) — value = logo-measured; comment = dark value -
     maturity: 01 signal / 02 pilot / 03 receipt / 04 proven
      #AAC6DF/#1073CA/#0963B2/#053865   [light: 1.70:4.65:5.85:11.42]
      #053865/#0963B2/#117EDD/#AAC6DF   [dark: 1.61:3.14:4.62:10.83]
      #ABDED8/#2DB4A3/#018171/#016155   [light: 1.42:2.46:4.59:7.07]
      #016155/#018171/#2DB4A3/#ABDED8   [dark: 2.60:4.00:7.47:12.95]
      #BA92DC/#7F27CC/#690CBA/#460A7B   [light: 2.44:6.56:8.51:12.65]
      #460A7B/#870FEF/#A25BE0/#BA92DC   [dark: 1.45:3.06:4.67:7.53]
  */
    /* blue ladder — light | dark (quiet→strong on theme ground) */
    --pa-blue-1: #AAC6DF;  /* dark: #053865 */
    --pa-blue-2: #1073CA;  /* dark: #0963B2 */
    --pa-blue-3: #0963B2;  /* dark: #117EDD */
    --pa-blue-4: #053865;  /* dark: #AAC6DF */
    /* teal ladder — light | dark (quiet→strong on theme ground) */
    --pa-teal-1: #ABDED8;  /* dark: #016155 */
    --pa-teal-2: #2DB4A3;  /* dark: #018171 */
    --pa-teal-3: #018171;  /* dark: #2DB4A3 */
    --pa-teal-4: #016155;  /* dark: #ABDED8 */
    /* purple ladder — light | dark (quiet→strong on theme ground) */
    --pa-purple-1: #BA92DC;  /* dark: #460A7B */
    --pa-purple-2: #7F27CC;  /* dark: #870FEF */
    --pa-purple-3: #690CBA;  /* dark: #A25BE0 */
    --pa-purple-4: #460A7B;  /* dark: #BA92DC */

  /* -- brand constants -----------------------------------------------------
     --pa-brand is the wordmark blue and the Leader lane core: one colour.
     #0A5DB2 must stay exact in the light theme (addendum §4). */
    --pa-brand: #0A5DB2;
    --pa-teal-logo: #019380;  /* exact logo teal — FILL ONLY, never body text (3.83:1 on paper) */

  /* -- spacing — 8px base, 4px half-step ---------------------------------- */
    --sp-4: 4px;   --sp-8: 8px;    --sp-12: 12px;  --sp-16: 16px;
    --sp-24: 24px; --sp-32: 32px;  --sp-40: 40px;  --sp-48: 48px;
    --sp-64: 64px; --sp-80: 80px;  --sp-96: 96px;  --sp-128: 128px;

  /* -- layout rhythm -------------------------------------------------------- */
    --content-max: 72rem;    /* 1152px — single column, generous margins */
    --measure: 68ch;         /* prose measure; ledgers may exceed, prose may not */
    --gutter: 24px;          /* page gutter, 16px below 768px (documented rule) */

  /* -- typefaces -------------------------------------------------------------
     display: Montserrat 300/700 — the measured wordmark match (addendum §3:
     double-storey a rules out Futura/Century Gothic/Poppins; stroke ratio
     1:2.5 = 300/700). Headlines echo the wordmark: light lines 300,
     emphasised lines 700. UI chrome shares the display face.
     text: Source Serif 4 — editorial body for the receipts/ledger prose the
     structure is built on; sturdy at 16-18px, true italics.
     mono: IBM Plex Mono — proof slugs, eyebrows, ledger metadata.
     Production self-hosts woff2 (Phase 3); fallback stacks are real. */
    --font-display: 'Montserrat', 'Avenir Next', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-text: 'Source Serif 4', 'Iowan Old Style', Palatino, Georgia, 'Times New Roman', serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  /* -- type scale (sizes px, paired line-heights) --------------------------- */
    --fs-12: 12px;  --lh-12: 1.45;
    --fs-14: 14px;  --lh-14: 1.5;
    --fs-16: 16px;  --lh-16: 1.6;
    --fs-18: 18px;  --lh-18: 1.6;
    --fs-20: 20px;  --lh-20: 1.5;
    --fs-24: 24px;  --lh-24: 1.35;
    --fs-32: 32px;  --lh-32: 1.2;
    --fs-40: 40px;  --lh-40: 1.15;
    --fs-56: 56px;  --lh-56: 1.05;

  /* -- radii — the mark has no strokes; planes stay quiet ------------------ */
    --r-s: 4px;  --r-m: 8px;  --r-l: 16px;  --r-pill: 999px;

  /* -- elevation: light uses shadow, dark swaps to surface steps + line ---- */
    --shadow-1: 0 1px 2px rgb(12 15 20 / 0.05), 0 1px 8px rgb(12 15 20 / 0.04);
    --shadow-2: 0 2px 6px rgb(12 15 20 / 0.07), 0 8px 24px rgb(12 15 20 / 0.06);

  /* -- motion: nothing moves unless asked; reduced-motion honoured upstream */
    --t-fast: 120ms;  --t-base: 200ms;  --t-slow: 320ms;
    --ease-out: cubic-bezier(0.2, 0.6, 0.2, 1);
    --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- dark theme: OS preference (manual light override wins) ---------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --ground: #0C0F14;
    --surface: #12161D;
    --surface-2: #171D27;
    --line: #242B38;
    --line-2: #3E4756;
    --ink: #ECEFF3;
    --ink-soft: #B6BDC9;
    --ink-mute: #868F9D;
    --ink-faint: #5F6875;

    /* lane ladders — INVERTED maturity direction, hue fixed */
    --pa-blue-1: #053865;
    --pa-blue-2: #0963B2;
    --pa-blue-3: #117EDD;
    --pa-blue-4: #AAC6DF;
    --pa-teal-1: #016155;
    --pa-teal-2: #018171;
    --pa-teal-3: #2DB4A3;
    --pa-teal-4: #ABDED8;
    --pa-purple-1: #460A7B;
    --pa-purple-2: #870FEF;
    --pa-purple-3: #A25BE0;
    --pa-purple-4: #BA92DC;

    --pa-brand: #0D7BEC;  /* lifted from #0A5DB2 for AA on dark; wordmark value unchanged */
    --pa-teal-logo: #019380;  /* exact logo teal both themes — fill only (4.94:1 on dark ground) */

    /* elevation: shadow flattens, surface steps + line do the separating */
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 2px 8px rgb(0 0 0 / 0.5);
  }
}

/* ---- dark theme: manual toggle (wins over OS preference) ------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;

    --ground: #0C0F14;
    --surface: #12161D;
    --surface-2: #171D27;
    --line: #242B38;
    --line-2: #3E4756;
    --ink: #ECEFF3;
    --ink-soft: #B6BDC9;
    --ink-mute: #868F9D;
    --ink-faint: #5F6875;

  /* lane ladders — INVERTED maturity direction, hue fixed */
    --pa-blue-1: #053865;
    --pa-blue-2: #0963B2;
    --pa-blue-3: #117EDD;
    --pa-blue-4: #AAC6DF;
    --pa-teal-1: #016155;
    --pa-teal-2: #018171;
    --pa-teal-3: #2DB4A3;
    --pa-teal-4: #ABDED8;
    --pa-purple-1: #460A7B;
    --pa-purple-2: #870FEF;
    --pa-purple-3: #A25BE0;
    --pa-purple-4: #BA92DC;

    --pa-brand: #0D7BEC;  /* lifted from #0A5DB2 for AA on dark; wordmark value unchanged */
  --pa-teal-logo: #019380;

  /* elevation: shadow flattens, surface steps + line do the separating */
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-2: 0 2px 8px rgb(0 0 0 / 0.5);
}
