/* Transcribed verbatim from design/tokens.json (ADR-001/ADR-003) — the
   single source for color/type. Component code references these custom
   properties only; no raw values (PRN-03, ui-lint enforced). */

:root {
  --font-ui: 'Inter', 'SF Pro Text', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-display: 1.75rem;
  --leading-tight: 1.25;
  --leading-ui: 1.45;
  --leading-prose: 1.6;
  --tracking-display: -0.02em;

  --canvas: oklch(1.000 0.000 0);
  --surface-1: oklch(0.978 0.003 240);
  --surface-2: oklch(0.955 0.004 240);
  --surface-3: oklch(0.930 0.005 240);
  --hairline: oklch(0.885 0.006 240);
  --input-border: oklch(0.600 0.006 240);
  --ink: oklch(0.215 0.012 250);
  --ink-muted: oklch(0.400 0.014 250);
  --ink-subtle: oklch(0.520 0.014 250);
  /* PRN-05 audit, 2026-07-10: light accent vs light surface-2 (nav active-
     item text, DESIGN-SYSTEM.md's shell nav recipe) measured 4.100:1 —
     short of WCAG 1.4.3's 4.5:1. Darkened lightness-only, hue 230/chroma
     0.130 locked (ADR-032's ratified mechanism, same move as MS-22) to the
     minimal L clearing 4.5:1 against surface-2: 0.545 -> 0.520. Also
     raises white-on-accent from 4.681:1 to 5.179:1 (only improves, still
     pinned >=4.5 by tokens.contrast.test.ts). */
  --accent: oklch(0.520 0.130 230);
  --on-accent: oklch(1.000 0.000 0);
  --accent-hover: oklch(0.500 0.130 230);
  --focus: oklch(0.560 0.130 230);
  --danger: oklch(0.550 0.190 25);
  --warn: oklch(0.640 0.150 85);
  --ok: oklch(0.560 0.140 155);
  /* ADR-039: semantic tint roles — same hue as the parent semantic, chroma
     dropped to 0.04 (>= the 0.02 anti-gray floor, well inside the 0.03-0.05
     band) and lightness raised to 0.95 (inside the 0.94-0.96 light-binding
     band). Computed once, pinned by tokens.contrast.test.ts, so every
     recipe references the role instead of hand-mixing color-mix(semantic,
     neutral) — the OKLCH-hue-interpolation drift (violet/cyan) that ADR-039
     retires. Measured ink-on-tint (both >= 4.5:1 floor, this binding):
     danger-tint 14.614:1, warn-tint 15.122:1, ok-tint 15.345:1,
     accent-tint 15.191:1. */
  --danger-tint: oklch(0.950 0.040 25);
  --warn-tint: oklch(0.950 0.040 85);
  --ok-tint: oklch(0.950 0.040 155);
  --accent-tint: oklch(0.950 0.040 230);
  /* ADR-039: warn's hue/chroma locked (85/0.150, same discipline as
     ADR-032's lightness-only tuning), lightness dropped to 0.58 — the
     minimal move clearing WCAG 1.4.11's 3:1 non-text floor against
     surface-2 (measured 3.782:1 this binding). Meaningful semantic borders
     only (governed pill, activation-confirm box) — decorative container
     hairlines stay exempt per ADR-039's challenge-gate (c). */
  --warn-border: oklch(0.580 0.150 85);
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: oklch(0.145 0.006 250);
    --surface-1: oklch(0.185 0.007 250);
    --surface-2: oklch(0.225 0.008 250);
    --surface-3: oklch(0.270 0.009 250);
    --hairline: oklch(0.300 0.010 250);
    --input-border: oklch(0.540 0.010 250);
    --ink: oklch(0.955 0.004 240);
    --ink-muted: oklch(0.800 0.010 240);
    --ink-subtle: oklch(0.640 0.012 240);
    --accent: oklch(0.680 0.115 230);
    --on-accent: oklch(0.145 0.006 250);
    --accent-hover: oklch(0.740 0.115 230);
    --focus: oklch(0.680 0.115 230);
    --danger: oklch(0.660 0.170 25);
    --warn: oklch(0.780 0.140 85);
    --ok: oklch(0.720 0.130 155);
    /* ADR-039: dark-binding tints — same hue/chroma discipline as the light
       binding above, lightness dropped to 0.245 (inside the 0.23-0.26
       dark-binding band). Measured ink-on-tint (this binding): danger-tint
       14.424:1, warn-tint 14.268:1, ok-tint 14.057:1, accent-tint 14.148:1. */
    --danger-tint: oklch(0.245 0.040 25);
    --warn-tint: oklch(0.245 0.040 85);
    --ok-tint: oklch(0.245 0.040 155);
    --accent-tint: oklch(0.245 0.040 230);
    /* ADR-039: warn hue/chroma locked (85/0.140, dark binding's own warn
       chroma), lightness raised to 0.58 — clears 3:1 against dark surface-2
       (measured 3.963:1 this binding). */
    --warn-border: oklch(0.580 0.140 85);
  }
}

:root[data-theme='dark'] {
  --canvas: oklch(0.145 0.006 250);
  --surface-1: oklch(0.185 0.007 250);
  --surface-2: oklch(0.225 0.008 250);
  --surface-3: oklch(0.270 0.009 250);
  --hairline: oklch(0.300 0.010 250);
  --input-border: oklch(0.540 0.010 250);
  --ink: oklch(0.955 0.004 240);
  --ink-muted: oklch(0.800 0.010 240);
  --ink-subtle: oklch(0.640 0.012 240);
  --accent: oklch(0.680 0.115 230);
  --on-accent: oklch(0.145 0.006 250);
  --accent-hover: oklch(0.740 0.115 230);
  --focus: oklch(0.680 0.115 230);
  --danger: oklch(0.660 0.170 25);
  --warn: oklch(0.780 0.140 85);
  --ok: oklch(0.720 0.130 155);
  /* ADR-039 — see the @media dark-scheme block above for the math. */
  --danger-tint: oklch(0.245 0.040 25);
  --warn-tint: oklch(0.245 0.040 85);
  --ok-tint: oklch(0.245 0.040 155);
  --accent-tint: oklch(0.245 0.040 230);
  --warn-border: oklch(0.580 0.140 85);
}

:root[data-theme='light'] {
  --canvas: oklch(1.000 0.000 0);
  --surface-1: oklch(0.978 0.003 240);
  --surface-2: oklch(0.955 0.004 240);
  --surface-3: oklch(0.930 0.005 240);
  --hairline: oklch(0.885 0.006 240);
  --input-border: oklch(0.600 0.006 240);
  --ink: oklch(0.215 0.012 250);
  --ink-muted: oklch(0.400 0.014 250);
  --ink-subtle: oklch(0.520 0.014 250);
  /* PRN-05 audit, 2026-07-10: light accent vs light surface-2 (nav active-
     item text, DESIGN-SYSTEM.md's shell nav recipe) measured 4.100:1 —
     short of WCAG 1.4.3's 4.5:1. Darkened lightness-only, hue 230/chroma
     0.130 locked (ADR-032's ratified mechanism, same move as MS-22) to the
     minimal L clearing 4.5:1 against surface-2: 0.545 -> 0.520. Also
     raises white-on-accent from 4.681:1 to 5.179:1 (only improves, still
     pinned >=4.5 by tokens.contrast.test.ts). */
  --accent: oklch(0.520 0.130 230);
  --on-accent: oklch(1.000 0.000 0);
  --accent-hover: oklch(0.500 0.130 230);
  --focus: oklch(0.560 0.130 230);
  --danger: oklch(0.550 0.190 25);
  --warn: oklch(0.640 0.150 85);
  --ok: oklch(0.560 0.140 155);
  /* ADR-039 — see the :root block above for the math. */
  --danger-tint: oklch(0.950 0.040 25);
  --warn-tint: oklch(0.950 0.040 85);
  --ok-tint: oklch(0.950 0.040 155);
  --accent-tint: oklch(0.950 0.040 230);
  --warn-border: oklch(0.580 0.150 85);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-ui); /* tokens.json role, not a literal font */
  font-size: var(--text-base);
  line-height: var(--leading-ui);
  color: var(--ink);
  background: var(--surface-3);
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Form controls don't inherit body's font-family from the UA stylesheet —
   a classic CSS gotcha. Without this, every input/textarea/select/button
   falls back to the browser default (Chrome renders bare <textarea> in
   monospace specifically), silently bypassing --font-ui everywhere.
   Found during the 2026-07-05 UI consistency audit — this was systemic
   across every screen with a form control, not a one-off. */
input,
input[type='number'],
input[type='date'],
textarea,
select,
button {
  font-family: inherit; /* inherits body's tokens.json --font-ui role, not a literal font */
}

/* Canonical toolbar search/filter control recipe (design/DESIGN-SYSTEM.md
   "Toolbar search/filter control"). Found during a 2026-07-06 consistency
   audit: three separate builder-agent passes each independently
   implemented a "search box" / "filter dropdown" with slightly different
   padding/background, and one screen's own search and filter controls
   didn't even match each other. One global rule, not three local copies
   that drift — the :focus-visible rule above already covers these
   selectors, so no per-screen focus override is needed or permitted. */
input[type='text'],
input[type='search'],
input[type='number'],
input[type='date'],
/* MS-39 (SCR-25/26 login forms, ADR-046): email/password are form controls
   same as every type above — this selector list had simply never grown
   them until an htmx screen actually used one. Same central-fix precedent
   as MS-23's number/date addition and MS-25's textarea addition to this
   exact rule. */
input[type='email'],
input[type='password'],
select,
/* MS-25 PRN-05 audit (2026-07-10): textarea is a form control same as the
   others above — the recipe's intent was always "all form controls," this
   selector list had simply never grown a textarea (comment case) until an
   htmx screen actually used a bare <textarea>. Same central-fix precedent
   as MS-23's number/date addition to this exact rule. */
textarea {
  background: var(--surface-2);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  padding: 0.375rem 0.625rem;
  color: var(--ink);
}

/* Placeholder text needs body-text contrast (≥4.5:1), not the browser's
   UA-default gray, which isn't guaranteed to clear that bar against an
   arbitrary custom background — found failing this exact check during the
   same audit. ink-muted is already used elsewhere for muted-but-legible
   text and clears 4.5:1 against surface-1/canvas in both bindings. */
::placeholder {
  color: var(--ink-muted);
  opacity: 1;
}
