/*
 * Chartlumo website – design tokens.
 * Source of truth for colours, type, space, radii, shadows and glass materials.
 * Dark is the default; light applies via :root[data-theme="light"] (set by /theme-init.js before first paint).
 * Colours derive from the existing Chartlumo palette (landing/style.css + theme.css, November 2026).
 * Contrast values are documented in docs/WEBSITE-DESIGNSYSTEM.md.
 */

:root {
  color-scheme: dark;

  /* Backgrounds */
  --bg: #121311;              /* page */
  --bg-alt: #171815;          /* set-off section band */
  --surface-1: #1e1f1c;       /* panels, cards, device bezel */
  --surface-2: #262724;       /* nested controls, inputs, hover fill */

  /* Text */
  --text-1: #eee8dc;          /* primary: headings, body on emphasis */
  --text-2: #a8a294;          /* secondary: body copy, descriptions */
  --text-3: #958f83;          /* tertiary: captions, meta – still ≥ 4.5:1 on every surface */

  /* Gold accent */
  --gold: #dcc9a4;            /* gold as text/icon/serif statements */
  --gold-fill: #dcc9a4;       /* filled primary button, selected segment */
  --gold-fill-hover: #e6d6b6;
  --gold-fill-pressed: #cdb991;
  --on-gold: #141412;         /* text on gold fill */
  --gold-line: rgba(220, 201, 164, .48); /* meaningful gold borders (≥ 3:1) */
  --gold-tint: rgba(220, 201, 164, .12); /* quiet gold wash: badge, selected row */

  /* Chart semantics (always paired with sign/arrow/shape, never colour alone) */
  --pos: #9db384;
  --pos-tint: rgba(157, 179, 132, .14);
  --neg: #c98b78;
  --neg-tint: rgba(201, 139, 120, .14);

  /* Lines */
  --line: rgba(236, 228, 212, .11);        /* hairline separators (decorative) */
  --line-strong: rgba(236, 228, 212, .2);  /* panel outlines */
  --line-ui: rgba(236, 228, 212, .42);     /* control boundaries that must be seen (≥ 3:1) */

  /* Interaction */
  --focus: #dcc9a4;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--focus);
  --hover: rgba(236, 228, 212, .06);
  --pressed: rgba(236, 228, 212, .1);
  --selected: var(--gold-tint);
  --disabled-opacity: .45;

  /* Shadows – restrained, always offset + soft */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 16px -8px rgba(0, 0, 0, .55);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .3), 0 24px 48px -24px rgba(0, 0, 0, .75);
  --shadow-device: 0 40px 80px -36px rgba(0, 0, 0, .85), 0 12px 24px -16px rgba(0, 0, 0, .6);

  /* Glass material (small floating chrome only) */
  --glass-bg: rgba(30, 31, 28, .78);
  --glass-bg-solid: rgba(30, 31, 28, .97);
  --sheet-bg: #1e1f1c;        /* opaque menu sheet below the glass bar */
  --glass-chip-bg: rgba(24, 25, 22, .84);
  --glass-border: rgba(238, 232, 220, .1);
  --glass-edge-top: rgba(255, 250, 238, .1);
  --glass-edge-bottom: rgba(0, 0, 0, .28);
  --glass-sheen: linear-gradient(180deg, rgba(255, 250, 238, .05), rgba(255, 250, 238, 0) 55%);
  --glass-shadow: 0 10px 28px -14px rgba(0, 0, 0, .7);
  --glass-text-2: #cfc8b9;    /* secondary text on glass (≥ 4.5:1 even over white) */
  --glass-blur: 18px;

  /* Device frame (phone bezel stays dark in both themes, like real hardware) */
  --device-bezel: #0b0c0a;
  --device-outline: rgba(236, 228, 212, .16);

  --theme-color: #121311;    /* mirrors meta[name=theme-color] */

  /* Type families – system fonts only (CSP: no web fonts) */
  --sans: "Avenir Next", Avenir, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

  /* Type scale (fluid between 360px and 1440px viewport) */
  --fs-display: clamp(2.75rem, 1.85rem + 4vw, 5.5rem);      /* 44 → 88 */
  --fs-h2: clamp(2rem, 1.55rem + 2vw, 3.25rem);             /* 32 → 52 */
  --fs-serif: clamp(1.625rem, 1.3rem + 1.45vw, 2.625rem);   /* 26 → 42 */
  --fs-h3: clamp(1.25rem, 1.15rem + .45vw, 1.5rem);         /* 20 → 24 */
  --fs-lead: clamp(1.125rem, 1.05rem + .35vw, 1.3125rem);   /* 18 → 21 */
  --fs-body: clamp(1rem, .97rem + .14vw, 1.0625rem);        /* 16 → 17 */
  --fs-small: .875rem;                                       /* 14 */
  --fs-caption: .8125rem;                                    /* 13 */
  --fs-label: .75rem;                                        /* 12 */

  --lh-display: 1.02;
  --lh-h2: 1.08;
  --lh-h3: 1.25;
  --lh-lead: 1.55;
  --lh-body: 1.65;
  --lh-tight: 1.35;

  --ls-display: -.035em;
  --ls-h2: -.025em;
  --ls-h3: -.012em;
  --ls-label: .08em;

  --measure: 66ch;

  /* Space (4px grid) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 128px;
  --section-y: clamp(72px, 4rem + 4.5vw, 136px);
  --gutter: clamp(16px, 1rem + 2vw, 40px);

  /* Layout widths */
  --w-text: 720px;
  --w-std: 1180px;
  --w-wide: 1360px;

  /* Radii */
  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 22px; --r-pill: 999px;
  --r-device: 13.5% / 6.2%;   /* proportional iPhone-like corners for the 690/1500 frame */

  /* Motion */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --dur-1: 120ms; --dur-2: 220ms; --dur-3: 420ms;

  /* Layers */
  --z-header: 40; --z-menu: 45; --z-skip: 60;
  --header-h: 64px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f5f3ee;
  --bg-alt: #eeece5;
  --surface-1: #ffffff;
  --surface-2: #e9e5dc;

  --text-1: #24251f;
  --text-2: #686458;
  --text-3: #6b665a;

  --gold: #78603c;
  --gold-fill: #78603c;
  --gold-fill-hover: #6b5534;
  --gold-fill-pressed: #5f4b2e;
  --on-gold: #fbfaf6;
  --gold-line: rgba(120, 96, 60, .76);
  --gold-tint: rgba(120, 96, 60, .1);

  --pos: #4e6935;
  --pos-tint: rgba(78, 105, 53, .1);
  --neg: #a14e3c;
  --neg-tint: rgba(161, 78, 60, .08);

  --line: rgba(45, 42, 32, .11);
  --line-strong: rgba(45, 42, 32, .21);
  --line-ui: rgba(45, 42, 32, .52);

  --focus: #78603c;
  --hover: rgba(45, 42, 32, .05);
  --pressed: rgba(45, 42, 32, .09);

  --shadow-1: 0 1px 2px rgba(55, 47, 30, .08), 0 6px 16px -8px rgba(55, 47, 30, .18);
  --shadow-2: 0 2px 6px rgba(55, 47, 30, .07), 0 24px 48px -24px rgba(55, 47, 30, .28);
  --shadow-device: 0 40px 80px -40px rgba(55, 47, 30, .35), 0 10px 24px -16px rgba(55, 47, 30, .22);

  --glass-bg: rgba(251, 250, 247, .8);
  --glass-bg-solid: rgba(251, 250, 247, .97);
  --sheet-bg: #fbfaf7;
  --glass-chip-bg: rgba(251, 250, 247, .86);
  --glass-border: rgba(45, 42, 32, .1);
  --glass-edge-top: rgba(255, 255, 255, .95);
  --glass-edge-bottom: rgba(45, 42, 32, .07);
  --glass-sheen: linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 55%);
  --glass-shadow: 0 10px 28px -16px rgba(55, 47, 30, .3);
  --glass-text-2: #4f4b41;

  --device-bezel: #1d1e1b;
  --device-outline: rgba(45, 42, 32, .22);

  --theme-color: #f5f3ee;
}
