:root {
  --ink: #10130f;
  --ink-2: #171b14;
  --card: #141814;
  --bone: #f4efe6;
  --muted: #cfc8b8;
  --line: rgba(244, 239, 230, 0.14);
  --lime: #dff25a;
  --coral: #ff6a4a;
  --paper: #f3eee4;
  --paper-ink: #171910;
  --olive: #4e5a28;
  --nav: 68px;
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: Outfit, "Avenir Next", "Segoe UI", sans-serif;
  font-size: 1.05rem;
  line-height: 1.55;
  padding-top: var(--nav);
}

body.bare { padding-top: 0; }

img, svg { max-width: 100%; }

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

a { color: inherit; }

::selection {
  background: var(--lime);
  color: #142000;
}

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

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--lime);
  color: #142000;
  padding: 8px 12px;
  z-index: 80;
  text-decoration: none;
}

.skip:focus { left: 16px; }

.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 70;
  pointer-events: none;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--lime);
  transform: scaleX(0);
  transform-origin: left center;
}

.spine {
  display: none;
}

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: var(--nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  background: rgba(16, 19, 15, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.logo svg { display: block; flex: none; }

.nav-links {
  display: flex;
  gap: 22px;
  align-items: center;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav-links a:hover { color: var(--bone); }

.lang {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
}

.lang a { text-decoration: none; color: var(--muted); }

.lang a[aria-current="page"] { color: var(--lime); }

.wrap {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
}

.kicker {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lime);
}

h1, h2, .question, .figure strong, .close h2, .missing h1 {
  font-family: Fraunces, "Iowan Old Style", Palatino, serif;
  font-weight: 560;
  letter-spacing: -0.035em;
}

h1 {
  margin-top: 14px;
  font-size: clamp(3.3rem, 7.2vw, 6.4rem);
  line-height: 0.92;
}

h1 em, .close h2 em {
  font-style: italic;
  font-weight: 500;
  color: var(--lime);
}

.paper h2 em { color: var(--olive); }

h2 {
  margin-top: 12px;
  font-size: clamp(2.2rem, 4.6vw, 3.7rem);
  line-height: 1.02;
}

.lede {
  margin-top: 18px;
  max-width: 38ch;
  color: var(--muted);
  font-size: 1.12rem;
}

.hero { padding: 42px 0 72px; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  gap: 36px;
  align-items: center;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.btn-primary { background: var(--lime); color: #142000; }

.btn-primary:hover { background: #eaf78a; }

.btn-ghost {
  border: 1px solid var(--line);
  color: var(--bone);
}

.btn-ghost:hover { border-color: rgba(244, 239, 230, 0.4); }

.bay {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(230px, 0.82fr);
  gap: 48px;
  align-items: center;
  min-height: 440px;
}

.wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.wire { fill: none; }

.wire-track {
  stroke: rgba(244, 239, 230, 0.16);
  stroke-width: 1.25;
}

.wire-track.live { stroke: rgba(223, 242, 90, 0.55); }

.wire-packet {
  stroke: transparent;
  stroke-width: 2;
  stroke-linecap: round;
}

.wire-packet.live {
  stroke: var(--lime);
  stroke-dasharray: 5 13;
  animation: packet 0.9s linear infinite;
}

.bay-sources, .bay-core { position: relative; z-index: 1; }

.bay-sources { display: grid; gap: 12px; }

.jack, .bay-core, .card {
  background: var(--card);
  border: 1px solid var(--line);
}

.jack {
  position: relative;
  padding: 13px 22px 13px 14px;
  transition: border-color 0.35s ease, background 0.35s ease;
}

.jack.live {
  border-color: rgba(223, 242, 90, 0.7);
  background: #1c2216;
}

.jk, .jm, .tag, .story-count, .tools code, .how .n, .chips li {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.jk {
  color: var(--lime);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.jack h3 {
  margin-top: 4px;
  font-family: Outfit, sans-serif;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.jm {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.jack-port, .bay-in {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(244, 239, 230, 0.5);
  background: var(--ink);
}

.jack-port {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
}

.jack.live .jack-port,
.bay.ready .bay-in, .bay-in {
  background: var(--lime);
  border-color: var(--lime);
}

.jack.live .jack-port { box-shadow: 0 0 0 4px rgba(223, 242, 90, 0.16); }

.bay-core { padding: 20px 18px 18px 22px; }

.bay-in {
  position: absolute;
  left: 0;
  top: 28px;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 4px rgba(223, 242, 90, 0.16);
}

.bay-status {
  margin-top: 10px;
  font-size: 1.2rem;
  line-height: 1.25;
  min-height: 2.5em;
}

.bay-answer {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

.bay.ready .bay-answer {
  max-height: 320px;
  opacity: 1;
  margin-top: 12px;
  transition: opacity 0.45s ease, max-height 0.45s ease;
}

.bay-answer p { color: var(--bone); font-size: 0.98rem; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.chips li {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid rgba(223, 242, 90, 0.45);
  color: var(--lime);
  padding: 4px 7px;
}

.marquee {
  overflow: hidden;
  background: var(--lime);
  color: #142000;
  padding: 13px 0;
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: ticker 32s linear infinite;
}

.marquee span {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

section { padding: 88px 0; }

.intro { max-width: 40rem; }

.section-copy { margin-top: 16px; max-width: 46rem; color: var(--muted); }

.split {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 36px;
}

.card { padding: 18px; min-height: 100%; }

.card h3 {
  margin: 10px 0 6px;
  font-family: Outfit, sans-serif;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.card p { color: var(--muted); }

.tag {
  color: var(--coral);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.bridge {
  margin-top: 28px;
  font-family: Fraunces, serif;
  font-style: italic;
  font-size: 1.35rem;
}

.story {
  height: 420vh;
  padding: 0;
  background: #0c0f0b;
}

.story-sticky {
  position: sticky;
  top: var(--nav);
  height: calc(100vh - var(--nav));
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
  gap: 28px;
  align-items: center;
}

.question {
  margin-top: 16px;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.5rem, 2.4vw, 2.05rem);
  line-height: 1.15;
}

.story-count {
  margin-top: 22px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
}

.steps {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
}

.steps li {
  color: var(--muted);
  padding: 8px 0 8px 14px;
  border-left: 2px solid rgba(244, 239, 230, 0.16);
}

.steps li.on { color: var(--bone); border-left-color: rgba(223, 242, 90, 0.4); }

.steps li.current { color: var(--lime); border-left-color: var(--lime); }

.paper {
  background: var(--paper);
  color: var(--paper-ink);
}

.paper .kicker, .paper .tools code { color: var(--olive); }

.paper .section-copy, .paper .note, .paper .figure .label { color: #3e4432; }

.figures-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
  margin-top: 36px;
}

.figure strong {
  display: block;
  font-size: clamp(2rem, 3vw, 2.8rem);
  line-height: 1;
}

.figure .label {
  display: block;
  margin-top: 10px;
  max-width: 18ch;
}

.note { margin-top: 22px; font-size: 0.92rem; }

.tools {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
}

.tools li {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 18px;
  align-items: baseline;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.tools li:last-child { border-bottom: 1px solid var(--line); }

.tools code { color: var(--lime); font-size: 0.86rem; }

.how {
  position: relative;
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
}

.how::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 12px;
  bottom: 12px;
  width: 1px;
  background: rgba(223, 242, 90, 0.5);
  transform-origin: top center;
}

.js .how::before { transform: scaleY(0); }

.js .how.in::before { transform: scaleY(1); transition: transform 1.1s ease; }

.how li {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  padding: 16px 0;
}

.how .n { color: var(--lime); }

.how p { color: var(--muted); max-width: 46ch; }

.close { padding-bottom: 72px; }

.close h2 {
  font-size: clamp(2.8rem, 6vw, 5.2rem);
  line-height: 0.96;
}

.close .lede { color: #3e4432; max-width: 36ch; }

.site-footer {
  padding-bottom: 28px;
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 22px;
  padding-bottom: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer a { color: var(--bone); }

.missing {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 10vh 8vw;
}

.missing h1 {
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  line-height: 0.96;
  max-width: 12ch;
}

.missing p { color: var(--muted); }

.js .reveal {
  opacity: 0;
  transform: translateY(18px);
}

.js .reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s ease, transform 0.7s ease;
}

@keyframes packet {
  to { stroke-dashoffset: -36; }
}

@keyframes ticker {
  to { transform: translateX(-50%); }
}

@media (min-width: 1100px) {
  .spine {
    display: grid;
    place-items: center;
    position: fixed;
    z-index: 45;
    left: 0;
    top: 0;
    bottom: 0;
    width: 46px;
    margin: 0;
    writing-mode: vertical-rl;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 11px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--muted);
  }

  body { padding-left: 46px; }

  .nav, .progress { left: 46px; }

  .skip:focus { left: 60px; }
}

@media (max-width: 980px) {
  .hero-grid, .story-sticky, .bay, .split, .figures-grid {
    grid-template-columns: 1fr;
  }

  .bay { min-height: 0; gap: 22px; }

  .wires { display: none; }

  .jack.live { box-shadow: inset 3px 0 0 var(--lime); }

  .story {
    height: auto;
    padding: 72px 0;
  }

  .story-sticky {
    position: static;
    height: auto;
    display: grid;
  }

  .tools li { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 720px) {
  .nav-links { display: none; }

  h1 { font-size: clamp(2.8rem, 14vw, 4rem); }

  .split, .figures-grid { grid-template-columns: 1fr; }
}

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

  .js .reveal,
  .js .reveal.in,
  .bay-answer,
  .bay.ready .bay-answer {
    opacity: 1;
    transform: none;
    max-height: none;
    transition: none;
  }

  .marquee-track, .wire-packet.live { animation: none; }

  .wire-packet.live { stroke-dasharray: none; }

  .js .how::before { transform: none; }
}
