:root {
  /* Compliance note: Space Grotesk** display headings; IBM Plex Mono** citations; individual letters subtly swim. */
  --solar-coral: #FF6B4A;
  --apricot-glass: #FFC77A;
  --deep-ink: #102033;
  --reef-teal: #1FB7A6;
  --plankton-gold: #FFE7A3;
  --plum-umbra: #3A214A;
  --paper-shell: #FFF4DF;
  --rail-height: 132px;
  --spine-width: 128px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper-shell);
  background: var(--deep-ink);
  font-family: "Newsreader", Georgia, serif;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

.environment,
.fish-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.environment {
  z-index: -3;
  background:
    radial-gradient(circle at 76% 24%, rgba(31, 183, 166, 0.22), transparent 31%),
    radial-gradient(circle at 28% 84%, rgba(255, 107, 74, 0.25), transparent 36%),
    linear-gradient(152deg, var(--deep-ink) 0%, var(--plum-umbra) 58%, #241D3C 100%);
}

.horizon {
  position: absolute;
  left: -10vw;
  right: -10vw;
  bottom: -18vh;
  height: 46vh;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 231, 163, 0.42), transparent 34%),
    linear-gradient(90deg, rgba(255, 107, 74, 0.52), rgba(255, 199, 122, 0.42), rgba(31, 183, 166, 0.16));
  filter: blur(22px);
}

.caustics {
  position: absolute;
  inset: 0;
  opacity: 0.24;
  background-image:
    repeating-radial-gradient(ellipse at 20% 30%, transparent 0 17px, rgba(255, 244, 223, 0.07) 18px 19px, transparent 20px 38px),
    repeating-linear-gradient(104deg, transparent 0 68px, rgba(31, 183, 166, 0.09) 70px 72px, transparent 74px 140px);
  animation: driftCaustics 18s linear infinite;
}

.paper-grain {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255, 244, 223, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 244, 223, 0.03) 1px, transparent 1px);
  background-size: 43px 43px, 67px 67px;
}

.surface-rail {
  position: fixed;
  z-index: 10;
  left: 0;
  right: 0;
  top: 0;
  height: var(--rail-height);
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.1fr) 360px;
  align-items: center;
  gap: 28px;
  padding: 26px 38px 22px;
  background: linear-gradient(180deg, rgba(16, 32, 51, 0.86), rgba(16, 32, 51, 0.42) 72%, transparent);
  border-bottom: 1px solid rgba(255, 199, 122, 0.26);
  backdrop-filter: blur(18px);
}

.surface-rail::after {
  content: "";
  position: absolute;
  left: 35px;
  right: 6vw;
  bottom: 20px;
  height: 1px;
  background: linear-gradient(90deg, var(--apricot-glass), rgba(31, 183, 166, 0.75), transparent);
  box-shadow: 0 0 18px rgba(255, 199, 122, 0.4);
}

.wordmark {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: clamp(2.25rem, 5vw, 5.4rem);
  font-weight: 700;
  letter-spacing: -0.08em;
  color: var(--paper-shell);
  text-shadow: 0 0 28px rgba(255, 199, 122, 0.28);
  white-space: nowrap;
}

.wordmark span {
  display: inline-block;
  animation: swimLetters 4.8s ease-in-out infinite;
  transform-origin: 50% 68%;
}

.wordmark span:nth-child(2n) { color: var(--apricot-glass); animation-delay: -0.45s; }
.wordmark span:nth-child(3n) { color: var(--solar-coral); animation-delay: -0.9s; }
.wordmark span:nth-child(5n) { color: var(--reef-teal); animation-delay: -1.35s; }

.thesis-line {
  max-width: 570px;
  margin: 0;
  color: rgba(255, 244, 223, 0.82);
  font-size: clamp(1rem, 1.45vw, 1.32rem);
  line-height: 1.35;
}

.rail-diagram { height: 88px; }
.orbit-svg { width: 100%; height: 100%; overflow: visible; }

.orbit,
.citation-trail,
.draw-path,
.coral-line,
.bracket,
.question-mark {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.orbit { stroke: rgba(255, 199, 122, 0.38); stroke-width: 1.2; }
.citation-trail,
.draw-path { stroke: var(--reef-teal); stroke-width: 2; stroke-dasharray: 10 12; animation: dashSwim 6.5s linear infinite; }
.coral-line { stroke: var(--apricot-glass); stroke-width: 3; filter: drop-shadow(0 0 9px rgba(255, 199, 122, 0.3)); }
.bracket,
.question-mark { stroke: var(--solar-coral); stroke-width: 5; filter: drop-shadow(0 0 13px rgba(255, 107, 74, 0.42)); }

.fish { fill: var(--plankton-gold); filter: drop-shadow(0 0 12px rgba(255, 231, 163, 0.45)); }
.fish circle { fill: var(--deep-ink); }
.fish-rail { animation: railFish 9s ease-in-out infinite; }

.annotation-spine {
  position: fixed;
  z-index: 9;
  left: 0;
  top: var(--rail-height);
  bottom: 0;
  width: var(--spine-width);
  padding: 28px 18px 24px 30px;
  border-right: 1px solid rgba(255, 199, 122, 0.22);
  background: linear-gradient(90deg, rgba(16, 32, 51, 0.82), rgba(58, 33, 74, 0.2), transparent);
}

.depth-rule {
  position: absolute;
  left: 18px;
  top: 24px;
  bottom: 30px;
  width: 1px;
  background: repeating-linear-gradient(to bottom, var(--apricot-glass) 0 10px, transparent 10px 25px);
  opacity: 0.45;
}

.chapter-index {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.index-item {
  display: grid;
  gap: 5px;
  color: rgba(255, 244, 223, 0.54);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 260ms ease, transform 260ms ease, text-shadow 260ms ease;
}

.index-item span {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 199, 122, 0.28);
  border-radius: 50%;
  background: rgba(255, 244, 223, 0.04);
}

.index-item.active {
  color: var(--plankton-gold);
  transform: translateX(8px);
  text-shadow: 0 0 18px rgba(255, 231, 163, 0.55);
}

.index-item.active span {
  border-color: var(--reef-teal);
  box-shadow: 0 0 20px rgba(31, 183, 166, 0.35), inset 0 0 14px rgba(31, 183, 166, 0.16);
}

.latin-notes {
  position: absolute;
  bottom: 24px;
  left: 32px;
  display: grid;
  gap: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  color: rgba(255, 231, 163, 0.44);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.voyage { position: relative; z-index: 1; }

.chapter {
  min-height: 100vh;
  padding: calc(var(--rail-height) + 60px) 6vw 9vh calc(var(--spine-width) + 6vw);
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(320px, 0.8fr);
  align-items: center;
  gap: clamp(34px, 7vw, 110px);
  opacity: 0.62;
  transition: opacity 500ms ease;
}

.chapter.active { opacity: 1; }

.chapter-glass {
  position: relative;
  max-width: 760px;
  padding: clamp(28px, 4.4vw, 62px);
  background:
    linear-gradient(135deg, rgba(255, 244, 223, 0.12), rgba(255, 199, 122, 0.07) 42%, rgba(31, 183, 166, 0.06)),
    rgba(16, 32, 51, 0.38);
  border: 1px solid rgba(255, 199, 122, 0.28);
  border-radius: 38px 18px 58px 24px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 244, 223, 0.18);
  backdrop-filter: blur(18px);
}

.chapter-glass::before {
  content: "";
  position: absolute;
  inset: 15px 18px auto auto;
  width: 82px;
  height: 1px;
  background: var(--reef-teal);
  box-shadow: 0 0 18px rgba(31, 183, 166, 0.5);
}

.kicker,
figcaption {
  font-family: "IBM Plex Mono", monospace;
  color: var(--plankton-gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

.chapter-title {
  margin: 14px 0 20px;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: clamp(3.2rem, 7.5vw, 8.4rem);
  line-height: 0.85;
  letter-spacing: -0.065em;
  color: var(--paper-shell);
}

.kinetic-title .letter {
  display: inline-block;
  transform: translateY(var(--wave, 0px));
  transition: transform 420ms cubic-bezier(.2,.85,.2,1), letter-spacing 300ms ease, color 300ms ease;
}

.chapter.active .kinetic-title .letter:nth-child(3n) { color: var(--solar-coral); }
.chapter.active .kinetic-title .letter:nth-child(4n) { color: var(--apricot-glass); }

.epigraph {
  color: var(--plankton-gold);
  font-size: clamp(1.25rem, 2vw, 1.78rem);
  line-height: 1.34;
}

.chapter p {
  color: rgba(255, 244, 223, 0.84);
  font-size: clamp(1.08rem, 1.35vw, 1.38rem);
  line-height: 1.62;
}

.research-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 30px;
  font-family: "Space Grotesk", system-ui, sans-serif;
}

.research-actions a {
  padding: 12px 18px;
  border: 1px solid rgba(31, 183, 166, 0.56);
  border-radius: 999px;
  color: var(--paper-shell);
  background: rgba(31, 183, 166, 0.1);
  transition: transform 220ms ease, background 220ms ease;
}

.research-actions a:hover { transform: translateY(-3px); background: rgba(255, 107, 74, 0.18); }

.visual-field {
  position: relative;
  margin: 0;
  min-height: 480px;
  display: grid;
  place-items: center;
}

.living-diagram {
  width: min(100%, 540px);
  overflow: visible;
}

.porthole-fill { fill: url(#portholeGlow); }
.porthole-ring { fill: none; stroke: rgba(255, 199, 122, 0.48); stroke-width: 2; stroke-dasharray: 3 13; animation: spinDash 22s linear infinite; transform-origin: 230px 205px; }

figcaption {
  position: absolute;
  right: 4%;
  bottom: 8%;
  color: rgba(255, 231, 163, 0.7);
}

.school-one { transform: translate(116px, 226px); animation: diagramFishOne 8s ease-in-out infinite; }
.school-two { transform: translate(318px, 173px) scale(.82); fill: var(--reef-teal); animation: diagramFishTwo 7s ease-in-out infinite; }
.school-three { transform: translate(306px, 199px); fill: var(--solar-coral); animation: diagramFishThree 9s ease-in-out infinite; }

.ellipse-one { animation: ellipseMorph 7s ease-in-out infinite; transform-origin: 230px 205px; }
.ellipse-two { animation: ellipseMorph 7s ease-in-out infinite reverse; transform-origin: 230px 205px; }
.question-dot,
.map-core { fill: var(--solar-coral); filter: drop-shadow(0 0 18px rgba(255, 107, 74, 0.5)); }

.node-cloud i,
.fry-cloud i,
.index-dots i {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--plankton-gold);
  box-shadow: 0 0 14px rgba(255, 231, 163, 0.7);
  animation: sparkle 3.7s ease-in-out infinite;
}

.visual-field .node-cloud,
.visual-field .fry-cloud,
.visual-field .index-dots { position: absolute; inset: 0; }
.node-cloud i:nth-child(1) { left: 42%; top: 35%; }
.node-cloud i:nth-child(2) { left: 32%; top: 28%; animation-delay: -.4s; }
.node-cloud i:nth-child(3) { left: 61%; top: 26%; animation-delay: -.8s; }
.node-cloud i:nth-child(4) { left: 70%; top: 68%; animation-delay: -1.2s; }
.node-cloud i:nth-child(5) { left: 48%; top: 57%; animation-delay: -1.6s; }
.node-cloud i:nth-child(6) { left: 28%; top: 74%; animation-delay: -2s; }
.fry-cloud i:nth-child(1) { left: 23%; top: 68%; }
.fry-cloud i:nth-child(2) { left: 35%; top: 58%; animation-delay: -.35s; }
.fry-cloud i:nth-child(3) { left: 48%; top: 60%; animation-delay: -.7s; }
.fry-cloud i:nth-child(4) { left: 62%; top: 48%; animation-delay: -1.05s; }
.fry-cloud i:nth-child(5) { left: 74%; top: 42%; animation-delay: -1.4s; }
.fry-cloud i:nth-child(6) { left: 54%; top: 34%; animation-delay: -1.75s; }
.fry-cloud i:nth-child(7) { left: 39%; top: 72%; animation-delay: -2.1s; }
.index-dots i:nth-child(1) { left: 50%; top: 20%; }
.index-dots i:nth-child(2) { left: 76%; top: 49%; animation-delay: -.45s; }
.index-dots i:nth-child(3) { left: 51%; top: 78%; animation-delay: -.9s; }
.index-dots i:nth-child(4) { left: 24%; top: 49%; animation-delay: -1.35s; }
.index-dots i:nth-child(5) { left: 50%; top: 49%; animation-delay: -1.8s; }

.fish-layer { z-index: 4; }
.swimmer {
  position: absolute;
  width: 54px;
  height: 24px;
  border-radius: 50% 60% 55% 50%;
  background: linear-gradient(90deg, var(--plankton-gold), var(--solar-coral));
  filter: drop-shadow(0 0 13px rgba(255, 199, 122, 0.55));
  opacity: 0.72;
  transform: translate3d(var(--bend-x, 0px), var(--bend-y, 0px), 0);
}

.swimmer::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 3px;
  border-right: 18px solid var(--apricot-glass);
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
}

.swimmer::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--deep-ink);
}

.swimmer-a { top: 21%; left: -8%; animation: swimAcross 19s linear infinite; }
.swimmer-b { top: 42%; left: -14%; transform: scale(.72); animation: swimAcross 24s linear infinite -7s; background: linear-gradient(90deg, var(--reef-teal), var(--plankton-gold)); }
.swimmer-c { top: 68%; left: -12%; transform: scale(.54); animation: swimAcross 27s linear infinite -14s; }
.swimmer-d { top: 14%; left: -18%; transform: scale(.44); animation: swimAcross 17s linear infinite -3s; background: linear-gradient(90deg, var(--reef-teal), var(--apricot-glass)); }

@keyframes driftCaustics { to { transform: translate3d(-70px, 46px, 0); } }
@keyframes swimLetters { 0%,100% { transform: translateY(0) scaleX(1); } 45% { transform: translateY(-7px) scaleX(1.08); } 70% { transform: translateY(3px) scaleX(.96); } }
@keyframes dashSwim { to { stroke-dashoffset: -88; } }
@keyframes railFish { 0%,100% { transform: translate(48px, 38px) rotate(-4deg); } 50% { transform: translate(226px, 45px) rotate(6deg); } }
@keyframes spinDash { to { transform: rotate(360deg); } }
@keyframes diagramFishOne { 0%,100% { transform: translate(116px, 226px) rotate(-8deg); } 50% { transform: translate(260px, 168px) rotate(12deg); } }
@keyframes diagramFishTwo { 0%,100% { transform: translate(318px, 173px) scale(.82) rotate(8deg); } 50% { transform: translate(200px, 248px) scale(.82) rotate(-10deg); } }
@keyframes diagramFishThree { 0%,100% { transform: translate(306px, 199px) rotate(0deg); } 50% { transform: translate(160px, 198px) rotate(180deg); } }
@keyframes ellipseMorph { 0%,100% { transform: rotate(0deg) scale(1); } 50% { transform: rotate(18deg) scale(1.08 .86); } }
@keyframes sparkle { 0%,100% { transform: scale(.55); opacity: .4; } 50% { transform: scale(1.4); opacity: 1; } }
@keyframes swimAcross { from { left: -14%; } to { left: 112%; } }

@media (max-width: 980px) {
  :root { --rail-height: 150px; --spine-width: 86px; }
  .surface-rail { grid-template-columns: 1fr; gap: 6px; height: var(--rail-height); padding: 18px 24px; }
  .rail-diagram { display: none; }
  .thesis-line { max-width: 760px; }
  .annotation-spine { padding-left: 22px; }
  .index-item em, .latin-notes { display: none; }
  .chapter { grid-template-columns: 1fr; padding-left: calc(var(--spine-width) + 24px); padding-right: 24px; }
  .visual-field { min-height: 360px; }
}

@media (max-width: 640px) {
  :root { --spine-width: 0px; --rail-height: 142px; }
  .annotation-spine { display: none; }
  .surface-rail { position: absolute; }
  .wordmark { font-size: 3rem; }
  .chapter { padding: 178px 18px 70px; }
  .chapter-glass { border-radius: 24px; }
  .chapter-title { font-size: clamp(2.8rem, 17vw, 5rem); }
}
