/* ============================================================
   HAPPI/1.0  —  Canonical Stylesheet
   Swiss Nihilism × Dark × GRIP Commander themes
   Mobile-first · Three themes · JIT quality gate
   ============================================================ */

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: hidden; font-size: 110%; }
body { overflow-x: hidden; }
/* Ensure images/media never bust the viewport width */
img, video, svg, iframe { max-width: 100%; height: auto; }

/* ============================================================
   DESIGN TOKENS — Dark (default)
   ============================================================ */
:root {
  /* Surfaces */
  --bg:         #0a0e14;
  --bg-dark:    #060910;
  --bg-elev:    #0f151f;
  --bg-panel:   #131a26;
  --bg-primary: var(--bg);
  --bg-surface: var(--bg-panel);

  /* Borders */
  --border:        #1f2937;
  --border-strong: #2a3545;

  /* Text */
  --text:       #e5e9ef;
  --text-dim:   #a0aab8;
  --text-mute:  #6b7687;
  --text-muted: var(--text-mute);

  /* Accents */
  --accent:        #4d9de0;
  --accent-2:      #39d353;
  --accent-glow:   rgba(77, 157, 224, 0.15);
  --accent-2-glow: rgba(57, 211, 83, 0.12);

  /* Code */
  --code-bg: #0b1119;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  /* Shape — Living Protocol (default theme): soft corners + depth.
     The commander (matrix) and nihil (swiss) themes keep sharp corners below. */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Glass depth */
  --glass-bg:     rgba(19, 26, 38, 0.55);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur:   14px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
  --shadow-md: 0 8px 28px rgba(0,0,0,0.40);
  --shadow-lg: 0 24px 64px rgba(0,0,0,0.50);
  --shadow-glow: 0 0 56px rgba(77, 157, 224, 0.20);

  /* Living-Protocol motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-1: 0.18s;
  --dur-2: 0.4s;
  --dur-3: 0.8s;

  /* Typography — Swiss Nihilism Law 1: system fonts only.
     Inter and JetBrains Mono removed (Google Fonts pedigree forbidden). */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
  --mono: var(--font-mono);

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   GRIP COMMANDER THEME — Matrix-authentic palette
   Source: schemecolor.com/matrix-code-green
   #0D0208 Vampire Black · #003B00 Dark Green
   #008F11 Islam Green  · #00FF41 Erin (leading rain char)
   ============================================================ */
[data-theme="commander"] {
  --bg:         #0d0208;   /* Vampire Black — film-accurate Matrix dark */
  --bg-dark:    #000000;
  --bg-elev:    #0d0208;
  --bg-panel:   #0a120a;   /* Dark green-tinted panel */
  --bg-primary: var(--bg);
  --bg-surface: var(--bg-panel);
  --border:        #0a1a0a;
  --border-strong: #143d14;
  --text:       #00b300;   /* Comfortable reading green — WCAG AA 6.6:1 */
  --text-dim:   #009614;   /* Dim text — WCAG AA 4.8:1 */
  --text-mute:  #007300;   /* Dark Green ambient — WCAG large-text 3.2:1 */
  --text-muted: var(--text-mute);
  --accent:     #00ff41;   /* Erin — the authentic Matrix leading-char green */
  --accent-2:   #39ff14;   /* Chartreuse — secondary digital-rain accent */
  --accent-glow:   rgba(0, 255, 65, 0.08);
  --accent-2-glow: rgba(57, 255, 20, 0.06);
  --code-bg:    #000000;
  --radius:     0px;
  --radius-lg:  0px;
  --shadow-sm:  none;
  --shadow-md:  none;
  --shadow-lg:  0 0 0 1px #0a1a0a;
}

/* ============================================================
   SWISS NIHIL THEME
   ============================================================ */
[data-theme="nihil"] {
  --bg:         #ffffff;
  --bg-dark:    #eeeeee;
  --bg-elev:    #f8f8f8;
  --bg-panel:   #f2f2f2;
  --bg-primary: var(--bg);
  --bg-surface: var(--bg-panel);
  --border:        #cccccc;
  --border-strong: #888888;
  --text:       #000000;
  --text-dim:   #333333;
  --text-mute:  #777777;
  --text-muted: var(--text-mute);
  --accent:     #000000;
  --accent-2:   #444444;
  --accent-glow:   rgba(0, 0, 0, 0.05);
  --accent-2-glow: rgba(0, 0, 0, 0.04);
  --code-bg:    #ebebeb;
  --radius:     0px;
  --radius-lg:  0px;
  --shadow-sm:  none;
  --shadow-md:  none;
  --shadow-lg:  none;
}

/* Prism "tomorrow" dark theme injected via CDN — background reset for nihil light mode.
   Token colours are overridden at end of file (near the other nihil bug-fix blocks).
   [attr] + element beats Prism's plain element selector in the cascade. */
[data-theme="nihil"] code[class*="language-"],
[data-theme="nihil"] pre[class*="language-"] {
  background: var(--code-bg);
  color: var(--text);
  text-shadow: none;
}

/* ============================================================
   BASE
   ============================================================ */
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

[data-theme="commander"] body { font-family: var(--font-mono); }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.6em;
  color: var(--text);
}
h1 { font-size: clamp(2rem, 5.5vw, 4.2rem); font-weight: 800; letter-spacing: -0.035em; }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.75rem); }
h3 { font-size: clamp(1.05rem, 1.8vw, 1.35rem); }
h4 { font-size: 1rem; font-weight: 600; }
p  { margin: 0 0 1em; color: var(--text-dim); }
a  { color: var(--accent); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--accent-2); }
strong { color: var(--text); font-weight: 600; }
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.12em 0.4em;
  border-radius: var(--radius);
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--text);
}
pre { margin: 0; }
pre code {
  display: block;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
  border: 1px solid var(--border);
  background: var(--code-bg);
  border-radius: var(--radius);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.25rem;
}
.section      { padding: 3.5rem 0; position: relative; }
.section-dark { background: var(--bg-dark); }
.section-head {
  max-width: 820px;
  margin-bottom: 2.5rem;
}
.section-head.center { margin-left: auto; margin-right: auto; text-align: center; }
.section-head .eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.section-head h2 { margin-bottom: 1rem; }
.lede {
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--text-dim);
  max-width: 65ch;
}
.accent { color: var(--accent); }

/* ============================================================
   HEADER / NAV
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
}
.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.875rem;
  padding-bottom: 0.875rem;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.logo:hover { color: var(--accent); }
.logo-mark  { color: var(--accent); transition: color 0.2s var(--ease); }
.logo:hover .logo-mark { color: var(--accent-2); }
.logo-version { color: var(--text-dim); font-weight: 500; margin-left: 2px; }

/* Mobile: nav hidden; shown at ≥ 721px */
.main-nav {
  display: none;
  gap: 1rem;
  font-size: 0.82rem;
}
.main-nav a {
  color: var(--text-dim);
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  transition: color 0.15s var(--ease);
  white-space: nowrap;
}
.main-nav a:hover { color: var(--text); }

/* ---- Mobile nav drawer (activated by .nav-open class via JS) ---- */
.main-nav.nav-open {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  /* Scroll containment: cap at viewport minus header so short phones don't overflow.
     vh first as fallback; dvh adjusts for dynamic browser chrome on mobile. */
  max-height: calc(100vh - 3.6rem);
  max-height: calc(100svh - 3.6rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-dark);
  border-bottom: 2px solid var(--border);
  z-index: 99;
  padding: 0.5rem 0 1rem;
  gap: 0;
  /* No box-shadow — Swiss Nihilism Law 6 (drop-shadows forbidden outside terminal-window). */
  /* Slide-in animation: starts invisible-shifted, JS adds .nav-ready to settle */
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.main-nav.nav-open.nav-ready {
  opacity: 1;
  transform: translateY(0);
}
/* Individual link rows — minimum 48px touch targets */
.main-nav.nav-open a {
  display: flex;
  align-items: center;
  min-height: 3rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  white-space: normal;
  color: var(--text-dim);
}
.main-nav.nav-open a:last-child { border-bottom: none; }
.main-nav.nav-open a:hover,
.main-nav.nav-open a:focus-visible { background: var(--bg-surface); color: var(--text); outline: none; }
/* Section divider between in-page anchors and standalone pages — mobile drawer only */
.main-nav .nav-divider { display: none; }
.main-nav.nav-open .nav-divider {
  display: block;
  height: 1px;
  margin: 0.4rem 1.5rem;
  background: var(--border);
  flex-shrink: 0;
}

/* ---- Hamburger button (mobile only) ---- */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.nav-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 3rem;
  height: 3rem;
  min-width: 48px;
  min-height: 48px;
  padding: 0.5rem;
  touch-action: manipulation;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.nav-hamburger:hover { color: var(--accent); border-color: var(--accent); }
.hamburger-bar {
  display: block;
  width: 1.1rem;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}
/* Animates into an X when open */
.nav-hamburger[aria-expanded="true"] .hamburger-bar:nth-child(1) {
  transform: translateY(5.5px) rotate(45deg);
}
.nav-hamburger[aria-expanded="true"] .hamburger-bar:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.nav-hamburger[aria-expanded="true"] .hamburger-bar:nth-child(3) {
  transform: translateY(-5.5px) rotate(-45deg);
}

/* ---- Nav backdrop (injected by JS, handles outside-click to close) ---- */
/* Uses opacity + pointer-events instead of display toggle to allow fade-out */
.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 98;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
  transition: background-color 0.2s var(--ease);
}
.nav-backdrop.active {
  background: rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

/* ---- Theme toggle ---- */
.theme-toggle {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.3rem 0.65rem;
  min-height: 48px;
  min-width: 48px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
  user-select: none;
  white-space: nowrap;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  padding: 3.5rem 0 4.5rem;
  /* Ensure hero breathes on small phones without forcing full-screen lock */
  min-height: 50vh;
  min-height: 50dvh;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 40% at 30% 30%, var(--accent-glow), transparent 70%),
    radial-gradient(ellipse 50% 40% at 70% 40%, var(--accent-2-glow), transparent 70%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}
[data-theme="commander"] .hero::before,
[data-theme="nihil"]     .hero::before { display: none; }
.hero > .container { position: relative; z-index: 1; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.85rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 6px var(--accent-2);
  animation: pulse 2s infinite var(--ease);
}
[data-theme="commander"] .badge-dot {
  border-radius: 0;
  box-shadow: none;
  animation: blink 1s steps(1) infinite;
}
[data-theme="nihil"] .badge-dot {
  border-radius: 0;
  background: #000;
  box-shadow: none;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.hero-title { margin-bottom: 1.25rem; }
.hero-sub {
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  color: var(--text-dim);
  max-width: 52ch;
  margin-bottom: 1rem;
}
.hero-tagline {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 2rem;
}
.hero-tagline strong { color: var(--accent); font-weight: 600; }
.hero-cta {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 3rem;
}
/* Full-width buttons on smallest viewports for easy tap */
.hero-cta .btn { width: 100%; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.5rem;
  min-height: 48px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.005em;
  transition: all 0.18s var(--ease);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  touch-action: manipulation;
}
.btn-primary {
  background: var(--accent);
  color: #0a0e14;
  border-color: var(--accent);
}
.btn-primary:hover {
  filter: brightness(1.1);
  color: #0a0e14;
  transform: translateY(-1px);
}
[data-theme="commander"] .btn-primary           { color: #0d0208; }
[data-theme="commander"] .btn-primary:hover     { transform: none; filter: none; box-shadow: 0 0 12px rgba(0,255,65,0.4); }
[data-theme="nihil"]     .btn-primary           { background: #000; color: #fff; border-color: #000; }
[data-theme="nihil"]     .btn-primary:hover     { transform: none; background: #333; border-color: #333; filter: none; }
.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { border-color: var(--text-dim); transform: translateY(-1px); }
[data-theme="commander"] .btn-secondary         { color: var(--accent); border-color: var(--accent); }
[data-theme="commander"] .btn-secondary:hover   { transform: none; }
[data-theme="nihil"]     .btn-secondary         { border-color: #666; }
[data-theme="nihil"]     .btn-secondary:hover   { transform: none; border-color: #000; }

/* ============================================================
   LIVING PROTOCOL FLOW — one envelope in -> eight events out -> receipt
   ============================================================ */
.protocol-flow {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 1.25rem;
  margin: 0 0 2.5rem;
  padding: 1.4rem 1.5rem;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}
.pf-node {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.8rem 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  white-space: nowrap;
}
.pf-node-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.pf-code { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); }
.pf-envelope { animation: pf-pulse 6s var(--ease-out) infinite; }

.pf-channel {
  position: relative;
  height: 2px;
  min-width: 64px;
  align-self: center;
  background: linear-gradient(90deg, var(--border-strong), var(--accent), var(--border-strong));
  border-radius: var(--radius-pill);
}
.pf-particle {
  position: absolute;
  top: 50%;
  left: 0;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pf-flow 2s linear infinite;
}
.pf-particle:nth-child(2) { animation-delay: 0.66s; }
.pf-particle:nth-child(3) { animation-delay: 1.33s; }

.pf-events { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pf-event {
  padding: 0.32rem 0.62rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-mute);
  opacity: 0.4;
  animation: pf-light 6s var(--ease-out) infinite;
  animation-delay: calc(var(--i) * 0.18s + 0.3s);
}
.pf-idr {
  color: var(--accent-2);
  border-color: var(--border-strong);
  animation-name: pf-light-idr;
}

@keyframes pf-flow {
  0%   { left: 0;    opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}
@keyframes pf-light {
  0%, 38%   { opacity: 0.4; color: var(--text-mute); border-color: var(--border); }
  50%, 86%  { opacity: 1;   color: var(--accent);    border-color: var(--accent); }
  100%      { opacity: 0.4; color: var(--text-mute); border-color: var(--border); }
}
@keyframes pf-light-idr {
  0%, 58%   { opacity: 0.4; color: var(--text-mute); border-color: var(--border); box-shadow: none; }
  70%, 90%  { opacity: 1;   color: var(--accent-2);  border-color: var(--accent-2); box-shadow: 0 0 14px var(--accent-2-glow); }
  100%      { opacity: 0.4; color: var(--text-mute); border-color: var(--border); box-shadow: none; }
}
@keyframes pf-pulse {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  45%      { box-shadow: 0 0 0 3px var(--accent-glow); }
}

/* Pause the whole flow while it is scrolled off-screen (compositor-friendly). */
.protocol-flow:not(.in-view) .pf-envelope,
.protocol-flow:not(.in-view) .pf-particle,
.protocol-flow:not(.in-view) .pf-event { animation-play-state: paused; }

/* Alt themes keep their sharp identity; the flow stays legible, motion trimmed. */
[data-theme="commander"] .protocol-flow,
[data-theme="nihil"] .protocol-flow {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: var(--shadow-md);
}

/* Protocol flow: vertical stacking on narrow viewports.
   Mobile-first: stack by default, restore horizontal at ≥721px. */
.protocol-flow {
  grid-template-columns: 1fr;
  justify-items: start;
  gap: 0.9rem;
}
.pf-channel {
  width: 2px;
  min-width: 0;
  height: 28px;
  background: linear-gradient(180deg, var(--border-strong), var(--accent), var(--border-strong));
  margin-left: 1.25rem;
}
.pf-particle { animation-name: pf-flow-v; }
@keyframes pf-flow-v {
  0%   { top: 0;    opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}
/* Mobile heading fit — shrink + hard-wrap so long titles never overflow at 375px */
h1 { font-size: clamp(1.5rem, 7.5vw, 2.1rem); }
h2 { font-size: clamp(1.2rem, 5.5vw, 1.7rem); }
h1, h2, h3 { overflow-wrap: anywhere; }

/* ≥ 721px: restore horizontal protocol flow */
@media (min-width: 721px) {
  .protocol-flow {
    grid-template-columns: auto auto 1fr;
    justify-items: stretch;
    gap: 1.25rem;
  }
  .pf-channel {
    width: auto;
    min-width: 64px;
    height: 2px;
    background: linear-gradient(90deg, var(--border-strong), var(--accent), var(--border-strong));
    margin-left: 0;
  }
  .pf-particle { animation-name: pf-flow; }
  h1 { font-size: clamp(2rem, 5.5vw, 4.2rem); }
  h2 { font-size: clamp(1.6rem, 3.5vw, 2.75rem); }
}

@media (prefers-reduced-motion: reduce) {
  .pf-envelope, .pf-particle, .pf-event, .pf-idr { animation: none !important; }
  .pf-event { opacity: 1; color: var(--accent); border-color: var(--accent); }
  .pf-idr { color: var(--accent-2); border-color: var(--accent-2); }
  .pf-particle { display: none; }
}

/* ============================================================
   SCROLL-REVEAL — fade/slide sections in (JS-gated; no-JS shows all)
   ============================================================ */
.reveal-ready .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out);
}
.reveal-ready .reveal.is-visible {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .reveal-ready .reveal { opacity: 1; transform: none; transition: none; }
}

/* ============================================================
   DEMO TERMINAL
   ============================================================ */
.hero-demo { margin-top: 0.5rem; }
.demo-terminal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  max-width: 900px;
  /* Isolate layout: mutations inside can't trigger reflow outside (scroll-jank fix) */
  contain: content;
}
[data-theme="commander"] .demo-terminal { border-color: var(--accent); }
[data-theme="nihil"]     .demo-terminal { border: 1px solid #000; box-shadow: none; }

.demo-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
}
.demo-header .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border-strong);
}
[data-theme="commander"] .demo-header .dot                   { border-radius: 0; }
[data-theme="nihil"]     .demo-header .dot                   { border-radius: 0; background: #bbb; }
.demo-header .dot.red    { background: #ff5f56; }
.demo-header .dot.yellow { background: #ffbd2e; }
.demo-header .dot.green  { background: #27c93f; }
[data-theme="commander"] .demo-header .dot.red,
[data-theme="commander"] .demo-header .dot.yellow,
[data-theme="commander"] .demo-header .dot.green { background: var(--accent); }
[data-theme="nihil"] .demo-header .dot.red,
[data-theme="nihil"] .demo-header .dot.yellow,
[data-theme="nihil"] .demo-header .dot.green     { background: #999; }

.demo-title {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-mute);
}
.demo-body { padding: 1rem 1.25rem 1.25rem; }
.demo-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  margin-top: 0.75rem;
  margin-bottom: 0.4rem;
}
.demo-body pre       { background: transparent; padding: 0; margin: 0; }
.demo-body pre code  {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.78rem;
  min-height: 1.5em;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
.demo-stdin  code              { color: var(--accent); }
.demo-stdout code              { color: var(--text-dim); }
.demo-stdout .event-started   { color: var(--text-mute); }
.demo-stdout .event-delta     { color: var(--accent); }
.demo-stdout .event-complete  { color: var(--accent-2); }

/* ============================================================
   THE CONTRACT
   ============================================================ */
.contract-grid {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 3.5rem;
}
.contract-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}
.panel-label {
  position: absolute;
  top: 0.75rem;
  left: 0.9rem;
  right: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  background: var(--bg-dark);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  z-index: 1;
}
.contract-panel pre code { border: none; border-radius: var(--radius-lg); font-size: 0.78rem; }
.contract-arrow { color: var(--accent); opacity: 0.7; text-align: center; }
.contract-fields {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.contract-fields h3 { margin-bottom: 1.25rem; }
.field-list         { margin: 0; padding: 0; }
.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--border);
}
.field-row:first-child { border-top: none; padding-top: 0; }
.field-row dt { font-family: var(--font-mono); font-size: 0.95rem; color: var(--accent); }
.field-row dd { margin: 0; color: var(--text-dim); font-size: 0.9rem; }
.exit-note {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-dim);
}

/* ============================================================
   EVENT TYPES
   ============================================================ */
.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.event-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color 0.18s var(--ease), transform 0.18s var(--ease);
}
.event-card:hover { border-color: var(--accent); transform: translateY(-2px); }
[data-theme="commander"] .event-card:hover,
[data-theme="nihil"]     .event-card:hover { transform: none; }
.event-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}
.event-card h3      { font-size: 1.05rem; margin-bottom: 0.5rem; }
.event-card h3 code {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: transparent;
  font-size: 0.9rem;
  padding: 0.15em 0.5em;
}
.event-card p { font-size: 0.9rem; color: var(--text-dim); margin: 0; line-height: 1.6; }

/* ============================================================
   POLYGLOT
   ============================================================ */
.polyglot-wrap {
  max-width: 900px;
  margin: 0 auto 3rem;
}
.polyglot-wrap pre code { font-size: 0.82rem; line-height: 1.65; }
.polyglot-bullets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto;
}
.pg-bullet {
  display: flex;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pg-icon {
  flex: 0 0 2.75rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent);
}
.pg-bullet h3 { margin: 0 0 0.3rem; font-size: 0.9rem; }
.pg-bullet p  { margin: 0; font-size: 0.85rem; color: var(--text-dim); }

/* ============================================================
   POLYMORPHISM
   ============================================================ */
.polymorph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.polymorph-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  transition: border-color 0.18s var(--ease), transform 0.18s var(--ease);
}
.polymorph-card:hover { border-color: var(--accent); transform: translateY(-2px); }
[data-theme="commander"] .polymorph-card:hover,
[data-theme="nihil"]     .polymorph-card:hover { transform: none; }
.polymorph-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  margin-bottom: 1rem;
}
.polymorph-card h3 { font-size: 0.95rem; margin-bottom: 0.4rem; }
.polymorph-card p  { font-size: 0.87rem; color: var(--text-dim); margin: 0; line-height: 1.6; }
.polymorph-note {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: 1.75rem 2rem;
  margin-bottom: 2.5rem;
}
.polymorph-note h3 { margin-bottom: 0.75rem; font-size: 1.15rem; }
.polymorph-note p  { color: var(--text-dim); margin: 0 0 1rem; font-size: 0.95rem; line-height: 1.7; }
.polymorph-note p:last-child { margin-bottom: 0; }
.polymorph-aside {
  font-size: 0.88rem !important;
  color: var(--text-mute) !important;
  font-style: italic;
}
.polymorph-extract { margin-top: 2rem; }
.polymorph-extract h3 { margin-bottom: 1rem; font-size: 1rem; }
.polymorph-extract pre code { font-size: 0.8rem; }

/* ============================================================
   AXIOMS
   ============================================================ */
.axiom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}
.axiom-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: border-color 0.2s var(--ease);
}
.axiom-card:hover { border-color: var(--accent); }
.axiom-num {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}
.axiom-card h3 { margin-bottom: 0.65rem; font-size: 1.2rem; }
.axiom-card p  { color: var(--text-dim); margin-bottom: 1rem; font-size: 0.92rem; }
.axiom-falsify {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  margin-top: 0.75rem;
  font-size: 0.83rem;
  color: var(--text-dim);
  line-height: 1.6;
}
.falsify-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-2);
  margin-right: 0.5rem;
  font-weight: 600;
}

/* ============================================================
   WHY IT MATTERS
   ============================================================ */
.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
}
.why-col {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}
.why-col h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-weight: 500;
  margin-bottom: 0.75rem;
}
.why-col:nth-child(3) h3 { color: var(--accent-2); }
.why-col p { font-size: 1rem; color: var(--text-dim); margin: 0; line-height: 1.7; }
.why-quote {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.75rem 2rem;
  border-left: 2px solid var(--accent);
  background: var(--bg-elev);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.why-quote p {
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--text);
  margin: 0;
  font-weight: 300;
}
[data-theme="nihil"] .why-quote { border-left: 2px solid #000; }

/* ============================================================
   GET STARTED — .start-step grid fix (mobile-first)
   Grid bug: 2-column grid + 3 children caused third child to
   wrap back to col 1 (48px wide). Fix: step-num spans rows.
   ============================================================ */
.start-steps {
  display: grid;
  gap: 1.75rem;
  margin-bottom: 2rem;
}

/* Mobile default: single column stack */
.start-step {
  display: grid;
  gap: 0.75rem;
  align-items: start;
}

.step-num {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius);
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.start-step h3 { margin-bottom: 0.75rem; font-size: 1.1rem; min-width: 0; }

.start-note {
  padding: 1.25rem 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-2);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.start-note p { margin: 0; color: var(--text-dim); }

/* ---- Runtime examples ---- */
.runtime-tabs {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.runtime-tab {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-width: 0;
}
.runtime-lang {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.runtime-tab pre { margin: 0; border-radius: 0; border: none; overflow-x: auto; }
.runtime-tab pre code { font-size: 0.78rem; border: none; border-radius: 0; }

/* ============================================================
   FAQ
   ============================================================ */
.faq-list {
  max-width: 860px;
  display: grid;
  gap: 0.625rem;
}
.faq-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s var(--ease);
}
.faq-item[open] { border-color: var(--accent); }
.faq-item summary {
  padding: 1.1rem 1.25rem;
  min-height: 48px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  user-select: none;
  touch-action: manipulation;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--accent);
  transition: transform 0.2s var(--ease);
  line-height: 1;
  flex-shrink: 0;
}
.faq-item[open] summary::after { content: '\2212'; }
.faq-body {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.7;
}
.faq-body p { margin: 0; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  padding: 3.5rem 0 0;
}
.footer-wrap {
  display: grid;
  gap: 2rem;
  padding-bottom: 2.5rem;
}
.footer-logo  { margin-bottom: 0.75rem; }
.footer-tag   { font-weight: 500; color: var(--text); margin-bottom: 0.5rem; }
.footer-meta  { font-size: 0.83rem; color: var(--text-dim); margin: 0; }
.footer-meta a { text-decoration: underline; text-underline-offset: 2px; }
.footer-col h3 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 0.875rem;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.footer-col li { color: var(--text-dim); font-size: 0.9rem; }
.footer-col a  { color: var(--text-dim); transition: color 0.15s var(--ease); }
.footer-col a:hover { color: var(--accent); }
.footer-col a[aria-disabled="true"]       { color: var(--text-mute); cursor: not-allowed; }
.footer-col a[aria-disabled="true"]:hover { color: var(--text-mute); }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.footer-bottom p { margin: 0; color: var(--text-dim); }

/* ============================================================
   COPY / CURL BUTTONS (injected by JS)
   ============================================================ */
.code-wrap { position: relative; }
.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  padding: 0.3rem 0.7rem;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  opacity: 0;
  transition: all 0.18s var(--ease);
  z-index: 2;
}
.code-wrap:hover .copy-btn { opacity: 1; }
/* Touch devices have no hover — keep copy/cURL buttons visible + tappable */
@media (hover: none) { .copy-btn { opacity: 1; } }
.copy-btn:hover  { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { color: var(--accent-2); border-color: var(--accent-2); opacity: 1; }

/* cURL button sits left of the Copy button */
.copy-btn.curl-btn {
  right: 4.25rem;
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}
.copy-btn.curl-btn:hover { background: rgba(77, 157, 224, 0.22); }

/* ---------- Focus States (a11y) ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}
.btn:focus-visible { outline-offset: 3px; }
.faq-item summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ---------- cURL button variant ---------- */
.curl-btn {
  background: rgba(88, 166, 255, 0.1);
  border-color: rgba(88, 166, 255, 0.3);
  color: var(--accent);
}
.curl-btn:hover { background: rgba(88, 166, 255, 0.2); }

/* ---------- Provider Diff View ---------- */
.diff-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 2rem;
}
.diff-col {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.diff-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.diff-provider {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}
.diff-anthropic { background: rgba(210, 100, 60, 0.15); color: #f0855e; }
.diff-openai    { background: rgba(79, 172, 133, 0.15); color: #4fac85; }
.diff-gemini    { background: rgba(66, 133, 244, 0.15); color: #81aeff; }
[data-theme="nihil"] .diff-anthropic { background: rgba(210,100,60,0.1); }
[data-theme="nihil"] .diff-openai    { background: rgba(79,172,133,0.1); }
[data-theme="nihil"] .diff-gemini    { background: rgba(66,133,244,0.1); }

.diff-format {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: var(--mono);
}
.diff-col pre {
  margin: 0;
  padding: var(--space-4);
  font-size: 0.72rem;
  overflow-x: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.diff-col pre code { border: none; background: transparent; padding: 0; font-size: 0.72rem; }
.diff-unified {
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
  margin-bottom: 2rem;
}
.diff-unified-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: var(--space-3);
  text-align: center;
}
.diff-unified pre { margin: 0 0 var(--space-3); font-size: 0.78rem; }
.diff-note { font-size: 0.85rem; color: var(--text-dim); text-align: center; margin: 0; }

/* ---- Transport Grid ---- */
.transports   { margin-top: var(--space-4); }
.transports h3 { margin-bottom: var(--space-4); }
.transport-grid { display: flex; flex-direction: column; gap: var(--space-2); }
.transport-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: start;
  gap: 0.25rem var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.transport-name   { font-family: var(--mono); font-size: 0.85rem; grid-column: 1; grid-row: 1; }
.transport-desc   { font-size: 0.83rem; color: var(--text-dim); grid-column: 1; grid-row: 2; }
.transport-status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius);
  text-align: center;
  white-space: nowrap;
  grid-column: 2;
  grid-row: 1;
  align-self: start;
}
.status-stable  { background: rgba(63, 185, 80, 0.15);  color: #3fb950; }
.status-planned { background: rgba(210, 153, 34, 0.15); color: #d29922; }

/* ============================================================
   OVERFLOW HARDENING — no horizontal scroll on any viewport
   ============================================================ */

/* Grid/flex children default to min-width:auto which lets content exceed
   column bounds. Explicit 0 lets the browser shrink them. */
.event-card, .axiom-card, .why-col, .diff-col,
.contract-panel, .pg-bullet, .start-step,
.transport-row, .footer-col,
.polymorph-card, .runtime-tab { min-width: 0; }

/* Long tech tokens in headings must wrap on narrow screens */
h1, h2, h3, h4 { word-break: break-word; overflow-wrap: break-word; }

/* Code blocks: scroll internally, never push the page */
pre { max-width: 100%; overflow-x: auto; }

/* ============================================================
   RESPONSIVE — Mobile-first: enhance at wider viewports
   ============================================================ */

/* ≥ 480px — phablet */
@media (min-width: 480px) {
  .container { padding: 0 1.5rem; }
  .hero-cta  { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .btn       { width: auto; }
}

/* ≥ 640px — tablet */
@media (min-width: 640px) {
  .section       { padding: 5rem 0; }
  .section-head  { margin-bottom: 3rem; }
  .contract-fields { padding: 1.75rem 2rem; }
  .field-row {
    grid-template-columns: 90px 1fr;
    gap: 1.5rem;
    align-items: baseline;
  }
  .footer-wrap { grid-template-columns: repeat(2, 1fr); }
}

/* ≥ 721px — desktop: show nav, fix .start-step grid */
/* Desktop horizontal nav only where the full link row fits (14 links).
   ≤999px uses the hamburger drawer — covers phone (390) AND tablet (768). */
@media (min-width: 1000px) {
  /* Always show nav as flex row — override any JS-added .nav-open state */
  .main-nav,
  .main-nav.nav-open,
  .main-nav.nav-open.nav-ready {
    display: flex;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    background: transparent;
    border-bottom: none;
    box-shadow: none;
    padding: 0;
    gap: 0.5rem 1rem;
    z-index: auto;
    max-height: none;
    overflow: visible;
    opacity: 1;
    transform: none;
    transition: none;
  }
  .main-nav a,
  .main-nav.nav-open a {
    display: inline;
    min-height: auto;
    padding: 0;
    border-bottom: none;
    font-size: 0.82rem;
    background: transparent;
    color: var(--text-dim);
  }
  .main-nav.nav-open a:hover { background: transparent; }
  .nav-divider { display: none; }
  .nav-hamburger { display: none; }
  .nav-backdrop  { display: none; }
}

@media (min-width: 721px) {
  .hero     { padding: 5rem 0 6rem; }

  /* Contract: 3-column layout */
  .contract-grid { grid-template-columns: 1fr auto 1fr; align-items: center; }

  /* .start-step fix: step-num spans title + code rows */
  .start-step {
    grid-template-columns: 3rem 1fr;
    grid-template-rows: auto auto;
    gap: 0.5rem 1.5rem;
  }
  .step-num { grid-column: 1; grid-row: 1 / 3; align-self: start; margin-top: 0.2rem; }
  .start-step h3 { grid-column: 2; grid-row: 1; align-self: end; min-width: 0; }
  .start-step > pre,
  .start-step > .code-wrap { grid-column: 2; grid-row: 2; min-width: 0; }
}

/* ≥ 900px — wide */
@media (min-width: 900px) {
  .section { padding: 6rem 0; }
  .diff-grid { grid-template-columns: repeat(3, 1fr); }
  .runtime-tabs { grid-template-columns: repeat(2, 1fr); }
  .transport-row {
    grid-template-columns: 140px 1fr 90px;
    grid-template-rows: auto;
    align-items: center;
  }
  .transport-name   { grid-column: 1; grid-row: 1; }
  .transport-desc   { grid-column: 2; grid-row: 1; }
  .transport-status { grid-column: 3; grid-row: 1; justify-self: end; }
  .footer-wrap { grid-template-columns: 1.4fr repeat(3, 1fr); gap: 3rem; }
}

/* ≥ 1100px — large */
@media (min-width: 1100px) {
  .container { padding: 0 2rem; }
}

/* ============================================================
   ACCESSIBILITY — Focus states
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius);
}
.btn:focus-visible { outline-offset: 3px; }
.faq-item summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .badge-dot { animation: none; }
}

/* ============================================================
   BUG FIX — MOBILE CODE BLOCK OVERFLOW + COPY BUTTON VISIBILITY
   Bug: start-step code blocks overflowed viewport with no scroll.
   Root cause: min-width:auto on grid children + opacity:0 on touch.
   ============================================================ */

/* Constrain start-step code blocks in all viewports */
.start-step > pre,
.start-step > .code-wrap { min-width: 0; overflow-x: auto; }

/* Touch devices: copy/curl buttons have no hover — show at resting opacity */
@media (hover: none) {
  .copy-btn { opacity: 0.65; }
}

/* ============================================================
   BUG FIX — CURL BUTTON THEME-AWARE HOVER
   Bug: hover background was hardcoded blue, wrong in nihil theme.
   ============================================================ */
.copy-btn.curl-btn:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }

/* Nihil: curl btn uses border-strong so it reads against light code-bg */
[data-theme="nihil"] .copy-btn.curl-btn {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
[data-theme="nihil"] .copy-btn.curl-btn:hover {
  background: var(--bg-panel);
  border-color: var(--text);
}

/* ============================================================
   BUG FIX — NIHIL THEME PRISM SYNTAX TOKEN CONTRAST
   Bug: prism-tomorrow assigns light token colors (#ccc punctuation)
   that are illegible on nihil's --code-bg: #ebebeb.
   ============================================================ */
[data-theme="nihil"] pre code { color: var(--text); }

[data-theme="nihil"] .token.comment,
[data-theme="nihil"] .token.prolog,
[data-theme="nihil"] .token.doctype,
[data-theme="nihil"] .token.cdata               { color: #555555; font-style: italic; }

[data-theme="nihil"] .token.punctuation          { color: #333333; }

[data-theme="nihil"] .token.property,
[data-theme="nihil"] .token.tag,
[data-theme="nihil"] .token.boolean,
[data-theme="nihil"] .token.number,
[data-theme="nihil"] .token.constant,
[data-theme="nihil"] .token.symbol,
[data-theme="nihil"] .token.deleted             { color: #b05000; }

[data-theme="nihil"] .token.selector,
[data-theme="nihil"] .token.attr-name,
[data-theme="nihil"] .token.string,
[data-theme="nihil"] .token.char,
[data-theme="nihil"] .token.builtin,
[data-theme="nihil"] .token.inserted            { color: #1a7a00; }

[data-theme="nihil"] .token.operator,
[data-theme="nihil"] .token.entity,
[data-theme="nihil"] .token.url                 { color: #555555; }

[data-theme="nihil"] .token.atrule,
[data-theme="nihil"] .token.attr-value,
[data-theme="nihil"] .token.keyword             { color: #003894; font-weight: 600; }

[data-theme="nihil"] .token.function,
[data-theme="nihil"] .token.class-name          { color: #7a0077; }

[data-theme="nihil"] .token.regex,
[data-theme="nihil"] .token.important,
[data-theme="nihil"] .token.variable            { color: #b05000; }

/* ============================================================
   BUG FIX — NIHIL DEMO TERMINAL EVENT COLOURS
   event-started uses --text-mute (#777) on bg-panel (#f2f2f2) = 3.4:1
   Fails WCAG AA (4.5:1 minimum). Bump to #555555 = 5.7:1.
   event-delta/complete inherit --accent/#444 which already pass.
   ============================================================ */
[data-theme="nihil"] .demo-stdout .event-started { color: #555555; }

/* ============================================================
   WHY HAPPI? — #why section
   ============================================================ */
.why-compare {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin: 2.5rem 0;
}

@media (min-width: 769px) {
  .why-compare {
    grid-template-columns: 1fr 1fr;
  }
}

.why-col {
  display: flex;
  flex-direction: column;
}

.why-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.45rem 0.875rem;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 0;
}

.why-label-bad {
  background: rgba(248, 81, 73, 0.12);
  color: #f85149;
  border: 1px solid rgba(248, 81, 73, 0.28);
  border-bottom: none;
}

.why-label-good {
  background: rgba(63, 185, 80, 0.12);
  color: #3fb950;
  border: 1px solid rgba(63, 185, 80, 0.28);
  border-bottom: none;
}

.why-label-bad + pre,
.why-label-good + pre {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: 0;
  flex: 1;
}

.compare-heading {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 2.5rem 0 0.875rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.compare-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 0.75rem);
  margin-bottom: 2rem;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.compare-table th,
.compare-table td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.45;
}

.compare-table thead th {
  background: var(--bg-surface);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.compare-table tbody tr:last-child td {
  border-bottom: none;
}

.compare-table tbody td:first-child {
  font-weight: 600;
  color: var(--text-secondary, var(--text-muted));
  white-space: nowrap;
}

.compare-table td.happi-col,
.compare-table th.happi-col {
  background: rgba(88, 166, 255, 0.06);
}

.compare-table th.happi-col {
  color: var(--accent);
  font-weight: 700;
}

.why-cta {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

@media (min-width: 769px) {
  .why-cta {
    flex-direction: row;
  }
}

/* ============================================================
   IMPLEMENTATIONS PAGE — shared card styles
   ============================================================ */
.impl-page {
  padding-top: 5rem;
}

.impl-hero {
  background: var(--bg-dark, var(--bg-surface));
  border-bottom: 1px solid var(--border);
  padding: var(--space-10) 0 var(--space-8);
  text-align: center;
}

.impl-hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin-bottom: 0.5rem;
}

.impl-hero p {
  color: var(--text-muted);
  max-width: 560px;
  margin: 0.75rem auto 0;
  font-size: 1.05rem;
  line-height: 1.6;
}

.impl-tabs {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.impl-tab {
  padding: 0.625rem 1rem;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.impl-tab:hover,
.impl-tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.06);
}

.impl-block {
  margin-bottom: 3rem;
}

.impl-block-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}

.impl-lang-badge {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  border-radius: 2rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.impl-lang-python  { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.impl-lang-ts      { background: rgba(49, 120, 198, 0.15); color: #38bdf8; }
.impl-lang-go      { background: rgba(0, 173, 216, 0.15);  color: #67e8f9; }
.impl-lang-rust    { background: rgba(234, 88, 12, 0.15);  color: #fb923c; }
.impl-lang-bash    { background: rgba(16, 185, 129, 0.15); color: #34d399; }

.impl-conformance {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 0.75rem);
  padding: 1.5rem 2rem;
  margin: 2rem 0;
}

.impl-conformance h3 {
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

.impl-conformance ul {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.5rem;
}

.impl-conformance li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.impl-conformance li::before {
  content: "□";
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 0.05em;
}

