/* ==========================================================================
   tokens.css — Unified Cross-Site Design Token System
   Shared across: BeaconLight Research, Garman Unified Systems,
                  iDirect Ships, and DRUstack.
   Principle: Shared structure & semantic contract; brand-owned palettes.
   House core: Garman Meridian canonical tokens (--gm-*), v2026.12.
   Law: 90% rag & ink · 8% structural pigment · 2% Venetian sanguine focal.
   ========================================================================== */

/* ── Garman Meridian House Bloodline (invariant across all five rooms) ── */
:root {
  --gm-vellum:        #F5EFE2; /* primary aged cotton-rag sheet */
  --gm-vellum-plate:  #FAF6EC; /* raised paper / framed plate card */
  --gm-vellum-deep:   #ECE3D0; /* recessed drafting bed */
  --gm-ink:           #231B14; /* iron-gall walnut ink (14.9:1) */
  --gm-ink-sepia:     #574B40; /* secondary prose (7.1:1) */
  --gm-ink-muted:     #685B4E; /* captions & mono metadata (5.4:1 AA+) */

  --gm-harbor:        #23404E; /* harbor slate-teal (9.6:1) */
  --gm-harbor-soft:   rgba(35, 64, 78, 0.08);
  --gm-verdigris:     #1F543E; /* verified pass */
  --gm-verdigris-soft: rgba(31, 84, 62, 0.09);
  --gm-amber:         #B87D28; /* burnished brass: construction & threshold hairlines */
  --gm-amber-soft:    rgba(184, 125, 40, 0.18);

  --gm-sanguine:      #8B2C1D; /* Venetian red chalk (7.2:1), focal only */
  --gm-sanguine-deep: #6E2115;
  --gm-sanguine-soft: rgba(139, 44, 29, 0.10);

  --gm-rule:          rgba(35, 27, 20, 0.22);
  --gm-rule-faint:    rgba(35, 27, 20, 0.12);
  --gm-rule-strong:   rgba(35, 27, 20, 0.44);

  --gm-font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --gm-font-sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  --gm-font-mono:  "JetBrains Mono", "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gm-nav-h:         62px;
  --gm-scroll-offset: 88px;
  --gm-radius:        2px; /* strictly 2px letterpress; zero pill radii */
  --gm-ease:          cubic-bezier(0.16, 1, 0.3, 1);
  --gm-dur-fast:      120ms;
  --gm-dur-med:       220ms;
  --gm-room-accent:   var(--gm-harbor);
}

[data-gm-room="beaconlight"] {
  --gm-room-accent: var(--gm-verdigris);
  --gm-container-max: 1140px;
}

/* Nocturne: same bloodline, lamplit inversion */
[data-theme="dark"] {
  --gm-vellum:        #16120E;
  --gm-vellum-plate:  #1D1813;
  --gm-vellum-deep:   #241E17;
  --gm-ink:           #EFE7D8;
  --gm-ink-sepia:     #C3B5A0;
  --gm-ink-muted:     #A39380;
  --gm-harbor:        #8DB4C4;
  --gm-harbor-soft:   rgba(141, 180, 196, 0.12);
  --gm-verdigris:     #6FC49B;
  --gm-verdigris-soft: rgba(111, 196, 155, 0.13);
  --gm-amber:         #DFAC5C;
  --gm-amber-soft:    rgba(223, 172, 92, 0.18);
  --gm-sanguine:      #D96B52;
  --gm-sanguine-deep: #E48A72;
  --gm-sanguine-soft: rgba(217, 107, 82, 0.13);
  --gm-rule:          rgba(239, 231, 216, 0.20);
  --gm-rule-faint:    rgba(239, 231, 216, 0.10);
  --gm-rule-strong:   rgba(239, 231, 216, 0.40);
}

section[id],
div[id] {
  scroll-margin-top: var(--gm-scroll-offset, 88px);
}

.gm-tnum {
  font-variant-numeric: tabular-nums lining-nums slashed-zero;
}

:root {
  /* ── Typography ── */
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --text-xs:   clamp(0.6875rem, 0.670rem + 0.08vw, 0.75rem);   /* 11–12px */
  --text-sm:   clamp(0.8125rem, 0.795rem + 0.10vw, 0.875rem);  /* 13–14px */
  --text-base: clamp(1rem,      0.970rem + 0.15vw, 1.0625rem); /* 16–17px */
  --text-md:   clamp(1.125rem,  1.070rem + 0.25vw, 1.25rem);
  --text-lg:   clamp(1.375rem,  1.250rem + 0.60vw, 1.75rem);
  --text-xl:   clamp(1.75rem,   1.450rem + 1.40vw, 2.5rem);
  --text-2xl:  clamp(2.25rem,   1.700rem + 2.60vw, 3.75rem);
  --text-hero: clamp(2.75rem,   1.900rem + 4.20vw, 5.5rem);

  --lh-tight: 1.08;
  --lh-snug:  1.25;
  --lh-body:  1.62;
  --lh-prose: 1.70;

  --track-tight:  -0.025em;
  --track-normal:  0;
  --track-label:   0.11em;

  --fvn-tabular: tabular-nums lining-nums slashed-zero;

  /* ── Spacing Rhythm (4px base, modular progression) ── */
  --space-1:  0.25rem;  /*  4px */
  --space-2:  0.5rem;   /*  8px */
  --space-3:  0.75rem;  /* 12px */
  --space-4:  1rem;     /* 16px */
  --space-5:  1.5rem;   /* 24px */
  --space-6:  2rem;     /* 32px */
  --space-7:  3rem;     /* 48px */
  --space-8:  4rem;     /* 64px */
  --space-9:  6rem;     /* 96px */
  --space-10: 8rem;     /* 128px */

  --section-y:     clamp(4rem, 3rem + 5vw, 6.75rem);
  --gutter:        clamp(1.25rem, 4vw, 2.5rem);
  --container-max: 77.5rem; /* 1240px */
  --prose-max:     68ch;

  /* ── Shape, Hairlines & Elevation (Archival Print) ── */
  --radius-sm:   0px;
  --radius-md:   2px;
  --radius-lg:   2px;
  --radius-pill: 0px;

  --hairline-w: 1px;
  --hairline:   var(--hairline-w) solid var(--border-hairline);

  --shadow-rgb: 20 20 19;
  --shadow-1: none;
  --shadow-2: 0 2px 8px rgb(var(--shadow-rgb) / 0.08);
  --shadow-3: 0 6px 18px rgb(var(--shadow-rgb) / 0.10);

  /* ── Z-Index Layers ── */
  --z-base:    0;
  --z-bar:     95;
  --z-sticky:  100;
  --z-drawer:  200;
  --z-overlay: 300;
  --z-toast:   400;

  /* ── Motion Rhythm ── */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:   cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 120ms;
  --dur-med:  240ms;
  --dur-slow: 480ms;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0.01ms;
    --dur-med:  0.01ms;
    --dur-slow: 0.01ms;
  }
  html:focus-within {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   SEMANTIC SURFACE & INK CONTRACT
   Every property defines: --bg-canvas, --bg-elevated, --bg-surface,
   --ink-primary, --ink-secondary, --ink-muted, --border-hairline,
   --accent-primary, --accent-signal, --status-verified, --status-warn,
   --focus-ring, --shadow-rgb.
   ========================================================================== */

/* ── 1. BeaconLight Research: Vellum — laid rag, iron-gall & sanguine (Light Default) ── */
[data-brand="beaconlight"],
[data-brand="beaconlight"][data-theme="light"] {
  --bg-canvas:       #F5EFE2; /* = --gm-vellum */
  --bg-elevated:     #FAF6EC; /* = --gm-vellum-plate */
  --bg-surface:      #ECE3D0; /* = --gm-vellum-deep */
  --ink-primary:     #231B14; /* = --gm-ink */
  --ink-secondary:   #574B40; /* = --gm-ink-sepia */
  --ink-muted:       #685B4E; /* = --gm-ink-muted (5.4:1 AA+) */
  --border-hairline: rgba(35, 27, 20, 0.22); /* = --gm-rule */
  --accent-primary:  #8b2c1d; /* Venetian sanguine red chalk */
  --accent-signal:   #8b2c1d;
  --status-verified: #1f543e; /* archival verdigris */
  --status-warn:     #8b2c1d;
  --focus-ring:      #8b2c1d;
  --shadow-rgb:      35 27 20;
}

/* ── 1b. BeaconLight Research: Nocturne (Optional Dark) ── */
[data-brand="beaconlight"][data-theme="dark"] {
  --bg-canvas:       #16120e;
  --bg-elevated:     #1d1813;
  --bg-surface:      #241e17;
  --ink-primary:     #efe7d8;
  --ink-secondary:   #c3b5a0;
  --ink-muted:       #a39380;
  --border-hairline: #3a3128;
  --accent-primary:  #d96b52;
  --accent-signal:   #d96b52;
  --status-verified: #6fc49b;
  --status-warn:     #d96b52;
  --focus-ring:      #d96b52;
  --shadow-rgb:      0 0 0;
}

/* ── 2. Garman Unified Systems: Light Paper (Default) & Dark ── */
[data-brand="gusystems"],
[data-brand="gusystems"][data-theme="light"],
[data-brand="gusystems"][data-theme="paper"] {
  --font-mono:       "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --bg-canvas:       #faf9f6;
  --bg-elevated:     #ffffff;
  --bg-surface:      #f3efe7;
  --ink-primary:     #141413;
  --ink-secondary:   #4a4843;
  --ink-muted:       #69665f;
  --border-hairline: rgb(20 20 19 / 0.12);
  --accent-primary:  #0f5257;
  --accent-signal:   #8c6239;
  --status-verified: #1f7a5a;
  --status-warn:     #9a4a1f;
  --focus-ring:      #0f5257;
  --shadow-rgb:      20 20 19;
}

[data-brand="gusystems"][data-theme="dark"] {
  --font-mono:       "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --bg-canvas:       #121211;
  --bg-elevated:     #1a1a18;
  --bg-surface:      #22221f;
  --ink-primary:     #f7f5f0;
  --ink-secondary:   #b8b4ac;
  --ink-muted:       #99958d;
  --border-hairline: rgb(247 245 240 / 0.14);
  --accent-primary:  #67c3ba;
  --accent-signal:   #c9a77c;
  --status-verified: #6fcf9f;
  --status-warn:     #e0a06a;
  --focus-ring:      #67c3ba;
  --shadow-rgb:      0 0 0;
}

/* ── 3. iDirect Ships: Walnut Workbench (Dark) & Cool Drafting Chart (Light) ── */
[data-brand="idirectships"],
[data-brand="idirectships"][data-theme="dark"] {
  --font-serif:      "Routed Gothic", "EB Garamond", Georgia, serif;
  --font-sans:       "Alegreya Sans", "osifont", system-ui, sans-serif;
  --font-mono:       "Departure Mono", "JetBrains Mono", ui-monospace, monospace;
  --bg-canvas:       #1a120c;
  --bg-elevated:     #281e16;
  --bg-surface:      #382a20;
  --ink-primary:     #f6f0e3;
  --ink-secondary:   #d3c9b4;
  --ink-muted:       #a89c86;
  --border-hairline: rgb(212 174 106 / 0.24);
  --accent-primary:  #d4ae6a; /* Brushed Brass */
  --accent-signal:   #d9826b;
  --status-verified: #6fbf9a;
  --status-warn:     #e0a35a;
  --focus-ring:      #d4ae6a;
  --shadow-rgb:      0 0 0;
}

[data-brand="idirectships"][data-theme="light"] {
  --font-serif:      "Routed Gothic", "EB Garamond", Georgia, serif;
  --font-sans:       "Alegreya Sans", "osifont", system-ui, sans-serif;
  --font-mono:       "Departure Mono", "JetBrains Mono", ui-monospace, monospace;
  --bg-canvas:       #dbe7ea; /* Cool Drafting Chart */
  --bg-elevated:     #f4f0e3; /* Archival Paper */
  --bg-surface:      #c7d8dc;
  --ink-primary:     #22313c;
  --ink-secondary:   #46545b;
  --ink-muted:       #56646b;
  --border-hairline: rgb(11 43 85 / 0.20);
  --accent-primary:  #0b2b55; /* Harbor */
  --accent-signal:   #b45f4c;
  --status-verified: #1e563f;
  --status-warn:     #8c3d2b;
  --focus-ring:      #0b2b55;
  --shadow-rgb:      11 43 85;
}

/* ── 4. DRUstack: Technical Documentation Skin (Light Default & Dark) ── */
[data-brand="drustack"],
[data-brand="drustack"][data-theme="light"] {
  --bg-canvas:       #f7f8fa;
  --bg-elevated:     #ffffff;
  --bg-surface:      #eef0f4;
  --ink-primary:     #12161c;
  --ink-secondary:   #3b4350;
  --ink-muted:       #5d6675;
  --border-hairline: rgb(18 22 28 / 0.12);
  --accent-primary:  #3b4fd1;
  --accent-signal:   #b8480f;
  --status-verified: #17794f;
  --status-warn:     #a85d00;
  --focus-ring:      #3b4fd1;
  --shadow-rgb:      18 22 28;
}

[data-brand="drustack"][data-theme="dark"] {
  --bg-canvas:       #0b0d10;
  --bg-elevated:     #12151a;
  --bg-surface:      #181c22;
  --ink-primary:     #eceff3;
  --ink-secondary:   #b4bbc6;
  --ink-muted:       #8f98a6;
  --border-hairline: rgb(236 239 243 / 0.12);
  --accent-primary:  #8b9dff;
  --accent-signal:   #ff9f6b;
  --status-verified: #4fd1a1;
  --status-warn:     #f0b429;
  --focus-ring:      #8b9dff;
  --shadow-rgb:      0 0 0;
}

/* ── Shared Utilities ── */
.tnum {
  font-variant-numeric: var(--fvn-tabular);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: 2px;
}
