/* Paper and ink, one accent, no gradients. Light is the default; html[data-mode="dark"] (set by theme-lab.js for now) swaps the tokens. */

:root {
  --paper: #F3EEE4;
  --ink: #1C1A16;
  --muted: #6A6458;
  --tint: #EAE3D6;
  --rule: #CFC6B5;
  --amber: #D9952E;
  --on-accent: #1C1A16; /* text on an accent fill */
  /* how far the drawings' faces lift towards white and how far their shaded sides sink towards black */
  --face-lift: 55%; --top-lift: 90%; --s0: 22%; --s1: 15%; --s2: 8%; --s3: 3.5%;
  --serif: 'DM Serif Display', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --pad: clamp(20px, 4vw, 48px);
}

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

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; overflow-x: clip; }

a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a:hover { background: var(--tint); }

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

h1, h2 { margin: 0; font-family: var(--serif); font-weight: 400; text-wrap: balance; }
p { margin: 0; }
em { font-style: italic; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.prose { font-size: 16px; line-height: 1.7; max-width: 640px; text-wrap: pretty; }
.prose-sm { font-size: 14px; line-height: 1.6; max-width: 640px; text-wrap: pretty; }

/* JS-only pieces fall away when the script does not run. */
html:not(.js) .js-only { display: none !important; }
html.js .no-js-only { display: none; }

/* ---------- header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}
.top-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px var(--pad);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
.brand { font-weight: 600; letter-spacing: .02em; }
.trace-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.trace-nav .muted { margin-right: 6px; }
.count { margin-left: 6px; min-width: 28px; }

.node {
  width: 26px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  transition: background .3s, color .3s;
}
.node[data-state="running"] { background: var(--amber); color: var(--on-accent); }
.node[data-state="done"] { background: var(--ink); color: var(--paper); }

.status { display: flex; align-items: center; gap: 8px; }
.diamond {
  width: 8px;
  height: 8px;
  background: var(--amber);
  border: 1px solid var(--ink);
  transform: rotate(45deg);
}

/* ---------- layout ---------- */
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 var(--pad); }

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: 48px;
  align-items: end;
  padding: clamp(40px, 7vw, 88px) 0 56px;
}
.hero-copy { display: flex; flex-direction: column; gap: 28px; }

.hero h1 {
  font-size: clamp(56px, 8.4vw, 116px);
  line-height: .92;
  letter-spacing: -.02em;
}
.lede { font-size: 17px; line-height: 1.65; max-width: 540px; text-wrap: pretty; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn { padding: 14px 20px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.btn-solid { background: var(--ink); color: var(--paper); }
.btn-solid:hover { background: var(--amber); color: var(--on-accent); }
.btn-line { border: 1px solid var(--ink); padding: 13px 20px; font-size: 14px; }
.btn-line:hover { background: var(--tint); }

/* ---------- portrait ---------- */
.portrait-col {
  display: flex;
  justify-content: center;
  justify-self: center;
  width: 100%;
  max-width: 420px;
}
.portrait { width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: contain; }
.portrait-link { position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; font: inherit; cursor: pointer; color: inherit; border-radius: 6px; }
.portrait-link:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; }
.portrait-link:hover .portrait { filter: contrast(1.04); }
.portrait-hint { position: absolute; right: 8px; bottom: 8px; font: 13px "IBM Plex Mono", monospace; padding: 4px 8px; background: var(--paper); border: 1px solid currentColor; border-radius: 999px; }

/* ---------- trace ---------- */
.trace-intro { font-size: 13px; padding-bottom: 16px; }

.step {
  display: grid;
  grid-template-columns: minmax(64px, 150px) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 40px);
  padding: 48px 0;
  border-top: 1px solid var(--ink);
  scroll-margin-top: 72px;
}
.step-final { padding-bottom: 72px; }

.step-side { display: flex; flex-direction: column; gap: 6px; font-size: 12px; letter-spacing: .08em; }
.step-num { font-size: 13px; font-weight: 600; }
.step-label { letter-spacing: 0; }

.step-body {
  display: flex;
  flex-direction: column;
  gap: 22px;
  transition: opacity .6s, filter .6s;
}
.step h2 { font-size: clamp(32px, 4.4vw, 54px); line-height: 1.02; }

/* Until a step runs, it stays blurred. Without JS everything shows. */
html.js .step:not([data-state="done"]) .step-body { opacity: .16; filter: blur(5px); }
html.js .step[data-state="done"] .step-body { opacity: 1; filter: none; }

.tool {
  font-size: 14px;
  background: var(--tint);
  align-self: flex-start;
  padding: 4px 10px;
}

.role { display: flex; flex-direction: column; gap: 8px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 20px 32px;
}
.card {
  border-top: 1px solid var(--rule);
  padding-top: 12px;
  font-size: 14px;
  line-height: 1.6;
}
.card b { font-weight: 600; }

.stack { line-height: 1.5; }

/* results */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 32px;
}
.metric { display: flex; flex-direction: column; gap: 10px; }
.big {
  font-family: var(--serif);
  font-size: clamp(64px, 9vw, 112px);
  line-height: .9;
  font-variant-numeric: tabular-nums;
}

/* Aperture */
.loop { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.loop-chip { border: 1px solid var(--ink); padding: 6px 12px; transition: background .3s; }
.loop-chip.on { background: var(--amber); color: var(--on-accent); }

.checkpoints { display: flex; flex-wrap: wrap; gap: 3px; }
.checkpoints .cp { width: 14px; height: 14px; border: 1px solid var(--ink); }
.checkpoints .cp.on { background: var(--ink); }

/* projects: scroll-pinned. Vertical scroll turns the rail sideways, one project per viewport width, then the page goes on. */
.rail-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.step-projects { --slide-pad: max(var(--pad), calc((100vw - 1160px) / 2 + var(--pad))); --pin-top: 52px; }
.rail-pin { grid-column: 1 / -1; margin-inline: calc(50% - 50vw); width: 100vw; }
.rail-sticky { position: relative; }
.rail {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  transition: opacity .6s, filter .6s;
}
.rail::-webkit-scrollbar { display: none; }
html.js .step-projects:not([data-state="done"]) .rail { opacity: .16; filter: blur(5px); }
.proj {
  flex: 0 0 100vw;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: grid;
  grid-template-columns: minmax(280px, 440px) minmax(0, 1fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  padding: 28px var(--slide-pad) 64px;
  min-height: min(82vh, 700px);
  border-left: 1px solid var(--rule);
}
.proj:first-child { border-left: 0; }
.proj-text { display: flex; flex-direction: column; gap: 14px; min-width: 0; align-self: stretch; justify-content: center; }
.proj-fig { min-width: 0; max-width: 760px; width: 100%; justify-self: center; }
.proj h3 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 5vw, 64px); line-height: 1; }
.proj-kicker { font-size: 11px; letter-spacing: .1em; }
.proj-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.proj-list li { border-top: 1px solid var(--rule); padding-top: 10px; font-size: 13px; line-height: 1.55; }
.proj-list b { font-weight: 600; }
.proj-foot {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}
.proj-links { display: flex; gap: 18px; }

/* small arrows either side of the dots at the bottom */
.rail-hint { position: absolute; left: 0; right: 0; bottom: 12px; z-index: 3; display: flex; align-items: center; justify-content: center; gap: 18px; font-size: 12px; letter-spacing: .08em; }
.rail-btn { width: 34px; height: 30px; border: 0; background: none; font-size: 20px; line-height: 1; }
.rail-btn:hover { color: var(--amber); }
.rail-sticky[data-first] #railNext { animation: rail-spring 2.2s ease-in-out infinite; }
.rail-dots { display: inline-flex; gap: 8px; }
.rail-dot { width: 9px; height: 9px; border: 1px solid var(--ink); border-radius: 50%; transition: background .25s, width .35s cubic-bezier(.34, 1.56, .64, 1); }
.rail-dot[aria-current="true"] { background: var(--ink); width: 24px; border-radius: 6px; }
.rail-count { min-width: 40px; text-align: center; }
@keyframes rail-spring {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(10px); }
  40% { transform: translateX(2px); }
  55% { transform: translateX(6px); }
  70% { transform: translateX(0); }
}
.rail-sticky.is-fading .rail { opacity: 0; transition-duration: .15s; }

/* wide screens: the pin is on, the rail is moved by the page's scroll */
@media (min-width: 861px) {
  .rail-pin.is-pinned .rail-sticky { position: sticky; top: var(--pin-top); height: calc(100vh - var(--pin-top)); display: flex; align-items: center; }
  .rail-pin.is-pinned .rail { overflow-x: hidden; scroll-snap-type: none; width: 100%; }
}
@media (min-width: 861px) and (max-height: 820px) {
  .proj { padding-block: 12px 56px; }
  .proj-text { gap: 10px; }
  .proj h3 { font-size: 44px; }
  .proj .prose-sm { font-size: 13px; line-height: 1.5; }
  .proj-list { gap: 6px; }
  .proj-list li { padding-top: 6px; font-size: 12.5px; line-height: 1.45; }
  .proj-foot { padding-top: 10px; gap: 6px; }
}
@media (max-width: 860px) {
  .proj { grid-template-columns: minmax(0, 1fr); align-items: start; min-height: 0; padding-inline: var(--slide-pad); }
  .proj-fig { order: -1; max-width: 520px; }
  .rail-hint { position: static; padding: 10px 0 0; }
}
@media (prefers-reduced-motion: reduce) { #railNext { animation: none !important; } }

/* final answer */
.verdict {
  font-size: clamp(72px, 12vw, 168px);
  line-height: .85;
  letter-spacing: -.02em;
}
.pitch { font-size: 17px; line-height: 1.6; max-width: 600px; text-wrap: pretty; margin-top: 16px; }
.tag { font-size: 13px; background: var(--tint); align-self: flex-start; padding: 4px 10px; margin-bottom: 16px; }
#branch h2.verdict { font-size: clamp(56px, 9vw, 120px); line-height: .88; }

#copyEmail { white-space: nowrap; font-size: clamp(15px, 1.8vw, 20px); padding: 16px 22px; }
.mail { font-size: 14px; padding: 6px 4px; }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  font-size: 14px;
  border-top: 1px solid var(--rule);
  padding-top: 18px;
}

.controls { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; }
.dash { border: 1px dashed var(--ink); padding: 8px 12px; }
.dash:hover { background: var(--tint); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--ink); }
.foot-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 18px var(--pad);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  font-size: 12px;
}

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .step { grid-template-columns: 1fr; gap: 14px; padding: 36px 0; }
  .step-side { flex-direction: row; flex-wrap: wrap; gap: 4px 12px; }
  .top-inner { gap: 8px 16px; }
  .status { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- intro: the signature video ---------- */
.sign { display: none; }
.js .sign {
  display: grid; place-items: center; position: fixed; inset: 0; z-index: 1000;
  background: var(--paper); transition: opacity .6s ease;
}
.js .sign.out { opacity: 0; pointer-events: none; }
.js .sign.gone { display: none; }
/* 1200x960 video on pure white, blended with multiply so the page paper shows through exactly (white x paper = paper) */
.sign-video {
  display: block; width: min(94vw, 820px); height: auto; aspect-ratio: 1200 / 960; mix-blend-mode: multiply;
  filter: hue-rotate(var(--nib-hue, 0deg)); /* the nib is amber in the video; turn it towards the accent */
}
/* dark: invert (white ground -> black, black ink -> white) and screen it onto the dark paper */
html[data-mode="dark"] .sign-video { mix-blend-mode: screen; filter: invert(1) hue-rotate(calc(180deg + var(--nib-hue, 0deg))); }
.sign-skip {
  position: absolute; right: var(--pad); bottom: 20px;
  font: 500 12px var(--mono); letter-spacing: .04em; color: var(--muted);
  padding: 8px 12px; border: 1px solid var(--rule); background: none;
}
.sign-skip:hover, .sign-skip:focus-visible { color: var(--ink); border-color: var(--ink); }
.js.signing { overflow: hidden; }

/* back to the top: a bare vertical arrow that bobs on a spring and launches when pressed */
.step-final { position: relative; }
.to-top { position: absolute; right: 0; bottom: 18px; width: 44px; height: 54px; display: grid; place-items: center; color: var(--ink); }
.to-top svg { animation: top-bob 2.4s ease-in-out infinite; }
.to-top:hover { color: var(--amber); }
.to-top.go svg { animation: top-launch .9s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes top-bob { 0%, 100% { transform: translateY(0); } 30% { transform: translateY(-7px); } 45% { transform: translateY(-1px); } 60% { transform: translateY(-4px); } 75% { transform: translateY(0); } }
@keyframes top-launch { 0% { transform: translateY(0); } 18% { transform: translateY(9px); } 55% { transform: translateY(-22px); opacity: .2; } 56% { transform: translateY(14px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .to-top svg, .to-top.go svg { animation: none; } }
