:root {
  /* IBM Plex Mono" from Google Fonts. Interaction should reward inspection rather than conversion. Hovering a marginal note can draw a line to a root node and trigger a soft ripple. Hovering a blob can reveal a small scholarly label such as “constraint boundary”. IntersectionObserver to update folio numbers. */
  --deep-fern: #101A14;
  --parchment: #EFE3C2;
  --amber: #FFB000;
  --teal: #237C72;
  --moss: #5F7F3A;
  --persimmon: #D76F45;
  --ink: #2B2118;
  --shadow: rgba(16, 26, 20, 0.42);
  --display: "Alegreya", Georgia, serif;
  --humanist: "Alegreya Sans", "Trebuchet MS", sans-serif;
  --mono: "IBM Plex Mono", "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--deep-fern);
  color: var(--ink);
  font-family: var(--humanist);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  background:
    repeating-linear-gradient(90deg, rgba(239, 227, 194, 0.035) 0 1px, transparent 1px 9px),
    radial-gradient(circle at 14% 22%, rgba(255, 176, 0, 0.08), transparent 28%),
    radial-gradient(circle at 82% 78%, rgba(35, 124, 114, 0.08), transparent 32%);
  mix-blend-mode: screen;
}

.codex { width: 100%; }

.chapter {
  --left: 58%;
  --accent: var(--amber);
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--left) 22px 1fr;
  position: relative;
  isolation: isolate;
  background: var(--parchment);
  overflow: hidden;
}

.chapter.ratio-narrow { --left: 42%; }
.chapter.ratio-wide { --left: 58%; }

.specimen-panel {
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 14%, rgba(35, 124, 114, 0.48), transparent 30%),
    radial-gradient(circle at 80% 74%, rgba(95, 127, 58, 0.3), transparent 28%),
    linear-gradient(145deg, #101A14 0%, #13281E 62%, #237C72 160%);
  overflow: hidden;
}

.specimen-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(239, 227, 194, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(239, 227, 194, 0.035) 1px, transparent 1px);
  background-size: 74px 74px;
  opacity: 0.45;
}

.organic-field { position: absolute; inset: 0; }

.ledger-panel {
  position: relative;
  min-height: 100vh;
  padding: clamp(4rem, 8vw, 7.5rem) clamp(2rem, 5vw, 5.5rem);
  background:
    linear-gradient(90deg, rgba(43, 33, 24, 0.08), transparent 18%),
    radial-gradient(circle at 72% 20%, rgba(255, 176, 0, 0.15), transparent 25%),
    var(--parchment);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ledger-panel::before {
  content: "";
  position: absolute;
  top: 5vh;
  bottom: 5vh;
  left: clamp(1rem, 2vw, 2rem);
  width: 1px;
  background: linear-gradient(var(--amber), transparent, var(--teal));
  opacity: 0.55;
}

.spine {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--ink), var(--teal) 50%, var(--ink));
  position: relative;
  box-shadow: 0 0 32px rgba(255, 176, 0, 0.25);
}

.spine::before {
  content: "";
  position: absolute;
  inset: 0 8px;
  background: repeating-linear-gradient(180deg, var(--amber) 0 6px, transparent 6px 18px);
  opacity: 0.75;
  animation: spineShimmer 4s ease-in-out infinite;
}

.spine span {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% var(--pulse-y, 30%), rgba(255, 176, 0, 0.8), transparent 12%);
  filter: blur(4px);
}

.fixed-bookplate {
  position: fixed;
  top: 22px;
  left: 24px;
  z-index: 40;
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 9px 13px;
  border: 1px solid rgba(239, 227, 194, 0.35);
  background: rgba(16, 26, 20, 0.72);
  color: var(--parchment);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.book-index {
  position: fixed;
  top: 50%;
  left: calc(58% - 16px);
  transform: translateY(-50%);
  z-index: 35;
  display: grid;
  gap: 13px;
  transition: left 0.7s ease;
}

.book-index.narrow { left: calc(42% - 16px); }

.index-tab {
  width: 32px;
  height: 46px;
  border: 1px solid rgba(255, 176, 0, 0.55);
  border-left: 0;
  background: rgba(239, 227, 194, 0.82);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  cursor: pointer;
  transform: translateX(-9px);
  transition: transform 0.35s ease, background 0.35s ease;
}

.index-tab.active { background: var(--amber); transform: translateX(2px); }

.kicker, .folio, .stamp, .specimen-label, .marginal-note, .footnote {
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kicker {
  color: var(--teal);
  font-size: clamp(0.72rem, 1vw, 0.86rem);
  margin-bottom: 1rem;
}

.folio {
  position: absolute;
  top: 32px;
  right: 34px;
  color: rgba(43, 33, 24, 0.56);
  font-size: 0.75rem;
}

h1, h2 {
  font-family: var(--display);
  color: var(--ink);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.045em;
  font-size: clamp(4.8rem, 10vw, 12rem);
  margin-bottom: 1.6rem;
  max-width: 7ch;
}

h2 { font-size: clamp(4rem, 8vw, 9rem); max-width: 8ch; }

.lead {
  font-size: clamp(1.35rem, 2vw, 2.15rem);
  line-height: 1.18;
  color: var(--ink);
  max-width: 720px;
  margin-bottom: 2rem;
}

.bookplate-card {
  max-width: 560px;
  border: 1px solid rgba(43, 33, 24, 0.28);
  border-left: 5px solid var(--amber);
  padding: 1.1rem 1.2rem;
  background: rgba(239, 227, 194, 0.56);
  box-shadow: 8px 8px 0 rgba(43, 33, 24, 0.08);
}

.bookplate-card.persimmon { border-left-color: var(--persimmon); }
.bookplate-card p, .footnote { font-size: 1.08rem; line-height: 1.45; margin-top: 0.6rem; }
.stamp { color: var(--persimmon); font-size: 0.72rem; font-weight: 600; }

.annotation-stack { display: grid; gap: 1rem; justify-items: start; }

.marginal-note {
  margin-top: 1rem;
  width: fit-content;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--teal);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.2rem 0;
}

.marginal-note:hover { color: var(--persimmon); }

.closing-seal {
  width: 168px;
  height: 168px;
  display: grid;
  place-items: center;
  margin: 1rem 0;
  border-radius: 50%;
  border: 2px solid var(--persimmon);
  color: var(--persimmon);
  font-family: var(--mono);
  text-transform: uppercase;
  transform: rotate(-12deg);
  background: rgba(215, 111, 69, 0.08);
}

.blob {
  position: absolute;
  border: 1px solid rgba(239, 227, 194, 0.15);
  background: radial-gradient(circle at 34% 26%, rgba(239, 227, 194, 0.18), transparent 22%), rgba(35, 124, 114, 0.34);
  box-shadow: inset 0 0 54px rgba(255, 176, 0, 0.13), 0 0 70px rgba(35, 124, 114, 0.28);
  animation: morphBlob 12s ease-in-out infinite alternate;
  cursor: crosshair;
}

.blob-a { width: 36vw; height: 48vh; left: -8vw; top: 10vh; border-radius: 54% 46% 62% 38% / 42% 58% 42% 58%; }
.blob-b { width: 27vw; height: 34vh; right: 6vw; bottom: 10vh; border-radius: 32% 68% 42% 58% / 64% 38% 62% 36%; animation-delay: -4s; background-color: rgba(95, 127, 58, 0.35); }
.blob-c { width: 20vw; height: 20vw; left: 40%; top: 18%; border-radius: 60% 40% 45% 55% / 44% 54% 46% 56%; animation-delay: -7s; }
.blob-d { width: 32vw; height: 56vh; left: -11vw; top: 19vh; border-radius: 38% 62% 64% 36% / 44% 58% 42% 56%; }
.blob-e { width: 22vw; height: 24vh; right: 5vw; top: 12vh; border-radius: 70% 30% 54% 46% / 48% 70% 30% 52%; background-color: rgba(255, 176, 0, 0.12); }
.blob-f { width: 42vw; height: 38vh; left: 7vw; top: 28vh; border-radius: 66% 34% 49% 51% / 36% 48% 52% 64%; background-color: rgba(215, 111, 69, 0.22); }
.blob-g { width: 18vw; height: 44vh; right: 0; top: 8vh; border-radius: 48% 52% 30% 70% / 56% 42% 58% 44%; }
.blob-h { width: 34vw; height: 44vh; left: -4vw; top: 20vh; border-radius: 45% 55% 68% 32% / 60% 40% 56% 44%; }
.blob-i { width: 24vw; height: 31vh; right: 10vw; bottom: 10vh; border-radius: 60% 40% 34% 66% / 46% 54% 42% 58%; background-color: rgba(95, 127, 58, 0.28); }

.root-map {
  position: absolute;
  inset: 4vh 2vw;
  width: calc(100% - 4vw);
  height: 92vh;
  fill: none;
  stroke: rgba(95, 127, 58, 0.9);
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(255, 176, 0, 0.14));
}

.root-map path { stroke-dasharray: 9 14; animation: rootTravel 18s linear infinite; }

.root-node {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 8px rgba(255, 176, 0, 0.12), 0 0 28px rgba(255, 176, 0, 0.6);
  z-index: 4;
}

.node-one { left: 31%; top: 50%; }
.node-two { left: 58%; top: 19%; }
.node-three { left: 70%; top: 38%; }
.node-four { left: 26%; top: 63%; }
.node-five { left: 54%; top: 34%; }
.node-six { left: 45%; top: 49%; }
.node-seven { left: 73%; top: 23%; }

.ripple {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 1px solid rgba(255, 176, 0, 0.7);
  z-index: 3;
  animation: ripple 4.8s ease-out infinite;
}
.ripple::after, .ripple::before { content: ""; position: absolute; inset: 26px; border-radius: 50%; border: 1px solid rgba(35, 124, 114, 0.75); }
.ripple::before { inset: 54px; border-color: rgba(255, 176, 0, 0.38); }
.ripple-one { left: calc(31% - 90px); top: calc(50% - 90px); }
.ripple-two { left: calc(58% - 90px); top: calc(19% - 90px); animation-delay: -2s; }
.ripple-three { left: calc(70% - 90px); top: calc(38% - 90px); }
.ripple-four { left: calc(54% - 90px); top: calc(34% - 90px); border-color: rgba(215, 111, 69, 0.75); }
.ripple-five { left: calc(45% - 90px); top: calc(49% - 90px); }

.specimen-label {
  position: absolute;
  z-index: 5;
  color: var(--parchment);
  background: rgba(16, 26, 20, 0.64);
  border: 1px solid rgba(239, 227, 194, 0.24);
  padding: 0.55rem 0.7rem;
  font-size: 0.68rem;
}
.specimen-label::after { content: ""; position: absolute; top: 50%; left: 100%; width: 12vw; height: 1px; background: rgba(255, 176, 0, 0.56); }
.label-root { left: 12%; top: 18%; }
.label-canopy { left: 18%; top: 76%; }
.label-surface { left: 9%; top: 17%; }
.label-continuity { left: 14%; top: 74%; }

.boundary-grid {
  position: absolute;
  inset: 8vh 8vw;
  border: 1px solid rgba(215, 111, 69, 0.38);
  background: repeating-linear-gradient(90deg, rgba(215, 111, 69, 0.18) 0 1px, transparent 1px 28px);
  opacity: 0.65;
}

.hover-label {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  padding: 0.45rem 0.65rem;
  background: var(--parchment);
  border: 1px solid var(--amber);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: opacity 0.18s ease;
}
.hover-label.visible { opacity: 1; }

.chapter.page-turn .ledger-panel { animation: pageTurn 0.8s ease both; }
.chapter.active .index-tab { transform: translateX(2px); }

@keyframes morphBlob {
  0% { transform: translate3d(0, 0, 0) scale(1); filter: blur(0); }
  50% { border-radius: 37% 63% 46% 54% / 57% 35% 65% 43%; }
  100% { transform: translate3d(18px, -12px, 0) scale(1.04); filter: blur(0.5px); }
}

@keyframes ripple {
  0% { transform: scale(0.45); opacity: 0; }
  18% { opacity: 1; }
  100% { transform: scale(2.25); opacity: 0; }
}

@keyframes rootTravel { to { stroke-dashoffset: -220; } }
@keyframes spineShimmer { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.95; } }
@keyframes pageTurn { 0% { transform: translateX(32px); opacity: 0.72; } 100% { transform: translateX(0); opacity: 1; } }

@media (max-width: 900px) {
  .chapter, .chapter.ratio-narrow, .chapter.ratio-wide { grid-template-columns: 1fr; grid-template-rows: 48vh 16px auto; }
  .specimen-panel, .ledger-panel, .spine { min-height: auto; }
  .ledger-panel { min-height: 52vh; padding: 4rem 1.6rem; }
  .spine { height: 16px; }
  .spine::before { inset: 5px 0; background: repeating-linear-gradient(90deg, var(--amber) 0 6px, transparent 6px 18px); }
  .book-index, .book-index.narrow { left: auto; right: 14px; }
  h1, h2 { font-size: clamp(3.6rem, 16vw, 6.2rem); }
  .fixed-bookplate { left: 12px; top: 12px; }
}
