/* ===========================
   JWG AI — Cosmos
   =========================== */

/* ─── Self-hosted fonts (no third-party requests) ─── */

@font-face {
  font-family: 'Inter Tight';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(/assets/fonts/inter-tight-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter Tight';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(/assets/fonts/inter-tight-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url(/assets/fonts/jetbrains-mono-latin.woff2) format('woff2');
}

/* ─── Tokens ─── */

:root {
  color-scheme: dark;

  --space:      #04050a;
  --space-2:    #0a0c14;
  --ink:        #ecebe6;
  --ink-2:      #b9bac2;
  --muted:      #80828e;
  --line:       rgba(236, 235, 230, 0.10);
  --line-2:     rgba(236, 235, 230, 0.18);
  --glass:      rgba(10, 12, 20, 0.55);
  --signal:     #f2c078;
  --signal-dim: rgba(242, 192, 120, 0.14);

  --font-sans:  'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --gutter: clamp(16px, 4vw, 48px);
  --max:    1240px;
  --ease:   cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── Base ─── */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  background: var(--space);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
::selection { background: var(--signal); color: var(--space); }

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  background: var(--ink);
  color: var(--space);
  padding: 8px 14px;
  font-size: 14px;
}
.skip-link:focus { top: 12px; }

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.mono, .eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 12px var(--signal);
}

/* ─── Starfield ─── */

#cosmos {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.page { position: relative; z-index: 1; }

/* ─── Navigation ─── */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
  border-bottom: 1px solid transparent;
}

.nav.scrolled {
  background: rgba(4, 5, 10, 0.72);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 24px;
}

.logo {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.04em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
  font-size: 15px;
  color: var(--ink-2);
}

.nav-links a { transition: color 0.2s; }
.nav-links a:hover { color: var(--ink); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.lang {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.lang a, .lang span { padding: 4px 2px; }
.lang span { color: var(--ink); }
.lang a:hover { color: var(--ink); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}

.btn svg { width: 15px; height: 15px; transition: transform 0.3s var(--ease); }
.btn:hover svg { transform: translateX(3px); }

.btn-primary { background: var(--ink); color: var(--space); }
.btn-primary:hover { background: var(--signal); }

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

.btn-sm { height: 38px; padding: 0 16px; font-size: 14px; }

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  background: none;
  border: 0;
  color: var(--ink);
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  margin: 5px auto;
  background: currentColor;
  transition: transform 0.3s var(--ease), opacity 0.2s;
}

.nav.open .nav-toggle span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav.open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav.open .nav-toggle span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ─── Hero ─── */

.hero {
  min-height: min(100vh, 1000px);
  min-height: min(100svh, 1000px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 140px 0 56px;
  background: radial-gradient(ellipse 80% 60% at 70% 40%, rgba(80, 70, 140, 0.10), transparent 70%);
}

.hero h1 {
  font-size: clamp(3rem, 9.5vw, 8.5rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.045em;
  margin: 28px 0 32px;
  max-width: 11ch;
}

.hero-lede {
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 40ch;
}

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

.telemetry {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 88px;
  border-top: 1px solid var(--line);
}

.telemetry div {
  padding: 18px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.telemetry b {
  display: block;
  margin-top: 4px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

/* ─── Sections ─── */

.section { padding: clamp(96px, 14vw, 180px) 0; }

.section-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px 64px;
  align-items: end;
  margin-bottom: clamp(48px, 7vw, 88px);
}

.section-head h2,
.h2 {
  font-size: clamp(2.2rem, 5.2vw, 4.4rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.035em;
  margin-top: 20px;
}

.section-head p {
  color: var(--ink-2);
  font-size: 1.1rem;
  max-width: 46ch;
}

/* ─── Stack (orbit path) ─── */

.orbit {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  list-style: none;
}

.orbit::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--line-2), var(--signal) 50%, var(--line-2));
  opacity: 0.6;
}

.orbit li { position: relative; padding: 44px 24px 0 0; }

.orbit li::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid var(--signal);
  background: var(--space);
}

.orbit li:last-child::before {
  background: var(--signal);
  box-shadow: 0 0 20px var(--signal);
}

.orbit .step {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--signal);
}

.orbit h3 {
  font-size: 1.25rem;
  font-weight: 550;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 8px 0 10px;
}

.orbit p { font-size: 15px; color: var(--ink-2); }

/* ─── Services ─── */

.services {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.service {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  min-height: 340px;
  padding: 32px;
  background: rgba(4, 5, 10, 0.86);
  transition: background 0.4s var(--ease);
}

.service:hover { background: rgba(14, 16, 28, 0.9); }

.service.wide { grid-column: span 3; }

.service > svg {
  width: 40px;
  height: 40px;
  margin: 0 0 24px;
  color: var(--signal);
}

.service h3 {
  font-size: 1.45rem;
  font-weight: 550;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.service p { color: var(--ink-2); font-size: 15.5px; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 28px;
  list-style: none;
}

.tags li {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  padding: 5px 10px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
}

/* ─── Product (CARWATCH) ─── */

.product {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: clamp(40px, 6vw, 96px);
  align-items: center;
}

.example-title {
  font-size: clamp(1.9rem, 3.6vw, 2.8rem);
  font-weight: 550;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 16px 0 20px;
}

.product-copy p { color: var(--ink-2); font-size: 1.1rem; max-width: 50ch; }
.product-copy p + p { margin-top: 16px; }

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 40px 0;
  background: var(--line);
  border: 1px solid var(--line);
}

.metrics div { padding: 20px; background: rgba(4, 5, 10, 0.9); }

.metrics b {
  display: block;
  font-size: 1.8rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.metrics span { font-size: 14px; color: var(--muted); }

/* Detection readout visual */

.scope {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line-2);
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 40px 40px,
    rgba(6, 8, 14, 0.85);
  overflow: hidden;
}

.scope svg { width: 100%; height: 100%; }

.scope-hud {
  position: absolute;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.scope-hud.top { top: 12px; }
.scope-hud.bottom { bottom: 12px; }

.rec { color: var(--signal); }
.rec::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--signal);
  animation: blink 1.6s steps(2, start) infinite;
}

@keyframes blink { to { visibility: hidden; } }

.scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 30%;
  background: linear-gradient(180deg, transparent, rgba(242, 192, 120, 0.06));
  border-bottom: 1px solid rgba(242, 192, 120, 0.35);
  animation: scan 4.5s linear infinite;
}

@keyframes scan {
  from { transform: translateY(-100%); }
  to   { transform: translateY(340%); }
}

/* ─── About ─── */

.about {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(40px, 6vw, 96px);
}

.about-text p {
  font-size: clamp(1.25rem, 2.2vw, 1.7rem);
  line-height: 1.45;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.about-text p + p { margin-top: 24px; color: var(--ink-2); font-size: 1.1rem; letter-spacing: 0; }

.facts { list-style: none; border-top: 1px solid var(--line); }

.facts li {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.facts span:first-child {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 4px;
}

.facts span:last-child { text-align: right; }

/* ─── Healthcare ─── */

.lead {
  font-size: clamp(1.15rem, 1.8vw, 1.4rem);
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.checks {
  list-style: none;
  margin-top: 32px;
  border-top: 1px solid var(--line);
}

.checks li {
  position: relative;
  padding: 16px 0 16px 26px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
}

.checks li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 25px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--signal);
}

/* ─── Contact ─── */

.contact { text-align: center; }

.contact .h2 {
  font-size: clamp(2.8rem, 8vw, 7rem);
  margin: 24px auto 24px;
}

.contact p { color: var(--ink-2); font-size: 1.15rem; max-width: 44ch; margin: 0 auto; }

.contact-mail {
  display: inline-block;
  margin-top: 44px;
  font-size: clamp(1.4rem, 3.4vw, 2.4rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 6px;
  transition: color 0.25s, border-color 0.25s;
}

.contact-mail:hover { color: var(--signal); border-color: var(--signal); }

/* ─── Footer ─── */

.footer {
  border-top: 1px solid var(--line);
  padding: 40px 0 48px;
  background: rgba(4, 5, 10, 0.8);
  font-size: 14px;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px 32px;
}

.footer nav { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.footer a:hover { color: var(--ink); }

/* ─── Legal pages ─── */

.legal { padding: 140px 0 120px; }

.legal-body {
  max-width: 720px;
  padding: clamp(24px, 4vw, 48px);
  background: rgba(4, 5, 10, 0.86);
  border: 1px solid var(--line);
}

.legal h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin: 16px 0 40px;
}

.legal h2 {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--signal);
  margin: 36px 0 10px;
}

.legal p, .legal li { color: var(--ink-2); font-size: 15.5px; }
.legal p + p { margin-top: 10px; }
.legal ul { padding-left: 20px; margin-top: 8px; }
.legal a { border-bottom: 1px solid var(--line-2); }
.legal a:hover { color: var(--ink); border-color: var(--ink); }

/* ─── Reveal ─── */

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}

.reveal.visible { opacity: 1; transform: none; }

.no-js .reveal { opacity: 1; transform: none; }

/* ─── Responsive ─── */

@media (max-width: 1024px) {
  .services { grid-template-columns: 1fr 1fr; }
  .service, .service.wide { grid-column: span 1; }
  .orbit { grid-template-columns: 1fr; gap: 0; }
  .orbit::before {
    top: 0;
    bottom: 0;
    left: 7px;
    right: auto;
    width: 1px;
    height: auto;
    background: linear-gradient(180deg, var(--line-2), var(--signal) 50%, var(--line-2));
  }
  .orbit li { padding: 0 0 36px 44px; }
  .orbit li:last-child { padding-bottom: 0; }
  .product, .about { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: fixed;
    top: 68px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 8px var(--gutter) 24px;
    background: rgba(4, 5, 10, 0.96);
    border-bottom: 1px solid var(--line);
    font-size: 20px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease), visibility 0.3s;
  }
  .nav-links a { width: 100%; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .nav.open { background: rgba(4, 5, 10, 0.96); }
  .nav.open .nav-links { opacity: 1; visibility: visible; transform: none; }
  .nav-right .btn { display: none; }
  .section-head { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .services { grid-template-columns: 1fr; }
  .service:last-child { grid-column: span 1; }
  .service { min-height: 0; padding: 26px 22px; }
  .telemetry { grid-template-columns: 1fr; margin-top: 56px; }
  .telemetry div { padding: 14px 0; border-bottom: 1px solid var(--line); }
  .metrics b { font-size: 1.45rem; }
  .facts li { flex-direction: column; gap: 4px; }
  .facts span:last-child { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .scan, .rec::before { animation: none; }
}

.tags.built-from { margin: 4px 0 20px; padding-top: 16px; }
.tags.built-from li { color: var(--signal); border-color: rgba(242, 192, 120, 0.35); }

/* A second example directly following the first */
.section-follow { padding-top: 0; }
#examples .section-head { margin-bottom: clamp(40px, 6vw, 72px); }

/* ─── Service cards link to detail pages ─── */

.service .more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  transition: color 0.25s var(--ease);
}

.service .more svg { width: 14px; height: 14px; transition: transform 0.3s var(--ease); }
.service:hover .more { color: var(--signal); }
.service:hover .more svg { transform: translateX(4px); }

/* ─── Service detail pages ─── */

.service-hero { padding: 132px 0 40px; }

.crumbs { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }
.crumbs [aria-current] { color: var(--ink-2); }

.service-hero-icon { margin: 48px 0 24px; color: var(--signal); }
.service-hero-icon svg { width: 56px; height: 56px; }

.service-hero h1 {
  font-size: clamp(2.6rem, 6.5vw, 5.6rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
  max-width: 16ch;
  margin-bottom: 28px;
}

.service-hero .hero-lede { max-width: 52ch; }
.service-hero .tags { margin-top: 0; padding-top: 28px; }
.service-hero .hero-actions { margin-top: 36px; }

.section-tight { padding: clamp(64px, 9vw, 112px) 0; }
.section-tight .section-head { margin-bottom: clamp(32px, 4vw, 48px); }

.scope-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.scope-item { padding: 28px; background: rgba(4, 5, 10, 0.86); }

.scope-item h3 {
  font-size: 1.15rem;
  font-weight: 550;
  letter-spacing: -0.015em;
  margin-bottom: 8px;
}

.scope-item p { font-size: 15px; color: var(--ink-2); }

.orbit-4 { grid-template-columns: repeat(4, 1fr); margin-top: 40px; }

.related {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.related-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  border: 1px solid var(--line-2);
  background: rgba(4, 5, 10, 0.86);
  font-weight: 500;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.related-card svg:first-child { width: 28px; height: 28px; flex: none; color: var(--signal); }
.related-card > svg:last-child { width: 15px; height: 15px; margin-left: auto; flex: none; transition: transform 0.3s var(--ease); }
.related-card:hover { border-color: var(--ink); background: rgba(14, 16, 28, 0.9); }
.related-card:hover > svg:last-child { transform: translateX(4px); }
.related-card.example { flex-wrap: wrap; gap: 4px 16px; }
.related-card.example .mono { width: 100%; color: var(--muted); }
.related-card.example > svg:last-child { margin-top: -22px; }

@media (max-width: 1024px) {
  .scope-grid { grid-template-columns: 1fr 1fr; }
  .orbit-4 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .scope-grid { grid-template-columns: 1fr; }
  .scope-item { padding: 22px; }
}
.section-tight .section-head { align-items: start; }

/* ─── Engineering: GPU timeline ─── */

.trace {
  border: 1px solid var(--line-2);
  background: rgba(6, 8, 14, 0.9);
  padding: 0 0 12px;
}

.trace-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.legend { display: inline-flex; align-items: center; gap: 8px; color: var(--signal); }
.legend i { width: 14px; height: 8px; background: var(--signal); }

.trace-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.lane {
  padding: 0 20px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  white-space: nowrap;
}

.trace-row.custom .lane { color: var(--signal); }

.track {
  display: block;
  width: 100%;
  height: 34px;
  border-left: 1px solid var(--line);
  background-image: linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 25% 100%;
}

.track .scroll { animation: trace 9s linear infinite; }

@keyframes trace {
  from { transform: translateX(0); }
  to   { transform: translateX(-600px); }
}

.trace-axis {
  display: flex;
  justify-content: space-between;
  margin-left: 200px;
  padding: 10px 0 0 4px;
  color: var(--muted);
  font-size: 10.5px;
}

.trace-axis span:last-child { padding-right: 12px; }

.code {
  margin: 0;
  border: 1px solid var(--line-2);
  background: rgba(6, 8, 14, 0.92);
  min-width: 0;
}

.code figcaption {
  display: flex;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.code pre {
  margin: 0;
  padding: 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-2);
}

.code .k { color: #9fb4ff; }
.code .f { color: var(--signal); }
.code .n { color: #c7e3b0; }
.code .c { color: var(--muted); font-style: italic; }

.stack-list { list-style: none; border-top: 1px solid var(--line); }

/* ─── Frame walkthrough ─── */

.walk-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 64px;
  align-items: end;
  margin: clamp(56px, 8vw, 96px) 0 24px;
}

.walk-head h3 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 550;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.walk-head p { color: var(--ink-2); max-width: 52ch; }

.walk {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: stretch;
}

.walk-viz {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-2);
  background: rgba(6, 8, 14, 0.92);
  min-width: 0;
}

.walk-tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  border-bottom: 1px solid var(--line);
}

.walk-tabs button {
  appearance: none;
  background: none;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 12px 8px 11px;
  color: var(--muted);
  font: 500 12.5px/1.2 var(--font-sans);
  text-align: left;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.walk-tabs button:last-child { border-right: 0; }
.walk-tabs button span { display: block; font: 11px var(--font-mono); margin-bottom: 3px; color: var(--muted); }
.walk-tabs button:hover { color: var(--ink); }
.walk-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--signal); background: rgba(242, 192, 120, 0.05); }
.walk-tabs button[aria-selected="true"] span { color: var(--signal); }

.walk-viz canvas { display: block; width: 100%; flex: 1; min-height: 340px; }

.walk-viz p {
  padding: 16px 20px 18px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 15px;
  min-height: 92px;
}

.walk .code { display: flex; flex-direction: column; }
.walk .code pre { flex: 1; font-size: 11px; line-height: 1.7; }

.code .ln { display: block; min-height: 1.7em; padding: 0 6px; margin: 0 -6px; border-left: 2px solid transparent; transition: background 0.3s, border-color 0.3s, opacity 0.3s; }
.walk:has(.ln.active) .code .ln { opacity: 0.45; }
.walk:has(.ln.active) .code .ln.active { opacity: 1; background: rgba(242, 192, 120, 0.08); border-left-color: var(--signal); }

.stack-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0 32px;
  margin-top: clamp(40px, 6vw, 64px);
}
.stack-list li { padding: 20px 0; border-bottom: 1px solid var(--line); }
.stack-list b { display: block; font-weight: 550; margin-bottom: 4px; }
.stack-list span { color: var(--ink-2); font-size: 15px; }


@media (max-width: 1024px) {
  .walk, .walk-head { grid-template-columns: 1fr; }
  .stack-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .walk-tabs { grid-template-columns: repeat(3, 1fr); }
  .walk-tabs button:nth-child(3) { border-right: 0; }
  .walk-tabs button:nth-child(-n+3) { border-bottom-color: var(--line); }
  .walk-tabs button[aria-selected="true"] { border-bottom-color: var(--signal); }
  .walk-viz canvas { min-height: 280px; }
  .stack-row { grid-template-columns: 1fr; }
  .trace-row { grid-template-columns: 116px 1fr; }
  .lane { padding: 0 10px; font-size: 10px; white-space: normal; line-height: 1.2; }
  .trace-axis { margin-left: 116px; }
  .trace-axis span:nth-child(even) { visibility: hidden; }
  .code pre { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .track .scroll { animation: none; }
}

/* ─── Finale: from the Milky Way to Earth ─── */

.finale { position: relative; height: 460vh; }

.finale-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--space);
}

.finale-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.finale-text {
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(40px, 10vh, 110px);
  padding: 0 var(--gutter);
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.finale-text h2 {
  font-size: clamp(2.2rem, 5.8vw, 5rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.04em;
  margin: 0 auto 28px;
  max-width: 18ch;
  text-shadow: 0 2px 30px rgba(4, 5, 10, 0.8);
}

.no-js .finale { height: auto; }
.no-js .finale-stage { position: relative; height: auto; padding: 120px 0; }
.no-js .finale-text { position: static; opacity: 1; pointer-events: auto; }
