/* Chris Glasky Design System v2 · tokens
   Two axes on the root element:
     data-palette  the register: instrument (dashboards, tools) · editorial (site, notes, case studies) · linen (memos, reports, decks)
     data-mode     light | dark. Defaults: instrument dark, editorial dark, linen light. Every artifact must work in both.
   Type: Libron (serif, emotion, self hosted from fonts/) · Schibsted Grotesk (sans, reading + UI) · JetBrains Mono (data). */

@import url('https://fonts.googleapis.com/css2?family=Schibsted+Grotesk:wght@400..700&family=JetBrains+Mono:wght@400..600&display=swap');

:root {
  --font-serif: 'Libron', Georgia, serif;
  --font-sans:  'Schibsted Grotesk', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, Menlo, monospace;
  --display: clamp(40px, 5.2vw, 68px); --title: 34px; --heading: 22px; --subhead: 17px; --lead: 19px; --body: 16px; --small: 14px; --label: 11px; --data: 13px; --metric: 34px;
  --radius-sm: 6px; --radius: 9px; --radius-lg: 12px; --radius-xl: 18px;
  --ease-out: cubic-bezier(.22,1,.36,1); --dur: 180ms;
  --measure: 64ch; --container: 1120px; --gutter: 32px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 14px; --space-5: 16px; --space-6: 20px; --space-7: 24px; --space-8: 32px; --space-10: 40px; --space-12: 52px; --space-16: 64px; --space-20: 88px;
}

/* ---------- MODE · DARK (default for instrument and editorial) ---------- */
:root, [data-palette], [data-mode="dark"] {
  --base: #131012; --surface: #1D181C; --surface-2: #252019; --desk: #0E0C0D;
  --line: rgba(235,229,233,.09); --line-2: rgba(235,229,233,.17);
  --text: #ECE7DD; --text-2: #B4ABA3; --text-3: #918886; --text-on-accent: #06201F;
  --primary: #5BBAC4; --primary-bright: #A2E2E8; --primary-deep: #1E5A60;
  --primary-ring: rgba(91,186,196,.22); --primary-soft: rgba(91,186,196,.10);
  --gold: #D2B575; --underline: rgba(198,141,160,.42);
  --emphasis: var(--gold);   /* defined in every register so FlowMap tone 'emphasis' and the FlowSpine loop marker always resolve. RULES keeps it out of Instrument, not the token. */
  --ok: #8FB57E; --watch: #D2B575; --alert: #D8675A;
  --ok-soft: rgba(143,181,126,.14); --watch-soft: rgba(210,181,117,.14); --alert-soft: rgba(216,103,90,.14);
  --cat-1: #5BBAC4; --cat-2: #D2B575; --cat-3: #C68DA0; --cat-4: #8FB57E; --cat-5: #CE8E72; --cat-6: #7E97C4;
  --wash: radial-gradient(70% 50% at 15% 0%, rgba(91,186,196,.10), transparent 60%);
  --shadow: 0 24px 60px -30px rgba(0,0,0,.7); --focus: 0 0 0 3px rgba(91,186,196,.22);
  color-scheme: dark;
}

/* ---------- MODE · LIGHT (default for linen) ---------- */
[data-mode="light"], [data-palette="linen"]:not([data-mode="dark"]) {
  --base: #FBF8F2; --surface: #F4EEE2; --surface-2: #EDE6D8; --desk: #E6DFD1;
  /* Light contrast floor: every text token clears 4.5:1 against --base, --surface AND --surface-2, not base alone. FlowMap fills its nodes with --surface and --surface-2, so a node's mono sub label is text on a card, and the darkest surface sets the floor. Run `node ds-v2/check.js --tokens` after any change here. Hairlines run heavier than dark because cream hides low alpha. */
  --line: rgba(60,48,30,.16); --line-2: rgba(60,48,30,.30);
  --text: #2A2218; --text-2: #6B5E4C; --text-3: #73654C; --text-on-accent: #FBF8F2;
  /* On light, brighter means deeper: --primary-bright is the hover and emphasis step below --primary, not above it. */
  --primary: #15706F; --primary-bright: #0F5F5E; --primary-deep: #0E4F4E;
  --primary-ring: rgba(21,112,111,.22); --primary-soft: rgba(21,112,111,.09);
  --gold: #826126; --emphasis: #826126; --underline: rgba(166,100,126,.45);
  --ok: #33734C; --watch: #866026; --alert: #A54D3A;
  --ok-soft: rgba(53,119,79,.12); --watch-soft: rgba(148,106,42,.13); --alert-soft: rgba(168,78,59,.12);
  --cat-1: #15706F; --cat-2: #B58942; --cat-3: #AB664A; --cat-4: #B36C65; --cat-5: #A6647E; --cat-6: #435F8A;
  --wash: none;
  --shadow: 0 22px 50px -32px rgba(40,28,12,.35); --focus: 0 0 0 3px rgba(21,112,111,.22);
  color-scheme: light;
}

/* ---------- REGISTER · EDITORIAL (mode-independent: which accents exist) ---------- */
[data-palette="editorial"] {
  --emphasis: var(--gold);                  /* FlowMap: the one path that matters. The only non-neutral color a map may use here. */
  /* status and categorical are NOT part of this register. They resolve to neutral so a leak renders grey, and check.js fails the file. */
  --ok: var(--text-2); --watch: var(--text-2); --alert: var(--text-2);
  --ok-soft: transparent; --watch-soft: transparent; --alert-soft: transparent;
  --cat-1: var(--text-3); --cat-2: var(--text-3); --cat-3: var(--text-3); --cat-4: var(--text-3); --cat-5: var(--text-3); --cat-6: var(--text-3);
}
[data-palette="editorial"]:not([data-mode="light"]) {
  --base: #141113;
  --wash: radial-gradient(60% 40% at 85% 0%, rgba(210,181,117,.08), transparent 60%), radial-gradient(60% 40% at 0% 10%, rgba(91,186,196,.08), transparent 60%);
}
[data-palette="editorial"][data-mode="light"] {
  --wash: radial-gradient(60% 40% at 85% 0%, rgba(168,128,58,.07), transparent 60%);
}

/* ---------- LIBRON · serif ----------
   Every register sets the serif in Libron (a Newsreader derivative with more weight, tuned for reading).
   Libron ships 400 + 700 only: weight 500 resolves to Regular, 600+ to Bold. Files live in fonts/ beside ds-v2/. */
@font-face { font-family: 'Libron'; src: url('../fonts/Libron-Regular.woff2') format('woff2'); font-weight: 400 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Libron'; src: url('../fonts/Libron-Italic.woff2') format('woff2'); font-weight: 400 500; font-style: italic; font-display: swap; }
@font-face { font-family: 'Libron'; src: url('../fonts/Libron-Bold.woff2') format('woff2'); font-weight: 600 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Libron'; src: url('../fonts/Libron-BoldItalic.woff2') format('woff2'); font-weight: 600 800; font-style: italic; font-display: swap; }

/* ---------- REGISTER · LINEN (documents) ---------- */
[data-palette="linen"] { --wash: none; }
[data-palette="linen"][data-mode="dark"] { --base: #171316; --surface: #1F1A1E; --surface-2: #27211F; --desk: #100D0F; }

/* v1 alias bridge so existing components re-theme */
:root, [data-palette] {
  --success: var(--ok); --warning: var(--watch); --error: var(--alert); --info: var(--primary);
  --secondary: var(--alert); --accent-warm: var(--watch);
  --surface-lift: transparent; --surface-lift-2: var(--surface-2);
  --primary-glow: transparent; --glow-primary: none; --glow-primary-sm: none; --glow-coral: none;
  --aurora: var(--wash); --focus-ring: var(--focus);
  --shadow-card: var(--shadow); --shadow-panel: var(--shadow);
  --status-on: var(--ok); --status-risk: var(--watch); --status-off: var(--alert);
  --status-on-bg: var(--ok-soft); --status-risk-bg: var(--watch-soft); --status-off-bg: var(--alert-soft);
}

body { font-family: var(--font-sans); background: var(--base); color: var(--text); -webkit-font-smoothing: antialiased; }
p { text-wrap: pretty; }
::selection { background: var(--primary-ring); }
