/* ============================================================================
   Cortex DS v4 — tokens
   The panel world. Supersedes the v3 warm-paper elevated-card language.

   Locked direction: projects/cortex/design/lane.md (vault).
   Load AFTER the v3 manifest to override it, or instead of it. Same --cx-*
   names by design, so a surface migrates without renaming anything.

   THE ONE RULE THAT ORGANISES THIS FILE — three layers, different owners:

     HOUSE   constant across every client instance. Type, spacing, radius,
             density, motion, elevation, chart ink. Never themed.
     CLIENT  one accent ramp + the mark. This is the ONLY thing a client
             instance overrides. Everything below reads --cx-accent-*.
     MEANING semantic hues. Reserved, never the accent, never a chart series.

   Strip the client layer and every surface must still work. That is the test.
   ========================================================================= */

:root {
  /* ── HOUSE · ground and surfaces ─────────────────────────────────────────
     A TINTED ground, not white. Panels float on it as rounded cards separated
     by radius and ground-contrast — a hairline, almost no shadow. Depth is
     NOT lift. (v3 was the opposite: white cards lifting on warm shadows.) */
  --cx-ground:        #f5f2ef;  /* app canvas — panels sit on this */
  --cx-panel:         #ffffff;  /* panel fill */
  --cx-panel-sunken:  #fbf9f7;  /* inset wells inside a panel */
  --cx-line:          #e6e1dc;  /* panel edge */
  --cx-line-2:        #f0ece8;  /* divider inside a panel — softer than the edge */
  --cx-line-strong:   #d6cfc7;  /* hover edge, focus outline base */

  /* ── HOUSE · ink ─────────────────────────────────────────────────────── */
  --cx-ink:    #1c1b1a;  /* primary */
  --cx-ink-2:  #5d5952;  /* body-dim, secondary */
  --cx-ink-3:  #8d887f;  /* metadata, captions, placeholders */
  --cx-ink-on-accent: #ffffff;

  /* ── CLIENT · the accent ramp ────────────────────────────────────────────
     THE ONLY LAYER A CLIENT INSTANCE OVERRIDES. Five steps. Shipped values
     are this instance's ramp (soft pink). Measured against --cx-panel:
       base  5.84:1 with white       quiet 7.38:1 on wash
     A client accent MUST clear 4.5:1 white-on-base before it ships. There is
     no automatic fallback — a brand colour that cannot carry white text gets a
     darkened base step, and the brand's own colour moves to -bright. */
  --cx-accent:        #a8425c;
  --cx-accent-hover:  #8e3549;  /* down — hover/press on a solid fill */
  --cx-accent-bright: #e0a3b2;  /* up — edges, focus glow, the soft brand tone */
  --cx-accent-wash:   #fbeef1;  /* faint tint — active nav, selected row */
  --cx-accent-quiet:  #83324a;  /* accent-coloured TEXT on wash (AA) */

  /* ── MEANING · reserved, never the accent ────────────────────────────────
     Canon teal marks VERIFIED TRUTH and is the most load-bearing colour in the
     product. It is RESERVED: a client whose own brand is teal still gets a
     non-teal chrome accent — the semantic wins over the brand. Status is ALWAYS mark + word —
     never colour alone — so these survive greyscale and forced-colors. */
  --cx-canon:      #35786f;  --cx-canon-wash: #e9f2f0;  /* verified / promoted */
  --cx-working:    #6d7684;  --cx-working-wash:#eef0f2; /* draft, unverified */
  --cx-ok:         #2e7d4f;  --cx-ok-wash:    #e7f0e9;
  --cx-warn:       #8a6508;  --cx-warn-wash:  #faf3e0;
  --cx-error:      #b23f34;  --cx-error-wash: #fdeeec;
  --cx-info:       #3b6ea5;  --cx-info-wash:  #e8eef6;

  /* ── HOUSE · machine output ──────────────────────────────────────────────
     Derived from the accent so AI never becomes a fourth voice. A client
     instance sets these from its own ramp, it does not invent a hue. */
  --cx-ai:      var(--cx-accent-wash);
  --cx-ai-line: #eed3da;
  --cx-ai-ink:  var(--cx-accent-quiet);

  /* ── HOUSE · chart ink — NEVER themed, NEVER client-specific ─────────────
     TWO SERIES IS THE CEILING, and it is a computed result, not a preference.
     Validated with the six checks (lightness band, chroma floor, CVD
     separation, normal-vision floor, contrast). Three hues FAIL the dark
     band L 0.48–0.67 against orange at the 15 ΔE normal-vision floor —
     purple, violet, rose, green and cyan were all tried.
     Beyond two series: FACET into small multiples. Never add a hue.
     Never use a semantic colour as a series. */
  --cx-series-1: #2a78d6;
  --cx-series-2: #eb6834;

  /* ── HOUSE · type ────────────────────────────────────────────────────────
     One working face everywhere. NO MONO IN THE DATA SURFACE — all four
     corpus references refuse it; figures use tabular numerals instead.
     Mono survives for machine strings only (IDs, paths, raw payloads).
     The display face is the house nod and is permitted on HOME ONLY. */
  --cx-font:         Figtree, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --cx-font-display: "Bricolage Grotesque", var(--cx-font);   /* Home wordmark ONLY */
  --cx-font-mono:    ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --cx-display: 60px;  /* Home wordmark — the one moment of scale */
  --cx-h1:      25px;
  --cx-h2:      18px;
  --cx-h3:      14.5px;
  --cx-body:    13.5px;
  --cx-sm:      12px;
  --cx-xs:      10.5px;  /* uppercase eyebrows */

  --cx-w-regular: 400;
  --cx-w-medium:  500;
  --cx-w-semi:    600;
  --cx-w-bold:    700;

  --cx-lh-display: 1.02;
  --cx-lh-tight:   1.25;
  --cx-lh-snug:    1.4;
  --cx-lh-normal:  1.55;

  --cx-tr-display: -.035em;
  --cx-tr-heading: -.015em;
  --cx-tr-normal:  0;
  --cx-tr-wide:    .09em;   /* xs uppercase eyebrows */

  /* ── HOUSE · spacing, 4-based ────────────────────────────────────────── */
  --cx-s1: 4px;   --cx-s2: 8px;   --cx-s3: 12px;  --cx-s4: 16px;
  --cx-s5: 24px;  --cx-s6: 32px;  --cx-s7: 48px;  --cx-s8: 64px;

  /* ── HOUSE · radius. The panel world is generously rounded. ───────────── */
  --cx-radius-sm:    6px;   /* quiet buttons, chips-in-cell */
  --cx-radius-md:    9px;   /* inputs, rail items */
  --cx-radius-lg:    12px;  /* cards inside a panel, reading cards */
  --cx-radius-panel: 16px;  /* the panel itself */
  --cx-radius-modal: 18px;
  --cx-radius-pill:  999px; /* status pills, buttons */

  /* ── HOUSE · density. Authored, never a user setting. ─────────────────── */
  --cx-row-comfortable: 44px;
  --cx-row-compact:     32px;
  --cx-row: var(--cx-row-comfortable);

  /* ── HOUSE · elevation. The panel world is nearly flat. ──────────────────
     Separation is ground-contrast + radius + hairline. Shadow appears only
     where something genuinely floats ABOVE the plane: popover, panel, modal. */
  --cx-shadow-none:    none;
  --cx-shadow-hover:   0 4px 14px rgb(28 27 26 / .07);
  --cx-shadow-popover: 0 4px 14px rgb(28 27 26 / .09), 0 1px 2px rgb(28 27 26 / .05);
  --cx-shadow-modal:   0 24px 60px rgb(28 27 26 / .22);

  --cx-focus-ring: 0 0 0 3px color-mix(in oklab, var(--cx-accent) 30%, transparent);

  --cx-scrim: rgb(28 27 26 / .28);      /* modal scrim — a BLUR, not a dim */
  --cx-scrim-blur: 3px;

  /* ── HOUSE · motion. Calm and quick. Never bounce, never overshoot. ───── */
  --cx-dur-fast: 120ms;
  --cx-dur:      140ms;
  --cx-dur-slow: 240ms;
  --cx-ease:        cubic-bezier(.2, 0, 0, 1);
  --cx-ease-in-out: cubic-bezier(.4, 0, .2, 1);
}

/* ============================================================================
   DARK — selected, never an automatic flip.
   Chart steps are re-picked for the dark band (L 0.48–0.67) and re-validated;
   the light steps FAIL it. Accent lifts so white-on-accent inverts to ink.
   ========================================================================= */
[data-theme="dark"] {
  --cx-ground:        #141312;
  --cx-panel:         #1e1d1c;
  --cx-panel-sunken:  #191817;
  --cx-line:          #302e2c;
  --cx-line-2:        #262423;
  --cx-line-strong:   #423f3c;

  --cx-ink:    #f2f0ec;
  --cx-ink-2:  #a8a29a;
  --cx-ink-3:  #7d776f;
  --cx-ink-on-accent: #1c1b1a;   /* INVERTS — dark ink on the lifted accent */

  --cx-accent:        #e88fa4;   /* 6.56:1 on --cx-panel */
  --cx-accent-hover:  #f2a8ba;
  --cx-accent-bright: #f7c3d0;
  --cx-accent-wash:   #33222a;
  --cx-accent-quiet:  #f2a8ba;

  --cx-canon:      #4fa89c;  --cx-canon-wash:  #1c2f2d;   /* 5.47:1 */
  --cx-working:    #98a0ad;  --cx-working-wash:#24262a;
  --cx-ok:         #56b07a;  --cx-ok-wash:     #1a2b21;
  --cx-warn:       #d1a13c;  --cx-warn-wash:   #33291a;
  --cx-error:      #e08379;  --cx-error-wash:  #33211f;
  --cx-info:       #7aa8db;  --cx-info-wash:   #1c2733;

  --cx-ai-line: #4a3239;

  --cx-series-1: #3a83da;
  --cx-series-2: #dd6b3c;

  --cx-shadow-hover:   0 4px 14px rgb(0 0 0 / .45);
  --cx-shadow-popover: 0 4px 14px rgb(0 0 0 / .5), 0 1px 2px rgb(0 0 0 / .4);
  --cx-shadow-modal:   0 24px 60px rgb(0 0 0 / .65);
  --cx-scrim: rgb(0 0 0 / .5);
}

[data-density="compact"] { --cx-row: var(--cx-row-compact); }

@media (prefers-reduced-motion: reduce) {
  :root { --cx-dur-fast: 0ms; --cx-dur: 0ms; --cx-dur-slow: 0ms; }
}
