/* ============================================================
   ETS HQ — design tokens (H-043, 2026-10-14)
   The single :root block, moved out of styles.css unchanged except the
   tokens noted below. Loaded before styles.css by every page shell (legacy
   layout(), Shell.astro, the login page). DESIGN.md is the spec; this file is
   its implementation.
   ============================================================ */

:root {
  /* Core brand */
  --ets-navy: #0a2342;
  --ets-navy-deep: #061731;
  --ets-navy-soft: #1b3560;
  --ets-gold: #e5b13a;
  --ets-gold-deep: #c8952a;
  --ets-gold-soft: #f2cb6e;
  /* The ONLY gold allowed as foreground text on a light surface — holds the
     brand hue at >=4.5:1 on parchment (gold/gold-deep/gold-soft are fills only). */
  --ets-gold-text: #8a6410;

  /* Warm canvas */
  --ets-parchment: #f5f4ed;
  --ets-parchment-deep: #edebe0;
  --ets-cream: #faf8f2;
  --ets-ivory: #fffdf7;

  /* Warm neutrals */
  --ets-ink: #1a1a1a;
  --ets-graphite: #3a3a38;
  --ets-stone: #6b6962;
  --ets-sand: #a8a396;
  --ets-mist: #d9d5c6;
  --ets-rule: #c9c3b0;

  /* Semantic (editorial, muted) */
  --ets-success: #4a6b3f;
  --ets-success-soft: #e8ebdf;
  --ets-warning: #b87333;
  --ets-warning-soft: #f3e6d4;
  /* AA text-only variant for --ets-warning; fills/borders keep #b87333.
     Computed AA replacement, 2026-07-22 audit. */
  --ets-warning-text: #8a5220;
  --ets-danger: #8b2e2e;
  --ets-danger-soft: #f0dede;
  --ets-info: #2a4a6b;
  --ets-info-soft: #dde4eb;

  /* Return-status pill tints (Returns table). Promoted from inline hex so the
     status palette is themeable. fg values are AA-computed replacements,
     2026-07-22 audit (were failing WCAG AA on their -bg tints). */
  --ets-status-hold-bg: #efe7d6;
  --ets-status-hold-fg: #6f5322;
  --ets-status-sign-bg: #f3e0cf;
  --ets-status-sign-fg: #8a4718;
  --ets-status-ready-bg: #f6eccf;
  --ets-status-ready-fg: #7a5410;
  --ets-status-done-bg: #d3ead0;
  --ets-status-done-fg: #2f5a28;
  --ets-status-ext-bg: #e6e0ee;
  --ets-status-ext-fg: #5a4a7a;
  --ets-status-dead-bg: #ead8d8;

  /* Body text is Figtree (H-441), with Inter kept as the fallback. Back to
     Inter is one line: drop "Figtree", from --font-sans (and set FONT in
     tests/dec-c-look.test.ts back to Inter). Headings stay Archivo. */
  --font-display: "Archivo", "Figtree", -apple-system, sans-serif;
  --font-sans: "Figtree", "Inter", -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, monospace;

  --ring-card: 0 0 0 1px var(--ets-rule), 0 1px 0 0 rgba(10, 35, 66, 0.03);
  --ring-card-raised:
    0 0 0 1px var(--ets-rule), 0 2px 8px -2px rgba(10, 35, 66, 0.06);
  --ring-emphasis:
    0 0 0 1px var(--ets-gold), 0 0 0 4px rgba(229, 177, 58, 0.15);

  --r-xs: 3px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 999px;

  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* Spacing scale — ONE rhythm for gaps/margins/padding across the app.
     Bigger groupings get the bigger steps (section > grid row > kpi cluster). */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Alias so var(--ets-muted) stops falling back to a raw off-token hex
     (#6b6b60 vs the real --ets-stone #6b6962). */
  --ets-muted: var(--ets-stone);

  /* Soft border tints + the second paper tone — promoted from raw hex so the
     palette is one source of truth (values unchanged; zero visual diff). */
  --ets-success-border: #b9c7ab;
  --ets-warning-border: #e0b894;
  --ets-danger-border: #e0b8b8;
  --ets-paper-2: #f3efe6;
  /* Promoted one-off hexes (zero visual diff; values unchanged). */
  --ets-nav-muted: #b8c2d1; /* muted text on the navy header */
  --ets-copper: #8f5523; /* feed badge — deepened for >=4.5:1 on ivory */
  --ets-ar-late: #b5552f; /* AR aging 61-90 bar fill */
  /* W12-A: a bookkeeping month before Elevated books since (someone else kept
     those books). Aliases of the existing brown tones, so no new colour enters
     the palette: the hold pill's tint and text (AA on that tint) and copper. */
  --ets-bk-before-bg: var(--ets-status-hold-bg);
  --ets-bk-before-fg: var(--ets-status-hold-fg);
  --ets-bk-before-border: var(--ets-copper);

  /* Extend the spacing rhythm for shell-scale gaps (reuses --space-* above). */
  --space-10: 40px;
  --space-12: 64px;
  /* One height for every pill, chip, tag and status badge (batch Q). */
  --pill-h: 22px;

  /* Console shell metrics (single source; app.js reads --cmdbar-h). */
  --rail-w: 244px;
  --cmdbar-h: 56px;

  /* Type scale (H-390). One list of font sizes for the v2 pages: public/assets/
     v2.css takes every size from here, and tests/v2-grid-fill.test.js fails on
     a raw px size there. Named by role, not by number, so a step up or down is
     one edit per line. px on purpose: the browser's page zoom is the reader's
     control.
     2026-11-05: one step up, after every coordinator asked for bigger type.
     Each size from the caret to the subtitle rose 1 px (it was 9, 10, 10.5, 11,
     11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15, 16), so the small labels rise with
     the body. Figures and titles stay. V2List scales its column widths with the
     list text, so no column that fitted before clips.
     2026-12-04 (DEC-C, H-441): the page body goes to 16px, the size Basecamp's
     app uses (Catherine, 12/3), and section headings to 16.5px so the scale
     still rises with no repeat. List cells stay at 14.5px. */
  --fs-caret-sm: 10px; /* the billing picker's caret */
  --fs-caret: 11px; /* carets and sort marks */
  --fs-micro: 11.5px; /* the close checklist's source tag */
  --fs-tiny: 12px; /* keycaps, initials, service and source tags */
  --fs-label: 12.5px; /* column heads, uppercase labels, pills and tags */
  --fs-small: 13px; /* sub-lines, hints, small buttons, chips */
  --fs-small-lg: 13.5px; /* dates, panel tables, notes */
  --fs-control: 14px; /* buttons, inputs, menus, pickers, secondary text */
  --fs-text: 14.5px; /* list cells, panel text, masthead links, tabs */
  --fs-text-lg: 15px; /* data-health section heads */
  --fs-body: 16px; /* the page body (body.v2) */
  --fs-lead: 16.5px; /* section headings */
  --fs-subtitle: 17px; /* masthead app name, modal and overhead titles */
  --fs-figure: 18px; /* figure values (the big numbers) */
  --fs-title: 20px; /* side-panel title */
  --fs-title-lg: 22px; /* page title on a phone */
  --fs-display: 26px; /* page title */

  /* ============================================================
     SEMANTIC TOKEN LAYER (three-tier: primitive -> semantic -> component).
     Console register: warm greige ground, warm paper panels, navy rail.
     ============================================================ */
  --surface-page: #f6f5f2;
  --surface-panel: var(--ets-cream);
  --surface-raised: var(--ets-ivory);
  --surface-sunken: var(--ets-parchment-deep);
  --surface-rail: var(--ets-navy);
  --text-strong: var(--ets-ink);
  --text-body: var(--ets-graphite);
  --text-muted: var(--ets-stone);
  --text-on-rail: var(--ets-nav-muted);
  --text-on-rail-strong: var(--ets-ivory);
  --border-hair: var(--ets-rule);
  --border-soft: var(--ets-mist);
  /* Non-text contrast (WCAG 1.4.11): --ets-rule is under 3:1 on ivory controls.
     Computed AA replacement, 2026-07-22 audit — input/select/search rest border only. */
  --border-control: #8f8b7e;
  --accent: var(--ets-gold);
  --accent-hover: var(--ets-gold-deep);
  --state-ok-fg: var(--ets-success);
  --state-warn-fg: var(--ets-warning);
  --state-danger-fg: var(--ets-danger);

  /* Defined 2026-10-14 (H-043): these were used in styles.css but never
     declared, so each rule fell back or silently did nothing. */
  /* Severity badges on the Overview feed (DESIGN.md "Daily Hero"). */
  --state-danger-bg: var(--ets-danger-soft);
  --state-warn-bg: var(--ets-warning-soft);
  /* Gold always pairs with navy text (DESIGN.md "Earned Gold"). */
  --text-on-gold: var(--ets-navy);
  /* Light gold wash behind an active filter chip (was a raw fallback). */
  --ets-gold-wash: #fdf6e4;
  /* AA olive for text on light grounds (was a raw fallback). */
  --ets-success-text: #2f5e3a;

  /* Focus (H-048, WCAG 1.4.11 / 2.4.13): gold alone is 1.78:1 on parchment,
     so every light-surface focus state is a navy outline (>= 3:1 on every
     warm ground) plus the brand's gold halo. */
  /* The gold halo outside the 2px navy focus outline (styles.css, end). */
  --ring-focus-halo: 0 0 0 5px rgba(229, 177, 58, 0.45);

  /* DEC-C (H-440): navy as a FILL (buttons, the active tab, the selected
     chip, keycaps) and the text that sits on it. They never change
     between themes: in Dark --ets-navy turns light blue (it is the TEXT navy)
     and --ets-ivory turns dark (it is the paper), so a navy fill with ivory
     text on it reads these two instead. */
  --fill-strong: #0a2342;
  --text-on-strong: #fffdf7;
  /* The popover's drop shadow and the tour's dim scrim (were raw in v2.css). */
  --shadow-pop: rgba(10, 35, 66, 0.22);
  --scrim: rgba(10, 35, 66, 0.18);
  /* The avatar in the masthead (a light disc on the navy bar) and the gold
     chip's tint behind --ets-gold-text. Tokens so a theme can set each pair. */
  --avatar-bg: var(--ets-parchment);
  --avatar-fg: var(--ets-navy);
  --ets-gold-chip: var(--ets-gold-soft);
}

/* ============================================================
   THEMES (DEC-C, H-440, 2026-12-04). Each person picks White, Warm or Dark in
   the avatar menu; the server draws it as <html data-theme="...">. Warm is
   the :root block above, unchanged. The blocks below re-declare only what
   changes; every value is a 6-digit hex so tests/dec-c-look.test.ts can read
   it and prove the contrast. That test is the contract: a theme change that
   drops a pair under 4.5:1 (text) or 3:1 (marks) fails it.
   ============================================================ */

/* White: a white page and white panels with neutral grey borders and sunken
   areas. Text, navy and gold are Warm's. This block ALSO styles the body of a
   classic page in Dark (the second selector; public/styles.css adds the
   background), so it lists every token either theme changes and each
   dependent token (a var() in a custom property is read where it is declared,
   so a descendant cannot re-read it from a changed primitive). */
:root[data-theme="white"],
:root[data-theme="dark"] body.v2--classic .hq-main {
  color-scheme: light;
  --ets-navy: #0a2342;
  --ets-gold-text: #8a6410;
  --ets-parchment: #f6f7f8;
  --ets-parchment-deep: #eceef1;
  --ets-cream: #ffffff;
  --ets-ivory: #ffffff;
  --ets-paper-2: #f3f4f6;
  --ets-ink: #1a1a1a;
  --ets-graphite: #3a3a38;
  --ets-stone: #6b6962;
  --ets-sand: #a8a396;
  --ets-mist: #e1e3e7;
  --ets-rule: #cfd2d8;
  --ets-success: #4a6b3f;
  --ets-success-soft: #e8ebdf;
  --ets-success-border: #b9c7ab;
  --ets-success-text: #2f5e3a;
  /* Warm's warning orange is 3.1:1 as text on its tint (it fails today and
     Warm is unchanged); White darkens it to the AA text brown. */
  --ets-warning: #8a5220;
  --ets-warning-soft: #f3e6d4;
  --ets-warning-border: #e0b894;
  --ets-warning-text: #8a5220;
  --ets-danger: #8b2e2e;
  --ets-danger-soft: #f0dede;
  --ets-danger-border: #e0b8b8;
  --ets-info: #2a4a6b;
  --ets-info-soft: #dde4eb;
  --ets-status-hold-bg: #efe7d6;
  --ets-status-hold-fg: #6f5322;
  --ets-status-sign-bg: #f3e0cf;
  --ets-status-sign-fg: #8a4718;
  --ets-status-ready-bg: #f6eccf;
  --ets-status-ready-fg: #7a5410;
  --ets-status-done-bg: #d3ead0;
  --ets-status-done-fg: #2f5a28;
  --ets-status-ext-bg: #e6e0ee;
  --ets-status-ext-fg: #5a4a7a;
  --ets-status-dead-bg: #ead8d8;
  --ets-copper: #8f5523;
  --ets-gold-wash: #fdf6e4;
  --ets-gold-chip: #f6eccf;
  --surface-page: #ffffff;
  --surface-panel: var(--ets-cream);
  --surface-raised: var(--ets-ivory);
  --surface-sunken: var(--ets-parchment-deep);
  --surface-rail: var(--ets-navy);
  --text-strong: var(--ets-ink);
  --text-body: var(--ets-graphite);
  --text-muted: var(--ets-stone);
  --ets-muted: var(--ets-stone);
  --text-on-rail-strong: var(--ets-ivory);
  --text-on-gold: var(--ets-navy);
  --border-hair: var(--ets-rule);
  --border-soft: var(--ets-mist);
  --border-control: #80838a;
  --state-ok-fg: var(--ets-success);
  --state-warn-fg: var(--ets-warning);
  --state-danger-fg: var(--ets-danger);
  --state-danger-bg: var(--ets-danger-soft);
  --state-warn-bg: var(--ets-warning-soft);
  --ets-bk-before-bg: var(--ets-status-hold-bg);
  --ets-bk-before-fg: var(--ets-status-hold-fg);
  --ets-bk-before-border: var(--ets-copper);
  --ring-card: 0 0 0 1px var(--ets-rule), 0 1px 0 0 rgba(10, 35, 66, 0.03);
  --ring-card-raised:
    0 0 0 1px var(--ets-rule), 0 2px 8px -2px rgba(10, 35, 66, 0.06);
  --shadow-pop: rgba(10, 35, 66, 0.22);
  --scrim: rgba(10, 35, 66, 0.18);
}

/* Dark: a dark navy-black page, slightly lighter panels, light warm text and
   light borders that still read. The NAMES are roles, not colours: in Dark the
   paper names (parchment, cream, ivory, paper-2) hold dark values and the ink
   names (ink, graphite, stone) hold light ones, and --ets-navy as TEXT (links,
   headings, the active tab) is a light blue. Navy as a FILL is --fill-strong
   and the text on it --text-on-strong, which never change. The masthead stays
   navy through --surface-rail. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ets-navy: #9db9e6;
  --ets-gold-text: #e8bd55;
  --ets-parchment: #0d1520;
  --ets-parchment-deep: #0a111a;
  --ets-cream: #111b29;
  --ets-ivory: #172335;
  --ets-paper-2: #131e2d;
  --ets-ink: #f3f0e6;
  --ets-graphite: #d8d4c8;
  --ets-stone: #aaa89c;
  --ets-sand: #77756b;
  --ets-mist: #26334a;
  --ets-rule: #3b4a63;
  --ets-success: #7fb778;
  --ets-success-soft: #16291c;
  --ets-success-border: #2f4d33;
  --ets-success-text: #8fcf8a;
  --ets-warning: #d4924f;
  --ets-warning-soft: #2d2213;
  --ets-warning-border: #5a4126;
  --ets-warning-text: #e3a362;
  --ets-danger: #ef8d8d;
  --ets-danger-soft: #321a1d;
  --ets-danger-border: #5e2f2f;
  --ets-info: #8fb5e3;
  --ets-info-soft: #14253b;
  --ets-status-hold-bg: #2a2416;
  --ets-status-hold-fg: #e0c88f;
  --ets-status-sign-bg: #33241a;
  --ets-status-sign-fg: #f0b88a;
  --ets-status-ready-bg: #33290f;
  --ets-status-ready-fg: #f0d27a;
  --ets-status-done-bg: #17301a;
  --ets-status-done-fg: #9fdc98;
  --ets-status-ext-bg: #261f38;
  --ets-status-ext-fg: #c3b3ec;
  --ets-status-dead-bg: #331c1c;
  --ets-copper: #dd9a62;
  --ets-gold-wash: #2a2210;
  --ets-gold-chip: #3a2f12;
  --avatar-bg: #b8c2d1;
  --avatar-fg: #0a2342;
  --surface-page: #0b121c;
  --surface-rail: #061731;
  --text-on-rail-strong: var(--text-on-strong);
  --text-on-gold: var(--fill-strong);
  --border-control: #7f8ca3;
  --shadow-pop: rgba(0, 0, 0, 0.6);
  --scrim: rgba(0, 0, 0, 0.5);
}
