/* V6 home: one living particle field behind the whole story. The DOM carries every word; the field carries the image. */
:root {
  --ink: var(--site-bg, #070709);
  --ink-2: var(--site-panel, #131317);
  --on-ink: var(--site-text, #f2f0eb);
  --muted: var(--site-muted, #a3a097);
  --faint: #8a877f;
  --unlit: #5f5d58;
  --line: var(--site-line, rgba(242, 240, 235, .14));
  --mark: var(--site-mark, #ffd84d);
  --mark-hover: #ffe680;
  --sans: var(--site-sans, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --gutter: clamp(18px, 4.4vw, 72px);
  --header-h: 64px;
  --ease: cubic-bezier(.2, .7, .1, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--header-h); background: var(--ink); }
body {
  margin: 0;
  background: var(--ink);
  color: var(--on-ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3, p, ol { margin: 0; }
ol { padding: 0; list-style: none; }
h1, h2, h3 { font-weight: 600; word-break: keep-all; overflow-wrap: anywhere; line-break: strict; }
::selection { background: var(--mark); color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 3px; border-radius: 6px; }

#field { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(ellipse 120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, .55)),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.55'/></svg>");
  opacity: .22;
  mix-blend-mode: overlay;
}
main, .site-footer { position: relative; z-index: 2; }

.skip-link { position: fixed; left: 16px; top: -60px; z-index: 50; padding: 10px 16px; border-radius: 8px; background: var(--mark); color: var(--ink); text-decoration: none; }
.skip-link:focus { top: 12px; }

/* ---------- header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto; z-index: 20;
  height: var(--header-h);
  display: flex; align-items: center; gap: 32px;
  padding: 0 var(--gutter);
  background: linear-gradient(rgba(7, 7, 9, .85), rgba(7, 7, 9, 0));
}
.brand { margin-right: auto; font-size: 16px; font-weight: 600; text-decoration: none; letter-spacing: .01em; }
.site-header nav { display: flex; gap: 28px; }
.site-header nav a { font-size: 15px; text-decoration: none; opacity: .66; transition: opacity .2s; }
.site-header nav a:hover { opacity: 1; }
.header-cta { padding: 8px 16px; border-radius: 999px; background: var(--mark); color: var(--ink); font-size: 15px; font-weight: 600; text-decoration: none; transition: background-color .2s; }
.header-cta:hover { background: var(--mark-hover); }

/* ---------- shared ---------- */
.kicker { font-size: 14px; letter-spacing: .02em; color: var(--muted); }
.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 50px; padding: 0 26px;
  border-radius: 999px;
  font-size: 16px; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background-color .2s, transform .25s var(--ease);
}
.button:hover { transform: translateY(-2px); }
.button-mark { background: var(--mark); color: var(--ink); }
.button-mark:hover { background: var(--mark-hover); }

.beat { position: relative; min-height: 100vh; min-height: 100svh; padding: 0 var(--gutter); }
.beat h2, .beat h3, .beat p { text-shadow: 0 0 28px rgba(7, 7, 9, .85); }

/* Each beat's words arrive when it owns the middle of the screen. */
.js .beat > *, .js .work-text > * { transition: opacity .8s var(--ease), transform .9s var(--ease); }
@media (prefers-reduced-motion: no-preference) {
  .js .beat:not(.is-active):not(:focus-within) > :not(.work-img), .js .beat.work:not(.is-active):not(:focus-within) .work-text > * { opacity: .12; transform: translateY(16px); }
}
.js .beat.work .work-text > :nth-child(2) { transition-delay: .06s; }
.js .beat.work .work-text > :nth-child(3) { transition-delay: .12s; }
.js .beat.work .work-text > :nth-child(4) { transition-delay: .16s; }
.js .beat.work .work-text > :nth-child(5) { transition-delay: .2s; }
.js .beat.work > .work-text { opacity: 1; transform: none; }

/* ---------- hero ---------- */
.hero { display: flex; flex-direction: column; padding-top: calc(var(--header-h) + 20px); padding-bottom: clamp(24px, 5vh, 56px); }
.fallback-idea { display: none; }
.hero-foot {
  margin-top: auto;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 32px;
}
.hero h1 { font-size: clamp(40px, 6.3vw, 104px); line-height: 1.02; letter-spacing: -.04em; }
.invite { margin-top: 14px; font-size: clamp(17px, 1.5vw, 22px); color: var(--muted); }
.idea-form { flex: none; width: min(380px, 100%); }
.idea-form label { display: block; margin-bottom: 10px; font-size: 14px; color: var(--muted); }
.idea-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px 22px;
  border-radius: 999px;
  background: rgba(242, 240, 235, .07);
  box-shadow: inset 0 0 0 1px rgba(242, 240, 235, .18);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: box-shadow .2s, background-color .2s;
}
.idea-row:focus-within { background: rgba(242, 240, 235, .1); box-shadow: inset 0 0 0 1px var(--mark), 0 0 0 4px rgba(255, 216, 77, .16); outline: 2px solid transparent; outline-offset: 2px; }
@media (forced-colors: active) { .idea-row { border: 1px solid CanvasText; } .idea-row:focus-within { outline: 2px solid Highlight; } }
.idea-row input {
  flex: 1; min-width: 0;
  padding: 10px 0;
  border: 0; outline: 0; background: transparent;
  color: var(--on-ink); font: inherit; font-size: 18px;
}
.idea-row input::placeholder { color: var(--faint); }
.idea-row button {
  flex: none; width: auto; height: 48px; padding: 0 18px; white-space: nowrap;
  border: 0; border-radius: 999px;
  background: var(--mark); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: transform .25s var(--ease), background-color .2s;
}
.idea-row button:hover { background: var(--mark-hover); transform: scale(1.03); }

/* ---------- statement ---------- */
.statement { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.statement h2 { font-size: clamp(44px, 7.4vw, 128px); line-height: 1.04; letter-spacing: -.045em; }
.statement p { margin-top: 28px; max-width: 30em; font-size: clamp(17px, 1.4vw, 21px); color: var(--muted); }

/* ---------- works ---------- */
.work { display: flex; align-items: center; }
.work-text { width: min(33vw, 470px); }
.work-index { font-family: var(--mono); font-size: 13px; letter-spacing: .04em; color: var(--muted); }
.work-index b { color: var(--mark); font-weight: 500; }
.work h3 { margin-top: 14px; font-size: clamp(34px, 3.7vw, 58px); line-height: 1.05; letter-spacing: -.03em; }
.work-desc { margin-top: 18px; font-size: clamp(17px, 1.3vw, 19px); line-height: 1.75; color: rgba(242, 240, 235, .82); }
.work-try { margin-top: 10px; font-size: 15px; color: var(--muted); }
.work-links { display: flex; gap: 24px; margin-top: 26px; font-size: 15px; font-weight: 500; }
.work-links a, .small-work a { text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat; padding-bottom: 2px; transition: color .2s; }
.work-links a::after { content: " ↗"; }
.work-links a:hover, .small-work a:hover { color: var(--mark); }
.webgl .work:not(.img-fallback) .work-img { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
.small-work { position: relative; z-index: 2; padding: 0 var(--gutter) 64px; font-size: 16px; color: var(--muted); }

/* ---------- Agent loop ---------- */
.loop { padding: 0; }
.js .loop { height: 230vh; }
.js .loop-inner { position: sticky; top: 0; }
.loop-inner {
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--header-h) + 16px) var(--gutter) 40px;
}
.loop-text { margin-top: 24px; width: min(45vw, 680px); font-size: clamp(28px, 3.1vw, 50px); line-height: 1.5; font-weight: 600; letter-spacing: -.02em; }
.clause {
  padding: .04em .1em;
  margin: 0 -.1em;
  color: var(--ink);
  background: linear-gradient(var(--mark), var(--mark)) 0 0 / 100% 100% no-repeat;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  transition: background-size .55s var(--ease), color .25s ease;
  text-shadow: none !important;
}
.js .clause:not(.is-on) { color: rgba(242, 240, 235, .26); background-size: 0% 100%; }
.clause.is-on { transition: background-size .55s var(--ease), color .2s ease .3s; }
.loop-steps { display: flex; flex-wrap: wrap; gap: 8px 26px; margin-top: 36px; font-size: 15px; counter-reset: step; }
.loop-steps li { counter-increment: step; color: var(--mark); transition: color .4s; }
.js .loop-steps li:not(.is-on) { color: var(--unlit); }
.loop-steps li::before { content: counter(step, decimal-leading-zero) "  "; font-family: var(--mono); font-size: 12px; }
.loop-steps li.is-on { color: var(--mark); }
.loop-note { margin-top: 22px; width: min(45vw, 620px); font-size: 16px; color: var(--muted); }

/* ---------- course ---------- */
.course { padding-top: clamp(120px, 16vh, 200px); padding-bottom: clamp(80px, 12vh, 140px); }
.course > * { width: min(54vw, 780px); }
.course h2 { margin-top: 16px; font-size: clamp(34px, 4.2vw, 70px); line-height: 1.1; letter-spacing: -.035em; }
.lesson-one { margin-top: clamp(48px, 7vh, 80px); padding-top: 28px; border-top: 2px solid var(--on-ink); }
.lesson-tag { font-size: 14px; color: var(--mark); }
.lesson-one h3 { margin-top: 10px; font-size: clamp(26px, 2.6vw, 42px); line-height: 1.18; letter-spacing: -.02em; }
.lesson-desc { margin: 18px 0 28px; font-size: 17px; line-height: 1.8; color: rgba(242, 240, 235, .78); }
.lesson-modules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; margin-top: 40px; border-top: 1px solid var(--line); }
.lesson-modules a { display: flex; align-items: baseline; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 16px; text-decoration: none; transition: color .2s, padding-left .3s var(--ease); }
.lesson-modules a:hover { color: var(--mark); padding-left: 6px; }
.lesson-modules span { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.next-lessons { margin-top: clamp(64px, 9vh, 110px); }
.next-lessons li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: baseline; padding: 24px 0; border-top: 1px solid var(--line); }
.next-lessons li:last-child { border-bottom: 1px solid var(--line); }
.next-num { font-family: var(--mono); font-size: 15px; color: var(--faint); }
.next-lessons h3 { font-size: clamp(20px, 1.8vw, 26px); line-height: 1.3; letter-spacing: -.01em; }
.next-lessons p { margin-top: 6px; font-size: 16px; color: var(--muted); }
.next-state { font-size: 14px; color: var(--faint); }

/* ---------- closing ---------- */
.home-resources{padding:80px var(--gutter);background:var(--ink);position:relative;border-top:1px solid var(--line)}
.home-resources h2{font-size:clamp(34px,4.5vw,72px);line-height:1.15;letter-spacing:-.035em;margin:20px 0 48px;max-width:16em}
.resource-rows a{display:grid;grid-template-columns:45px minmax(190px,.6fr) minmax(0,1fr) 28px;gap:24px;align-items:baseline;border-top:1px solid var(--line);padding:28px 0;text-decoration:none}
.resource-rows a:hover h3{color:var(--mark)}
.resource-no{font:13px var(--mono);color:var(--muted)}
.resource-rows h3{font-size:clamp(24px,2.4vw,36px);letter-spacing:-.02em}
.resource-rows p{font-size:16px;color:var(--muted);max-width:35em}
.resource-arrow{color:var(--mark);font-size:24px}
.home-experience{display:flex;align-items:center;justify-content:space-between;gap:35px;padding:35px 40px;margin-top:32px;background:var(--mark);color:var(--ink);text-decoration:none}
.home-experience h3{font-size:clamp(25px,3vw,43px);line-height:1.3;margin:12px 0 15px;letter-spacing:-.025em}
.home-experience p{font-size:16px;max-width:48em}
.home-experience>span{font-size:45px;flex:none}
@media(max-width:860px){.resource-rows a{grid-template-columns:28px minmax(0,1fr) 24px;gap:12px 18px}.resource-rows p{grid-column:2;grid-row:2}.resource-arrow{grid-column:3;grid-row:1}.home-experience{padding:27px}.home-resources{padding-top:58px;padding-bottom:58px}.home-experience>span{font-size:32px}}
.closing { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: clamp(56px, 10vh, 120px); text-align: center; }
.closing h2 { font-size: clamp(32px, 4.4vw, 72px); line-height: 1.12; letter-spacing: -.035em; }
.closing p { margin-top: 16px; font-size: clamp(17px, 1.4vw, 21px); color: var(--muted); }
.closing .closing-idea { margin: 22px 0 32px; font-size: clamp(20px, 1.8vw, 28px); color: var(--on-ink); }
.closing-idea span { color: var(--mark); }

.site-footer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 32px; padding: 28px var(--gutter) 36px; border-top: 1px solid var(--line); font-size: 14px; color: var(--faint); background: var(--ink); }
.site-footer span { color: var(--on-ink); font-weight: 600; }
.site-footer p { margin-right: auto; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--on-ink); }

/* ---------- without WebGL or JS: the same story, told with the real images ---------- */
:root:not(.webgl) #field { display: none; }
:root:not(.webgl) .fallback-idea { display: block; margin: auto 0; max-width: 100%; overflow-wrap: anywhere; font-size: min(clamp(96px, 20vw, 300px), calc((100vw - 2 * var(--gutter)) / (var(--idea-chars, 2) * 1.02))); font-weight: 600; line-height: 1; letter-spacing: -.05em; text-align: center; color: var(--on-ink); }
:root:not(.webgl) .hero-foot { margin-top: 0; }
:root:not(.webgl) .work, .work.img-fallback { gap: 4vw; }
.work-img { flex: 1; min-width: 0; border-radius: 14px; }

/* ---------- smaller screens ---------- */
@media (max-width: 860px) {
  .site-header nav { display: none; }
  .hero-foot { flex-direction: column; align-items: stretch; }
  .idea-form { width: 100%; }
  .work { align-items: flex-end; padding-bottom: 56px; }
  .work::before { content: ""; position: absolute; inset: 40% 0 0; background: linear-gradient(transparent, rgba(7, 7, 9, .92) 45%); pointer-events: none; }
  .work-text { position: relative; width: 100%; }
  .loop-text, .loop-note { width: 100%; }
  .loop-inner { justify-content: flex-end; padding-bottom: 56px; }
  .loop-inner::before { content: ""; position: absolute; inset: 35% 0 0; background: linear-gradient(transparent, rgba(7, 7, 9, .9) 40%); pointer-events: none; }
  .loop-inner > * { position: relative; }
  .course > * { width: 100%; }
  :root:not(.webgl) .work, .work.img-fallback { flex-direction: column-reverse; justify-content: center; }
  :root:not(.webgl) .work::before, .work.img-fallback::before { display: none; }
  .work-img { flex: none; width: 100%; }
}
@media (max-width: 560px) {
  .lesson-modules { grid-template-columns: 1fr; }
  .next-lessons li { grid-template-columns: 40px minmax(0, 1fr); }
  .next-state { grid-column: 2; }
  .site-footer p { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .js .beat > *, .js .work-text > * { transition: none; }
  .js .loop { height: auto; }
  .js .loop-inner { position: static; }
  .clause, .js .clause:not(.is-on) { transition: none; }
}
