:root {
  --deep-canopy: #06251B;
  --moss-glass: #1F6B4A;
  --fern-glow: #8EE6B0;
  --pond-mint: #C8F7DC;
  --lichen-cream: #F1E8C8;
  --wet-slate: #183A35;
  --spore-amber: #D8A441;
  --scroll-progress: 0;
  --wave-boost: 0;
  --IntersectionObserver-chapter-state-changes: 1;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--deep-canopy);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--pond-mint);
  font-family: "IBM Plex Sans", Inter, sans-serif;
  font-weight: 400;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 10%, rgba(142, 230, 176, 0.16), transparent 32rem),
    radial-gradient(circle at 86% 24%, rgba(216, 164, 65, 0.09), transparent 26rem),
    radial-gradient(circle at 48% 62%, rgba(31, 107, 74, 0.32), transparent 34rem),
    linear-gradient(135deg, #06251B 0%, #0a2d21 48%, #183A35 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, rgba(200, 247, 220, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(200, 247, 220, 0.025) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
  z-index: 0;
}

.rain-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.55;
  background:
    radial-gradient(circle, rgba(241, 232, 200, 0.16) 0 1px, transparent 1.4px) 0 0 / 31px 37px,
    radial-gradient(circle, rgba(142, 230, 176, 0.12) 0 1px, transparent 1.6px) 11px 19px / 47px 53px,
    repeating-linear-gradient(100deg, transparent 0 44px, rgba(200, 247, 220, 0.035) 45px 46px, transparent 47px 100px);
}

.forest-depth {
  position: fixed;
  inset: auto -5vw 0 -5vw;
  height: 70vh;
  z-index: 0;
  opacity: 0.24;
  transform: translate3d(0, calc(var(--scroll-progress) * -80px), 0);
  pointer-events: none;
}

.forest-depth svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--fern-glow);
  stroke-width: 2;
  stroke-linecap: round;
  filter: drop-shadow(0 0 16px rgba(142, 230, 176, 0.14));
}

.quest-trail {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 620vh;
  min-height: 5200px;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}

.trail-shadow,
.trail-line,
.branch {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trail-shadow {
  stroke: rgba(6, 37, 27, 0.84);
  stroke-width: 12;
  filter: blur(9px);
}

.trail-line {
  stroke: var(--fern-glow);
  stroke-width: calc(3px + var(--wave-boost) * 2px);
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--scroll-progress));
  filter: drop-shadow(0 0 calc(9px + var(--wave-boost) * 12px) rgba(142, 230, 176, 0.72));
}

.branch {
  stroke: rgba(216, 164, 65, 0.5);
  stroke-width: 2;
  stroke-dasharray: 9 16;
  animation: branchPulse 5s ease-in-out infinite;
}

.branch-b { animation-delay: -1.6s; }
.branch-c { animation-delay: -3s; }

.specimen-nav {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.specimen-nav a,
.field-tag,
.floating-label,
.final-stamp,
.micro-label {
  font-family: "IBM Plex Mono", "Space Mono", monospace;
  letter-spacing: 0.02em;
}

.specimen-nav a,
.field-tag {
  color: var(--lichen-cream);
  text-decoration: none;
  border: 1px solid rgba(200, 247, 220, 0.24);
  background: rgba(31, 107, 74, 0.2);
  backdrop-filter: blur(18px) saturate(1.25);
  box-shadow: inset 0 1px 0 rgba(241, 232, 200, 0.12), 0 12px 32px rgba(0, 0, 0, 0.18);
}

.specimen-nav a {
  padding: 8px 10px;
  font-size: 11px;
  writing-mode: vertical-rl;
  border-radius: 999px;
  opacity: 0.72;
  transition: opacity 260ms ease, color 260ms ease, border-color 260ms ease, transform 260ms ease;
}

.specimen-nav a.active,
.specimen-nav a:hover {
  opacity: 1;
  color: var(--fern-glow);
  border-color: rgba(142, 230, 176, 0.65);
  transform: translateX(-3px);
}

main {
  position: relative;
  z-index: 3;
}

.chapter {
  min-height: 104vh;
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
  padding: clamp(36px, 6vw, 86px);
  isolation: isolate;
}

.chapter::before {
  content: attr(data-chapter);
  position: absolute;
  left: clamp(18px, 3vw, 44px);
  top: 34px;
  font-family: "Space Mono", monospace;
  font-size: clamp(52px, 12vw, 180px);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: rgba(200, 247, 220, 0.035);
  z-index: -1;
}

.glass-pane,
.lens,
.diagram,
.notebook {
  background: rgba(31, 107, 74, 0.22);
  backdrop-filter: blur(18px) saturate(1.25);
  border: 1px solid rgba(200, 247, 220, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(241, 232, 200, 0.12),
    inset 0 -18px 48px rgba(6, 37, 27, 0.17),
    0 28px 80px rgba(0, 0, 0, 0.28);
  position: relative;
  overflow: hidden;
  transform: translate3d(0, var(--parallax, 0px), 0);
  transition: border-color 300ms ease, box-shadow 300ms ease, background 300ms ease;
}

.glass-pane::before,
.lens::before,
.diagram::before,
.notebook::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 12%, rgba(241, 232, 200, 0.18), transparent 18%),
    repeating-linear-gradient(98deg, transparent 0 22px, rgba(200, 247, 220, 0.045) 23px 24px, transparent 25px 80px);
  opacity: 0.72;
}

.glass-pane:hover,
.lens:hover,
.diagram:hover,
.notebook:hover,
.pane-hot {
  border-color: rgba(142, 230, 176, 0.58);
  background: rgba(31, 107, 74, 0.3);
  box-shadow:
    inset 0 1px 0 rgba(241, 232, 200, 0.18),
    inset 0 -18px 58px rgba(142, 230, 176, 0.08),
    0 34px 96px rgba(0, 0, 0, 0.33),
    0 0 32px rgba(142, 230, 176, 0.16);
}

.micro-label {
  display: inline-block;
  color: var(--lichen-cream);
  font-size: 12px;
  text-transform: lowercase;
  margin-bottom: 18px;
}

h1,
h2 {
  font-family: "Space Mono", monospace;
  margin: 0;
  letter-spacing: -0.04em;
  line-height: 0.92;
}

h1 {
  font-size: clamp(58px, 10vw, 148px);
  color: var(--pond-mint);
  text-shadow: 0 0 30px rgba(142, 230, 176, 0.22);
}

h2 {
  font-size: clamp(38px, 6vw, 86px);
  color: var(--pond-mint);
  max-width: 850px;
}

p {
  font-size: clamp(17px, 1.5vw, 22px);
  line-height: 1.55;
  color: rgba(200, 247, 220, 0.87);
  max-width: 620px;
}

.field-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

button.field-tag {
  font: inherit;
  font-family: "IBM Plex Mono", monospace;
}

.field-tag:hover {
  color: var(--deep-canopy);
  background: var(--fern-glow);
  border-color: var(--fern-glow);
}

.canopy {
  min-height: 100vh;
  align-items: end;
}

.hero-copy {
  grid-column: 1 / 8;
  align-self: end;
  margin-bottom: 4vh;
  padding: clamp(24px, 4vw, 54px);
  border-radius: 42px 72px 36px 28px;
}

.hero-copy p {
  font-size: clamp(20px, 2.4vw, 32px);
}

.giant-lens {
  grid-column: 8 / 13;
  align-self: start;
  justify-self: end;
  width: min(44vw, 520px);
  aspect-ratio: 1;
  border-radius: 50%;
  margin-top: 5vh;
}

.giant-lens span,
.leaf-lens span,
.ruler-lens span {
  position: absolute;
  left: 28px;
  bottom: 24px;
  color: var(--lichen-cream);
}

.edge-note,
.floating-label,
.final-stamp {
  position: absolute;
  color: rgba(241, 232, 200, 0.78);
  font-size: 12px;
  border-left: 1px solid rgba(216, 164, 65, 0.55);
  padding: 8px 0 8px 12px;
}

.edge-note {
  right: 16vw;
  bottom: 11vh;
}

.notice {
  align-items: center;
}

.note-pane {
  grid-column: 2 / 7;
  padding: clamp(24px, 4vw, 48px);
  border-radius: 28px 60px 44px 28px;
}

.leaf-lens {
  grid-column: 6 / 12;
  height: min(52vw, 500px);
  border-radius: 46% 54% 35% 65%;
  margin-top: 20vh;
}

.scribble {
  color: var(--lichen-cream);
  font-family: "Space Mono", monospace;
  font-size: 15px;
}

.disturb {
  align-items: center;
}

.beaker-pane {
  grid-column: 1 / 6;
  height: 620px;
  border-radius: 64px 36px 80px 40px;
  transform: rotate(-2deg) translate3d(0, var(--parallax, 0px), 0);
}

.offset-pane {
  grid-column: 7 / 12;
  padding: clamp(26px, 4vw, 54px);
  border-radius: 70px 30px 34px 56px;
  margin-top: -10vh;
}

.floating-label {
  right: 12vw;
  bottom: 18vh;
}

.measure {
  align-items: center;
}

.measure-pane {
  grid-column: 2 / 8;
  padding: clamp(26px, 4vw, 54px);
  border-radius: 34px 78px 44px 34px;
}

.ruler-lens {
  grid-column: 7 / 13;
  height: 420px;
  border-radius: 40px 40px 90px 36px;
  margin-top: 34vh;
}

.field-list {
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
  display: grid;
  gap: 12px;
  color: rgba(200, 247, 220, 0.82);
}

.field-list li {
  border-top: 1px dotted rgba(200, 247, 220, 0.28);
  padding-top: 12px;
}

.field-list span {
  font-family: "IBM Plex Mono", monospace;
  color: var(--spore-amber);
  margin-right: 14px;
}

.wonder {
  align-items: center;
}

.orbit-pane {
  grid-column: 1 / 7;
  height: 560px;
  border-radius: 50%;
}

.wonder-pane {
  grid-column: 6 / 12;
  padding: clamp(26px, 4vw, 58px);
  border-radius: 42px 84px 40px 68px;
  margin-top: 18vh;
}

.amber {
  color: var(--spore-amber);
}

.return {
  min-height: 110vh;
  align-items: center;
}

.notebook {
  grid-column: 3 / 11;
  padding: clamp(32px, 6vw, 74px);
  border-radius: 30px 30px 80px 30px;
  background:
    linear-gradient(90deg, rgba(241, 232, 200, 0.08) 0 1px, transparent 1px) 0 0 / 38px 38px,
    rgba(31, 107, 74, 0.25);
}

.question-line {
  margin: 34px 0 24px;
  padding: 22px;
  border: 1px dashed rgba(216, 164, 65, 0.52);
  border-radius: 18px;
  color: var(--lichen-cream);
  font-family: "Space Mono", monospace;
  font-size: clamp(18px, 2vw, 28px);
  line-height: 1.4;
}

#questionSeed {
  color: var(--fern-glow);
}

.final-stamp {
  left: 12vw;
  bottom: 12vh;
}

.diagram svg,
.lens svg {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
  fill: none;
  stroke: rgba(200, 247, 220, 0.82);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.diagram circle,
.lens circle {
  stroke: rgba(142, 230, 176, 0.72);
}

.osc,
.wave {
  stroke: var(--fern-glow);
  filter: drop-shadow(0 0 12px rgba(142, 230, 176, 0.58));
  animation: waveBreathe 3.8s ease-in-out infinite;
}

.experiment-live .osc,
.experiment-live .wave,
.experiment-live .trail-line {
  animation-duration: 1.3s;
}

.leaf,
.liquid {
  fill: rgba(142, 230, 176, 0.08);
}

.gridline,
.ticks path {
  stroke: rgba(241, 232, 200, 0.48);
}

.amber-dot {
  fill: var(--spore-amber);
  stroke: var(--spore-amber);
  filter: drop-shadow(0 0 16px rgba(216, 164, 65, 0.85));
}

.chapter:not(.visible) .glass-pane,
.chapter:not(.visible) .diagram,
.chapter:not(.visible) .lens,
.chapter:not(.visible) .notebook {
  opacity: 0.58;
}

.chapter.visible .glass-pane,
.chapter.visible .diagram,
.chapter.visible .lens,
.chapter.visible .notebook {
  animation: paneArrive 850ms ease both;
}

@keyframes waveBreathe {
  0%, 100% { stroke-dasharray: 1 0; transform: translateX(0); }
  50% { stroke-dasharray: 10 3; transform: translateX(5px); }
}

@keyframes branchPulse {
  0%, 100% { opacity: 0.28; stroke-dashoffset: 0; }
  50% { opacity: 0.85; stroke-dashoffset: -24; }
}

@keyframes paneArrive {
  from { opacity: 0.35; filter: blur(3px); }
  to { opacity: 1; filter: blur(0); }
}

@media (max-width: 900px) {
  .specimen-nav { display: none; }
  .chapter {
    min-height: auto;
    padding: 72px 20px;
    display: flex;
    flex-direction: column;
  }
  .hero-copy,
  .note-pane,
  .offset-pane,
  .measure-pane,
  .wonder-pane,
  .notebook,
  .giant-lens,
  .leaf-lens,
  .beaker-pane,
  .ruler-lens,
  .orbit-pane {
    width: 100%;
    margin: 0;
    grid-column: auto;
  }
  .giant-lens,
  .leaf-lens,
  .orbit-pane { height: auto; aspect-ratio: 1; }
  .beaker-pane,
  .ruler-lens { height: 420px; }
  .edge-note,
  .floating-label,
  .final-stamp { position: relative; inset: auto; margin: 18px 0; }
  .quest-trail { opacity: 0.46; }
}
