@font-face {
  font-family: "Unbounded";
  src: url("./assets/unbounded-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --paper: #f6f5f1;
  --surface: #fffefb;
  --sunk: #efede7;
  --ink: #1b1f1d;
  --ink-soft: #3a403c;
  --muted: #66706a;
  --faint: #959c97;
  --line: #e5e2da;
  --jade: #0f6b55;
  --jade-soft: #e5f0eb;
  --jade-line: #9cc7b6;
  --amber-soft: #f8f0e0;
  --amber: #8a5a12;
  --night: #111718;
  --sans: "PingFang SC", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --gutter: clamp(20px, 6vw, 96px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.75 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--jade); }
h1, h2, h3, p, figure, ol { margin: 0; }
code { font-family: var(--mono); font-size: .92em; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 10; padding: 6px 12px; background: var(--ink); color: #fff; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--jade); outline-offset: 3px; }

/* Navigation */
.nav { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px var(--gutter); background: rgb(246 245 241 / 88%); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid transparent; transition: border-color .2s; }
.nav.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; }
.brand b { font: 600 12px/1 "Unbounded", var(--sans); letter-spacing: .12em; color: var(--muted); }
.nav nav { display: flex; align-items: center; gap: clamp(14px, 2.4vw, 30px); }
.nav nav a { color: var(--ink-soft); text-decoration: none; font-size: 14px; }
.nav nav a:hover { color: var(--jade); }
.nav .nav-github { padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.language-switch { display: flex; flex: 0 0 auto; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.language-switch[hidden] { display: none; }
.nav .language-switch a { display: grid; place-items: center; min-width: 44px; min-height: 36px; padding: 4px 9px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-soft); font: 13px var(--sans); cursor: pointer; }
.nav .language-switch a:hover { color: var(--jade); }
.nav .language-switch a[aria-current="true"] { background: var(--ink); color: var(--surface); }
.nav.is-dark .language-switch { border-color: #40534b; }
.nav.is-dark .language-switch a { color: #cfe3da; }
.nav.is-dark .language-switch a[aria-current="true"] { background: #d2e7db; color: var(--night); }
.nav.is-dark :focus-visible { outline-color: #8bc1a8; }

/* Story chapters. Without the 3D stage each is a band: copy beside a product mock. */
.journey { position: relative; }
.spatial-stage { display: none; }
.chapter { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: clamp(32px, 6vw, 96px); padding: clamp(72px, 12vh, 128px) var(--gutter); border-top: 1px solid var(--line); }
.hero-chapter { grid-template-columns: minmax(0, 1fr); padding-block: clamp(72px, 14vh, 150px); border-top: 0; }
body:not(.enhanced) section[id] { scroll-margin-top: 90px; }
.chapter-copy { position: relative; z-index: 3; max-width: 540px; }
.hero-chapter .chapter-copy { max-width: 820px; }
.eyebrow { color: var(--jade); font-size: 13px; font-weight: 600; letter-spacing: .08em; }
h1 { margin-top: 18px; font-size: clamp(42px, 6.4vw, 84px); font-weight: 700; line-height: 1.12; letter-spacing: -.035em; color: var(--chapter-ink, var(--ink)); }
h1 em, h2 em { font-style: normal; color: var(--jade); }
h2 { margin-top: 12px; font-size: clamp(30px, 3.6vw, 52px); font-weight: 680; line-height: 1.18; letter-spacing: -.03em; color: var(--chapter-ink, var(--ink)); }
.chapter-copy > p:not(.eyebrow) { margin-top: 22px; color: var(--chapter-soft, var(--ink-soft)); font-size: clamp(16px, 1.3vw, 18px); }
.chapter-copy > p.lede { max-width: 620px; font-size: clamp(17px, 1.6vw, 20px); line-height: 1.8; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-top: 40px; }
.terminal { position: relative; display: grid; gap: 2px; padding: 16px 92px 16px 20px; border-radius: 14px; background: var(--night); color: #e9f1ee; box-shadow: 0 20px 50px rgb(17 23 24 / 18%); }
.terminal code { white-space: nowrap; }
.terminal code span { color: #8bc1a8; margin-right: 10px; user-select: none; }
.copy { position: absolute; right: 12px; top: 50%; translate: 0 -50%; padding: 6px 12px; border: 1px solid #2c3a36; border-radius: 8px; background: transparent; color: #cfe3da; font: 13px var(--sans); cursor: pointer; }
.copy:hover { background: #1b2422; }
.button { display: inline-flex; align-items: center; padding: 12px 22px; border-radius: 999px; background: var(--ink); color: #fff; text-decoration: none; font-size: 15px; font-weight: 550; transition: background .2s; }
.button:hover { background: var(--jade); }
.scroll-cue { display: none; }
figcaption { margin-top: 10px; color: var(--faint); font-size: 12px; }

.chapter-nav { position: fixed; right: 22px; top: 50%; z-index: 6; display: flex; flex-direction: column; gap: 2px; transform: translateY(-50%); }
.chapter-nav[hidden] { display: none; }
.chapter-nav a { display: grid; width: 25px; height: 25px; place-items: center; }
.chapter-nav i { width: 5px; height: 5px; border-radius: 50%; background: #9da6a4; transition: height .2s, background .2s; }
.chapter-nav a[aria-current="step"] i { height: 18px; border-radius: 4px; background: var(--jade); }
.chapter-nav a:hover i { background: var(--jade); }

/* The plain document is complete; the scroll story is an enhancement. */
.enhanced .spatial-stage { position: sticky; top: 0; display: block; width: 100%; height: 100svh; min-height: 620px; overflow: hidden; contain: layout paint; pointer-events: none; background: var(--scene-background, var(--paper)); }
.enhanced .chapters { position: relative; margin-top: -100svh; }
.enhanced .chapter { display: block; height: 155svh; padding: 0 var(--gutter); border-top: 0; background: transparent; }
.enhanced .static-figure { display: none; }
.enhanced .chapter-copy { position: sticky; top: 28svh; width: 40%; max-width: 500px; opacity: var(--copy-opacity, 1); transform: translateY(var(--copy-y, 0px)); will-change: opacity, transform; }
.enhanced .hero-chapter { height: 135svh; }
.enhanced .hero-chapter .chapter-copy { top: 24svh; width: 46%; max-width: 580px; }
.enhanced .chapter:last-child { height: 140svh; }
.enhanced .database-chapter .chapter-copy { width: 32%; }
.enhanced .scroll-cue { position: absolute; top: calc(100svh - 76px); left: 50%; z-index: 4; display: grid; width: 48px; height: 48px; place-items: center; color: var(--muted); transform: translateX(-50%); }
.scroll-cue svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; animation: cue 2.4s ease-in-out infinite; }
@keyframes cue { 0%, 100% { opacity: .35; transform: translateY(-3px); } 50% { opacity: 1; transform: translateY(3px); } }
.enhanced .roundtable-chapter .eyebrow, .enhanced .roundtable-chapter h2 em { color: #8bc1a8; }
.footer button { margin-left: 18px; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.footer button:hover { color: var(--jade); }
.footer button:disabled { cursor: default; opacity: .7; }

@media (max-width: 1050px) {
  .enhanced .chapter-copy { width: 44%; }
  .enhanced .hero-chapter .chapter-copy { width: 52%; }
  .enhanced .terminal { padding-right: 20px; padding-bottom: 52px; }
  .enhanced .copy { top: auto; bottom: 10px; translate: none; }
  .enhanced .terminal code { white-space: normal; }
  .enhanced .database-chapter .chapter-copy { top: 12svh; width: 100%; max-width: 640px; }
}
@media (max-width: 700px) {
  .enhanced .spatial-stage { min-height: 580px; }
  .enhanced .chapter { height: 150svh; padding: 0 22px; }
  .enhanced .chapter-copy, .enhanced .hero-chapter .chapter-copy { top: max(90px, 10svh); width: 100%; max-width: 380px; }
  .enhanced .chapter-copy > p:not(.eyebrow) { font-size: 15px; margin-top: 14px; }
  .enhanced h2 { font-size: 32px; }
  .enhanced .hero-chapter h1 { font-size: 40px; }
  .enhanced .database-chapter .chapter-copy { top: max(90px, 10svh); max-width: 380px; }
  .enhanced .database-chapter .chapter-copy > p:not(.eyebrow) { font-size: 14px; line-height: 1.65; }
  .enhanced .hero-actions { display: none; }
  .enhanced .scroll-cue { top: calc(100svh - 64px); }
  .chapter-nav { right: 4px; top: auto; bottom: 18px; transform: none; gap: 0; }
  .chapter-nav a { width: 22px; height: 21px; }
}

.window { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 24px 60px rgb(27 31 29 / 8%); overflow: hidden; }
figure.window { padding-bottom: 14px; }
figure.window figcaption { padding: 0 20px; }
.window-bar { display: flex; align-items: center; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.window-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.window-bar span { margin-left: 10px; color: var(--muted); font-size: 12px; }
.window-body { display: grid; gap: 12px; padding: 20px; font-size: 15px; }
.msg { padding: 10px 14px; border-radius: 12px; line-height: 1.7; }
.msg.user { justify-self: end; max-width: 85%; background: var(--sunk); }
.msg.agent { color: var(--ink-soft); }
.receipt { padding: 10px 14px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 14px; }
.receipt a { color: var(--jade); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.handoff { display: grid; gap: 6px; }
.handoff .window:first-child { width: 78%; }
.handoff .window:last-child { width: 82%; justify-self: end; }
.window.small .window-body { padding: 16px; font-size: 14px; }
.arrow { justify-self: center; color: var(--jade); font-size: 26px; rotate: 90deg; line-height: 1; }

.thread { display: grid; gap: 20px; padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.thread-msg { display: grid; grid-template-columns: 34px 1fr; gap: 12px; }
.thread-msg.reply { margin-left: 40px; }
.face { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--jade-soft); color: var(--jade); font-weight: 650; }
.reply .face { background: var(--sunk); color: var(--ink-soft); }
.by { color: var(--muted); font-size: 13px; }
.by b { color: var(--ink); margin-right: 8px; }
.by em { margin-right: 8px; padding: 1px 8px; border-radius: 999px; background: var(--sunk); font-style: normal; font-size: 12px; }
.bubble { margin-top: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 4px 12px 12px 12px; background: var(--paper); font-size: 15px; }

.layers { display: grid; gap: 14px; }
.layer { padding: 22px 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.layer.project { margin-left: clamp(16px, 6vw, 72px); border-color: var(--jade-line); background: var(--jade-soft); }
.layer h3 { margin-bottom: 12px; font-size: 14px; color: var(--muted); font-weight: 600; }
.layer p { display: flex; align-items: baseline; gap: 10px; margin-top: 8px; font-size: 15px; }
.chip { flex: 0 0 auto; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip.taste { background: var(--amber-soft); color: var(--amber); }
.chip.judgment { background: var(--surface); color: var(--ink-soft); border: 1px solid var(--line); }
.chip.personality { background: var(--jade-soft); color: var(--jade); }

.team { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.member { display: grid; gap: 2px; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.member span { display: grid; width: 42px; height: 42px; margin-bottom: 10px; place-items: center; border-radius: 12px; background: var(--jade-soft); color: var(--jade); font-size: 20px; font-weight: 650; }
.member small { color: var(--muted); font-size: 13px; }
.member.lead { border-color: var(--jade-line); }

.memory { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; }
.memory > div { display: grid; align-content: start; gap: 10px; padding: 22px; border-radius: 16px; }
.memory-digest { background: var(--jade-soft); border: 1px solid var(--jade-line); }
.memory-digest span { padding: 8px 12px; border-radius: 8px; background: var(--surface); font-size: 14px; }
.memory-recent { border: 1px solid var(--line); background: var(--paper); }
.memory-recent span { height: 14px; border-radius: 4px; background: var(--sunk); }
.memory-recent span:nth-child(odd) { width: 70%; justify-self: end; }
.memory b { font-size: 13px; color: var(--muted); }

.principles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(20px, 4vw, 56px); padding: clamp(64px, 10vh, 112px) var(--gutter); border-top: 1px solid var(--line); }
.principles h3 { font-size: 18px; font-weight: 650; }
.principles p { margin-top: 10px; color: var(--ink-soft); }

.start { padding: clamp(80px, 12vh, 140px) var(--gutter); background: var(--night); color: #e9f1ee; }
.start h2 { margin: 0; color: #fff; }
.start > p { max-width: 640px; margin-top: 18px; color: #b9c8c2; }
.start ol { display: grid; gap: 12px; max-width: 640px; margin-top: 36px; padding: 0; list-style: none; counter-reset: step; }
.start li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; padding: 14px 18px; border: 1px solid #26332f; border-radius: 12px; counter-increment: step; }
.start li::before { content: counter(step); color: #8bc1a8; font: 600 13px "Unbounded", var(--sans); }
.start li span { color: #8fa39b; font-size: 14px; }
.oneliner { display: grid; gap: 8px; max-width: 640px; margin-top: 24px; }
.oneliner p { margin: 0; color: #8fa39b; font-size: 14px; }
.oneliner code { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 12px 18px; border-radius: 12px; background: #16201d; color: #e9f1ee; font-size: 13px; overflow-wrap: anywhere; }
.oneliner code span { color: #8fa39b; font-family: var(--sans); font-size: 12px; }
.start-links { display: flex; flex-wrap: wrap; align-items: center; gap: 22px; margin-top: 36px; }
.start-links .button { background: #e9f1ee; color: var(--night); }
.start-links .button:hover { background: #8bc1a8; }
.start-links a:not(.button) { color: #cfe3da; }

.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 28px var(--gutter); color: var(--muted); font-size: 14px; }
.footer a { margin-left: 18px; color: var(--muted); }

/* Reveal on scroll only when scripting is available; content is visible otherwise. */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .8, .2, 1); }
.js .reveal.is-visible { opacity: 1; transform: none; }

@media (max-width: 880px) {
  .chapter { grid-template-columns: minmax(0, 1fr); }
  .handoff .window:first-child, .handoff .window:last-child { width: 100%; }
  .principles { grid-template-columns: minmax(0, 1fr); }
  .memory { grid-template-columns: minmax(0, 1fr); }
  .nav nav > a:not(.nav-github) { display: none; }
  .terminal { width: 100%; padding-right: 20px; padding-bottom: 52px; }
  .terminal code { white-space: normal; overflow-wrap: anywhere; }
  .copy { top: auto; bottom: 10px; translate: none; }
  .nav { gap: 12px; }
  .nav nav { gap: 10px; }
  .nav .nav-github { padding-inline: 10px; }
  .stack div { flex-wrap: wrap; gap: 2px 16px; }
}

@media (max-width: 380px) {
  .brand b { display: none; }
  .nav .language-switch a { min-height: 38px; }
}

html[lang="en"] h1, html[lang="en"] h2 { text-wrap: balance; }
html[lang="en"] .enhanced h1 { font-size: clamp(40px, 4.3vw, 64px); }
html[lang="en"] .enhanced h2 { font-size: clamp(30px, 3.1vw, 46px); }
@media (min-width: 1051px) {
  .enhanced .hero-chapter .lede { max-width: 520px; }
  html[lang="en"] .enhanced .hero-chapter .chapter-copy { width: 42%; max-width: 500px; }
}

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

/* Chapter numbers, the database chapter and its static fallback. */
.chapters { counter-reset: chapter; }
.chapter:not(.hero-chapter) { counter-increment: chapter; }
.chapter:not(.hero-chapter) .eyebrow::before { content: "0" counter(chapter) "  ·  "; font-family: "Unbounded", var(--sans); font-weight: 500; opacity: .7; white-space: pre; }
.enhanced .database-chapter .eyebrow, .enhanced .database-chapter h2 em { color: #8bc1a8; }
.stack { display: grid; gap: 10px; }
.stack div { display: flex; align-items: baseline; gap: 16px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.stack span { color: var(--muted); font-size: 13px; letter-spacing: .08em; }
.stack b { font-weight: 600; }
.stack .stack-db { background: var(--night); border-color: var(--night); color: #e9f1ee; }
.stack .stack-db span { color: #8bc1a8; }
.nav { transition: border-color .2s, background-color .35s; }
.nav.is-dark { background: rgb(17 23 24 / 82%); border-bottom-color: #1f2b28; }
.nav.is-dark .brand, .nav.is-dark nav a { color: #e1ece5; }
.nav.is-dark .brand b { color: #8fa39b; }
.nav.is-dark .nav-github { border-color: #2c3a36; background: #16201d; }
.nav .brand img { border-radius: 50%; transition: background-color .35s; }
.nav.is-dark .brand img { background: #e9f1ee; }
