/* packages/ui: the design tokens of every Shekspi UI (frontend/console, frontend/admin).
   Theme "A2 Control room" (owner decision 2026-11-28): a dark graphite sidebar, cool greys, 1px
   rules. Two meaning colours only: green for live and healthy, orange for problems. Everything
   else is ink and grey. Card pass (owner request 2026-11-28, "a bit more modern cards feel, just
   enough"): a soft cool-grey page, white cards with a 12px corner, a 1px edge and a very soft
   shadow, 8px corners on controls.

   Light by default, dark through prefers-color-scheme unless the page chose light, and
   :root[data-theme] for a theme switch. Served by each UI's own server at /ui/styles/tokens.css.

   A UI may ask for a LIGHT sidebar in light mode with :root[data-side="light"] (the admin dashboard,
   lane admin-completeness, 2026-11-29): the --side-* tokens then take the page's light values, and
   dark mode keeps the graphite sidebar. The console does not set it.

   The token names the pages already use (--bg --panel --ink --dim --line --accent --ok --warn
   --bad ...) are kept and given the A2 values, so every page follows without a rewrite. The A2
   names (--paper --wash --rule --muted --faint ...) are aliases for new rules. Text colours are
   at least 4.5:1 on white; the orange used for words (--bad) is a shade deeper than the orange
   used for marks and large figures (--bad-mark, #D9480F, 4.3:1, fine for graphics and big type). */

/* ================================================================== tokens */

:root {
  color-scheme: light;

  /* Sidebar: graphite, in both themes. */
  --side: #16181B;
  --side-ink: #E6E8EB;
  --side-text: #B4B9BF;
  --side-muted: #8A9098;
  --side-rule: #2A2D32;
  --side-on: #1E2125;
  --side-line-strong: #3A3E44;
  --side-input-line: #4A4F56;
  --side-scheme: dark;

  /* The admin dashboard's safety badge ("Admin" in its header): amber, a third hue that is neither
     the green of healthy nor the orange of a problem. Text 7:1 on its fill. */
  --admin-badge-bg: #FFF3CF;
  --admin-badge-ink: #6B4500;
  --admin-badge-line: #E5B53E;

  /* Surface and ink: cool neutrals. --bg is the page (soft cool grey), --panel a card. */
  --bg: #F4F5F7;
  --panel: #FFFFFF;
  --panel-2: #F3F4F5;
  --hover: #F7F8F9;
  --ink: #15171A;
  --ink-2: #3B3F45;
  --dim: #6B7178;
  --faint: #A2A8AF;
  --line: #E1E3E6;
  --grid: #ECEEF0;
  --line-strong: #C9CDD2;
  --rule-strong: #15171A;
  /* A form field's edge: 3:1 against white, so a field is findable (WCAG 1.4.11). */
  --input-line: #8F959C;
  --bar: #2B2F34;

  /* The primary action is ink, not a hue: a black button, ink links, an ink focus ring. */
  --accent: #15171A;
  --accent-hover: #2B2F34;
  --accent-bg: #F3F4F5;
  --accent-ink: #FFFFFF;

  /* Two meaning colours only. */
  --ok: #12805C;
  --ok-bg: #E7F3EE;
  --bad: #C2410C;
  --bad-mark: #D9480F;
  --bad-bg: #FCEEE7;
  --bad-hover: #F9E5DB;
  --bad-ink: #FFFFFF;
  /* A warning is a problem too: same orange, told apart by the mark (outlined, not filled). */
  --warn: #C2410C;
  --warn-bg: #FCEEE7;
  /* "Info" is not a colour in A2: neutral ink on the wash. */
  --info: #3B3F45;
  --info-bg: #F3F4F5;

  --scrim: rgba(16, 18, 20, 0.16);
  --chart-1: #2B2F34;
  --chart-1-live: #A2A8AF;

  /* Cards (the card pass): white, a 1px edge, a soft grey header row for tables, and a shadow so
     light it only lifts the card off the grey page. Floating layers keep the deeper shadow. */
  --card: #FFFFFF;
  --card-line: #E7E9EC;
  --card-head: #F8F9FA;
  --card-pad: 24px;
  --card-gap: 16px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-card-hover: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 10px rgba(16, 24, 40, 0.07);
  --shadow-1: var(--shadow-card);
  --shadow-2: 0 8px 24px rgba(16, 18, 20, 0.12);
  --shadow-float: 0 8px 24px rgba(16, 18, 20, 0.12);
  /* The highlighted figure card: graphite, like the sidebar, white words. */
  --feature: #16181B;
  --feature-hover: #1E2125;
  --feature-ink: #FFFFFF;
  --feature-text: #B4B9BF;
  --feature-muted: #8A9098;
  --feature-chip: rgba(255, 255, 255, 0.08);
  /* The small icon square on a figure card: light grey, never a pastel hue. */
  --chip: #F1F2F4;

  /* Type: system stacks, nothing downloaded. Monospace only for ids, hex, JSON and figures. */
  --sans: "Segoe UI Variable Text", "Segoe UI Variable", "SF Pro Text", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI Variable", "SF Pro Display", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;

  /* Type scale (px). The old --fs-* names map onto it. */
  --t-11: 11px;
  --t-12: 12px;
  --t-13: 13px;
  --t-14: 14px;
  --t-18: 18px;
  --t-22: 22px;
  --t-24: 24px;
  --t-30: 30px;
  --t-40: 40px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 18px;
  --fs-xl: 24px;

  /* Spacing (px). */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  /* Geometry: 8px corners on controls, 12px on cards and dialogs, 1px rules. */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --radius-card: 12px;
  --focus: 2px solid var(--ink);
  --row: 42px;
  --control-h: 32px;
  --ease: cubic-bezier(.2, .7, .3, 1);

  --topbar-h: 52px;
  --sidebar-w: 208px;
  --gutter: 40px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --side: #0C0D0F;
    --side-ink: #E6E8EB;
    --side-text: #B4B9BF;
    --side-muted: #8A9098;
    --side-rule: #24272B;
    --side-on: #1A1D21;
    --admin-badge-bg: #2E2410;
    --admin-badge-ink: #F2C24F;
    --admin-badge-line: #6B5422;
    --bg: #0F1113;
    --panel: #171A1D;
    --panel-2: #1F2226;
    --hover: #1D2024;
    --ink: #E6E8EB;
    --ink-2: #C4C8CD;
    --dim: #979DA4;
    --faint: #6B7178;
    --line: #2A2D32;
    --grid: #22252A;
    --line-strong: #3A3E44;
    --rule-strong: #C4C8CD;
    --input-line: #6B7178;
    --bar: #C4C8CD;
    --accent: #E6E8EB;
    --accent-hover: #FFFFFF;
    --accent-bg: #1E2125;
    --accent-ink: #15171A;
    --ok: #3FBF8A;
    --ok-bg: #10261D;
    --bad: #F2814F;
    --bad-mark: #F2814F;
    --bad-bg: #2E1A12;
    --bad-hover: #3A2016;
    --bad-ink: #15171A;
    --warn: #F2814F;
    --warn-bg: #2E1A12;
    --info: #C4C8CD;
    --info-bg: #1C1F23;
    --scrim: rgba(0, 0, 0, 0.5);
    --chart-1: #C4C8CD;
    --chart-1-live: #6B7178;
    --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.5);
    --card: #171A1D;
    --card-line: #272A2F;
    --card-head: #1B1E22;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-card-hover: 0 2px 8px rgba(0, 0, 0, 0.4);
    --feature: #262A2F;
    --feature-hover: #2C3036;
    --feature-chip: rgba(255, 255, 255, 0.07);
    --chip: #22262A;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --admin-badge-bg: #2E2410;
  --admin-badge-ink: #F2C24F;
  --admin-badge-line: #6B5422;
  --side: #0C0D0F;
  --side-ink: #E6E8EB;
  --side-text: #B4B9BF;
  --side-muted: #8A9098;
  --side-rule: #24272B;
  --side-on: #1A1D21;
  --bg: #0F1113;
  --panel: #171A1D;
  --panel-2: #1F2226;
  --hover: #1D2024;
  --ink: #E6E8EB;
  --ink-2: #C4C8CD;
  --dim: #979DA4;
  --faint: #6B7178;
  --line: #2A2D32;
  --grid: #22252A;
  --line-strong: #3A3E44;
  --rule-strong: #C4C8CD;
  --input-line: #6B7178;
  --bar: #C4C8CD;
  --accent: #E6E8EB;
  --accent-hover: #FFFFFF;
  --accent-bg: #1E2125;
  --accent-ink: #15171A;
  --ok: #3FBF8A;
  --ok-bg: #10261D;
  --bad: #F2814F;
  --bad-mark: #F2814F;
  --bad-bg: #2E1A12;
  --bad-hover: #3A2016;
  --bad-ink: #15171A;
  --warn: #F2814F;
  --warn-bg: #2E1A12;
  --info: #C4C8CD;
  --info-bg: #1C1F23;
  --scrim: rgba(0, 0, 0, 0.5);
  --chart-1: #C4C8CD;
  --chart-1-live: #6B7178;
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.5);
  --card: #171A1D;
  --card-line: #272A2F;
  --card-head: #1B1E22;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-card-hover: 0 2px 8px rgba(0, 0, 0, 0.4);
  --feature: #262A2F;
  --feature-hover: #2C3036;
  --feature-chip: rgba(255, 255, 255, 0.07);
  --chip: #22262A;
}

/* The light sidebar (opt-in, :root[data-side="light"]): only while the page itself is light, by
   choice or by the system's preference. White like a card, ink words, the page's rules. */
:root[data-side="light"][data-theme="light"] {
  --side: #FFFFFF;
  --side-ink: #15171A;
  --side-text: #3B3F45;
  --side-muted: #6B7178;
  --side-rule: #E1E3E6;
  --side-on: #F3F4F5;
  --side-line-strong: #C9CDD2;
  --side-input-line: #8F959C;
  --side-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-side="light"]:not([data-theme]) {
    --side: #FFFFFF;
    --side-ink: #15171A;
    --side-text: #3B3F45;
    --side-muted: #6B7178;
    --side-rule: #E1E3E6;
    --side-on: #F3F4F5;
    --side-line-strong: #C9CDD2;
    --side-input-line: #8F959C;
    --side-scheme: light;
  }
}
