/*
 * Design tokens: every colour, space, radius, type size and shadow the console uses. Components
 * name tokens, never raw values. Two themes share the token names:
 *   - light: `:root` and `:root[data-theme="light"]`
 *   - dark:  `:root[data-theme="dark"]`, and the device's dark setting when no theme is chosen
 *            (`data-theme` absent means "follow the system").
 * The dark block appears twice (explicit and under prefers-color-scheme); test/theme.test.ts checks
 * the two copies match, and docs/design/console/CONTRAST.md lists every pair's contrast in both.
 *
 * Fonts are self-hosted (SIL OFL 1.1, see src/fonts): nothing is loaded from outside this origin.
 */
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  font-stretch: 75% 100%;
  src: url(../fonts/instrument-sans-latin-wdth-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  font-stretch: 75% 100%;
  src: url(../fonts/instrument-sans-latin-ext-wdth-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Martian Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  src: url(../fonts/martian-mono-latin-wdth-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Martian Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  src: url(../fonts/martian-mono-latin-ext-wdth-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---- Theme-independent: type, space, radius, size ------------------------------------------- */
:root {
  --font-sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Martian Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  /* Instrument Sans' width axis: condensed for names and figures, normal for reading. */
  --wdth-display: 75;
  --wdth-figure: 85;
  --wdth-mono: 75;

  --fs-10: 10px;
  --fs-11: 11px;
  --fs-115: 11.5px;
  --fs-12: 12px;
  --fs-125: 12.5px;
  --fs-13: 13px;
  --fs-145: 14.5px;
  --fs-16: 16px;
  --fs-19: 19px;
  --fs-24: 24px;
  --fs-30: 30px;
  --lh-tight: 1.15;
  --lh-body: 1.38;

  --sp-1: 2px;
  --sp-2: 4px;
  --sp-3: 6px;
  --sp-4: 8px;
  --sp-5: 10px;
  --sp-6: 12px;
  --sp-7: 14px;
  --sp-8: 16px;
  --sp-9: 20px;
  --sp-10: 24px;
  --sp-11: 32px;

  --r-1: 3px;
  --r-2: 4px;
  --r-3: 5px;
  --r-4: 6px;
  --r-round: 999px;

  --h-scope: 44px;
  --h-strip: 34px;
  --h-tabs: 36px;
  --w-rail: 208px;
  --h-control: 32px;
  --h-control-sm: 26px;
  --h-row: 27px;

  --focus-width: 2px;
  --motion-fast: 120ms;
}

/* ---- Light (the default) --------------------------------------------------------------------- */
:root,
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-rail: #f6f7f6;
  --bg-hover: #eef1ef;
  --bg-row-hover: #f8faf9;
  --bg-selected: #f1f5f3;
  --bg-raised: #ffffff;
  --ink: #151a18;
  --ink-2: #3c4441;
  --ink-3: #5c6562;
  --rule: #e2e6e3;
  --rule-2: #cdd3cf;
  --control: #7c8783;
  --accent: #0c5a43;
  --accent-ink: #094a37;
  --accent-wash: #e6f1ec;
  --accent-line: #9cc3b3;
  --on-accent: #ffffff;
  --fail: #b0281f;
  --fail-ink: #7a1c16;
  --fail-wash: #fcecea;
  --fail-line: #e8b4ae;
  --warn: #7d4a00;
  --warn-ink: #3d2a00;
  --warn-wash: #fff4dc;
  --warn-line: #d9b066;
  --on-ink: #ffffff;
  --chart-bar: #6f7a76;
  --scrim: rgba(21, 26, 24, 0.45);
  --shadow-pop: 0 10px 28px -10px rgba(20, 32, 27, 0.32), 0 2px 4px rgba(20, 32, 27, 0.06);
  /* Log and code surface: dark in both themes. */
  --term: #13201b;
  --term-2: #1b2b25;
  --term-ink: #d8e2dd;
  --term-dim: #93a79e;
  --term-rule: #2a3d35;
  --term-live: #5fd0a3;
  --term-err: #ff9d8f;
  --term-err-ink: #ffd2ca;
  --term-errbg: #3a1d1a;
  --term-redact: #e8c37a;
  --term-hl: #1f362e;
}

/* ---- Dark ------------------------------------------------------------------------------------ */
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #161b19;
  --bg-rail: #1b211f;
  --bg-hover: #252d2a;
  --bg-row-hover: #1c2321;
  --bg-selected: #1f2926;
  --bg-raised: #1e2522;
  --ink: #e7ece9;
  --ink-2: #c4cdc9;
  --ink-3: #9ba7a2;
  --rule: #2a322f;
  --rule-2: #3a4541;
  --control: #76847e;
  --accent: #6ccaa4;
  --accent-ink: #8edbbb;
  --accent-wash: #173329;
  --accent-line: #2f6b55;
  --on-accent: #07140f;
  --fail: #ff8f82;
  --fail-ink: #ffb8ad;
  --fail-wash: #3a1d1a;
  --fail-line: #7a3a32;
  --warn: #f0b75e;
  --warn-ink: #f8dcab;
  --warn-wash: #31260f;
  --warn-line: #6e5422;
  --on-ink: #161b19;
  --chart-bar: #8a9792;
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 12px 30px -8px rgba(0, 0, 0, 0.7), 0 2px 4px rgba(0, 0, 0, 0.4);
  --term: #0a110e;
  --term-2: #121d19;
  --term-ink: #d8e2dd;
  --term-dim: #93a79e;
  --term-rule: #2a3d35;
  --term-live: #5fd0a3;
  --term-err: #ff9d8f;
  --term-err-ink: #ffd2ca;
  --term-errbg: #3a1d1a;
  --term-redact: #e8c37a;
  --term-hl: #1f362e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #161b19;
    --bg-rail: #1b211f;
    --bg-hover: #252d2a;
    --bg-row-hover: #1c2321;
    --bg-selected: #1f2926;
    --bg-raised: #1e2522;
    --ink: #e7ece9;
    --ink-2: #c4cdc9;
    --ink-3: #9ba7a2;
    --rule: #2a322f;
    --rule-2: #3a4541;
    --control: #76847e;
    --accent: #6ccaa4;
    --accent-ink: #8edbbb;
    --accent-wash: #173329;
    --accent-line: #2f6b55;
    --on-accent: #07140f;
    --fail: #ff8f82;
    --fail-ink: #ffb8ad;
    --fail-wash: #3a1d1a;
    --fail-line: #7a3a32;
    --warn: #f0b75e;
    --warn-ink: #f8dcab;
    --warn-wash: #31260f;
    --warn-line: #6e5422;
    --on-ink: #161b19;
    --chart-bar: #8a9792;
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow-pop: 0 12px 30px -8px rgba(0, 0, 0, 0.7), 0 2px 4px rgba(0, 0, 0, 0.4);
    --term: #0a110e;
    --term-2: #121d19;
    --term-ink: #d8e2dd;
    --term-dim: #93a79e;
    --term-rule: #2a3d35;
    --term-live: #5fd0a3;
    --term-err: #ff9d8f;
    --term-err-ink: #ffd2ca;
    --term-errbg: #3a1d1a;
    --term-redact: #e8c37a;
    --term-hl: #1f362e;
  }
}
