/* Layout concept: a studio stage fixed behind the page. The logo moves on the stage
   while chapters scroll past it, and the stage takes on the color of each logo piece. */
:root {
  color-scheme: dark;
  --ink: #0a1530;
  --fg: #f2f5fb;
  --muted: #b8c2d6;
  --line: rgba(226, 234, 250, 0.16);
  --panel: rgba(9, 14, 30, 0.82);
  --code-bg: rgba(4, 8, 20, 0.62);
  --blue: #8ab4ff;
  --green: #66d692;
  --red: #ff9182;
  --yellow: #ffcd57;
  --accent: var(--blue);
  --display: "Funnel Display", "Trebuchet MS", system-ui, sans-serif;
  --body: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --gutter-left: max(16px, env(safe-area-inset-left, 0px));
  --gutter-right: max(16px, env(safe-area-inset-right, 0px));
  --tint: var(--ink);
  --glow: rgba(74, 136, 239, 0.34);
  --glow-x: 74%;
}

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

html { background: var(--ink); scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--fg);
  font: 400 1.0625rem/1.65 var(--body);
  overflow-x: clip;
}

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

/* Stage */
.stage {
  position: fixed;
  inset: 0 0 auto;
  height: 100lvh;
  z-index: 0;
  background:
    radial-gradient(52% 62% at var(--glow-x) 48%, var(--glow), transparent 72%),
    var(--tint);
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 700ms ease;
}

.poster {
  position: absolute;
  top: 50%;
  right: 5vw;
  width: min(44vw, 74vh);
  height: auto;
  transform: translateY(-50%);
  transition: opacity 700ms ease;
}

.stage.ready canvas { opacity: 1; }
.stage.ready .poster { opacity: 0; }

.progress {
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  z-index: 30;
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #4a88ef, #3da357 38%, #faaf08 68%, #eb4537);
  transform: scaleX(0);
  transform-origin: left;
}

/* Header */
.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) var(--gutter-right) 14px var(--gutter-left);
  background: linear-gradient(180deg, rgba(5, 9, 22, 0.72), transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--fg);
  font: 600 1.0625rem/1 var(--display);
  text-decoration: none;
}

.site-header nav { display: flex; gap: clamp(14px, 2.4vw, 30px); }

.site-header nav a {
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 160ms ease;
}

.site-header nav a:hover { color: var(--fg); }

/* Chapters */
main { position: relative; z-index: 1; }

.chapter {
  display: grid;
  min-height: 165vh;
  padding-left: max(var(--gutter-left), 7vw);
  padding-right: max(var(--gutter-right), 7vw);
}

.chapter-long { min-height: 190vh; }

.copy {
  position: sticky;
  top: max(92px, 13vh);
  align-self: start;
  display: grid;
  gap: 18px;
  width: min(100%, 35rem);
  min-width: 0;
  padding-block: 10vh 12vh;
}

.copy-right .copy { justify-self: end; }

.copy > * { margin: 0; min-width: 0; }

.hero { min-height: 118vh; }

.hero .copy {
  position: static;
  align-self: center;
  width: min(100%, 44rem);
  padding-block: 112px 24px;
}

h1, h2 {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

h1 { font-size: clamp(3.1rem, 7.4vw, 6.9rem); line-height: 0.98; }
h2 { font-size: clamp(2.3rem, 4.3vw, 3.75rem); line-height: 1.04; }

.lede { max-width: 33rem; color: var(--fg); font-size: clamp(1.125rem, 1.6vw, 1.3125rem); line-height: 1.5; }

.copy p { color: var(--muted); }
.copy .lede { color: var(--fg); }

.eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--accent) !important;
  font: 500 0.8125rem/1.4 var(--mono);
  letter-spacing: 0.03em;
}

.tag {
  padding: 3px 9px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.75rem;
}

.note { font-size: 0.9375rem; line-height: 1.55; }

code { font-family: var(--mono); font-size: 0.875em; color: var(--fg); overflow-wrap: anywhere; }

.h-code { font-size: 0.86em; letter-spacing: -0.04em; }

.code {
  margin: 0;
  max-width: 100%;
  overflow-x: auto;
  padding: 18px 20px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.7;
}

.code code { font-size: 1em; overflow-wrap: normal; white-space: pre; color: #e7edf8; }
.code .k { color: var(--accent); }
.code .s { color: #ffd98a; }
.code .c { color: #9aa8c2; }

/* Actions */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.install {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  max-width: 100%;
  min-height: 50px;
  padding: 12px 18px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.install:hover { border-color: var(--accent); background: rgba(4, 8, 20, 0.85); }
.install code { font-size: 0.9375rem; overflow-wrap: anywhere; }
.install [data-copy-label] { color: var(--accent); font-size: 0.875rem; font-weight: 600; white-space: nowrap; }

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 50px;
  padding: 12px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
  transition: border-color 160ms ease, background 160ms ease;
}

.link-button:hover { border-color: var(--fg); }
.link-button.solid { background: var(--fg); border-color: var(--fg); color: #0a1530; }
.link-button.solid:hover { background: #fff; }

.scroll-cue { font-size: 0.9375rem; }

/* Definition rows */
.rows { display: grid; margin: 0; border-top: 1px solid var(--line); }

.rows div {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 16px;
  padding-block: 14px;
  border-bottom: 1px solid var(--line);
}

.rows dt { font-weight: 600; }
.rows dd { margin: 0; color: var(--muted); font-size: 0.9688rem; line-height: 1.5; }
.mono-terms div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
.mono-terms dt { font: 500 0.9375rem/1.4 var(--mono); color: var(--accent); }

/* Live chat */
.chat {
  display: grid;
  gap: 10px;
  padding: 18px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.copy .bubble {
  max-width: 88%;
  margin: 0;
  padding: 11px 14px;
  border-radius: 16px;
  color: var(--fg);
  font-size: 0.9688rem;
  line-height: 1.45;
}

.copy .bubble.user { justify-self: end; background: #3a6fc9; border-bottom-right-radius: 5px; }
.copy .bubble.bot { justify-self: start; min-height: 5.5em; background: rgba(226, 234, 250, 0.11); border-bottom-left-radius: 5px; }

.copy .counter {
  margin: 0;
  color: var(--muted);
  font: 400 0.8125rem/1 var(--mono);
  font-variant-numeric: tabular-nums;
}

/* Voice waveform */
.wave { display: flex; align-items: center; gap: 5px; height: 44px; }

.wave i {
  flex: 1 1 0;
  max-width: 7px;
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transform: scaleY(0.22);
  animation: speak 1.3s ease-in-out infinite alternate;
}

.wave i:nth-child(3n) { animation-delay: -0.4s; }
.wave i:nth-child(3n + 1) { animation-delay: -0.9s; animation-duration: 0.95s; }
.wave i:nth-child(4n) { animation-delay: -1.2s; animation-duration: 1.6s; }

@keyframes speak { to { transform: scaleY(1); } }

/* Agent tree */
.tree {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  font: 400 0.9375rem/1.5 var(--mono);
  overflow-wrap: anywhere;
}

.tree li { position: relative; padding: 6px 0 6px 26px; border-left: 1px solid var(--line); margin-left: 8px; color: var(--muted); }
.tree li::before { content: ""; position: absolute; left: 0; top: 50%; width: 16px; border-top: 1px solid var(--line); }
.tree li:last-child { border-image: linear-gradient(180deg, var(--line) 50%, transparent 50%) 1; }
.tree li.root { margin-left: 0; padding-left: 0; border: 0; color: var(--accent); }
.tree li.root::before { display: none; }

/* Pipeline */
.steps { counter-reset: step; display: grid; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  column-gap: 12px;
  padding-block: 13px;
  border-bottom: 1px solid var(--line);
}

.steps li::before {
  content: counter(step);
  grid-row: span 2;
  color: var(--accent);
  font: 500 0.9375rem/1.55 var(--mono);
  font-variant-numeric: tabular-nums;
}

.steps b { font-weight: 600; }
.steps span { color: var(--muted); font-size: 0.9688rem; line-height: 1.5; }

/* Finale */
.commands { display: grid; gap: 10px; justify-items: start; }
.commands .install { border-radius: 14px; flex-wrap: wrap; }
.lang { color: var(--muted); font-size: 0.875rem; }
.finale { min-height: 130vh; }

.site-footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 32px;
  padding: 26px max(var(--gutter-right), 7vw) calc(env(safe-area-inset-bottom, 0px) + 26px) max(var(--gutter-left), 7vw);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer p { margin: 0; }

/* Phones and small tablets: the logo holds the top of the screen, panels pass below it. */
@media (max-width: 820px) {
  :root { --glow-x: 50%; }

  body { font-size: 1rem; }

  .stage { background: radial-gradient(90% 40% at 50% 26%, var(--glow), transparent 72%), var(--tint); }

  .poster { top: 76px; left: 50%; right: auto; width: min(66vw, 36svh); transform: translateX(-50%); }

  .chapter, .chapter-long, .finale {
    min-height: 0;
    padding-top: 54svh;
    padding-bottom: 14svh;
    padding-left: var(--gutter-left);
    padding-right: var(--gutter-right);
  }

  .copy, .copy-right .copy {
    position: relative;
    top: auto;
    justify-self: stretch;
    width: 100%;
    padding: 22px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
  }

  .hero { min-height: 100svh; padding-top: 47svh; padding-bottom: 28px; align-items: end; }

  .hero .copy { padding: 0; background: none; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }

  h1 { font-size: clamp(2.6rem, 12.5vw, 4.25rem); }
  h2 { font-size: clamp(2rem, 9vw, 3rem); }

  .code { padding: 14px; font-size: 0.8125rem; }

  .rows div { grid-template-columns: minmax(0, 1fr); gap: 3px; }

  .actions > *, .commands .install { width: 100%; justify-content: space-between; }
  .link-button { justify-content: center; }
  .commands { justify-items: stretch; }
}

@media (max-width: 380px) {
  .hide-small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .wave i { animation: none; transform: scaleY(0.6); }
  .stage canvas, .poster { transition: none; }
}
