/* ==========================================================================
   IDigData Design System — site/tokens.css
   Warm Editorial Architecture & Precision Systems Telemetry
   Single shared token & primitive stylesheet for `/` and `/pamphlet`
   ==========================================================================

   GOOGLE FONTS IMPORT (link in <head> on both `/` and `/pamphlet`):
   https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Instrument+Sans:wght@400;500;600&family=Instrument+Serif:ital@0;1&display=swap

   THEME CONVENTION
   - Default (dark-first): :root (warm charcoal #141413, color-scheme: dark)
   - Light mode: set `data-theme="light"` on <html> (`document.documentElement`)
     (tactile bone-white paper #F5F2EB, color-scheme: light)
   - Persist preference in localStorage under key `idigdata-theme` ("dark" | "light")

   CSS CUSTOM PROPERTIES
   Surfaces & Hairlines:
     --bg               Primary canvas (#141413 dark / #F5F2EB light)
     --bg-elevated      Subtle elevated backdrop (#181715 / #EFECE3)
     --surface          Primary card surface (#1c1b19 / #ECE8DF)
     --surface-2        Secondary nested surface / input fill (#242320 / #E4DFD4)
     --surface-glass    Translucent sticky header / toolbar backdrop
     --border           Subtle 1px structural hairline
     --border-strong    Emphasized interactive hairline
     --selected-surface Neutral elevated fill for active non-error selections (e.g. L.01)
     --selected-border  Crisp bone/ink highlight border for active selections

   Typography & Archival Ink:
     --text             Primary high-contrast ink (#F2EFE9 / #161513)
     --text-secondary   Readable body prose ink (#B8B2A7 / #4D4942)
     --text-muted       Captions, metadata, inactive controls (#847E75 / #767168)
     --font-sans        "Instrument Sans", -apple-system, ... (refined 400/500/600)
     --font-serif       "Instrument Serif", Georgia, ... (editorial display accent)
     --font-mono        "IBM Plex Mono", ui-monospace, ... (tabular-nums)

   Semantic Telemetry Palette:
     --accent / --signal  Crisp Swiss Crimson (#e53935 dark / #dc2626 light)
                          Primary CTAs, editorial serif accents, live LED dots,
                          eyebrows, and active progress rail segments.
     --accent-hover / --accent-contrast (#ffffff) / --accent-soft / --accent-border
     --signal-soft / --signal-border
     --success          Muted Sage Emerald (#5FA87C dark / #246B45 light)
                        Verified proof metrics, uptime, and velocity gains.
     --success-soft / --success-border
     --danger           Heavier Oxblood Red (#B83B44 dark / #7F1D24 light)
                        Cost-bleed figures, vendor rent, failure-mode callouts.
     --danger-surface   Tinted oxblood plate (#201315 dark / #EFE3E3 light)
     --danger-soft / --danger-border
     --steel            Muted architectural steel (#7A8FA6 dark / #475569 light)
     --steel-soft / --steel-border

   Soft Luxury Geometry & Damped Motion:
     --hero-glow        none (clean warm matte canvas)
     --shadow-sm/md/lg  Subtle matte depth
     --focus-ring       Crisp 2px offset focus indicator
     --header-h         Sticky header height (68px)
     --container-max    Standard content container width (1180px)
     --container-wide   Wide layout container width (1260px)
     --touch-min        Minimum tablet/touch target size (44px)
     --space-1..8       4px, 8px, 12px, 16px, 24px, 32px, 48px, 64px
     --radius-sm/md/lg/pill  Soft luxury radii (6px, 8px, 10px, 6px)
     --ease             cubic-bezier(0.16, 1, 0.3, 1) (crisp damped response)
     --t-fast           120ms
     --t-med            240ms

   SHARED UTILITY CLASSES
     .container         Centered fluid max-width wrapper
     .eyebrow           Swiss Crimson monospace uppercase kicker
     .mono / .index-tag Tabular-nums IBM Plex Mono helpers
     .font-serif        Instrument Serif display helper
     .editorial-accent  Instrument Serif italic in Swiss Crimson (var(--accent))
     .exposed-grid      Clean hairline grid helper (optional)
     .led-dot           6px Swiss Crimson live status indicator
     .btn               Soft-radius button (44px min-height, 6px radius)
     .btn-primary / .btn.pri   Swiss Crimson primary CTA with white ink
     .btn-ghost         Borderless subtle action button
     .btn-sm            Compact button (40px min-height)
     .theme-toggle      Dark/light switch button (44px touch target)
     .card              Warm elevated surface card (10px radius)
     .card-elevated     Secondary elevated card
     .card-accent       Crimson-ruled highlight card
     .card-danger       Oxblood cost-bleed / failure-mode card
     .badge / .pill     Crisp 6px specification tag
     .badge-accent / .badge-signal / .badge-steel / .badge-success / .badge-danger
     .table-wrap / .data-table  Responsive comparison table
     .divider           1px structural horizontal rule
     .sr-only           Screen-reader-only utility
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Surfaces & Hairlines (Warm Charcoal Dark) */
  --bg: #141413;
  --bg-elevated: #181715;
  --surface: #1c1b19;
  --surface-2: #242320;
  --surface-glass: rgba(20, 20, 19, 0.88);
  --border: rgba(244, 240, 232, 0.09);
  --border-strong: rgba(244, 240, 232, 0.18);

  /* Selected Neutral Layer Highlight (Interactive non-error active state) */
  --selected-border: rgba(244, 240, 232, 0.42);
  --selected-surface: #252421;

  /* Warm Archival Ink */
  --text: #F2EFE9;
  --text-secondary: #B8B2A7;
  --text-muted: #847E75;

  /* Primary Accent & Signal — Crisp Swiss Crimson */
  --accent: #e53935;
  --accent-hover: #ef4444;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(229, 57, 53, 0.12);
  --accent-border: rgba(229, 57, 53, 0.34);

  --signal: #e53935;
  --signal-soft: rgba(229, 57, 53, 0.12);
  --signal-border: rgba(229, 57, 53, 0.34);

  /* Muted Blueprint Steel (Secondary technical annotations) */
  --steel: #7A8FA6;
  --steel-soft: rgba(122, 143, 166, 0.12);
  --steel-border: rgba(122, 143, 166, 0.28);

  /* Sage Emerald (Verified proof metrics, uptime, velocity gains) */
  --success: #5FA87C;
  --success-soft: rgba(95, 168, 124, 0.13);
  --success-border: rgba(95, 168, 124, 0.36);

  /* Heavier Oxblood Red (Cost-bleed figures, vendor rent, failure modes) */
  --danger: #B83B44;
  --danger-surface: #201315;
  --danger-soft: rgba(158, 42, 53, 0.18);
  --danger-border: rgba(184, 59, 68, 0.42);

  --warning: var(--danger);
  --warning-soft: var(--danger-soft);
  --warning-border: var(--danger-border);

  /* Subtle Matte Depth */
  --hero-glow: none;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.26);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.36);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  /* Refined Editorial Typography */
  --font-sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Layout & Spacing */
  --header-h: 68px;
  --container-max: 1180px;
  --container-wide: 1260px;
  --touch-min: 44px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Soft Luxury Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-pill: 6px;

  /* Crisp Damped Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 120ms;
  --t-med: 240ms;

  box-sizing: border-box;
}

/* Light Theme — Tactile Bone-White Paper */
[data-theme="light"] {
  color-scheme: light;

  --bg: #F5F2EB;
  --bg-elevated: #EFECE3;
  --surface: #ECE8DF;
  --surface-2: #E4DFD4;
  --surface-glass: rgba(245, 242, 235, 0.90);
  --border: rgba(20, 19, 17, 0.10);
  --border-strong: rgba(20, 19, 17, 0.20);

  /* Selected Neutral Layer Highlight (Light) */
  --selected-border: rgba(20, 19, 17, 0.42);
  --selected-surface: #E2DDD2;

  --text: #161513;
  --text-secondary: #4D4942;
  --text-muted: #767168;

  /* Swiss Crimson Light */
  --accent: #dc2626;
  --accent-hover: #b91c1c;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(220, 38, 38, 0.09);
  --accent-border: rgba(220, 38, 38, 0.30);

  --signal: #dc2626;
  --signal-soft: rgba(220, 38, 38, 0.09);
  --signal-border: rgba(220, 38, 38, 0.30);

  --steel: #475569;
  --steel-soft: rgba(71, 85, 105, 0.10);
  --steel-border: rgba(71, 85, 105, 0.26);

  /* Sage Emerald Light */
  --success: #246B45;
  --success-soft: rgba(36, 107, 69, 0.10);
  --success-border: rgba(36, 107, 69, 0.34);

  /* Oxblood Light */
  --danger: #7F1D24;
  --danger-surface: #EFE3E3;
  --danger-soft: rgba(127, 29, 36, 0.10);
  --danger-border: rgba(127, 29, 36, 0.38);

  --warning: var(--danger);
  --warning-soft: var(--danger-soft);
  --warning-border: var(--danger-border);

  --hero-glow: none;
  --shadow-sm: 0 1px 2px rgba(20, 19, 17, 0.05);
  --shadow-md: 0 6px 20px rgba(20, 19, 17, 0.07);
  --shadow-lg: 0 16px 36px rgba(20, 19, 17, 0.10);
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

/* ==========================================================================
   Base Reset & Refined Editorial Typography Defaults
   ========================================================================== */

*,
*::before,
*::after,
input,
select,
textarea,
button {
  box-sizing: inherit;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16.5px;
  font-weight: 400;
  line-height: 1.62;
  padding-top: env(safe-area-inset-top, 0px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--t-med) var(--ease), color var(--t-med) var(--ease);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2 {
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.08;
}

h3 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.24;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ==========================================================================
   Shared Layout & Editorial Typographic Utilities
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: clamp(18px, 4.5vw, 56px);
}

.mono,
.index-tag {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.index-tag {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.font-serif {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.editorial-accent {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--accent);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--accent);
}

.exposed-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.exposed-grid > * {
  background: var(--surface);
  min-width: 0;
}

/* Live Status Indicator */
.led-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--signal);
  flex: none;
}

.led-dot-success {
  background: var(--success);
}

.led-dot-steel {
  background: var(--steel);
}

.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-5) 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Buttons (Soft Luxury Radii, 44px Tablet Touch Targets)
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch-min);
  padding: 0.72em 1.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.94rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}

.btn:hover {
  border-color: var(--selected-border);
  background: var(--surface-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary,
.btn.pri {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.btn-primary:hover,
.btn.pri:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm {
  min-height: 40px;
  padding: 0.55em 1.1em;
  font-size: 0.86rem;
}

/* ==========================================================================
   Theme Toggle Primitive
   ========================================================================== */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  flex: none;
}

/* ==========================================================================
   Warm Luxury Cards & Technical Specification Badges
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(22px, 2.8vw, 34px);
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--t-fast) var(--ease),
    background-color var(--t-med) var(--ease);
}

.card-elevated {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.card-accent {
  background: var(--surface);
  border-color: var(--accent-border);
  border-top: 2px solid var(--accent);
}

.card-danger {
  background: var(--danger-surface);
  border-color: var(--danger-border);
  border-top: 2px solid var(--danger);
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.28em 0.7em;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-accent,
.badge-signal {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-steel {
  border-color: var(--steel-border);
  background: var(--steel-soft);
  color: var(--steel);
}

.badge-success {
  border-color: var(--success-border);
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning,
.badge-danger {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

/* ==========================================================================
   Table Primitive
   ========================================================================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table thead th {
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
