/* ---------- Tokens ---------- */
:root {
  --bg: #F4F0E8;
  --text: #181714;
  --muted: #68645D;
  --accent: #C65D3A;
  --line: rgba(24, 23, 20, 0.14);
  --surface: #ECE7DD;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;

  --wrap: 1180px;
  --gutter: clamp(20px, 5vw, 56px);
  --radius: 4px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171715;
    --text: #F2EEE6;
    --muted: #A29D93;
    --accent: #D8714E;
    --line: rgba(242, 238, 230, 0.14);
    --surface: #1F1F1C;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, figure, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: 12px; top: -40px; padding: 8px 12px; background: var(--text); color: var(--bg); z-index: 10; }
.skip:focus { top: 12px; }

/* ---------- Buttons & links ---------- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  font-size: 15px;
  border-radius: var(--radius);
  transition: background .2s var(--ease);
}
.btn:hover { background: var(--accent); }
.link-quiet { text-decoration: none; font-size: 15px; color: var(--muted); }
.link-quiet:hover { color: var(--text); }
.link-arrow {
  font-size: 15px;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
  transition: border-color .2s;
}
.link-arrow::after { content: " →"; display: inline-block; transition: transform .2s var(--ease); }
.link-arrow:hover { border-color: var(--text); }
.link-arrow:hover::after { transform: translateX(3px); }

/* ---------- Mark ---------- */
.mark { width: 26px; height: 26px; }
.mark-lines { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.mark-dots { fill: currentColor; }
.mark-end { fill: var(--accent); }
@media (prefers-color-scheme: dark) { .footer-mark { filter: invert(1) hue-rotate(180deg); } }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.nav.is-scrolled { border-color: var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-size: 21px; letter-spacing: -.01em; }
.nav-menu { display: flex; align-items: center; gap: 40px; }
.nav-menu ul { display: flex; gap: 28px; }
.nav-menu ul a { text-decoration: none; font-size: 15px; color: var(--muted); transition: color .2s; }
.nav-menu ul a:hover { color: var(--text); }
.nav-actions { display: flex; align-items: center; gap: 20px; }
.nav-toggle { display: none; }

@media (max-width: 860px) {
  .nav-toggle {
    display: grid; gap: 6px; place-content: center;
    width: 44px; height: 44px; margin-right: -10px;
    background: none; border: 0; cursor: pointer; color: var(--text);
  }
  .nav-toggle .bar { display: block; width: 20px; height: 1.5px; background: currentColor; transition: transform .25s var(--ease); }
  .nav-toggle[aria-expanded="true"] .bar:nth-child(2) { transform: translateY(3.75px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .bar:nth-child(3) { transform: translateY(-3.75px) rotate(-45deg); }

  .nav-menu {
    position: fixed; inset: 68px 0 0 0;
    flex-direction: column; align-items: stretch; gap: 32px;
    padding: 32px var(--gutter);
    background: var(--bg);
    visibility: hidden; opacity: 0;
    transition: opacity .2s, visibility .2s;
  }
  .nav-menu.is-open { visibility: visible; opacity: 1; }
  .nav-menu ul { flex-direction: column; gap: 0; }
  .nav-menu ul a { display: block; padding: 14px 0; font-family: var(--serif); font-size: 26px; color: var(--text); border-bottom: 1px solid var(--line); }
  .nav-actions { justify-content: space-between; }
  .nav-actions .btn { flex: 1; text-align: center; padding: 14px; }
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 64px;
  align-items: center;
  min-height: calc(100svh - 68px);
  padding-top: 48px; padding-bottom: 80px;
}
.eyebrow { font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-bottom: 36px; letter-spacing: .04em; }
h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(44px, 7vw, 88px);
  line-height: 1;
  letter-spacing: -.025em;
}
.hero-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(26px, 3.4vw, 40px);
  color: var(--muted);
  margin-top: 14px;
}
.lede { max-width: 32em; margin-top: 36px; color: var(--muted); font-size: 18px; }
.hero-actions { display: flex; align-items: center; gap: 28px; margin-top: 40px; flex-wrap: wrap; }

.hero-figure { justify-self: end; width: 100%; max-width: 520px; }
.hero-figure figcaption { color: var(--muted); margin-top: 16px; text-align: right; }
.converge { width: 100%; height: auto; overflow: visible; }
.c-paths path { fill: none; stroke: var(--text); stroke-width: 1.25; stroke-linecap: round; }
.c-paths .c-stray { stroke: var(--muted); stroke-dasharray: 3 5; }
.c-nodes circle { fill: var(--text); }
.c-nodes .c-dead { fill: var(--bg); stroke: var(--muted); stroke-width: 1.25; }
.c-end { fill: var(--accent); }

/* Hero drawing animation (enabled by JS so no-JS users see the finished figure) */
.anim .c-paths path:not(.c-stray) { stroke-dasharray: 460; stroke-dashoffset: 460; animation: draw 1.8s var(--ease) forwards; }
.anim .c-paths .c-stray { opacity: 0; animation: fade .8s ease forwards; animation-delay: .9s; }
.anim .c-paths path:nth-child(2) { animation-delay: .15s; }
.anim .c-paths path:nth-child(3) { animation-delay: .3s; }
.anim .c-paths path:nth-child(4) { animation-delay: .45s; }
.anim .c-paths path:nth-child(5) { animation-delay: .6s; }
.anim .c-end { transform-origin: 404px 200px; transform: scale(0); animation: land .6s var(--ease) 1.7s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }
@keyframes land { to { transform: scale(1); } }

/* ---------- Sections ---------- */
.section { padding-top: 120px; padding-bottom: 120px; border-top: 1px solid var(--line); }
.split { display: grid; grid-template-columns: 220px 1fr; gap: 48px; }
.split > * { min-width: 0; }
.split > :last-child { max-width: 760px; }
.label { color: var(--muted); font-weight: 400; padding-top: 10px; }
.big {
  font-family: var(--serif);
  font-size: clamp(24px, 2.6vw, 32px);
  line-height: 1.3;
  letter-spacing: -.01em;
}
.big em { color: var(--accent); }
.prose p + p { margin-top: 20px; }
.prose p:not(.big) { color: var(--muted); max-width: 36em; }
.prose .big + p { margin-top: 40px; }

/* Layers list */
.layers { margin-top: 56px; border-top: 1px solid var(--line); }
.layers li { display: grid; grid-template-columns: 120px 1fr; gap: 24px; padding: 28px 0; border-bottom: 1px solid var(--line); }
.layer-n { color: var(--accent); padding-top: 4px; text-transform: uppercase; }
.layers h3 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin-bottom: 6px; }
.layers p { color: var(--muted); max-width: 34em; }

/* Products & model family */
.family { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; margin-top: 72px; }
.family-label { color: var(--muted); font-weight: 400; margin-bottom: 20px; }
.family dl { margin: 0; }
.family dl > div { padding: 16px 0; border-top: 1px solid var(--line); }
.family dt { font-family: var(--serif); font-size: 21px; }
.family dd { margin: 4px 0 0; color: var(--muted); }
@media (max-width: 720px) { .family { grid-template-columns: 1fr; gap: 40px; } }

/* Progress log */
.log { margin-top: 48px; position: relative; }
.log::before { content: ""; position: absolute; left: 5px; top: 10px; bottom: 10px; width: 1px; background: var(--line); }
.log li { position: relative; display: grid; grid-template-columns: 80px 1fr; gap: 16px; padding: 0 0 28px 32px; }
.log li::before {
  content: ""; position: absolute; left: 0; top: 7px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--muted);
}
.log li.is-done::before { background: var(--text); border-color: var(--text); }
.log li.is-next::before { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--bg), inset 0 0 0 6px var(--accent); }
.log span { color: var(--muted); padding-top: 3px; }
.log p { color: var(--muted); }
.log strong { color: var(--text); font-weight: 500; }
.note { margin-top: 20px; font-family: var(--serif); font-style: italic; color: var(--muted); }

/* Code */
.code {
  margin: 48px 0 32px;
  padding: 28px;
  background: var(--surface);
  border-radius: var(--radius);
  font: 14px/1.7 var(--mono);
  overflow-x: auto;
}
.code .c { color: var(--muted); }
.code .s { color: var(--accent); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 64px 0 32px; }
.footer-inner { display: flex; justify-content: space-between; align-items: flex-start; gap: 48px; flex-wrap: wrap; }
.footer-brand { display: flex; gap: 14px; font-family: var(--serif); line-height: 1.4; }
.footer-cols { display: flex; gap: 72px; flex-wrap: wrap; }
.footer-cols h2 { font-weight: 400; color: var(--muted); margin-bottom: 16px; }
.footer-cols li + li { margin-top: 10px; }
.footer-cols a { text-decoration: none; color: var(--text); font-size: 15px; opacity: .85; }
.footer-cols a:hover { opacity: 1; color: var(--accent); }
.footer-base { display: flex; justify-content: space-between; align-items: center; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line); }
.socials { display: flex; gap: 6px; }
.socials a { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--muted); transition: color .2s, background .2s; }
.socials a:hover { color: var(--text); background: var(--surface); }
.socials svg { width: 18px; height: 18px; fill: currentColor; }
@media (max-width: 720px) { .footer-cols { gap: 40px; } }

/* ---------- Reveal ---------- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; min-height: 0; gap: 56px; padding-top: 56px; }
  .hero-figure { justify-self: start; max-width: 440px; }
  .hero-figure figcaption { text-align: left; }
  .split { grid-template-columns: 1fr; gap: 24px; }
  .section { padding-top: 80px; padding-bottom: 80px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .layers li { grid-template-columns: 1fr; gap: 8px; }
  .log li { grid-template-columns: 1fr; gap: 2px; }
  .code { padding: 20px; font-size: 12.5px; margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
  .anim .c-paths path { stroke-dashoffset: 0 !important; opacity: 1 !important; }
  .anim .c-end { transform: none !important; }
}
