/* ==========================================================================
   nuclide-research.com - Core Design System & Shared Surface Tokens
   Nocturnal Obsidian (default) + Daylight Vellum | 100% Local System Stacks
   Zero External CDNs | Strict CSP 'self' | Accessible WCAG AA/AAA Contrast
   ========================================================================== */

:root {
  /* Nocturnal Obsidian Default Tokens (SPEC 2.1) */
  --zs-bg: #09090B;
  --zs-bg-elev: #0F0F14;
  --zs-surface: #14141B;
  --zs-surface-2: #1B1B24;
  --zs-well: #070709;
  --zs-ink: #F4F4F5;
  --zs-ink-soft: #A1A1AA;
  --zs-ink-muted: #9494A0;
  --zs-accent: #E11D48;
  --zs-accent-soft: #FB7185;
  --zs-accent-ink: #FFFFFF;
  --zs-teal: #14B8A6;
  --zs-teal-text: #2DD4BF;
  --zs-emerald: #34D399;
  --zs-emerald-text: #34D399;
  --zs-amber: #FBBF24;
  --zs-rule: rgba(255, 255, 255, 0.08);
  --zs-rule-strong: rgba(255, 255, 255, 0.15);
  --zs-specular: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --zs-shadow-window: 0 28px 72px -20px rgba(0, 0, 0, 0.78), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --zs-shadow-card: 0 14px 36px -16px rgba(0, 0, 0, 0.55);

  /* Shared Semantic Aliases Across All 5 Pages */
  --bg-page: var(--zs-bg);
  --bg-page-alt: var(--zs-bg-elev);
  --bg-alt: var(--zs-bg-elev);
  --bg-card: var(--zs-surface);
  --bg-card-elev: var(--zs-surface-2);
  --bg-void: var(--zs-well);
  --bg-velvet: #0D0D12;
  --bg-velvet-deep: #09090B;

  --ink: var(--zs-ink);
  --ink-soft: var(--zs-ink-soft);
  --ink-muted: var(--zs-ink-muted);
  --ink-dark: var(--zs-ink);
  --ink-dark-muted: var(--zs-ink-muted);
  --ink-velvet: #F4F4F5;
  --ink-velvet-soft: #A1A1AA;

  --accent: var(--zs-accent);
  --ruby: #FB7185;
  --ruby-bright: #E11D48;
  --vermilion: #E11D48;
  --rose: #FDA4AF;
  --orchid: #C084FC;
  --gold: #FBBF24;
  --gold-bright: #FCD34D;
  --teal: #2DD4BF;
  --aqua: #14B8A6;
  --emerald: #34D399;
  --mint: #34D399;

  --rule: var(--zs-rule);
  --rule-ruby: rgba(225, 29, 72, 0.28);
  --rule-soft: rgba(255, 255, 255, 0.05);
  --rule-velvet: rgba(255, 255, 255, 0.08);
  --surface: rgba(255, 255, 255, 0.035);
  --surface-strong: rgba(255, 255, 255, 0.075);
  --border: var(--zs-rule);
  --border-strong: var(--zs-rule-strong);
  --ivory-border: var(--zs-rule);
  --ivory-card: var(--zs-surface);
  --ivory-bg: var(--zs-bg-elev);
  --ruby-border: rgba(225, 29, 72, 0.3);

  --aura-tint: rgba(225, 29, 72, 0.12);
  --aura-border: rgba(251, 113, 133, 0.4);

  /* Local System Typography Stacks (Zero Webfonts) */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --shadow-folio: var(--zs-shadow-card);
  --shadow-velvet: var(--zs-shadow-window);
  --max-w: 1240px;
}

/* Daylight Vellum Theme Parity (SPEC 2.1) */
body[data-theme="vellum"] {
  --zs-bg: #FAF9F6;
  --zs-bg-elev: #F3F2EE;
  --zs-surface: #FFFFFF;
  --zs-surface-2: #F4F4F6;
  --zs-well: #111116;
  --zs-ink: #09090B;
  --zs-ink-soft: #3F3F46;
  --zs-ink-muted: #52525B;
  --zs-accent: #BE123C;
  --zs-accent-soft: #9F1239;
  --zs-accent-ink: #FFFFFF;
  --zs-teal: #0F766E;
  --zs-teal-text: #115E59;
  --zs-emerald: #047857;
  --zs-emerald-text: #065F46;
  --zs-amber: #92400E;
  --zs-rule: rgba(9, 9, 11, 0.10);
  --zs-rule-strong: rgba(9, 9, 11, 0.18);
  --zs-specular: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  --zs-shadow-window: 0 24px 60px -20px rgba(9, 9, 11, 0.12), 0 0 0 1px rgba(9, 9, 11, 0.09);
  --zs-shadow-card: 0 10px 28px -12px rgba(9, 9, 11, 0.07);

  /* Re-bind ALL semantic aliases for Daylight Vellum so descendants never inherit dark values */
  --bg-page: #FAF9F6;
  --bg-page-alt: #F3F2EE;
  --bg-alt: #F3F2EE;
  --bg-card: #FFFFFF;
  --bg-card-elev: #F4F4F6;
  --bg-void: #111116;

  --ink: #09090B;
  --ink-soft: #3F3F46;
  --ink-muted: #52525B;
  --ink-dark: #09090B;
  --ink-dark-muted: #52525B;

  --accent: #BE123C;
  --ruby: #BE123C;
  --ruby-bright: #E11D48;
  --vermilion: #BE123C;
  --rose: #9F1239;
  --orchid: #7E22CE;
  --gold: #92400E;
  --gold-bright: #B45309;
  --teal: #115E59;
  --aqua: #0F766E;
  --emerald: #047857;
  --mint: #065F46;

  --rule: rgba(9, 9, 11, 0.10);
  --rule-ruby: rgba(190, 18, 60, 0.26);
  --rule-soft: rgba(9, 9, 11, 0.06);
  --surface: rgba(9, 9, 11, 0.035);
  --surface-strong: rgba(9, 9, 11, 0.075);
  --border: rgba(9, 9, 11, 0.10);
  --border-strong: rgba(9, 9, 11, 0.18);
  --ivory-border: rgba(9, 9, 11, 0.10);
  --ivory-card: #FFFFFF;
  --ivory-bg: #F3F2EE;
  --ruby-border: rgba(190, 18, 60, 0.28);
}

/* Accent Swatch Variations */
body[data-aura="aqua"] { --zs-accent: #14B8A6; --zs-accent-soft: #2DD4BF; --zs-accent-ink: #09090B; --aura-tint: rgba(20, 184, 166, 0.14); --aura-border: #14B8A6; }
body[data-aura="gold"] { --zs-accent: #D97706; --zs-accent-soft: #FBBF24; --zs-accent-ink: #09090B; --aura-tint: rgba(217, 119, 6, 0.14); --aura-border: #D97706; }
body[data-aura="mint"] { --zs-accent: #10B981; --zs-accent-soft: #34D399; --zs-accent-ink: #09090B; --aura-tint: rgba(16, 185, 129, 0.14); --aura-border: #10B981; }
body[data-aura="orchid"] { --zs-accent: #9333EA; --zs-accent-soft: #C084FC; --aura-tint: rgba(147, 51, 234, 0.14); --aura-border: #9333EA; }
body[data-aura="rose"] { --zs-accent: #E11D48; --zs-accent-soft: #FDA4AF; --aura-tint: rgba(225, 29, 72, 0.14); --aura-border: #FB7185; }

body[data-theme="vellum"][data-aura="aqua"] { --zs-accent: #0F766E; --zs-accent-soft: #115E59; --zs-accent-ink: #FFFFFF; }
body[data-theme="vellum"][data-aura="gold"] { --zs-accent: #92400E; --zs-accent-soft: #92400E; --zs-accent-ink: #FFFFFF; }
body[data-theme="vellum"][data-aura="mint"] { --zs-accent: #047857; --zs-accent-soft: #065F46; --zs-accent-ink: #FFFFFF; }
body[data-theme="vellum"][data-aura="orchid"] { --zs-accent: #7E22CE; --zs-accent-soft: #6B21A8; --zs-accent-ink: #FFFFFF; }
body[data-theme="vellum"][data-aura="rose"] { --zs-accent: #BE123C; --zs-accent-soft: #9F1239; --zs-accent-ink: #FFFFFF; }

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 68px;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

code, pre, kbd, samp {
  font-family: var(--font-mono);
}

code {
  font-size: 0.875em;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-strong);
  color: var(--zs-ink);
  border: 1px solid var(--zs-rule);
}

pre code {
  background: transparent;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
}

/* Dark-Well Token Scope: Isolate intentionally dark terminal/code plates from Vellum ink */
.velvet-terminal,
.velvet-plate.verification-plate,
.zr-code-well,
.ab-doc-pre,
.ab-doc-code,
.zs-bench-cmd,
.zs-disasm-trace,
.home-ex-gem-stage,
.home-ex-ab-stage {
  --zs-ink: #F4F4F5;
  --zs-ink-soft: #D4D4D8;
  --zs-ink-muted: #A1A1AA;
  --zs-teal-text: #2DD4BF;
  --zs-accent-soft: #FB7185;
  --zs-emerald-text: #34D399;
  --ink: #F4F4F5;
  --ink-soft: #D4D4D8;
  --ink-muted: #A1A1AA;
  --surface-strong: rgba(255, 255, 255, 0.12);
  --zs-rule: rgba(255, 255, 255, 0.14);
}

.velvet-plate.verification-plate code,
.velvet-terminal code:not(pre code),
.zr-code-well code:not(pre code),
.ab-doc-code code:not(pre code),
.home-ex-gem-stage code,
.home-ex-ab-stage code {
  color: #F4F4F5;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

input::placeholder,
textarea::placeholder {
  color: var(--zs-ink-muted);
  opacity: 1;
}

:focus-visible {
  outline: 2px solid var(--zs-accent-soft);
  outline-offset: 2px;
}

body[data-theme="vellum"] :focus-visible {
  outline-color: var(--zs-accent);
}

.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;
}

/* Shared Container & Section Cadence (Used by ablation/ and legacy selectors) */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 84px 0;
  border-top: 1px solid var(--rule);
  background: var(--bg-page);
  color: var(--ink);
}

.section-vellum-alt,
.section-alt {
  background: var(--bg-page-alt);
}

.chapter-head {
  margin: 0 0 36px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chapter-num {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--zs-accent-soft);
}

.chapter-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.7rem, 2.9vw, 2.4rem);
  font-weight: 680;
  letter-spacing: -0.025em;
  line-height: 1.12;
  color: var(--ink);
}

.chapter-head p {
  margin: 0;
  max-width: 64ch;
  color: var(--ink-soft);
}

/* Shared Base Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card-elev);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 550;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.14s ease;
}

.btn:hover {
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

body[data-theme="vellum"] .btn:hover {
  border-color: rgba(9, 9, 11, 0.3);
}

.btn-ruby {
  background: #F4F4F5;
  border-color: #F4F4F5;
  color: #09090B;
  font-weight: 600;
}

.btn-ruby:hover {
  background: #E4E4E7;
  border-color: #E4E4E7;
  color: #09090B;
}

body[data-theme="vellum"] .btn-ruby {
  background: #09090B;
  border-color: #09090B;
  color: #FAF9F6;
}

body[data-theme="vellum"] .btn-ruby:hover {
  background: #27272A;
  border-color: #27272A;
  color: #FAF9F6;
}

.btn-folio,
.btn-teal,
.btn-teal-folio {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-lg {
  min-height: 46px;
  padding: 11px 22px;
  font-size: 0.94rem;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.8rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
}

@media (max-width: 640px) {
  .container {
    padding: 0 16px;
  }
  .section {
    padding: 56px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
