/* Design tokens. The token NAMES and the file's structure are transcribed from the accepted
   Gate-C visual system at elevated-vayr-ux-lab@da8c159; the VALUES are Direction 3A, as
   docs/slices/slice-22-visual-system.md Appendix A states them (Slice 22 Unit 1).

   Source map (per element):
   - Token names and layering — the ink navigation palette, canvas + surfaces + lines, text
     ramp, accent, semantic tones, type scale and caps tracking, shape radii, layered
     elevation, and rail/drawer widths: src/app/ux25.css §1 ":root".
   - The binding of the accepted UX-1/UX-2 semantic names (--color-*, --tone-*,
     --radius, --shadow, --font-sans, --feedback-*-border) to the ux25 names:
       src/app/ux25.css §1 (binding block).
   - The spacing scale (--space-*) and motion durations (--motion-*) the ux25
     system composes on top of: src/app/tokens.css (base UX-1/UX-2 tokens).
   - Every colour, type-size, radius and shadow value, and the on-ink, signal,
     line-control and display-face tokens: Appendix A of the Slice 22 brief.

   Deviations kept, with reasons:
   - The Lab-Mode bright-accent study (:root[data-ux25-accent='bright']) is omitted:
     it is a comparison artifact reached only from Lab Mode, never a product default,
     and Slice 1 ships no Lab Mode.
   - No dark-scheme @media: the superseded token file's dark @media is not carried
     forward. The dark palette is the :root[data-theme='dark'] block below (Slice 25
     Unit 2), selected by the attribute packages/ui/src/theme.ts sets.

   Every screen composes exclusively from these variables — no screen hardcodes a
   colour, spacing, or type value. This is the token set Slice 2 formalizes. */

:root {
  color-scheme: light;

  /* Ink — the navigation frame and text ramp. */
  --ux25-ink-900: #14150f;
  --ux25-ink-800: #1c1d17;
  --ux25-ink-700: #2b2c26;
  --ux25-ink-600: #3c3d36;
  --ux25-ink-500: #55574f;
  --ux25-ink-400: #8c8e86;

  /* Warm light-neutral canvas and crisp surfaces. */
  --ux25-canvas: #f4f4f0;
  --ux25-surface: #ffffff;
  --ux25-surface-sunken: #f6f6f2;
  --ux25-line: #e4e4de;
  --ux25-line-strong: #cfcfc7;

  /* Text. */
  --ux25-text: #14150f;
  --ux25-text-muted: #5b5d55;
  --ux25-text-faint: #6a6c64;

  /* Near-black — the single primary accent. */
  --ux25-accent: #14150f;
  --ux25-accent-hover: #2b2c26;
  --ux25-accent-soft: #efefea;
  --ux25-accent-line: #b9bbb2;
  --ux25-accent-contrast: #fbfbf9;
  /* Green accent used only as small functional punctuation (Stage marker). */
  --ux25-accent-bright: #2f6e4e;

  /* Text on the ink rail: read by app.css's rail, top-bar and nav rules; the signal
     one by .rail :focus-visible. */
  --ux25-on-ink: #fbfbf9;
  --ux25-on-ink-muted: #bfc0bb;
  --ux25-on-ink-signal: #8fcba9;

  /* Signal green: --ux25-signal is read by --color-focus. --ux25-signal-soft has no
     reader in this unit (Appendix A §A.3 binds it to the drop target). */
  --ux25-signal: #2f6e4e;
  --ux25-signal-soft: #eaf1ec;

  /* Control outline: no reader in this unit (Appendix A §A.3 binds it to the field,
     toolbar-select and view-toggle borders). Measured 3.51:1 on --ux25-surface,
     3.18:1 on --ux25-canvas, 3.24:1 on --ux25-surface-sunken. */
  --ux25-line-control: #878a82;

  /* Restrained semantic tones. */
  --ux25-progress-bg: #eef0ec;
  --ux25-progress-fg: #33453a;
  --ux25-won-bg: #e7f0ea;
  --ux25-won-fg: #2f6e4e;
  --ux25-lost-bg: #f5e8e4;
  --ux25-lost-fg: #8a3b2e;
  --ux25-warn-bg: #f7f1e7;
  --ux25-warn-fg: #8a6438;

  /* Stage palette (Slice 6 §4). The eight preset tokens migration 0021's
     pipeline_stage_color_valid CHECK admits, given rendered values here for the
     first time — 0021 defined them as names only. Each stage's `wash` fills the
     full stage region on both boards; `edge` draws the 2px rule under the stage heading
     and fills the configuration surface's swatches.

     Every wash is asserted legible at >= 4.5:1 behind the text a stage region
     renders on it, and asserted distinguishable from the boards' ground, by the
     two 'horizontal board: ...' / 'vertical board: every preset stage colour
     renders as a pale wash its text stays legible on at 375px' tests in
     tests/web/unit4-stage-palette-web.test.ts. Those tests render the real board
     in both views and read every colour back through the cascade with the sheet's
     @media blocks resolved for a 375px viewport, so a rule that overrides one of
     these values at that width changes what they measure. */
  --ux25-stage-sky-wash: #eef3f7;
  --ux25-stage-sky-edge: #9db8ce;
  --ux25-stage-mint-wash: #edf4ee;
  --ux25-stage-mint-edge: #9cc3a4;
  --ux25-stage-lavender-wash: #f1f0f7;
  --ux25-stage-lavender-edge: #b3aad3;
  --ux25-stage-amber-wash: #f7f2e6;
  --ux25-stage-amber-edge: #d2b978;
  --ux25-stage-rose-wash: #f8eff1;
  --ux25-stage-rose-edge: #d7a3b0;
  --ux25-stage-teal-wash: #ebf3f2;
  --ux25-stage-teal-edge: #95c0bb;
  --ux25-stage-slate-wash: #f0f1f2;
  --ux25-stage-slate-edge: #adb5bd;
  --ux25-stage-coral-wash: #f9f0eb;
  --ux25-stage-coral-edge: #dda68f;
  /* The two text colours a stage region renders on its wash. The secondary one is
     the same as --ux25-text-muted, which the palette test measures. */
  --ux25-stage-wash-text: var(--ux25-text);
  --ux25-stage-wash-text-muted: var(--ux25-text-muted);

  /* Typography — system stacks only; no external font asset. */
  --ux25-font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  /* Display face; read by h1 in app.css. */
  --ux25-font-display: ui-serif, 'New York', 'Iowan Old Style', Georgia, serif;
  --ux25-font-numeric: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
  --ux25-text-2xs: 0.6875rem;
  --ux25-text-xs: 0.75rem;
  --ux25-text-sm: 0.84375rem;
  --ux25-text-base: 0.9375rem;
  --ux25-text-lg: 1.125rem;
  --ux25-text-xl: 1.75rem;
  --ux25-tracking-caps: 0.08em;

  /* Shape — rounded, never pill by default. */
  --ux25-radius-sm: 8px;
  --ux25-radius: 11px;
  --ux25-radius-lg: 16px;

  /* Elevation — subtle, layered. */
  --ux25-shadow-xs: 0 1px 2px rgb(20 21 15 / 0.04);
  --ux25-shadow-sm: 0 1px 2px rgb(20 21 15 / 0.04), 0 2px 8px rgb(20 21 15 / 0.04);
  --ux25-shadow-md: 0 6px 18px rgb(20 21 15 / 0.1);
  --ux25-shadow-lg: 0 1px 2px rgb(20 21 15 / 0.04), 0 12px 32px rgb(20 21 15 / 0.12);

  --ux25-rail-w: 208px;
  --ux25-rail-w-collapsed: 56px;
  --ux25-drawer-w: 416px;
  /* Modal scrim: the ink frame at the base's 0.42 alpha, derived from the token. */
  --ux25-scrim: color-mix(in srgb, var(--ux25-ink-900) 42%, transparent);

  /* Spacing scale and motion durations (base UX-1/UX-2 tokens). */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2.5rem;
  --motion-fast: 120ms;
  --motion-medium: 240ms;

  /* Density tokens (Slice 25 Unit 2): lengths app.css reads for the spacing and height of
     controls, rows, chips, headers and list items. The --space-fine-N names carry their
     comfortable value in sixteenths of a rem. :root[data-density='compact'] below
     redefines every one of them except --ux25-line-height-tight. */
  --space-fine-2: 0.125rem;
  --space-fine-3: 0.1875rem;
  --space-fine-5: 0.3125rem;
  --space-fine-6: 0.375rem;
  --space-fine-7: 0.4375rem;
  --space-fine-10: 0.625rem;
  --ux25-header-min-h: 52px;
  --ux25-rail-head-h: 2rem;
  --ux25-rail-control-h: 1.75rem;
  --ux25-line-height: 1.5;
  --ux25-line-height-tight: 1;

  /* Bind the accepted semantic token names to this system so components read it. */
  --font-sans: var(--ux25-font);
  --color-bg: var(--ux25-canvas);
  --color-surface: var(--ux25-surface);
  --color-text: var(--ux25-text);
  --color-muted: var(--ux25-text-muted);
  --color-border: var(--ux25-line);
  --color-accent: var(--ux25-accent);
  --color-accent-contrast: var(--ux25-accent-contrast);
  --color-focus: var(--ux25-signal);

  --tone-neutral-bg: var(--ux25-surface-sunken);
  --tone-neutral-fg: var(--ux25-ink-600);
  --tone-progress-bg: var(--ux25-progress-bg);
  --tone-progress-fg: var(--ux25-progress-fg);
  --tone-won-bg: var(--ux25-won-bg);
  --tone-won-fg: var(--ux25-won-fg);
  --tone-lost-bg: var(--ux25-lost-bg);
  --tone-lost-fg: var(--ux25-lost-fg);
  --tone-warn-bg: var(--ux25-warn-bg);
  --tone-warn-fg: var(--ux25-warn-fg);

  --feedback-ok-border: var(--ux25-won-fg);
  --feedback-error-border: var(--ux25-lost-fg);
  --feedback-warn-border: var(--ux25-warn-fg);

  --radius: var(--ux25-radius);
  --shadow: var(--ux25-shadow-sm);
}

/* Dark palette (Slice 25 D-1), selected by data-theme='dark' on the document root
   (packages/ui/src/theme.ts). A token not redeclared here keeps its :root value, the whole
   ink ramp and the on-ink trio among them.
   tests/web/slice22-visual-system-web.test.ts asserts: every custom property here is
   declared in :root; each one outside its shadow-and-scrim allow-list (DARK_NON_HEX, whose
   values it does not check) resolves to six-digit hex through both the :root chain and
   this block overlaid on it; the block's only other declaration is color-scheme: dark; and
   the contrast floors and the stage-wash pairs hold with this block overlaid on :root.
   tests/web/slice25-theme-board-web.test.ts measures the stage regions through the
   cascade under this block. */
:root[data-theme='dark'] {
  color-scheme: dark;

  --ux25-canvas: #1c1d17;
  --ux25-surface: #25261f;
  --ux25-surface-sunken: #20211b;
  --ux25-line: #383930;
  --ux25-line-strong: #4a4b42;

  --ux25-text: #ecece6;
  --ux25-text-muted: #a9aba2;
  --ux25-text-faint: #a0a299;

  --ux25-accent: #ecece6;
  --ux25-accent-hover: #d4d5ce;
  --ux25-accent-soft: #2f3029;
  --ux25-accent-line: #6b6d65;
  --ux25-accent-contrast: #14150f;
  --ux25-accent-bright: #6fbf8e;

  --ux25-signal: #5fb085;
  --ux25-signal-soft: #1f3027;

  --ux25-line-control: #7f8279;

  --ux25-progress-bg: #283029;
  --ux25-progress-fg: #b7cdbd;
  --ux25-won-bg: #1f3428;
  --ux25-won-fg: #8fcba9;
  --ux25-lost-bg: #3b2522;
  --ux25-lost-fg: #f0aa9c;
  --ux25-warn-bg: #372e20;
  --ux25-warn-fg: #e2bf8e;
  --tone-neutral-fg: #b3b5ac;

  --ux25-stage-sky-wash: #18212a;
  --ux25-stage-sky-edge: #5d87a8;
  --ux25-stage-mint-wash: #172219;
  --ux25-stage-mint-edge: #5f9a6c;
  --ux25-stage-lavender-wash: #1e1b29;
  --ux25-stage-lavender-edge: #8a7fb8;
  --ux25-stage-amber-wash: #241e12;
  --ux25-stage-amber-edge: #b39549;
  --ux25-stage-rose-wash: #271a1e;
  --ux25-stage-rose-edge: #b97384;
  --ux25-stage-teal-wash: #142224;
  --ux25-stage-teal-edge: #559a92;
  --ux25-stage-slate-wash: #1b1e22;
  --ux25-stage-slate-edge: #7f8994;
  --ux25-stage-coral-wash: #281b16;
  --ux25-stage-coral-edge: #c07a5e;

  --ux25-shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3);
  --ux25-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3), 0 2px 8px rgb(0 0 0 / 0.24);
  --ux25-shadow-md: 0 6px 18px rgb(0 0 0 / 0.4);
  --ux25-shadow-lg: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px rgb(0 0 0 / 0.48);
  --ux25-scrim: color-mix(in srgb, var(--ux25-ink-900) 64%, transparent);
}

/* Compact density (Slice 25 D-4), selected by data-density='compact' on the document root
   (packages/ui/src/theme.ts). Each value is its :root value times the COMPACT_RATIO constant
   in tests/web/slice22-visual-system-web.test.ts, rounded to four decimals, which that guard
   asserts. */
:root[data-density='compact'] {
  --space-1: 0.2125rem;
  --space-2: 0.425rem;
  --space-3: 0.6375rem;
  --space-4: 0.85rem;
  --space-5: 1.275rem;
  --space-6: 2.125rem;
  --space-fine-2: 0.1063rem;
  --space-fine-3: 0.1594rem;
  --space-fine-5: 0.2656rem;
  --space-fine-6: 0.3188rem;
  --space-fine-7: 0.3719rem;
  --space-fine-10: 0.5313rem;
  --ux25-header-min-h: 44.2px;
  --ux25-rail-head-h: 1.7rem;
  --ux25-rail-control-h: 1.4875rem;
  --ux25-line-height: 1.275;
}

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

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
