/* ============================================================
   BoardNotes — Design Tokens  (DELIVERABLE)
   Built on the Source Expert Advisors (SXA) brand system.
   Two layers:
     1. PRIMITIVES  — raw brand values (from SXA style guide v2.0)
     2. SEMANTIC    — role-named tokens, themed light + dark
   Consume ONLY the semantic layer in product code. Never a raw
   primitive, never a literal hex. Theme = [data-theme] on <html>
   (falls back to prefers-color-scheme when unset).

   Naming: <group>-<role>[-<modifier>]
     bg-*      surfaces (app < surface < raised < overlay)
     text-*    foreground text/icon
     border-*  strokes / dividers / focus
     brand-*   SXA green — primary action & identity
     accent-*  SXA blue  — provenance / links / info
     ok/warn/danger/info-* functional status
   ============================================================ */

/* ============================================================
   LAYER 1 — PRIMITIVES  (theme-invariant brand truth)
   ============================================================ */
:root {
  /* SXA core palette (exact from guide) */
  --sxa-green: #7EAA2D;  --sxa-blue: #009CD7;  --sxa-gold: #F6C63E;
  --sxa-black: #000000;  --sxa-white: #FFFFFF;

  /* Green ramp (brand primary) */
  --green-750:#56761D; --green-700:#5D7F1F; --green-600:#6E9628; --green-500:#7EAA2D;
  --green-400:#9EBF62; --green-300:#BED596; --green-200:#DFEACB; --green-100:#EEF4E0;
  /* Blue ramp (accent / provenance) */
  --blue-650:#0974A1; --blue-600:#0A7FB0; --blue-500:#009CD7; --blue-400:#40B5E1;
  --blue-300:#80CEEB; --blue-200:#BFE6F5; --blue-100:#E3F4FB;
  /* Gold ramp (secondary / warning) */
  --gold-700:#8B6B0C; --gold-600:#C99A12; --gold-500:#F6C63E; --gold-300:#FAE39F; --gold-100:#FDF6DF;
  /* Functional RED — not in SXA palette; added for error/destructive
     roles, tuned to sit harmoniously beside SXA green/blue. */
  --red-600:#B4362C; --red-500:#CC4033; --red-400:#E0695F;
  --red-300:#F0A9A2; --red-200:#F7D4D0; --red-100:#FBEAE8;
  /* Neutral ramp (SXA black-opacity ladder, resolved) */
  --grey-00:#FFFFFF; --grey-05:#F4F5F2; --grey-10:#E9EAE6; --grey-15:#E0E1DC;
  --grey-20:#CFD0CA; --grey-30:#B4B6AE; --grey-40:#95988E; --grey-50:#767a70;
  --grey-60:#5C5F57; --grey-70:#44463F; --grey-80:#2E302B; --grey-85:#232520;
  --grey-90:#1A1B17; --grey-95:#131410; --grey-100:#0C0D0A;

  /* Typography (SXA — Avenir Next, Eurostile logotype) */
  --font-body:"Avenir Next","Avenir","Segoe UI",-apple-system,BlinkMacSystemFont,system-ui,sans-serif;
  --font-logo:"Eurostile","Univers Condensed","Avenir Next",system-ui,sans-serif;
  --font-mono:"SF Mono","JetBrains Mono",ui-monospace,"Cascadia Code",Menlo,Consolas,monospace;

  --fw-ultralight:200; --fw-regular:400; --fw-medium:500; --fw-demibold:600; --fw-bold:700;

  /* Type scale (desktop app — denser than marketing scale) */
  --fs-display:2.25rem; /* 36 */ --fs-h1:1.75rem; /* 28 */ --fs-h2:1.375rem; /* 22 */
  --fs-h3:1.125rem; /* 18 */ --fs-h4:1rem; /* 16 */
  --fs-body:0.9375rem; /* 15 */ --fs-small:0.8125rem; /* 13 */
  --fs-caption:0.75rem; /* 12 */ --fs-micro:0.6875rem; /* 11 */

  --lh-tight:1.1; --lh-heading:1.25; --lh-body:1.5;
  --tracking-tight:-0.02em; --tracking-body:-0.01em;
  --tracking-caps:0.06em; --tracking-display:-0.03em;

  /* Space (4pt base) */
  --space-1:2px; --space-2:4px; --space-3:8px; --space-4:12px; --space-5:16px;
  --space-6:20px; --space-7:24px; --space-8:32px; --space-9:40px; --space-10:56px;

  /* Radius (brand reads sharp/angular) */
  --radius-xs:2px; --radius-sm:4px; --radius:6px; --radius-lg:10px; --radius-pill:999px;

  /* Motion */
  --ease:cubic-bezier(.2,.6,.2,1); --dur-1:120ms; --dur-2:200ms; --dur-3:320ms;

  /* Layout constants */
  --nav-w:240px; --nav-w-collapsed:64px; --topbar-h:52px; --app-min-w:1024px; --app-min-h:680px;
  --slash-w:5px; --slash-slant:-11deg;

  /* Z ladder */
  --z-sticky:10; --z-nav:20; --z-overlay:40; --z-modal:50; --z-toast:60;
}

/* ============================================================
   LAYER 2 — SEMANTIC  ·  LIGHT  (default)
   ============================================================ */
:root, [data-theme="light"] {
  color-scheme: light;

  /* Surfaces: app is the deepest, each step floats above the last */
  --bg-app:        var(--grey-05);
  --bg-surface:    var(--grey-00);
  --bg-raised:     var(--grey-00);
  --bg-overlay:    var(--grey-00);
  --bg-inset:      var(--grey-05);
  --bg-hover:      rgba(0,0,0,.045);
  --bg-active:     rgba(0,0,0,.075);
  --bg-selected:   var(--green-100);
  --bg-zebra:      rgba(0,0,0,.02);
  --bg-scrim:      rgba(26,27,23,.45);

  /* Text / icon */
  --text-primary:   var(--grey-90);
  --text-secondary: var(--grey-60);
  --text-tertiary:  var(--grey-50);
  --text-disabled:  var(--grey-30);
  --text-inverse:   var(--grey-00);
  --text-link:      var(--blue-600);

  /* Borders */
  --border-subtle:  var(--grey-10);
  --border-default: var(--grey-15);
  --border-strong:  var(--grey-30);
  --border-focus:   var(--blue-500);

  /* Brand — SXA green */
  --brand:        var(--green-500);
  --brand-hover:  var(--green-600);
  --brand-active: var(--green-700);
  --brand-weak:   var(--green-100);
  --brand-weak-border: var(--green-200);
  --brand-text:   var(--green-700);   /* green text on light, AA on --bg-surface */
  --on-brand:     var(--grey-00);

  /* Accent / provenance — SXA blue */
  --accent:       var(--blue-500);
  --accent-hover: var(--blue-600);
  --accent-weak:  var(--blue-100);
  --accent-weak-border: var(--blue-200);
  --accent-text:  var(--blue-650);   /* B-395, F16 R-15 (DIR-F16-08): 4.62:1 on --accent-weak */
  --on-accent:    var(--grey-00);

  /* Functional status */
  --ok:      var(--green-600); --ok-weak:var(--green-100); --ok-text:var(--green-750); --on-ok:var(--grey-00);
  --warn:    var(--gold-500);  --warn-weak:var(--gold-100); --warn-text:var(--gold-700); --on-warn:var(--grey-95);
  --danger:  var(--red-500);   --danger-weak:var(--red-100); --danger-text:var(--red-600); --on-danger:var(--grey-00);
  /* B-115(7) / D-172 — the counter-pill red: ONE named value, every pill. A SEMANTIC
     token, because style.css may consume only this layer (test_token_compliance) — the
     ramp stops are not reachable from an app sheet, which is what made this an addition
     to the contract rather than a line of CSS.
     THE VALUE IS RULED, WITH ITS COST ON THE RECORD. Nathan chose red-400 on 2026-08-05
     from a rendered comparison carrying measured contrast, ACCEPTING that white on
     red-400 is 3.30:1 — below the 4.5:1 WCAG AA floor for 12px bold — and, when shown
     that it required escalating D-049 and amending the v3 freeze, ruled "Pay for red-400
     anyway". The tinted alternative that passed AA at 5.15:1 was offered twice and
     declined. Recorded here because a contrast regression nobody wrote down is
     indistinguishable from a bug. Dark softens to red-300 and GAINS contrast (9.56:1). */
  --counter: var(--red-400); --on-counter: var(--grey-00);
  --info:    var(--blue-500);  --info-weak:var(--blue-100); --info-text:var(--blue-650); --on-info:var(--grey-00);

  /* Elevation (real shadows in light) */
  --shadow-sm: 0 1px 2px rgba(16,18,12,.10);
  --shadow:    0 4px 14px rgba(16,18,12,.12);
  --shadow-lg: 0 16px 40px rgba(16,18,12,.20);

  /* Skeleton shimmer */
  --skeleton-base: var(--grey-10);
  --skeleton-shine: rgba(255,255,255,.65);
}

/* ============================================================
   LAYER 2 — SEMANTIC  ·  DARK
   Dark is a first-class context: surfaces step UP in luminance
   as they rise, borders replace shadows, brand/accent lifted for
   legibility. (surface hierarchy per NN/g + Material tonal rules)
   ============================================================ */
[data-theme="dark"] {
  color-scheme: dark;

  --bg-app:        var(--grey-100);
  --bg-surface:    var(--grey-95);
  --bg-raised:     var(--grey-85);
  --bg-overlay:    var(--grey-80);
  --bg-inset:      #080906;
  --bg-hover:      rgba(255,255,255,.06);
  --bg-active:     rgba(255,255,255,.10);
  --bg-selected:   rgba(126,170,45,.18);
  --bg-zebra:      rgba(255,255,255,.025);
  --bg-scrim:      rgba(0,0,0,.62);

  --text-primary:   #ECEEE7;
  --text-secondary: #AFB3A8;
  --text-tertiary:  #7E8375;
  --text-disabled:  #565A50;
  --text-inverse:   var(--grey-95);
  --text-link:      var(--blue-300);

  --border-subtle:  #24261F;
  --border-default: #33362D;
  --border-strong:  #494D40;
  --border-focus:   var(--blue-400);

  --brand:        var(--green-500);
  --brand-hover:  var(--green-400);
  --brand-active: var(--green-300);
  --brand-weak:   rgba(126,170,45,.16);
  --brand-weak-border: rgba(126,170,45,.34);
  --brand-text:   var(--green-400);
  --on-brand:     #0E1207;

  --accent:       var(--blue-500);
  --accent-hover: var(--blue-400);
  --accent-weak:  rgba(0,156,215,.16);
  --accent-weak-border: rgba(0,156,215,.36);
  --accent-text:  var(--blue-300);
  --on-accent:    #04202b;

  --ok:      var(--green-500); --ok-weak:rgba(126,170,45,.16); --ok-text:var(--green-400); --on-ok:#0E1207;
  --warn:    var(--gold-500);  --warn-weak:rgba(246,198,62,.15); --warn-text:var(--gold-300); --on-warn:var(--grey-95);
  --danger:  var(--red-400);   --danger-weak:rgba(204,64,51,.18); --danger-text:var(--red-300); --on-danger:#2a0906;
  --counter: var(--red-300); --on-counter: #2a0906;
  --info:    var(--blue-400);  --info-weak:rgba(0,156,215,.16); --info-text:var(--blue-300); --on-info:#04202b;

  /* Elevation: shadows read weakly on dark → pair with raised surface + border */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 6px 18px rgba(0,0,0,.5);
  --shadow-lg: 0 18px 44px rgba(0,0,0,.6);

  --skeleton-base: #22241d;
  --skeleton-shine: rgba(255,255,255,.06);
}

/* System-preference fallback when no explicit data-theme is set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg-app:var(--grey-100); --bg-surface:var(--grey-95); --bg-raised:var(--grey-85);
    --bg-overlay:var(--grey-80); --bg-inset:#080906;
    --bg-hover:rgba(255,255,255,.06); --bg-active:rgba(255,255,255,.10);
    --bg-selected:rgba(126,170,45,.18); --bg-zebra:rgba(255,255,255,.025); --bg-scrim:rgba(0,0,0,.62);
    --text-primary:#ECEEE7; --text-secondary:#AFB3A8; --text-tertiary:#7E8375;
    --text-disabled:#565A50; --text-inverse:var(--grey-95); --text-link:var(--blue-300);
    --border-subtle:#24261F; --border-default:#33362D; --border-strong:#494D40; --border-focus:var(--blue-400);
    --brand-hover:var(--green-400); --brand-active:var(--green-300);
    --brand-weak:rgba(126,170,45,.16); --brand-weak-border:rgba(126,170,45,.34);
    --brand-text:var(--green-400); --on-brand:#0E1207;
    --accent-hover:var(--blue-400); --accent-weak:rgba(0,156,215,.16);
    --accent-weak-border:rgba(0,156,215,.36); --accent-text:var(--blue-300); --on-accent:#04202b;
    --ok:var(--green-500); --ok-weak:rgba(126,170,45,.16); --ok-text:var(--green-400); --on-ok:#0E1207;
    --warn-weak:rgba(246,198,62,.15); --warn-text:var(--gold-300);
    --danger:var(--red-400); --danger-weak:rgba(204,64,51,.18); --danger-text:var(--red-300); --on-danger:#2a0906;
    --counter: var(--red-300); --on-counter:#2a0906;
    --info:var(--blue-400); --info-weak:rgba(0,156,215,.16); --info-text:var(--blue-300); --on-info:#04202b;
    --shadow-sm:0 1px 2px rgba(0,0,0,.4); --shadow:0 6px 18px rgba(0,0,0,.5); --shadow-lg:0 18px 44px rgba(0,0,0,.6);
    --skeleton-base:#22241d; --skeleton-shine:rgba(255,255,255,.06);
  }
}
