/* ══════════════════════════════════════════════════════════
   maclaine.se design tokens (plain CSS, no build step)

   On finance pages it sits on the line directly above /finance/_shared.css;
   on the homepage family it is the line before the page's <style> (after
   /fonts/fonts.css, which only declares font faces). Once pushed, bump the ?v=
   query on every page and in sw.js PRECACHE when this file changes.

   Four layers, top to bottom:
   1. Primitives (--p-*): raw values named by hue and step, with no meaning.
      Components never read them directly.
   2. Semantic tokens (--bg, --ink, --accent, ...): what pages and components
      consume. The names are the finance suite's set, which carries the WCAG AA
      work (see the notes on --faint-2, --accent-text and --on-accent).
      Light is the default on :root, dark is [data-theme="dark"] on <html>.
   3. Looks: [data-look="home"] on <html> re-points the semantic tokens to the
      old homepage gold set (dark only). It falls through to the dark set for
      any name it does not set. [data-look="lav"] is the redesign (light and
      dark, the homepage since 2026-10-25); it also carries --hairline and the
      six type roles (--t-*, --lh-*, --tr-*).
   4. Compatibility aliases (--text, --border, --grotesk, ...): the older
      homepage names, pointing at semantic tokens so those pages keep working
      unchanged. Rename at leisure, then delete the alias.
   Chart colours (--chart-*) are read by finance/_shared.js (the CC palette).

   A redesign edits the primitives and the look blocks. Pages and tools keep
   their selectors; page-local overrides stay in the page and win by order.

   Specificity: every block here is a single class-level selector (0,1,0)
   and their order matters: :root, then dark, then the home look. A page's own
   :root block comes later, so it still wins.

   Breakpoints cannot be custom properties. The suite's common ones are 480,
   600 and 860 px (860 also switches --gutter below), plus (hover: none).
   ══════════════════════════════════════════════════════════ */

/* ── 1. Primitives ── */
:root {
  /* Sand (light surfaces and lines) */
  --p-sand-50: #FBF9F3;
  --p-sand-100: #F4F1EA;
  --p-sand-200: #EFEADC;
  --p-sand-300: #E7E0D1;
  --p-sand-400: #E2DBCC;

  /* Night (dark surfaces) */
  --p-night-950: #13151A;
  --p-night-900: #1A1D24;
  --p-night-850: #1C1F27;
  --p-night-800: #21252E;

  /* Ink and cream (body text) */
  --p-ink-900: #1C1E22;
  --p-cream-100: #EDE6D6;

  /* Slate and stone (secondary text) */
  --p-slate-600: #65686F;
  --p-slate-500: #84878F;
  --p-slate-480: #868991;
  --p-slate-460: #8A8D95;
  --p-slate-400: #9A9EA6;
  --p-slate-300: #A3A8B0;
  --p-stone-600: #6E6A5E;
  --p-stone-650: #6A665A;

  /* Gold (the accent) */
  --p-gold-300: #D4A95A;
  --p-gold-400: #C8974A;
  --p-gold-500: #B5792B;
  --p-gold-600: #966020;
  --p-gold-700: #8F5B1D;
  --p-gold-400-a10: rgba(200,151,74,0.10);
  --p-gold-400-a11: rgba(200,151,74,0.11);
  --p-gold-400-a13: rgba(200,151,74,0.13);
  --p-gold-400-a14: rgba(200,151,74,0.14);
  --p-gold-400-a22: rgba(200,151,74,0.22);
  --p-gold-400-a32: rgba(200,151,74,0.32);
  --p-gold-500-a10: rgba(181,121,43,0.10);

  /* Green and sage */
  --p-green-600: #43775D;
  --p-green-700: #376B51;
  --p-sage-300: #8FA89E;
  --p-sage-300-a15: rgba(143,168,158,0.15);

  /* Red */
  --p-red-600: #B04A35;
  --p-red-700: #A03F2B;
  --p-red-300: #E07070;
  --p-red-300-a15: rgba(224,112,112,0.15);

  /* Shadows */
  --p-shadow-light: 0 2px 18px rgba(120,90,30,0.06);
  --p-shadow-dark: 0 10px 34px rgba(0,0,0,0.34);

  /* Type families */
  --p-font-schibsted: 'Schibsted Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --p-font-jakarta: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --p-font-dm-mono: 'DM Mono', ui-monospace, 'SF Mono', monospace;
  --p-font-dm-mono-home: 'DM Mono', ui-monospace, monospace;
  --p-font-cormorant: 'Cormorant Garamond', ui-serif, Georgia, serif;

  /* Layout, shape and motion */
  --p-width-1200: 1200px;
  --p-space-56: 56px;
  --p-space-22: 22px;
  --p-radius-4: 4px;
  --p-ease-out-a: cubic-bezier(0.22, 1, 0.36, 1);
  --p-ease-out-b: cubic-bezier(0.25, 1, 0.5, 1);

  /* Lav (the redesign, 2026-10-25): one hue, 148 OKLCH, for every neutral in both
     themes. Steps run light to dark; the comment says which job each one has. */
  --p-lav-50: #DBE2DB;    /* dark ink */
  --p-lav-100: #C8D0C8;   /* light surface */
  --p-lav-150: #BCC6BD;   /* light ground */
  --p-lav-200: #ABB4AC;   /* light water */
  --p-lav-250: #A4ACA4;   /* dark muted */
  --p-lav-300: #99A19A;   /* light hairline */
  --p-lav-700: #424842;   /* dark hairline */
  --p-lav-750: #3D433D;   /* light muted */
  --p-lav-800: #2C332D;   /* dark surface */
  --p-lav-850: #242A25;   /* dark ground */
  --p-lav-900: #181D18;   /* dark water */
  --p-lav-950: #161A16;   /* light ink */
  --p-cobalt-700: #293785;   /* light accent: text links and focus only */
  --p-cobalt-300: #9FB1EE;   /* dark accent */
  --p-font-dm-sans: 'DM Sans', 'Helvetica Neue', Arial, sans-serif;
  --p-ease-settle: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ── 2a. Semantic: light (default) ── */
:root {
  --bg: var(--p-sand-100);
  --surface: var(--p-sand-50);
  --surface-2: var(--p-sand-200);
  --ink: var(--p-ink-900);
  --muted: var(--p-slate-600);
  --faint: var(--p-stone-600);
  /* --surface-2 is the darkest light surface, so it is the binding contrast
     constraint: --faint lands on 4.50 there, a hair under AA. --faint-2 is the
     sibling for text on --surface-2, same idea as --accent-text-2. --faint
     itself cannot simply be darkened further without passing --muted, which
     would inverse the hierarchy. */
  --faint-2: var(--p-stone-650);
  --line: var(--p-sand-400);
  --line-2: var(--p-sand-300);
  --accent: var(--p-gold-500);
  --accent-soft: var(--p-gold-500-a10);
  /* Accent TEXT at normal sizes (WCAG AA >= 4.5): darker than --accent, which
     stays for borders/buttons/chart colours/big-number (3:1 display rule).
     --accent-text-2 is the darker sibling for accent text on --surface-2. */
  --accent-text: var(--p-gold-600);
  --accent-text-2: var(--p-gold-700);
  /* Text ON an accent background (buttons, active tabs). #fff was 3.66:1 on the
     light accent and 2.63:1 on the dark one; this dark ink clears AA on both
     (4.56 / 6.34), so no dark-theme override is needed. */
  --on-accent: var(--p-ink-900);
  --green: var(--p-green-600);
  --green-2: var(--p-green-700);   /* --green on --green-soft is 3.97:1; this is 4.73, and it clears --surface-2 too */
  --green-soft: color-mix(in srgb, var(--green) 12%, transparent);
  --red: var(--p-red-600);
  --red-2: var(--p-red-700);   /* --red on a --red-soft tint is 4.14:1; this is 4.95 */
  --red-soft: color-mix(in srgb, var(--red) 12%, transparent);
  --amber: var(--p-gold-500);
  --shadow: var(--p-shadow-light);
  --sans: var(--p-font-schibsted);
  --mono: var(--p-font-dm-mono);
  --serif: var(--p-font-cormorant);
  --maxw: var(--p-width-1200);
  --gutter: var(--p-space-56);
  --radius: var(--p-radius-4);
  --ease: var(--p-ease-out-a);

  /* Chart palette, light. Mirrors _CC_LIGHT in finance/_shared.js, which keeps
     the same values as its fallback (_dev/tokens.test.js keeps them equal).
     Values that match a primitive point at it, so a palette edit reaches the
     charts; the rest are chart-only (the chart green and red are not --green
     and --red today). */
  --chart-accent: var(--p-gold-500);
  --chart-accent-alpha: rgba(181,121,43,0.25);
  --chart-green: #4F8A6D;
  --chart-green-alpha: rgba(79,138,109,0.2);
  --chart-red: #C0563F;
  --chart-red-alpha: rgba(192,86,63,0.5);
  --chart-muted: rgba(101,104,111,0.55);
  --chart-grid: rgba(181,121,43,0.08);
  --chart-text: rgba(28,30,34,0.75);
  --chart-tooltip-bg: var(--p-sand-50);
  --chart-tooltip-border: rgba(0,0,0,0.08);
  --chart-tooltip-title: var(--p-ink-900);
  --chart-tooltip-body: rgba(28,30,34,0.7);
}

@media (max-width: 860px) {
  :root { --gutter: var(--p-space-22); }
}

/* ── 2b. Semantic: dark ──
   The home look also starts from this set (it is dark only). */
[data-theme="dark"], [data-look="home"] {
  --bg: var(--p-night-950);
  --surface: var(--p-night-900);
  --surface-2: var(--p-night-800);
  --ink: var(--p-cream-100);
  --muted: var(--p-slate-400);
  --faint: var(--p-slate-500);
  --faint-2: var(--p-slate-460);
  --line: var(--p-gold-400-a14);
  --line-2: var(--p-gold-400-a13);
  --accent: var(--p-gold-400);
  --accent-soft: var(--p-gold-400-a10);
  /* Dark accent already clears AA on the dark surfaces, so accent text uses it directly. */
  --accent-text: var(--p-gold-400);
  --accent-text-2: var(--p-gold-400);
  --green: var(--p-sage-300);
  --green-2: var(--p-sage-300);   /* dark --green already clears AA on its own tint */
  --green-soft: var(--p-sage-300-a15);
  --red: var(--p-red-300);
  --red-2: var(--p-red-300);   /* dark --red already clears AA on its own tint */
  --red-soft: var(--p-red-300-a15);
  --amber: var(--p-gold-300);
  --shadow: var(--p-shadow-dark);

  /* Chart palette, dark. Mirrors _CC_DARK in finance/_shared.js. */
  --chart-accent: var(--p-gold-400);
  --chart-accent-alpha: rgba(200,151,74,0.25);
  --chart-green: var(--p-sage-300);
  --chart-green-alpha: rgba(143,168,158,0.2);
  --chart-red: var(--p-red-300);
  --chart-red-alpha: rgba(224,112,112,0.6);
  --chart-muted: rgba(122,125,133,0.55);
  --chart-grid: rgba(200,151,74,0.08);
  --chart-text: rgba(237,230,214,0.5);
  --chart-tooltip-bg: #2e2e2e;
  --chart-tooltip-border: rgba(255,255,255,0.1);
  --chart-tooltip-title: #fff;
  --chart-tooltip-body: rgba(240,237,232,0.8);
}

/* ── 3. Look: homepage gold (dark only) ──
   index, cv, photography, coins, domains, blog and its posts, brf.
   Values are the block those pages used to paste into their own :root.
   Page-local deviations stay in the page (brf and domains --muted, the
   brf and domains status colours, cv's missing --accent-line). */
[data-look="home"] {
  --bg: var(--p-night-950);
  --bg-alt: var(--p-night-900);     /* a band between --bg and --surface; only this look has one */
  --surface: var(--p-night-850);
  --ink: var(--p-cream-100);
  --muted: var(--p-slate-480);
  --faint: var(--p-slate-300);
  --line: var(--p-gold-400-a11);
  --line-2: var(--p-gold-400-a22);
  --accent: var(--p-gold-400);
  --accent-soft: var(--p-gold-400-a10);
  --accent-line: var(--p-gold-400-a32);
  --sans: var(--p-font-jakarta);
  --mono: var(--p-font-dm-mono-home);
  --serif: var(--p-font-cormorant);
  --ease: var(--p-ease-out-b);
}

/* ── 3b. Look: Lav (the redesign; the homepage first, BRF, Net Worth and
   Photography next). Light and dark, following the device until the toggle is
   used. One hairline token carries every rule (header line, footer line, the
   Work timeline); --line and --line-2 point at it and --faint at --muted, so a
   component written for the finance names still reads. Accent is for text
   links and the focus ring only. The six type roles from the Claude Design
   handover (01-colour-and-type) are custom properties so every Lav page sets
   the same sizes; weight 300 is only used at 44 px and up.
   Order matters: this block sits after the dark block so [data-look="lav"]
   alone wins over [data-theme="dark"] by source order, and the compound
   selector below wins over both. */
[data-look="lav"] {
  --bg: var(--p-lav-150);
  --surface: var(--p-lav-100);
  --surface-2: var(--p-lav-100);
  --water: var(--p-lav-200);
  --hairline: var(--p-lav-300);
  --line: var(--hairline);
  --line-2: var(--hairline);
  --ink: var(--p-lav-950);
  --muted: var(--p-lav-750);
  --faint: var(--p-lav-750);
  --faint-2: var(--p-lav-750);
  --accent: var(--p-cobalt-700);
  --accent-soft: rgba(41,55,133,0.10);
  --accent-text: var(--p-cobalt-700);
  --accent-text-2: var(--p-cobalt-700);
  --on-accent: var(--p-lav-100);
  --shadow: none;
  --sans: var(--p-font-dm-sans);
  --maxw: 1440px;
  --gutter: var(--p-space-56);
  --radius: 28px;
  --ease: var(--p-ease-settle);

  /* Type roles: size, line height (unitless), tracking. Desktop values; the
     mobile column of the scale applies under 768 px below. */
  --t-display: clamp(64px, 49px + 3.81vw, 104px); --lh-display: 0.93; --tr-display: -0.045em;
  --t-title: clamp(44px, 33.6px + 2.67vw, 72px); --lh-title: 0.945; --tr-title: -0.04em;
  --t-statement: clamp(28px, 23.5px + 1.14vw, 40px); --lh-statement: 1.1; --tr-statement: -0.02em;
  --t-body: clamp(17px, 15.9px + 0.29vw, 20px); --lh-body: 1.5; --tr-body: -0.005em;
  --t-ui: 15px; --lh-ui: 20px;
  --t-caption: 13px; --lh-caption: 18px; --tr-caption: 0.01em;
}
[data-look="lav"][data-theme="dark"] {
  --bg: var(--p-lav-850);
  --surface: var(--p-lav-800);
  --surface-2: var(--p-lav-800);
  --water: var(--p-lav-900);
  --hairline: var(--p-lav-700);
  --ink: var(--p-lav-50);
  --muted: var(--p-lav-250);
  --faint: var(--p-lav-250);
  --faint-2: var(--p-lav-250);
  --accent: var(--p-cobalt-300);
  --accent-soft: rgba(159,177,238,0.12);
  --accent-text: var(--p-cobalt-300);
  --accent-text-2: var(--p-cobalt-300);
  --on-accent: var(--p-lav-900);
}
@media (max-width: 860px) {
  [data-look="lav"] { --gutter: 20px; }
}
@media (max-width: 768px) {
  [data-look="lav"] {
    --lh-display: 0.94; --tr-display: -0.04em;
    --lh-title: 1; --tr-title: -0.03em;
    --lh-statement: 1.143; --tr-statement: -0.015em;
    --lh-body: 1.53; --tr-body: 0;
    --t-ui: 16px; --lh-ui: 22px;
  }
}

/* Finance look (2026-11-01 owner ruling: DM Sans as the one typeface, Clay in light mode,
   the night and gold set kept in dark mode; finance suite only). Finance pages carry data-look="finance" on <html> and <body>, so this block
   also beats the plain [data-theme="dark"] block on <body>. Every text pair here clears
   WCAG AA (4.5:1) on --bg, --surface and --surface-2; --green-2 and --red-2 are for text
   on their own soft tints. Charts read the --chart-* names through finance/_shared.js. */
:root {
  --p-clay-100: #E4D6C9;   /* light surface */
  --p-clay-150: #DECDBF;   /* light surface-2 */
  --p-clay-200: #D8C6B6;   /* light ground */
  --p-clay-400: #B9A491;   /* light hairline */
  --p-clay-600: #5A4536;   /* light muted */
  --p-clay-800: #342820;   /* dark surface */
  --p-clay-850: #2F241D;   /* dark surface-2 */
  --p-clay-900: #2A201A;   /* dark ground */
  --p-clay-700: #4E3E33;   /* dark hairline */
  --p-clay-300: #B8A595;   /* dark muted */
  --p-clay-50: #EADBCD;    /* dark ink */
  --p-clay-950: #24170F;   /* light ink */
  --p-rust-700: #7A3417;   /* light accent */
  --p-rust-300: #E89A73;   /* dark accent */
}
[data-look="finance"] {
  --sans: var(--p-font-dm-sans);
  --serif: var(--p-font-dm-sans);
  --mono: var(--p-font-dm-sans);
  /* Type roles, the homepage scale (see the lav block) at finance sizes. */
  --t-display: clamp(56px, 40px + 3.6vw, 96px); --lh-display: 0.95; --tr-display: -0.045em;
  --t-statement: clamp(24px, 20px + 1vw, 34px); --lh-statement: 1.1; --tr-statement: -0.02em;
  --t-body: clamp(17px, 15.9px + 0.29vw, 20px); --lh-body: 1.5; --tr-body: -0.005em;
  --t-caption: 13px; --tr-caption: 0.01em;
}
/* Clay colours: light mode only. Dark mode keeps the suite's night and gold. */
[data-look="finance"]:not([data-theme="dark"]) {
  --bg: var(--p-clay-200);
  --surface: var(--p-clay-100);
  --surface-2: var(--p-clay-150);
  --hairline: var(--p-clay-400);
  --line: var(--hairline);
  --line-2: var(--hairline);
  --ink: var(--p-clay-950);
  --muted: var(--p-clay-600);
  --faint: var(--p-clay-600);
  --faint-2: var(--p-clay-600);
  --accent: var(--p-rust-700);
  --accent-soft: rgba(122,52,23,0.10);
  --accent-text: var(--p-rust-700);
  --accent-text-2: var(--p-rust-700);
  --on-accent: var(--p-clay-100);
  --green: #2F5E3F;
  --green-2: #285236;
  --green-soft: rgba(47,94,63,0.12);
  --red: #8E2A17;
  --red-2: #7E2412;
  --red-soft: rgba(142,42,23,0.12);
  --amber: var(--p-rust-700);
  --shadow: none;
  --chart-accent: var(--p-rust-700);
  --chart-accent-alpha: rgba(122,52,23,0.22);
  --chart-green: #2F5E3F;
  --chart-green-alpha: rgba(47,94,63,0.2);
  --chart-red: #8E2A17;
  --chart-red-alpha: rgba(142,42,23,0.45);
  --chart-muted: rgba(36,23,15,0.4);
  --chart-grid: rgba(36,23,15,0.08);
  --chart-text: rgba(36,23,15,0.72);
  --chart-tooltip-bg: var(--p-clay-100);
  --chart-tooltip-border: rgba(36,23,15,0.12);
  --chart-tooltip-title: var(--p-clay-950);
  --chart-tooltip-body: rgba(36,23,15,0.75);
}


/* ── 4. Compatibility aliases (old homepage names) ──
   Declared wherever the semantic tokens are, so an alias always follows its
   target (finance pages set data-theme on <body> as well as <html>). */
:root, [data-theme], [data-look] {
  --text: var(--ink);
  --border: var(--line);
  --border-2: var(--line-2);
  --pale: var(--faint);
  --grotesk: var(--sans);
  --bg-2: var(--bg-alt);
  --bg2: var(--bg-alt);       /* domains.html spelling */
  --bh: var(--line-2);        /* domains.html: hover border */
}
