:root {
  /* Typography compliance note: IBM Plex Sans** Sans* keeps diagrams clean without becoming technical. Source Serif 4** 4* anchors bookish body text. */
  --deep-canopy: #123A2A;
  --fern: #2F6B46;
  --moss: #8CBF75;
  --paper: #F4E8CF;
  --lichen: #DDE8C8;
  --clay: #D99A73;
  --plum: #3B2636;
  --serif-display: "Cormorant Garamond", Georgia, serif;
  --serif-body: "Source Serif 4", Georgia, serif;
  --label: "Fraunces", Georgia, serif;
  --sans: "IBM Plex Sans", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--deep-canopy);
  background:
    radial-gradient(circle at 86% 12%, rgba(140, 191, 117, 0.28), transparent 24vw),
    radial-gradient(circle at 18% 86%, rgba(217, 154, 115, 0.22), transparent 28vw),
    linear-gradient(115deg, var(--paper), #f8edd8 62%, var(--lichen));
  font-family: var(--serif-body);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    radial-gradient(var(--deep-canopy) 0.7px, transparent 0.8px),
    radial-gradient(var(--clay) 0.6px, transparent 0.7px);
  background-position: 0 0, 13px 17px;
  background-size: 31px 31px, 47px 47px;
  mix-blend-mode: multiply;
}

a,
button {
  color: inherit;
}

button {
  font: inherit;
}

.field-guide {
  position: relative;
  height: 100vh;
  width: 100vw;
  padding-left: clamp(84px, 10vw, 142px);
  isolation: isolate;
}

.story-rail {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  width: clamp(76px, 9vw, 124px);
  height: 100vh;
  padding: 26vh 18px 8vh;
  background: linear-gradient(180deg, var(--deep-canopy), #163e2b 62%, var(--fern));
  color: var(--paper);
  box-shadow: 12px 0 36px rgba(18, 58, 42, 0.22);
}

.rail-line {
  position: absolute;
  top: 18vh;
  bottom: 6vh;
  left: 50%;
  width: 2px;
  background: linear-gradient(var(--clay), var(--lichen), var(--moss));
  opacity: 0.55;
}

.rail-mark {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  margin: 0 0 6vh;
  padding: 9px 9px 10px;
  text-decoration: none;
  border: 1px solid rgba(244, 232, 207, 0.22);
  border-radius: 999px 999px 16px 16px;
  background: rgba(244, 232, 207, 0.06);
  text-align: center;
  transition: transform 420ms ease, background 420ms ease, color 420ms ease;
}

.rail-mark::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--moss);
  transform: translate(-50%, -50%) scale(0);
  box-shadow: 0 0 0 9px rgba(140, 191, 117, 0.18);
  transition: transform 420ms ease;
}

.rail-mark span {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.16em;
  opacity: 0.78;
}

.rail-mark b {
  font-family: var(--label);
  font-size: clamp(12px, 1.1vw, 15px);
  font-weight: 650;
  letter-spacing: 0.04em;
}

.rail-mark.active {
  color: var(--deep-canopy);
  background: var(--paper);
  transform: translateX(14px);
}

.rail-mark.active::before {
  transform: translate(-50%, -50%) scale(1);
}

.orientation-shelf {
  position: fixed;
  z-index: 16;
  top: clamp(18px, 3.6vh, 42px);
  left: clamp(112px, 13vw, 178px);
  right: clamp(18px, 3vw, 42px);
  min-height: 118px;
  display: grid;
  grid-template-columns: minmax(240px, 0.85fr) minmax(240px, 1.1fr) auto;
  align-items: center;
  gap: clamp(18px, 3vw, 42px);
  padding: 18px clamp(18px, 3vw, 38px);
  background: rgba(244, 232, 207, 0.83);
  border: 1px solid rgba(18, 58, 42, 0.14);
  border-radius: 30px;
  box-shadow: 0 24px 58px rgba(18, 58, 42, 0.13);
  backdrop-filter: blur(8px);
}

.shelf-kicker,
.chapter-label,
.labels text,
.magnifier-label {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.shelf-kicker {
  margin: 0 0 -8px;
  color: var(--fern);
  font-size: 11px;
  font-weight: 600;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--deep-canopy);
  font-family: var(--serif-display);
  font-size: clamp(54px, 7vw, 108px);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 0.82;
}

.definition {
  max-width: 560px;
  color: var(--plum);
  font-size: clamp(17px, 1.45vw, 23px);
  line-height: 1.28;
}

.token-row {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: end;
}

.token {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: transform 360ms ease, filter 360ms ease;
}

.token::before {
  content: "";
  position: absolute;
  inset: 5px;
  background: var(--fern);
  box-shadow: 0 8px 0 rgba(18, 58, 42, 0.11), 0 0 0 0 rgba(140, 191, 117, 0);
  transition: box-shadow 360ms ease, background 360ms ease, transform 360ms ease;
}

.token span {
  position: absolute;
  top: 47px;
  left: 50%;
  color: var(--deep-canopy);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateX(-50%) translateY(-4px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.token:hover,
.token.focused {
  transform: translateY(-5px) scale(1.14);
  filter: saturate(1.1);
}

.token:hover::before,
.token.focused::before {
  background: var(--moss);
  box-shadow: 0 8px 0 rgba(18, 58, 42, 0.1), 0 0 0 13px rgba(140, 191, 117, 0.28);
}

.token:hover span,
.token.focused span {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.token.circle::before { border-radius: 50%; }
.token.square::before { border-radius: 7px; background: var(--clay); }
.token.triangle::before { clip-path: polygon(50% 4%, 96% 92%, 4% 92%); background: var(--moss); }
.token.hex::before { clip-path: polygon(25% 6%, 75% 6%, 100% 50%, 75% 94%, 25% 94%, 0 50%); }
.token.arch::before { border-radius: 50% 50% 6px 6px; background: var(--plum); }

.panel {
  position: absolute;
  inset: 0 0 0 clamp(84px, 10vw, 142px);
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(260px, 0.46fr) minmax(420px, 1fr);
  align-items: end;
  gap: clamp(18px, 3vw, 58px);
  padding: clamp(178px, 22vh, 230px) clamp(20px, 3.2vw, 52px) clamp(36px, 6vh, 72px) clamp(24px, 3vw, 46px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(28px) scale(0.985);
  transition: opacity 760ms ease, transform 760ms ease;
}

.panel.active {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.panel::before {
  content: "";
  position: absolute;
  top: 25vh;
  left: clamp(18px, 3vw, 52px);
  width: 118px;
  height: 34vh;
  border-left: 2px dashed rgba(47, 107, 70, 0.25);
  border-top: 2px dashed rgba(47, 107, 70, 0.25);
  pointer-events: none;
}

.panel-copy {
  position: relative;
  z-index: 2;
  align-self: center;
  max-width: 470px;
  padding: 26px 26px 29px;
  background: rgba(244, 232, 207, 0.72);
  border: 1px solid rgba(18, 58, 42, 0.13);
  border-radius: 28px 28px 28px 8px;
  box-shadow: 0 18px 52px rgba(18, 58, 42, 0.11);
}

.panel-copy::after {
  content: "";
  position: absolute;
  right: 22px;
  top: -18px;
  width: 82px;
  height: 34px;
  background: var(--clay);
  opacity: 0.65;
  clip-path: polygon(0 0, 100% 0, 84% 100%, 13% 100%);
}

.chapter-label {
  display: inline-block;
  margin-bottom: 15px;
  color: var(--fern);
  font-size: 11px;
  font-weight: 600;
}

h2 {
  margin-bottom: 18px;
  color: var(--deep-canopy);
  font-family: var(--serif-display);
  font-size: clamp(46px, 5.8vw, 88px);
  font-weight: 700;
  line-height: 0.88;
  letter-spacing: -0.045em;
}

.panel[data-theme="shift"] h2,
.panel[data-theme="open"] h2 {
  color: var(--plum);
}

.panel-copy p {
  color: rgba(18, 58, 42, 0.88);
  font-size: clamp(18px, 1.5vw, 24px);
  line-height: 1.38;
}

.diagram-band {
  position: relative;
  z-index: 1;
  align-self: end;
  min-height: min(54vh, 540px);
  display: grid;
  place-items: center;
  border-radius: 34px;
  background:
    linear-gradient(90deg, rgba(221, 232, 200, 0.72), rgba(244, 232, 207, 0.52)),
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(47, 107, 70, 0.045) 35px 36px);
  border: 1px solid rgba(18, 58, 42, 0.12);
  box-shadow: inset 0 0 0 12px rgba(244, 232, 207, 0.28), 0 28px 70px rgba(18, 58, 42, 0.16);
  overflow: hidden;
  transform-origin: 65% 52%;
  transition: transform 900ms cubic-bezier(.2,.72,.08,1), box-shadow 900ms ease;
}

.panel.active .diagram-band {
  animation: bandSettle 920ms cubic-bezier(.2,.72,.08,1) both;
}

.diagram-band::before,
.diagram-band::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 999px;
}

.diagram-band::before {
  width: 36vmin;
  height: 36vmin;
  right: -9vmin;
  top: -9vmin;
  background: rgba(140, 191, 117, 0.28);
}

.diagram-band::after {
  width: 22vmin;
  height: 22vmin;
  left: 8%;
  bottom: -6vmin;
  background: rgba(217, 154, 115, 0.22);
}

.diagram-svg {
  width: min(100%, 1040px);
  height: auto;
  overflow: visible;
}

.paper-field {
  fill: var(--lichen);
  stroke: rgba(18, 58, 42, 0.16);
  stroke-width: 2;
}

.seed-path,
.glyph path {
  fill: none;
  stroke: var(--paper);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 4px 0 rgba(18, 58, 42, 0.08));
}

.seed-path.wide {
  stroke-width: 18;
}

.glyph circle,
.grove,
.side-grove circle,
.idea-cells circle {
  fill: var(--fern);
  filter: drop-shadow(0 9px 0 rgba(18, 58, 42, 0.1));
}

.glyph path {
  stroke-width: 7;
}

.focus-source {
  transform-origin: 592px 210px;
}

.panel.active .focus-source {
  animation: glyphZoom 1200ms cubic-bezier(.22,.82,.12,1) 180ms both;
}

.leaf,
.plot,
.marker,
.doorway,
.nested-plots rect,
.nested-plots polygon,
.idea-cells polygon,
.seed-packets rect,
.leaf-border polygon {
  filter: drop-shadow(0 9px 0 rgba(18, 58, 42, 0.1));
}

.leaf.clay,
.grove.peach,
.seed-packets rect:first-child {
  fill: var(--clay);
}

.leaf.moss,
.plot,
.nested-plots rect,
.transparent-square rect {
  fill: var(--moss);
}

.marker,
.doorway,
.nested-plots polygon,
.leaf-border polygon {
  fill: var(--plum);
}

.shape-leaves > *,
.nested-plots > *,
.idea-cells > *,
.seed-packets > *,
.leaf-border > * {
  transform-box: fill-box;
  transform-origin: center;
}

.panel.active .shape-leaves > *,
.panel.active .nested-plots > *,
.panel.active .idea-cells > *,
.panel.active .seed-packets > *,
.panel.active .leaf-border > * {
  animation: paperArrive 780ms cubic-bezier(.2,.72,.08,1) both;
}

.panel.active .shape-leaves > *:nth-child(2),
.panel.active .nested-plots > *:nth-child(2),
.panel.active .idea-cells > *:nth-child(2),
.panel.active .seed-packets > *:nth-child(2) { animation-delay: 90ms; }
.panel.active .shape-leaves > *:nth-child(3),
.panel.active .nested-plots > *:nth-child(3),
.panel.active .idea-cells > *:nth-child(3),
.panel.active .seed-packets > *:nth-child(3) { animation-delay: 180ms; }
.panel.active .shape-leaves > *:nth-child(4),
.panel.active .nested-plots > *:nth-child(4),
.panel.active .idea-cells > *:nth-child(4),
.panel.active .seed-packets > *:nth-child(4) { animation-delay: 270ms; }

.labels text {
  fill: rgba(18, 58, 42, 0.72);
  font-size: 15px;
  font-weight: 600;
}

.map-rings circle {
  fill: none;
  stroke: rgba(47, 107, 70, 0.24);
  stroke-width: 2;
  stroke-dasharray: 8 14;
}

.room-frame rect {
  fill: var(--paper);
  stroke: var(--fern);
  stroke-width: 3;
}

.room-frame path:first-of-type {
  fill: var(--moss);
}

.room-frame path:last-of-type {
  fill: var(--clay);
}

.transparent-square rect {
  fill: rgba(221, 232, 200, 0.42);
  stroke: rgba(59, 38, 54, 0.58);
  stroke-width: 3;
}

.transparent-square line {
  stroke: rgba(59, 38, 54, 0.38);
  stroke-width: 2;
}

.idea-cells polygon {
  fill: var(--fern);
}

.open-door path:first-child {
  fill: var(--plum);
  filter: drop-shadow(0 11px 0 rgba(18, 58, 42, 0.12));
}

.open-door path:nth-child(2) {
  fill: var(--clay);
  transform-box: fill-box;
  transform-origin: left center;
}

.panel.active .open-door path:nth-child(2) {
  animation: doorSwing 1100ms cubic-bezier(.18,.76,.12,1) 260ms both;
}

.open-door circle {
  fill: var(--paper);
}

.side-grove circle:nth-child(2),
.side-grove circle:nth-child(3) {
  fill: var(--moss);
}

.seed-packets rect:nth-child(4) {
  fill: var(--lichen);
}

.magnifier {
  position: fixed;
  z-index: 30;
  left: 0;
  top: 0;
  width: 118px;
  height: 118px;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-200px, -200px, 0) scale(0.86);
  transition: opacity 260ms ease, transform 80ms linear;
}

.magnifier.visible {
  opacity: 1;
}

.magnifier-ring {
  position: absolute;
  inset: 0;
  border: 3px solid var(--moss);
  border-radius: 50%;
  background: rgba(221, 232, 200, 0.2);
  box-shadow: inset 0 0 0 10px rgba(244, 232, 207, 0.36), 0 16px 42px rgba(18, 58, 42, 0.2);
}

.magnifier-ring::after {
  content: "";
  position: absolute;
  width: 52px;
  height: 9px;
  right: -36px;
  bottom: 2px;
  border-radius: 999px;
  background: var(--deep-canopy);
  transform: rotate(42deg);
  transform-origin: left center;
}

.magnifier-label {
  position: absolute;
  left: 50%;
  top: 50%;
  color: var(--deep-canopy);
  font-size: 10px;
  font-weight: 600;
  transform: translate(-50%, -50%);
}

@keyframes bandSettle {
  0% { transform: scale(0.91) translateY(28px); }
  55% { transform: scale(1.035) translateY(0); }
  100% { transform: scale(1) translateY(0); }
}

@keyframes glyphZoom {
  0% { transform: translate(592px, 210px) scale(0.72) translate(-592px, -210px); opacity: 0.68; }
  58% { transform: translate(592px, 210px) scale(1.52) translate(-592px, -210px); opacity: 1; }
  100% { transform: translate(592px, 210px) scale(1) translate(-592px, -210px); opacity: 1; }
}

@keyframes paperArrive {
  from { opacity: 0; transform: translateY(24px) rotate(-3deg) scale(0.94); }
  to { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
}

@keyframes doorSwing {
  from { transform: skewY(0deg) translateX(0); }
  to { transform: skewY(-5deg) translateX(28px); }
}

@media (max-width: 980px) {
  body { overflow: auto; }

  .field-guide {
    height: auto;
    min-height: 100vh;
    padding-left: 74px;
  }

  .story-rail {
    width: 70px;
    padding-inline: 10px;
  }

  .rail-mark {
    padding-inline: 4px;
    transform: none;
  }

  .rail-mark.active {
    transform: translateX(6px);
  }

  .rail-mark b {
    writing-mode: vertical-rl;
    justify-self: center;
  }

  .orientation-shelf {
    position: sticky;
    top: 12px;
    left: auto;
    right: auto;
    margin: 12px 12px 0 0;
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .token-row {
    justify-content: start;
  }

  .panel {
    position: relative;
    inset: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    padding: 60px 16px 48px 0;
    opacity: 1;
    transform: none;
  }

  .diagram-band {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  h1 { font-size: 56px; }
  h2 { font-size: 48px; }
  .definition { font-size: 17px; }
  .panel-copy p { font-size: 18px; }
  .token-row { flex-wrap: wrap; }
}
