:root {
  color-scheme: dark light;
  --bg: #000000;
  --text: #f5f5f5;
  --muted: #bdbdbd;
  --line: #333333;
  --panel: #0d0d0d;
  --bar: #f5f5f5;
  --ok: #3fb950;
  --warn: #d29922;
  --max: 1040px;
  --gib-scale: calc(100% / 16);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f0e6;
    --text: #111111;
    --muted: #4a4a4a;
    --line: #cfc6b4;
    --panel: #ede6d8;
    --bar: #111111;
    --ok: #116329;
    --warn: #9a6700;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Helvetica, Arial, "Liberation Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-underline-offset: 0.2em; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 2px;
}
img { display: block; }

code {
  font: 500 0.88em ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}
p code, li code, td code, dd code, figcaption code {
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

main { max-width: var(--max); margin: 0 auto; padding: 0 24px; }

h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.2; }
h1 { margin: 0 0 24px; font-size: clamp(1.9rem, 4.4vw, 3rem); font-weight: 700; max-width: 19em; }
h2 { margin: 0 0 16px; font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 700; }
h3 { margin: 0 0 8px; font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 16px; max-width: 68ch; }
section { padding: 64px 0; border-top: 1px solid var(--line); }

nav {
  min-height: 72px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 12px 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  text-decoration: none;
}
.brand-logo { width: 28px; height: auto; }
.nav-links { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); font-size: 0.92rem; }
.nav-links a { text-decoration: none; padding: 2px 0; }
.nav-links a:hover { color: var(--text); text-decoration: underline; }

/* Full-width hero over the WebGPU scene. It stays dark in both themes. */
.hero {
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  min-height: min(96vh, 960px);
  padding: 0;
  border-top: 0;
  display: flex;
  align-items: flex-end;
  background: #000;
  color: #f5f5f5;
  overflow: hidden;
}
.hero-scene { position: absolute; inset: 0; z-index: 0; }
/* Keep the headline readable over the bright scene: darken the lower left, blur and
   dim the scene right behind the text, and give the letters a soft dark shadow. */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 18% 100%, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.6) 38%, rgba(0, 0, 0, 0) 72%),
    linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 50%);
  pointer-events: none;
  z-index: 1;
}
.hero-text::before {
  content: "";
  position: absolute;
  inset: 80px -10% -20px -10%;
  backdrop-filter: blur(10px) brightness(0.6) saturate(0.8);
  -webkit-backdrop-filter: blur(10px) brightness(0.6) saturate(0.8);
  mask-image: radial-gradient(70% 70% at 35% 70%, #000 45%, transparent 100%);
  -webkit-mask-image: radial-gradient(70% 70% at 35% 70%, #000 45%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}
.hero h1, .hero .lede, .scene-note {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 18px rgba(0, 0, 0, 0.65), 0 0 42px rgba(0, 0, 0, 0.45);
}
.hero-scene canvas { display: block; width: 100%; height: 100%; }
#unsupported { display: none !important; }
.hero.no-webgpu { background: #000 url("assets/scene-poster.jpg") center / cover no-repeat; }
.hero.no-webgpu .hero-scene { display: none; }
.hero-text {
  position: relative;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 160px 24px 56px;
  z-index: 2;
  isolation: isolate;
}
.hero .lede { color: #e2e2e2; }
.hero .tip { border-bottom-color: #bdbdbd; }
.hero .tip-text { background: #f5f5f5; color: #111; text-shadow: none; }
.scene-note { margin: 16px 0 0; font-size: 0.8rem; color: #bdbdbd; }
.scene-note a { color: inherit; }
.hero a:focus-visible, .hero .tip:focus-visible { outline-color: #f5f5f5; }
.try-wrap { border-top: 0; padding-top: 32px; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 62ch; }

/* Tooltip on the headline. It opens on hover and on keyboard focus. */
.tip { position: relative; border-bottom: 3px dotted var(--muted); cursor: help; outline-offset: 4px; }
.tip-text {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.4;
  width: max-content;
  max-width: min(28rem, calc(100vw - 32px));
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 2;
}
.tip:hover .tip-text, .tip:focus .tip-text, .tip:focus-within .tip-text { opacity: 1; pointer-events: auto; }
/* An invisible bridge over the gap, so the pointer can move into the tooltip. */
.tip-text::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; }
.tip-text a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 0.2em; }
@media (prefers-reduced-motion: reduce) { .tip-text { transition: none; } }

/* Terminal figure with the installer's real choices. */
.terminal { margin: 24px 0; }
.terminal pre {
  margin: 0;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow-x: auto;
  font: 0.84rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.terminal figcaption { margin-top: 8px; }
.terminal .tline { display: inline-block; }
.t-ok { color: var(--ok); }
.t-warn { color: var(--warn); }

/* Install */
.command {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.command pre {
  flex: 1;
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.command code { font-size: 0.95rem; }
button.copy {
  flex: none;
  min-width: 72px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: var(--text);
  font: 600 0.9rem Inter, Helvetica, Arial, sans-serif;
  cursor: pointer;
}
button.copy:hover { background: var(--line); }
.agent-title { margin: 40px 0 8px; }
.command.agent pre { white-space: pre-wrap; word-break: normal; overflow-wrap: anywhere; }
.command.agent code { font-size: 0.85rem; }
.status { min-height: 1.5em; color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }

.endpoints { margin: 0 0 24px; display: grid; gap: 8px; }
.endpoints div { display: grid; grid-template-columns: minmax(10rem, 14rem) 1fr; gap: 4px 16px; }
.endpoints dt { color: var(--muted); }
.endpoints dd { margin: 0; }

table { width: 100%; border-collapse: collapse; margin: 8px 0 0; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
caption { caption-side: bottom; text-align: left; color: var(--muted); font-size: 0.88rem; padding-top: 12px; }
.options td:first-child { white-space: nowrap; }

/* Memory chart: bar widths come from the measured values in GiB. */
.chart { margin: 32px 0; }
.chart-scale, .bar-track { margin-left: var(--label-w, 17rem); position: relative; }
.chart-scale { height: 24px; font-size: 0.8rem; color: var(--muted); }
.chart-scale span {
  position: absolute;
  left: calc(var(--at) * 100%);
  transform: translateX(-50%);
  white-space: nowrap;
}
.chart-scale span:first-child { transform: none; }
.chart-scale span.device { color: var(--text); font-weight: 600; }
.chart-scale span:last-child { transform: translateX(-100%); }

.bars { list-style: none; margin: 0; padding: 0; position: relative; }
.bars::before, .bars::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed var(--muted);
}
.bars::before { left: calc(var(--label-w, 17rem) + (100% - var(--label-w, 17rem)) * 0.5); }
.bars::after { left: calc(var(--label-w, 17rem) + (100% - var(--label-w, 17rem)) - 1px); }
.bars li { display: flex; align-items: center; min-height: 44px; }
.bar-label { width: var(--label-w, 17rem); flex: none; padding-right: 16px; font-size: 0.92rem; position: relative; }
.bar-track { margin-left: 0; flex: 1; display: flex; align-items: center; height: 28px; }
.seg { display: block; flex: none; height: 28px; width: calc(var(--gib) * var(--gib-scale)); }
.seg.weights { background: var(--bar); }
.seg.rest {
  background: repeating-linear-gradient(135deg, var(--muted) 0 2px, transparent 2px 6px);
  border: 1px solid var(--muted);
  border-left: 0;
}
.bar-value { position: relative; margin-left: 4px; padding: 0 4px; background: var(--bg); font-size: 0.88rem; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 16px 0 0; padding: 0; font-size: 0.9rem; }
.legend li { display: flex; align-items: center; gap: 8px; }
.swatch { width: 18px; height: 12px; display: inline-block; }
.swatch.weights { background: var(--bar); }
.swatch.rest { background: repeating-linear-gradient(135deg, var(--muted) 0 2px, transparent 2px 6px); border: 1px solid var(--muted); }
figcaption { margin-top: 16px; color: var(--muted); font-size: 0.88rem; max-width: 80ch; }

.credit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 24px 32px;
  margin: 32px 0;
}
.people { margin: 0 0 32px; padding-left: 20px; max-width: 72ch; }
.people li { margin-bottom: 10px; }
.credit-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.credit-grid p { color: var(--muted); }

/* Diagram: downloads outside the dashed machine boundary, steps inside it. */
.diagram { margin: 32px 0; display: grid; gap: 16px; }
.diagram ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.diagram li { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: var(--panel); position: relative; }
.diagram li p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.downloads { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.downloads li::after {
  content: "↓";
  position: absolute;
  left: 50%;
  bottom: -30px;
  color: var(--muted);
}
.machine { border: 2px dashed var(--muted); border-radius: 12px; padding: 20px 16px 16px; margin-top: 16px; }
.machine-label { margin: 0 0 12px; font-weight: 600; }
.steps { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); counter-reset: step; }
.steps li { counter-increment: step; }
.steps h3::before { content: counter(step) ". "; color: var(--muted); }

.limits ul { margin: 0; padding-left: 20px; max-width: 72ch; }
.limits li { margin-bottom: 12px; }

.links { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 0.92rem; }
.links a { color: var(--text); }
.provenance { margin-top: 8px; }

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  padding: 32px 0 48px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}
footer p { margin: 0; max-width: 70ch; }

@media (max-width: 720px) {
  main { padding: 0 16px; }
  section { padding: 48px 0; }
  .hero { min-height: 78vh; }
  .hero-text { padding: 120px 16px 40px; }
  .endpoints div { grid-template-columns: 1fr; }
  .options td:first-child { white-space: normal; }
  /* The chart keeps its scale; labels move above each bar. */
  .chart { --label-w: 0rem; }
  .bars li { flex-direction: column; align-items: stretch; padding: 6px 0; }
  .bar-label { width: auto; align-self: flex-start; margin-bottom: 4px; padding: 0 4px 0 0; background: var(--bg); z-index: 1; }
  .bar-track { width: 100%; flex: none; }
  .chart-scale span.device { font-size: 0.72rem; }
}


/* Link to the in-browser WebGPU demo. */
.try {
  margin-top: 40px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 24px;
  align-items: center;
}
.try h2 { margin: 0; font-size: 1.1rem; grid-column: 1; }
.try p { margin: 0; color: var(--muted); grid-column: 1; }
.try-link {
  grid-column: 2;
  grid-row: 1 / span 2;
  padding: 10px 16px;
  border: 1px solid var(--text);
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.try-link:hover { background: var(--text); color: var(--bg); }
@media (max-width: 720px) {
  .try { grid-template-columns: 1fr; }
  .try-link { grid-column: 1; grid-row: auto; justify-self: start; }
}

/* File size comparison. */
.size { margin: 32px 0; }
.size-row { display: grid; grid-template-columns: minmax(9rem, 13rem) 1fr 5rem; gap: 16px; align-items: center; min-height: 40px; }
.size-label { font-size: 0.92rem; }
.size-track { display: block; height: 20px; }
.size-bar { display: block; height: 100%; width: calc(var(--frac) * 100%); }
.size-bar.full { background: repeating-linear-gradient(135deg, var(--muted) 0 2px, transparent 2px 6px); border: 1px solid var(--muted); }
.size-bar.small { background: var(--bar); }
.size-value { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.size figcaption { margin-top: 12px; color: var(--muted); font-size: 0.88rem; }
@media (max-width: 720px) {
  .size-row { grid-template-columns: 1fr auto; }
  .size-track { grid-column: 1 / -1; grid-row: 2; }
}

/* Motion. Content is visible without JavaScript and under reduced motion. */
.caret { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: no-preference) {
  .js main > section.rise { opacity: 0; transform: translateY(16px); transition: opacity 600ms ease, transform 600ms ease; }
  .js main > section.rise.in { opacity: 1; transform: none; }

  .js .size:not(.in) .size-bar.small { width: 100%; }
  .js .size .size-bar.small { transition: width 1400ms cubic-bezier(0.2, 0.7, 0.2, 1) 300ms; }

  .js .chart:not(.in) .seg { width: 0; }
  .js .chart .seg { transition: width 900ms cubic-bezier(0.2, 0.7, 0.2, 1); }
  .js .chart .bars li:nth-child(2) .seg { transition-delay: 80ms; }
  .js .chart .bars li:nth-child(3) .seg { transition-delay: 160ms; }
  .js .chart .bars li:nth-child(4) .seg { transition-delay: 240ms; }
  .js .chart .bars li:nth-child(5) .seg { transition-delay: 320ms; }
  .js .chart .bars li:nth-child(6) .seg { transition-delay: 400ms; }

  .js .terminal .tline { opacity: 0; }
  .js .terminal.in .tline { animation: rise 360ms ease forwards; animation-delay: calc(var(--i) * 110ms); }
}
@media (prefers-reduced-motion: reduce) {
  .caret { animation: none; }
}

/* Labels that ride on the beam in the hero scene; the page moves them each frame. */
.beam-label {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  pointer-events: none;
  color: #f5f5f5;
  line-height: 1.25;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 16px rgba(0, 0, 0, 0.7);
  z-index: 3;
}
.beam-label b { display: block; font-size: clamp(1.2rem, 2.4vw, 1.7rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.beam-label span:not(.gb) { display: block; font-size: 0.85rem; color: #d6d6d6; }
.beam-in { text-align: right; }
.hero.no-webgpu .beam-label { display: none; }
