:root {
  --paper: #ffffff;
  --ink: #1b1f23;
  --body: #3a4046;
  --muted: #737a81;
  --hair: #e1e4e7;
  --plate: #f3f5f6;
  --signal: #0f7a83;

  --serif: "Spectral", "Iowan Old Style", Georgia, serif;
  --sans: "Geologica", "Helvetica Neue", sans-serif;

  --page: 72rem;
  --pad: clamp(1.25rem, 5vw, 3rem);
  --thumb: 9.5rem;
  --gap: 2rem;
  --indent: calc(var(--thumb) + var(--gap)); /* the text column every section lines up on */
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-underline-offset: 0.22em; text-decoration-thickness: 1px; text-decoration-color: var(--hair); }
a:hover { color: var(--signal); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: 1rem; top: -3rem; background: var(--ink); color: var(--paper); padding: 0.5rem 0.9rem; z-index: 5; }
.skip:focus { top: 1rem; }

/* Logo: a fixed 3:2 Lissajous figure */
.logo { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; overflow: visible; flex: none; }
.logo path { vector-effect: non-scaling-stroke; }

/* Masthead */
.masthead {
  max-width: var(--page);
  margin: 0 auto;
  padding: 2rem var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; font-weight: 400; }
.brand:hover .logo, .brand:focus-visible .logo { color: var(--signal); }
.foot .logo { width: 20px; height: 20px; }
.masthead nav { display: flex; gap: 1.6rem; font-size: 0.9rem; color: var(--muted); }
.masthead nav a { text-decoration: none; }

/* Hero */
/* Full-bleed so the cursor traces can run edge to edge; content still lines up with the page */
.hero {
  padding-block: clamp(4rem, 12vw, 9rem) clamp(4rem, 10vw, 7rem);
  padding-inline: max(var(--pad), calc((100% - var(--page)) / 2 + var(--pad)));
}
h1, h2 { font-family: var(--serif); font-weight: 300; margin: 0; }
h1 {
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  line-height: 1.06;
  letter-spacing: -0.02em;
  max-width: 17ch;
}

/* Sections */
.group {
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(4rem, 9vw, 6.5rem) var(--pad) 0;
}
.group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--ink);
}
h2 { font-size: clamp(2rem, 3.8vw, 3rem); line-height: 1.1; letter-spacing: -0.01em; }
.group-head p { margin: 0; font-size: 0.85rem; color: var(--muted); }

/* Projects: each row links to its own page */
.projects { list-style: none; margin: 0; padding: 0; }
.project {
  text-decoration: none;
  display: grid;
  grid-template-columns: var(--thumb) minmax(0, 1fr) 9rem;
  gap: var(--gap);
  align-items: start;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--hair);
}
.thumb {
  aspect-ratio: 16 / 11;
}
.thumb img, .thumb svg { width: 100%; height: 100%; display: block; object-fit: cover; }
.thumb svg { fill: none; stroke: #8b9298; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.thumb svg circle { fill: var(--paper); }
.thumb svg .faint { stroke-opacity: 0.4; }
.thumb svg .acc { stroke: var(--signal); }

/* The one number that sums up each build, like an instrument reading */
.reading { margin: 0; text-align: right; display: grid; gap: 0.1rem; }
.reading b {
  font-family: var(--sans);
  font-weight: 300;
  font-size: 2.6rem;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.reading small { font-size: 0.42em; letter-spacing: 0; margin-left: 0.15em; color: var(--signal); font-weight: 400; }
.reading span { font-size: 0.8rem; color: var(--muted); }

/* About */
.about-body { padding: 1.75rem 0 0 var(--indent); max-width: calc(var(--indent) + 38rem); }
.about-body p { margin: 0 0 1.1rem; color: var(--body); }
.about-body .lead { font-family: var(--serif); font-size: 1.6rem; line-height: 1.3; color: var(--ink); }

.foot {
  max-width: var(--page);
  margin: 0 auto;
  padding: 6rem var(--pad) 3rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.foot p { margin: 0; }


.hero-sub { margin: 1.5rem 0 0; color: var(--muted); font-size: 1.05rem; }

.project-text { display: grid; gap: 0.3rem; }
.title { font-family: var(--serif); font-size: 1.6rem; line-height: 1.2; }
.summary { color: var(--body); font-size: 0.95rem; max-width: 46ch; }
.fields { font-size: 0.8rem; color: var(--muted); }
.project:hover { color: inherit; }
.project:hover .title { color: var(--signal); }
.project:hover .thumb svg { stroke: var(--ink); }
.thumb svg { transition: stroke 0.2s ease; }

/* Experience */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: var(--thumb) minmax(0, 1fr);
  gap: var(--gap);
  padding: 1.6rem 0;
  border-bottom: 1px solid var(--hair);
}
.when { margin: 0; padding-top: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.timeline h3 { margin: 0 0 0.35rem; font-family: var(--serif); font-weight: 400; font-size: 1.45rem; line-height: 1.25; }
.timeline h3 span { font-family: var(--sans); font-weight: 300; font-size: 0.85rem; color: var(--muted); margin-left: 0.5rem; }
.timeline p:not(.when) { margin: 0; color: var(--body); font-size: 0.95rem; max-width: 60ch; }

.empty { margin: 0; padding: 1.6rem 0 0 var(--indent); color: var(--muted); }

/* Project pages */
.case { max-width: var(--page); margin: 0 auto; padding: clamp(2.5rem, 6vw, 4.5rem) var(--pad) 0; }
.crumb { font-size: 0.85rem; color: var(--muted); text-decoration: none; }
.case-head h1 { margin-top: 1.25rem; max-width: 18ch; }
.case-sum { margin: 1.25rem 0 0; font-size: 1.15rem; color: var(--body); max-width: 48ch; }
.case-figure { margin: clamp(2.5rem, 6vw, 4rem) 0 0; aspect-ratio: 16 / 7; }
.case-figure svg { max-height: 100%; stroke-width: 1; }
.case-grid {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 5rem);
  padding-top: 3rem;
  border-top: 1px solid var(--ink);
  margin-top: 3rem;
}
.case-facts .reading { text-align: left; margin-bottom: 1.75rem; }
.case-facts .reading b { font-size: 3.2rem; }
.case-facts dl { margin: 0; display: grid; gap: 1rem; }
.case-facts dt { font-size: 0.8rem; color: var(--muted); }
.case-facts dd { margin: 0; font-size: 0.95rem; }
.case-body { max-width: 38rem; color: var(--body); font-size: 1.05rem; }
.case-body h2 { font-size: 1.7rem; color: var(--ink); margin: 0 0 0.6rem; }
.case-body p { margin: 0 0 1.25rem; }
.case-body p + h2 { margin-top: 2.25rem; }
.case-next {
  margin-top: 5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.case-next span { font-size: 0.85rem; color: var(--muted); }
.case-next a { font-family: var(--serif); font-size: 1.6rem; text-decoration: none; }

@media (max-width: 52rem) {
  :root { --thumb: 7rem; --gap: 1.25rem; }
  .project { grid-template-columns: var(--thumb) minmax(0, 1fr); }
  .reading { grid-column: 2; text-align: left; display: flex; align-items: baseline; gap: 0.6rem; }
  .reading b { font-size: 1.8rem; }
  .about-body, .empty { padding-left: 0; }
  .case-grid { grid-template-columns: 1fr; }
  .case-facts .reading { display: grid; }
}
@media (max-width: 34rem) {
  .timeline li { grid-template-columns: 1fr; gap: 0.25rem; }
  .masthead nav { gap: 1.1rem; }
  .case-figure { aspect-ratio: 4 / 3; }
}

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

/* Hero trace canvas (script.js) sits behind the headline */
.hero { position: relative; }
.hero .traces { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.hero h1 { position: relative; z-index: 1; max-width: 22ch; font-size: clamp(2.2rem, 5vw, 4rem); }

/* Scroll-driven 3D project pages (assets/scroll3d.js) */
.scrolly {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--pad);
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  column-gap: clamp(1.5rem, 4vw, 3.5rem);
}
.chapters { grid-column: 1; grid-row: 1; }
.stage {
  grid-column: 2; grid-row: 1;
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  min-height: 28rem;
  cursor: grab;
  touch-action: pan-y;
}
.stage.dragging { cursor: grabbing; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 0.6s ease; }
.stage.ready canvas { opacity: 1; }
.stage-status, .stage-hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  margin: 0; font-size: 0.8rem; color: var(--muted); pointer-events: none; white-space: nowrap;
}
.stage-status { top: 50%; }
.stage.ready .stage-status, .stage.no-webgl .stage-status { display: none; }
.stage-hint { bottom: 2rem; opacity: 0; transition: opacity 0.4s ease 0.8s; }
.stage.ready .stage-hint { opacity: 1; }
.stage-fallback { display: none; position: absolute; inset: 25% 5%; aspect-ratio: auto; }
.stage.no-webgl .stage-fallback { display: block; }
.stage.no-webgl { cursor: default; }

.chapter {
  min-height: 85vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 0;
  max-width: 30rem;
}
.chapter h2 { font-size: clamp(1.9rem, 3vw, 2.5rem); margin-bottom: 0.9rem; }
.chapter p { margin: 0 0 1rem; color: var(--body); font-size: 1.05rem; }
.chapter-intro { min-height: calc(100vh - 6rem); justify-content: center; }
.chapter-intro h1 { margin-top: 1.25rem; font-size: clamp(2.3rem, 4.6vw, 3.8rem); }
.chapter-intro .case-sum { margin-top: 1.25rem; }
.scroll-cue { margin-top: 2.5rem !important; font-size: 0.85rem !important; color: var(--muted) !important; }
.scroll-cue::after {
  content: "";
  display: inline-block;
  width: 0.4rem; height: 0.4rem;
  margin-left: 0.6rem;
  border-right: 1.25px solid currentColor;
  border-bottom: 1.25px solid currentColor;
  transform: translateY(-0.2rem) rotate(45deg);
}

.case-after { max-width: var(--page); margin: 0 auto; padding: 2rem var(--pad) 0; }
.case-after .case-grid { margin-top: 0; }
.fact-list { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1.25rem 2rem; align-content: start; }
.fact-list dt { font-size: 0.8rem; color: var(--muted); }
.fact-list dd { margin: 0; font-size: 0.95rem; }

/* Build photos and drawings, after the 3D walkthrough */
.process { max-width: var(--page); margin: 0 auto; padding: clamp(3rem, 7vw, 5rem) var(--pad) 3rem; }
.figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem 2rem; margin-top: 2rem; }
.fig { margin: 0; }
.fig img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--plate); border-radius: 2px; }
.fig.tall img { aspect-ratio: 3 / 4; }
.fig.contain img { object-fit: contain; background: none; }
.fig figcaption { margin-top: 0.7rem; font-size: 0.88rem; color: var(--muted); max-width: 34rem; }
.stage-fallback img { width: 100%; height: 100%; object-fit: contain; }
@media (max-width: 34rem) { .figs { grid-template-columns: 1fr; } }

@media (max-width: 52rem) {
  .scrolly { grid-template-columns: 1fr; }
  .stage {
    grid-column: 1; grid-row: 1;
    height: 48vh; height: 48svh; min-height: 18rem;
    z-index: 1;
    background: linear-gradient(var(--paper) 85%, rgba(255, 255, 255, 0));
  }
  .chapters { grid-row: 2; }
  .chapter { min-height: 60vh; padding: 2rem 0; }
  .chapter-intro { min-height: 40vh; }
  .stage-hint { display: none; }
}

/* Neural network page: version history and inline figures */
.versions { list-style: none; margin: 0 0 1.5rem; padding: 0; border-top: 1px solid var(--hair); }
.versions li { display: grid; grid-template-columns: 5.5rem 1fr; gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--hair); }
.versions span { font-size: 0.85rem; color: var(--muted); padding-top: 0.2rem; }
.versions p { margin: 0; }
.case-body code { font-size: 0.85em; background: var(--plate); padding: 0.1em 0.35em; border-radius: 3px; white-space: nowrap; }
.case-inline { margin: 0.5rem 0 1.75rem; }
.case-inline img { display: block; width: 100%; max-width: 30rem; height: auto; }
.case-inline figcaption { margin-top: 0.7rem; font-size: 0.88rem; color: var(--muted); max-width: 30rem; }
.case-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; align-items: start; margin: 0.5rem 0 1.5rem; }
.case-pair .case-inline { margin: 0; }
.case-pair img { border: 1px solid var(--hair); border-radius: 2px; }
@media (max-width: 34rem) { .case-pair { grid-template-columns: 1fr; } }

/* Blog: homepage list (filled in by build.mjs) and post pages */
.posts { list-style: none; margin: 0; padding: 0; }
.post-link {
  display: grid;
  grid-template-columns: var(--thumb) minmax(0, 1fr);
  column-gap: var(--gap);
  padding: 1.6rem 0;
  border-bottom: 1px solid var(--hair);
  text-decoration: none;
  color: inherit;
}
.post-link time { grid-row: span 2; padding-top: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.post-title { font-family: var(--serif); font-size: 1.45rem; line-height: 1.25; color: var(--ink); }
.post-sum { margin-top: 0.35rem; color: var(--body); font-size: 0.95rem; max-width: 60ch; }
.post-link:hover .post-title { color: var(--signal); }
@media (max-width: 52rem) {
  .post-link { grid-template-columns: 1fr; }
  .post-link time { grid-row: auto; padding-top: 0; }
}

.post .case-head h1 { max-width: 22ch; }
.post-date { margin: 1rem 0 0; font-size: 0.9rem; color: var(--muted); }
.prose { max-width: 38rem; margin-top: clamp(2rem, 5vw, 3rem); padding-bottom: 2rem; color: var(--body); font-size: 1.05rem; line-height: 1.7; }
.prose > * { margin: 0 0 1.25rem; }
.prose h2 { font-family: var(--serif); font-weight: 300; font-size: 1.7rem; color: var(--ink); margin: 2.25rem 0 0.6rem; }
.prose h3 { font-family: var(--serif); font-weight: 400; font-size: 1.3rem; color: var(--ink); margin: 1.75rem 0 0.5rem; }
.prose a { color: var(--signal); }
.prose img { display: block; max-width: 100%; height: auto; border-radius: 2px; }
.prose figure, .prose p:has(> img:only-child) { margin: 1.75rem 0; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: 0.35rem; }
.prose blockquote { margin-left: 0; padding-left: 1.1rem; border-left: 2px solid var(--hair); color: var(--muted); }
.prose code { font-size: 0.88em; background: var(--plate); padding: 0.1em 0.35em; border-radius: 3px; }
.prose pre { background: var(--plate); padding: 1rem 1.1rem; border-radius: 3px; overflow-x: auto; font-size: 0.88rem; line-height: 1.55; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--hair); margin: 2.25rem 0; }
