:root {
  --deep-humus: #1C2418;
  --fern-shadow: #2D3A28;
  --moss-bed: #4A6741;
  --lichen-silver: #A8B5A0;
  --parchment-cream: #F0E8D8;
  --foxed-amber: #C4A265;
  --pressed-petal: #8B4E5A;
  --root-brown: #5C4033;
  --black: #000000;
  --scroll-pct: 0;
  --scroll-offset: 0px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--active-bg, #1C2418);
  color: var(--parchment-cream);
  font-family: "Lora", serif;
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  line-height: 1.75;
  letter-spacing: 0.01em;
  transition: background-color 700ms ease;
  overflow-x: hidden;
}

.filter-bank {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

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

.chapter {
  position: relative;
  min-height: 100vh;
  isolation: isolate;
  overflow: hidden;
  padding: 64px clamp(22px, 5vw, 80px);
}

.deckle {
  margin-top: -1px;
  clip-path: polygon(0% 0%, 2% 3%, 4% 1%, 6% 4%, 8% 2%, 10% 5%, 12% 2%, 14% 4%, 16% 1%, 18% 3%, 20% 1%, 22% 4%, 24% 2%, 26% 5%, 28% 2%, 30% 4%, 32% 1%, 34% 3%, 36% 0%, 38% 4%, 40% 2%, 42% 5%, 44% 1%, 46% 4%, 48% 2%, 50% 5%, 52% 1%, 54% 3%, 56% 0%, 58% 4%, 60% 2%, 62% 5%, 64% 1%, 66% 4%, 68% 2%, 70% 5%, 72% 1%, 74% 3%, 76% 0%, 78% 4%, 80% 2%, 82% 5%, 84% 1%, 86% 4%, 88% 2%, 90% 5%, 92% 1%, 94% 3%, 96% 0%, 98% 3%, 100% 0%, 100% 100%, 0% 100%);
}

.frontispiece {
  min-height: 100vh;
  background: #1C2418;
}

.front-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, transparent 50%, rgba(28,36,24,0.6) 100%);
  z-index: 2;
  pointer-events: none;
}

.botanical-svg {
  display: block;
  overflow: visible;
}

.front-vine {
  position: absolute;
  width: min(118vmin, 1040px);
  height: min(118vmin, 1040px);
  left: calc(61.8% - min(59vmin, 520px));
  top: calc(45% - min(59vmin, 520px));
  opacity: 0.92;
  transform: rotate(-8deg) scale(1.02);
}

.specimen-label {
  position: absolute;
  z-index: 3;
}

.front-label {
  left: 61.8%;
  top: 68%;
  transform: translate(-18%, -10%);
  max-width: 420px;
}

h1, h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-weight: 400;
  line-height: 1.1;
  color: #F0E8D8;
}

h1 {
  font-weight: 300;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  letter-spacing: calc(0.25em + (var(--scroll-pct) * 0.25em));
  text-transform: lowercase;
}

h2 {
  font-size: clamp(2rem, 5vw, 4rem);
  letter-spacing: 0.08em;
  margin-bottom: 40px;
}

p {
  margin: 0 0 24px;
}

em { color: #C4A265; }

.annotation {
  margin-bottom: 16px;
  font-family: "Karla", sans-serif;
  font-size: clamp(0.7rem, 1vw, 0.85rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6B7F5E;
}

.seed-indicator {
  position: absolute;
  z-index: 4;
  left: 38.2%;
  bottom: 11vh;
  width: 38px;
  height: 70px;
  animation: seedDrift 4s ease-in-out infinite;
}

@keyframes seedDrift {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  50% { transform: translate(10px, 30vh) rotate(15deg); opacity: 0.7; }
  100% { transform: translate(-5px, 60vh) rotate(-5deg); opacity: 0; }
}

.stem, .tendril, .fern-spine, .frond, .root {
  fill: none;
  stroke: #A8B5A0;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main-stem, .stem { stroke: #4A6741; }
.tendril { stroke: #C4A265; stroke-width: 2; opacity: 0.72; }
.leaf, .pressed-leaf {
  fill: url(#leafWash);
  stroke: #A8B5A0;
  stroke-width: 2;
}

.leaf.small { opacity: 0.82; }
.leaf.vein, .vein {
  fill: none;
  stroke: #C4A265;
  stroke-width: 1.4;
  opacity: 0.55;
}

.petal, .pressed-petal {
  fill: #8B4E5A;
  stroke: #C4A265;
  stroke-width: 1.5;
  opacity: 0.78;
}

.draw-botanical path {
  transition: stroke-dashoffset 2.5s cubic-bezier(0.25, 0.1, 0.25, 1), opacity 900ms ease, fill-opacity 900ms ease;
}

.draw-botanical:not(.is-drawn) path {
  stroke-dashoffset: var(--path-length, 900);
  fill-opacity: 0.05;
}

.draw-botanical.is-drawn path {
  stroke-dashoffset: 0;
  fill-opacity: 0.78;
}

.specimen {
  min-height: 100vh;
  background: #2D3A28;
  display: flex;
  align-items: center;
}

.plate-shell {
  position: relative;
  width: min(1100px, 100%);
  margin: 0 auto;
  min-height: 680px;
}

.plate-shell.reverse .float-illustration {
  float: right;
  margin: -64px -96px 24px 64px;
  shape-outside: ellipse(38% 48% at 54% 45%);
}

.float-illustration {
  width: min(52vw, 620px);
  max-width: calc(100% + 200px);
  float: left;
  margin: -40px 64px 24px -104px;
  shape-outside: ellipse(39% 47% at 45% 44%);
  shape-margin: 28px;
  filter: drop-shadow(2px 2px 0 rgba(92,64,51,0.15));
}

.fern .fern-spine {
  stroke: #C4A265;
  stroke-width: 6;
}

.frond {
  stroke: #4A6741;
  stroke-width: 3.5;
}

.specimen-text {
  position: relative;
  z-index: 2;
  width: min(720px, 100%);
  padding-top: 104px;
  color: #F0E8D8;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 300ms ease-out, transform 600ms ease-out;
}

.plate-right .specimen-text {
  margin-left: 0;
  padding-top: 88px;
}

.observe.is-visible .specimen-text,
.observe.is-visible .pressed-text,
.observe.is-visible .root-line,
.observe.is-visible .colophon-text {
  opacity: 1;
  transform: translateY(0);
}

.marginalia {
  position: absolute;
  width: 72px;
  height: 120px;
  opacity: 0.4;
  border-radius: 70% 15% 70% 15%;
  border: 1px solid #A8B5A0;
  transform: translateY(calc(var(--scroll-offset) * 0.3)) rotate(var(--r, -18deg));
  background: radial-gradient(ellipse at 55% 45%, rgba(168,181,160,0.22), transparent 58%);
}

.marginalia::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 8%;
  width: 1px;
  height: 84%;
  background: #A8B5A0;
  transform: rotate(16deg);
  opacity: 0.7;
}

.leafmark-one { --r: -22deg; right: 8%; top: 22%; }
.leafmark-two { --r: 31deg; left: 7%; bottom: 18%; }
.leafmark-three { --r: -39deg; right: 12%; bottom: 14%; }

.pressed-page {
  min-height: 100vh;
  color: #1C2418;
  background-color: #F0E8D8;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(196,162,101,0.14) 0 8px, transparent 9px),
    radial-gradient(circle at 78% 32%, rgba(196,162,101,0.10) 0 15px, transparent 16px),
    radial-gradient(circle at 44% 68%, rgba(196,162,101,0.13) 0 11px, transparent 12px),
    radial-gradient(circle at 87% 78%, rgba(196,162,101,0.09) 0 19px, transparent 20px),
    radial-gradient(circle at 25% 82%, rgba(92,64,51,0.08) 0 13px, transparent 14px),
    radial-gradient(ellipse at 50% 50%, rgba(240,232,216,0.84), rgba(196,162,101,0.12));
}

.pressed-page::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.03;
  filter: url(#paperGrain);
  background: #F0E8D8;
  pointer-events: none;
}

.pressed-specimen {
  width: min(1100px, 100%);
  min-height: calc(100vh - 128px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: 64px;
}

.pressed-flower {
  width: min(54vw, 680px);
  filter: drop-shadow(2px 2px 0 rgba(92,64,51,0.15));
}

.pressed, .pressed-leaf {
  stroke: #5C4033;
}

.pressed-leaf {
  fill: #4A6741;
  opacity: 0.55;
}

.pressed-petal { opacity: 0.58; }

.pressed-text {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 300ms ease-out, transform 600ms ease-out;
}

.pressed-text h2,
.pressed-text p { color: #1C2418; }
.pressed-text .annotation { color: #6B7F5E; }

.root-system {
  min-height: 100vh;
  background: #1C2418;
  padding-top: 0;
}

.roots {
  position: absolute;
  top: -7vh;
  left: 50%;
  width: min(112vw, 1250px);
  transform: translateX(-50%) translateY(calc(var(--scroll-offset) * -0.08));
  opacity: 0.9;
}

.root {
  stroke: #5C4033;
  stroke-width: 5;
  opacity: 0.9;
}

.root.trunk { stroke-width: 9; opacity: 1; }
.root.fine { stroke-width: 2; opacity: 0.35; }

.root-line {
  position: absolute;
  left: 38.2%;
  bottom: 13vh;
  width: min(560px, 54vw);
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 300ms ease-out, transform 600ms ease-out;
}

.colophon {
  min-height: 50vh;
  background: #000000;
  display: grid;
  place-items: center;
  padding: 104px 24px;
}

.colophon-leaf {
  position: absolute;
  width: min(34vw, 260px);
  opacity: 0.22;
  left: 61.8%;
  top: 12%;
  transform: rotate(28deg);
}

.colophon-text {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 300ms ease-out, transform 600ms ease-out;
}

.colophon h2 {
  font-weight: 300;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  letter-spacing: 0.25em;
  text-transform: lowercase;
}

@media (max-width: 768px) {
  .chapter { padding: 64px 22px; }
  .front-vine { transform: rotate(-8deg) scale(0.6); }
  .front-label { left: 38.2%; top: 64%; transform: none; }
  .seed-indicator { left: 61.8%; }
  .specimen { align-items: flex-start; }
  .plate-shell, .plate-shell.reverse { min-height: auto; }
  .float-illustration, .plate-shell.reverse .float-illustration {
    float: none;
    width: min(92vw, 520px);
    margin: 0 auto 24px;
    shape-outside: none;
  }
  .specimen-text { padding-top: 0; }
  .marginalia { transform: scale(0.6) rotate(var(--r, -18deg)); }
  .leafmark-three { display: none; }
  .pressed-specimen { display: block; }
  .pressed-flower { width: 92vw; margin-left: -8vw; }
  .root-line { left: 22px; width: calc(100% - 44px); }
}

@media (prefers-reduced-motion: reduce) {
  .marginalia, .roots { transform: none; }
}
