:root {
  --bg: #07060b;
  --ink: #f6f1ea;
  --muted: #cbbfb6;
  --faint: #8d827a;
  --card: rgba(14, 11, 14, 0.78);
  --line: rgba(246, 232, 220, 0.14);
  --coral: #e7a394;
  --coral-2: #f3d2c4;
  --liver: #9a4452;
  --bile: #7dba78;
  --pancreas: #e0b07a;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Outfit", system-ui, sans-serif;
  --stage: min(460px, 42vw);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--ink);
  color: #1a1214;
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 20;
}

.skip:focus { top: 12px; }

a { color: var(--coral-2); }

.top {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px 28px;
  background: linear-gradient(to bottom, rgba(7, 6, 11, 0.88), rgba(7, 6, 11, 0));
  pointer-events: none;
}

.top a, .top p { pointer-events: auto; }

.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 560;
  letter-spacing: 0.04em;
  font-size: 0.92rem;
}

.brand span {
  color: var(--faint);
  margin-right: 8px;
  font-weight: 400;
}

.now {
  margin: 0;
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--coral-2);
}

.hint {
  margin: 0;
  color: var(--faint);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 16;
  background: rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.progress > span {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #c46b6e, #f3d2c4);
}

.rail {
  display: none;
}

.scrolly { position: relative; }

.stage {
  position: relative;
  background:
    radial-gradient(ellipse 55% 42% at 50% 46%, rgba(150, 70, 64, 0.18), transparent 68%),
    var(--bg);
}

.viewport {
  position: relative;
  overflow: hidden;
}

.world {
  width: min(92vw, 540px);
  margin: 0 auto;
}

.world svg {
  display: block;
  width: 100%;
  height: auto;
}

.lens, .hud { display: none; }

.vignette, .grain { z-index: 3; }

.vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 42%, rgba(7, 6, 11, 0.55) 100%),
    linear-gradient(to bottom, rgba(7, 6, 11, 0.2), transparent 12%, transparent 88%, rgba(7, 6, 11, 0.45));
}

.grain {
  pointer-events: none;
  position: absolute;
  inset: 0;
  opacity: 0.18;
  mix-blend-mode: overlay;
  background-image: 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>");
}

.steps {
  width: min(720px, 92vw);
  margin: 0 auto 8vh;
  padding: 0 8px 4vh;
}

.step { padding: 28px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 18px;
  padding: 22px 22px 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.kicker {
  margin: 0 0 8px;
  color: var(--coral);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1, h2 {
  font-family: var(--serif);
  font-weight: 560;
  letter-spacing: -0.025em;
  line-height: 1.08;
  margin: 0 0 12px;
}

h1 { font-size: clamp(2.2rem, 5vw, 3.3rem); }
h2 { font-size: clamp(1.7rem, 3vw, 2.35rem); }

.card p {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 1.02rem;
}

.card p:last-of-type { margin-bottom: 0; }

.spec {
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}

.spec div {
  display: grid;
  grid-template-columns: 8.6rem 1fr;
  gap: 8px 12px;
  align-items: baseline;
}

.spec dt {
  margin: 0;
  color: var(--coral);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spec dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.facts, .key {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.facts li, .key li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--coral-2);
  background: rgba(231, 163, 148, 0.1);
  border-radius: 999px;
  padding: 5px 10px;
}

.key i {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  display: block;
}

.key .path { background: #e7a394; }
.key .liver { background: #9a4452; }
.key .bile { background: #7dba78; }
.key .pancreas { background: #e0b07a; }

.villi-fig {
  margin: 16px 0 0;
  padding: 10px 10px 8px;
  border-radius: 14px;
  background: rgba(255, 244, 238, 0.03);
  border: 1px solid var(--line);
}

.villi-fig svg, .villi-fig img { width: 100%; height: auto; display: block; border-radius: 10px; }

@media (min-width: 801px) {
  html.is-enhanced #step-small { padding-top: 6vh; padding-bottom: 4vh; }
  html.is-enhanced .villi-fig img {
    height: 128px;
    object-fit: cover;
    object-position: center 42%;
  }
}

.villi-fig figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 6px;
  color: var(--faint);
  font-size: 0.75rem;
}

.villi-fig figcaption span { display: inline-flex; align-items: center; gap: 6px; }

.swatch {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  display: inline-block;
}

.swatch.cap { background: #e2666a; }
.swatch.lac { background: #f0d7a4; }

.colophon {
  width: min(720px, 92vw);
  margin: 0 auto;
  padding: 12px 8px 48px;
  color: var(--faint);
  font-size: 0.88rem;
}

.colophon a { color: var(--coral-2); }

/* Plate */
.plate-photo, #shade, #route, #route-hot, #bolus, #holes { pointer-events: none; }
.organ { cursor: pointer; fill: rgba(0, 0, 0, 0.012); stroke: transparent; pointer-events: fill; }
.organ[fill="none"] { fill: none; stroke: rgba(0, 0, 0, 0.02); pointer-events: stroke; }
#shade { opacity: 0; }

#route {
  fill: none;
  stroke: rgba(255, 226, 210, 0.42);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1.4 9;
}

#route-hot {
  fill: none;
  opacity: 0.75;
  stroke: #ffe8dc;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url(#routeGlow);
}

#ducts, #sparks, #food { pointer-events: none; }
#ducts .duct {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2 5;
  opacity: 0;
  filter: url(#routeGlow);
}
#ducts .drips { opacity: 0; }
#food-glow { opacity: 0.32; }
#food-body { stroke-width: 1.2; }
#food .squeeze {
  fill: none;
  stroke: #ffe3d6;
  stroke-width: 2.4;
  stroke-linecap: round;
  opacity: 0;
}
#food .shine { fill: #fff; opacity: 0.55; }

/* Enhanced scrollytelling */
html.is-enhanced .world {
  position: absolute;
  left: 0;
  top: 0;
  width: 816px;
  height: 1460px;
  margin: 0;
  transform-origin: 0 0;
  will-change: transform;
}

html.is-enhanced .world svg { width: 816px; height: 1460px; }

html.is-enhanced .stage {
  position: sticky;
  top: 0;
  height: 100dvh;
  width: calc(100% - var(--stage));
  margin-left: auto;
  z-index: 0;
  overflow: hidden;
}

html.is-enhanced .viewport { position: absolute; inset: 0; }

html.is-enhanced .lens {
  display: block;
  position: absolute;
  right: 44px;
  bottom: 48px;
  width: min(30%, 240px);
  aspect-ratio: 1;
  margin: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transform-origin: 100% 100%;
}

html.is-enhanced .insides {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(243, 210, 196, 0.55);
  box-shadow: 0 0 0 6px rgba(7, 6, 11, 0.55), 0 18px 50px rgba(0, 0, 0, 0.55);
  background: #120d10;
}

html.is-enhanced .insides img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
}

html.is-enhanced .insides img[data-station="stomach"] { object-position: center 34%; }
html.is-enhanced .insides img[data-station="mouth"] { object-position: center 40%; }

html.is-enhanced .inside-note {
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translate(-50%, 100%);
  white-space: nowrap;
  margin: 0;
  color: #f6f1ea;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.85);
}

html.is-enhanced .hud {
  display: block;
  position: absolute;
  left: 24px;
  bottom: 22px;
  z-index: 5;
  width: min(430px, calc(100% - 48px));
  padding: 12px 14px 10px;
  border-radius: 14px;
  background: rgba(10, 8, 12, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.hud-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr;
  gap: 10px;
}

.hud-row p, .m-stats p { margin: 0; display: grid; gap: 1px; }

.hud-row span, .m-stats span {
  color: var(--faint);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud-row b, .m-stats b {
  font-family: var(--serif);
  font-weight: 560;
  font-size: 1.12rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tape {
  position: relative;
  height: 7px;
  margin-top: 10px;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.tape-segs {
  position: absolute;
  inset: 0;
  display: flex;
  opacity: 0.32;
}

.tape-segs i { display: block; height: 100%; min-width: 2px; }
.tape-segs i + i { box-shadow: -1px 0 0 rgba(7, 6, 11, 0.9); }

.tape-fill {
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #e59a95, #f1a092 30%, #e0b07a 80%, #9c6a4c);
  box-shadow: 0 0 12px rgba(241, 160, 146, 0.6);
}

.tape-note {
  margin: 5px 0 0;
  color: var(--faint);
  font-size: 0.68rem;
}

html.is-enhanced .steps {
  position: relative;
  z-index: 1;
  width: var(--stage);
  margin: -100dvh 0 0;
  padding: 0 22px 0 4vw;
}

html.is-enhanced .step {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding: 12vh 0;
}

html.is-enhanced .card {
  opacity: 0.38;
  transition: opacity 0.45s ease, border-color 0.45s ease;
  backdrop-filter: blur(16px);
}

html.is-enhanced .step.is-active .card {
  opacity: 1;
  border-left-color: var(--coral);
}

html.is-enhanced .rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 12;
}

html.is-enhanced .rail a {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: rgba(246, 241, 234, 0.28);
  display: block;
}

html.is-enhanced .rail a.is-current {
  background: var(--coral-2);
  box-shadow: 0 0 0 5px rgba(243, 210, 196, 0.16);
}

html.is-enhanced #plate[data-dim="1"] #shade { opacity: 0.72; transition: opacity 0.55s ease; }
html.is-enhanced #holes .hole { opacity: 0; }
html.is-enhanced #holes .hole.is-active { opacity: 1; }

@media (max-width: 800px) {
  :root { --stage: 100%; }

  .now { display: none; }

  html.is-enhanced .villi-fig img {
    height: auto;
    object-fit: fill;
  }

  html.is-enhanced .stage {
    width: 100%;
    height: 46dvh;
    margin-left: 0;
    z-index: 2;
    background: var(--bg);
  }

  html.is-enhanced .steps {
    width: 100%;
    margin-top: -46dvh;
    padding: 0 14px 6vh;
  }

  html.is-enhanced .step {
    min-height: 92dvh;
    align-items: flex-end;
    padding: 50dvh 0 6vh;
  }

  .spec div { grid-template-columns: 1fr; gap: 2px; }

  html.is-enhanced .lens {
    right: 12px;
    bottom: auto;
    top: 58px;
    width: min(34%, 150px);
    transform-origin: 100% 0;
  }

  html.is-enhanced .inside-note { font-size: 0.6rem; }

  html.is-enhanced .hud {
    left: 12px;
    top: 52px;
    bottom: auto;
    width: auto;
    max-width: calc(64% - 12px);
    padding: 8px 10px 7px;
  }

  .hud-row { grid-template-columns: 1fr; gap: 3px; }
  .hud-row p { display: flex; gap: 8px; align-items: baseline; }
  .hud-row b { font-size: 0.92rem; }
  .tape { margin-top: 6px; height: 5px; }
  .tape-note { display: none; }

  html.is-enhanced .rail {
    flex-direction: row;
    top: auto;
    bottom: calc(54dvh - 8px);
    right: 50%;
    transform: translateX(50%);
    gap: 9px;
    background: rgba(7, 6, 11, 0.35);
    padding: 6px 8px;
    border-radius: 999px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.is-enhanced .card { transition: none; }
}



/* Links into the 3D model */
.to-3d {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(231, 163, 148, 0.16);
  border: 1px solid rgba(231, 163, 148, 0.35);
  color: var(--coral-2);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
}
.to-3d:hover { background: rgba(231, 163, 148, 0.26); }

/* 3D model */
.model {
  width: min(1240px, 94vw);
  margin: 6vh auto 8vh;
  scroll-margin-top: 56px;
}

.model-head { max-width: 760px; margin-bottom: 18px; }
.model-head p:last-child { color: var(--muted); font-size: 1.02rem; margin: 0; }

.model-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

.model-stage {
  position: relative;
  height: min(78vh, 760px);
  min-height: 440px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse 60% 55% at 50% 45%, rgba(150, 70, 64, 0.22), transparent 70%),
    #0b0910;
}

#model-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: pan-y;
}
#model-canvas.is-dragging { cursor: grabbing; }

.model-labels { position: absolute; inset: 0; pointer-events: none; }

.model-labels button {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 6px;
  border-radius: 999px;
  border: 1px solid rgba(246, 232, 220, 0.18);
  background: rgba(10, 8, 12, 0.62);
  color: var(--ink);
  font: 500 0.74rem var(--sans);
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: opacity 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.model-labels button i {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  display: block;
  box-shadow: 0 0 8px currentColor;
}

.model-labels button.is-on {
  background: rgba(231, 163, 148, 0.3);
  border-color: rgba(243, 210, 196, 0.7);
}

.model-labels button.is-far { opacity: 0.45; }

.model-now {
  position: absolute;
  left: 16px;
  top: 14px;
  margin: 0;
  max-width: calc(100% - 90px);
  padding: 7px 12px;
  border-radius: 12px;
  background: rgba(10, 8, 12, 0.66);
  border: 1px solid var(--line);
  color: var(--coral-2);
  font-size: 0.86rem;
  pointer-events: none;
  backdrop-filter: blur(6px);
}
.model-now:empty { display: none; }

.model-zoom {
  position: absolute;
  right: 14px;
  top: 14px;
  display: grid;
  gap: 6px;
}

.model-zoom button, .model-controls button {
  font: 500 0.88rem var(--sans);
  color: var(--ink);
  background: rgba(20, 16, 20, 0.8);
  border: 1px solid rgba(246, 232, 220, 0.2);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.model-zoom button { width: 36px; height: 36px; padding: 0; font-size: 1.15rem; }

.model-controls button:hover, .model-zoom button:hover { border-color: rgba(243, 210, 196, 0.6); }
.model-controls button:focus-visible, .model-zoom button:focus-visible, .model-labels button:focus-visible, .m-stops button:focus-visible {
  outline: 2px solid var(--coral-2);
  outline-offset: 2px;
}

.model-controls button[aria-pressed="true"] {
  background: rgba(231, 163, 148, 0.24);
  border-color: rgba(243, 210, 196, 0.6);
}

.model-controls button.primary {
  background: var(--coral);
  color: #1a1214;
  border-color: transparent;
  font-weight: 600;
  min-width: 104px;
}

.model-fallback, .model-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}
.model-fallback[hidden], .model-loading[hidden] { display: none; }

.model-side {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--coral);
  border-radius: 18px;
  padding: 20px 20px 18px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.model-side h3 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 10px;
}

.model-side > p:not(.kicker) { color: var(--muted); margin: 0 0 6px; font-size: 0.96rem; }

.spec.compact { gap: 8px; margin-top: 10px; }
.spec.compact div { grid-template-columns: 1fr; gap: 2px; }
.spec.compact dd { font-size: 0.9rem; }

.m-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.m-stats p:last-child { grid-column: 1 / -1; }

.m-card {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--coral-2);
}
.m-card[hidden] { display: none; }

.model-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.scrub { flex: 1 1 260px; display: flex; }
.scrub input { width: 100%; accent-color: var(--coral); }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.m-stops {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 12px 0 0;
}

.m-stops button {
  font: 500 0.78rem var(--sans);
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
}

.m-stops button.is-on { color: #1a1214; background: var(--coral-2); border-color: transparent; }

@media (max-width: 900px) {
  .model-grid { grid-template-columns: 1fr; }
  .model-stage { height: 68vh; min-height: 380px; }
  .model-side { border-left-width: 1px; border-top: 3px solid var(--coral); }
}

@media (max-width: 800px) {
  .model { width: auto; margin: 4vh 16px 6vh; }
  .model-labels button { font-size: 0.66rem; padding: 2px 7px 2px 5px; }
  .model-now { font-size: 0.78rem; left: 10px; top: 10px; max-width: calc(100% - 64px); }
  .model-zoom { right: 10px; top: 10px; }
  .toggles { width: 100%; }
  .toggles button { flex: 1 1 auto; padding: 8px 10px; }
}
