:root {
  --design-event: "Source Noise scatters syllables like plankton Source Noise** Noise* Nois";
  --abyss-ink: #061018;
  --current-blue: #28D7FF;
  --phosphor-mint: #9CFFCB;
  --thought-violet: #7B61FF;
  --silt-gold: #D8B66A;
  --foam-white: #F4FBFF;
  --undertow-navy: #102B46;
  --serif: "Instrument Serif", serif;
  --sans: "Spline Sans", sans-serif;
  --mono: "Azeret Mono", monospace;
  --hand: "Caveat", cursive;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--abyss-ink);
}

body {
  margin: 0;
  color: var(--foam-white);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 18% 8%, rgba(40, 215, 255, 0.12), transparent 32rem),
    radial-gradient(circle at 84% 42%, rgba(123, 97, 255, 0.16), transparent 38rem),
    linear-gradient(180deg, #061018 0%, #102B46 38%, #061018 68%, #102B46 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    repeating-linear-gradient(105deg, transparent 0 38px, rgba(244, 251, 255, 0.025) 40px 43px, transparent 46px 92px),
    radial-gradient(ellipse at 52% 18%, rgba(156, 255, 203, 0.08), transparent 35%),
    radial-gradient(ellipse at 47% 84%, rgba(40, 215, 255, 0.08), transparent 34%);
  mix-blend-mode: screen;
  animation: causticDrift 18s linear infinite;
}

.submerged-light {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background: conic-gradient(from 210deg at 50% 50%, transparent, rgba(40, 215, 255, 0.08), transparent, rgba(216, 182, 106, 0.07), transparent);
  filter: blur(26px);
  animation: slowTurn 34s linear infinite;
}

.plankton-field {
  position: fixed;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.78;
}

.reasoning-river {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 500vh;
  min-height: 5200px;
  z-index: 3;
  pointer-events: none;
  overflow: visible;
}

.wide-current {
  fill: none;
  stroke: url(#riverCore);
  stroke-width: 220;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url(#liquidGlow);
}

.current-path,
.branch,
.undertow-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.current-path {
  stroke: rgba(40, 215, 255, 0.72);
  stroke-width: 8;
  filter: drop-shadow(0 0 18px rgba(40, 215, 255, 0.62));
}

.branch-left { stroke: rgba(123, 97, 255, 0.66); stroke-width: 6; }
.branch-right { stroke: rgba(156, 255, 203, 0.62); stroke-width: 6; }
.undertow-path { stroke: rgba(216, 182, 106, 0.64); stroke-width: 5; }

.depth-nav {
  position: fixed;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 12;
  display: grid;
  gap: 18px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.depth-nav a {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  color: var(--silt-gold);
  text-decoration: none;
  background: rgba(244, 251, 255, 0.13);
  border: 1px solid rgba(216, 182, 106, 0.32);
  box-shadow: 0 0 0 0 rgba(40, 215, 255, 0);
  position: relative;
  transition: transform 0.4s ease, background 0.4s ease, box-shadow 0.4s ease;
}

.depth-nav a::before {
  content: attr(data-depth);
  position: absolute;
  right: 20px;
  top: -1px;
  opacity: 0.55;
}

.depth-nav a span {
  position: absolute;
  left: 24px;
  top: -2px;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-7px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.depth-nav a.active,
.depth-nav a:hover {
  transform: scale(1.42);
  background: var(--current-blue);
  box-shadow: 0 0 22px rgba(40, 215, 255, 0.75);
}

.depth-nav a.active span,
.depth-nav a:hover span { opacity: 1; transform: translateX(0); }

.drift-buoy {
  position: fixed;
  right: 28px;
  bottom: 26px;
  z-index: 15;
  width: 76px;
  height: 76px;
  border-radius: 50% 50% 46% 54%;
  border: 1px solid rgba(216, 182, 106, 0.54);
  background: radial-gradient(circle at 35% 28%, rgba(244, 251, 255, 0.72), rgba(40, 215, 255, 0.22) 34%, rgba(16, 43, 70, 0.68) 72%);
  color: var(--foam-white);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(40, 215, 255, 0.22), inset 0 0 18px rgba(244, 251, 255, 0.18);
  animation: buoyDrift 5s ease-in-out infinite;
}

.thought-current { position: relative; z-index: 5; }

.chapter {
  min-height: 100vh;
  position: relative;
  display: grid;
  align-items: center;
  padding: 8vh 9vw;
  overflow: hidden;
}

.chapter-copy {
  max-width: 610px;
  position: relative;
  z-index: 7;
  text-shadow: 0 2px 18px rgba(6, 16, 24, 0.7);
}

.chapter-copy h1,
.chapter-copy h2 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 0.89;
  margin: 0 0 28px;
  color: var(--foam-white);
}

.chapter-copy h1 { font-size: clamp(74px, 13vw, 190px); max-width: 900px; }
.chapter-copy h2 { font-size: clamp(64px, 9vw, 142px); }
.chapter-copy h2 em { color: var(--phosphor-mint); font-style: italic; }

.chapter-copy p:not(.premise-id) {
  font-size: clamp(18px, 2.1vw, 28px);
  line-height: 1.45;
  color: rgba(244, 251, 255, 0.82);
  margin: 0;
}

.premise-id,
.mono-mark {
  font-family: var(--mono);
  color: var(--silt-gold);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0 0 18px;
}

.source { align-items: end; padding-bottom: 10vh; }
.source-copy { margin-left: 6vw; opacity: 0; transform: translateY(40px); transition: opacity 1.2s ease, transform 1.2s ease; }
body.has-touched .source-copy, .source.in-view .source-copy { opacity: 1; transform: translateY(0); }

.pool {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 43, 70, 0.86), rgba(6, 16, 24, 0.06) 64%, transparent 72%);
  filter: blur(3px);
}

.pool-left { width: 74vw; height: 74vw; left: -27vw; top: -18vw; }

.reflection-wordmark {
  position: absolute;
  top: 15vh;
  left: 50%;
  transform: translateX(-50%) scaleY(-1) skewX(-9deg);
  font-family: var(--serif);
  font-size: clamp(68px, 14vw, 210px);
  color: transparent;
  -webkit-text-stroke: 1px rgba(40, 215, 255, 0.28);
  opacity: 0.52;
  filter: blur(2px) url(#none);
  text-shadow: 0 0 28px rgba(40, 215, 255, 0.3);
  transition: transform 1.4s cubic-bezier(.2,.8,.2,1), opacity 1.4s ease, color 1.4s ease, filter 1.4s ease;
}

body.has-touched .reflection-wordmark,
.source.in-view .reflection-wordmark {
  transform: translateX(-50%) translateY(18vh) scaleY(1) skewX(0deg);
  color: rgba(244, 251, 255, 0.92);
  -webkit-text-stroke-color: rgba(40, 215, 255, 0.08);
  opacity: 0.18;
  filter: blur(0);
}

.source-noise span {
  position: absolute;
  z-index: 6;
  font-family: var(--mono);
  color: rgba(156, 255, 203, 0.68);
  font-size: clamp(12px, 1.8vw, 20px);
  text-shadow: 0 0 16px rgba(156, 255, 203, 0.42);
  animation: syllableFloat 9s ease-in-out infinite;
}

.source-noise span:nth-child(1) { left: 18%; top: 28%; animation-delay: -1s; }
.source-noise span:nth-child(2) { left: 36%; top: 18%; animation-delay: -5s; }
.source-noise span:nth-child(3) { left: 72%; top: 21%; animation-delay: -2s; }
.source-noise span:nth-child(4) { left: 58%; top: 38%; animation-delay: -6s; }
.source-noise span:nth-child(5) { left: 27%; top: 54%; animation-delay: -3s; }
.source-noise span:nth-child(6) { left: 80%; top: 54%; animation-delay: -7s; }
.source-noise span:nth-child(7) { left: 47%; top: 72%; animation-delay: -4s; }
.source-noise span:nth-child(8) { left: 12%; top: 68%; animation-delay: -8s; }
.source-noise span:nth-child(9) { left: 66%; top: 75%; animation-delay: -2.4s; }
.source-noise span:nth-child(10) { left: 88%; top: 35%; animation-delay: -6.4s; }
.source-noise span:nth-child(11) { left: 33%; top: 84%; animation-delay: -4.4s; }
.source-noise span:nth-child(12) { left: 5%; top: 40%; animation-delay: -7.4s; }

.surface-touch {
  margin-top: 30px;
  border: 1px solid rgba(40, 215, 255, 0.45);
  color: var(--foam-white);
  background: rgba(16, 43, 70, 0.36);
  border-radius: 999px;
  padding: 15px 22px;
  font-family: var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: inset 0 0 18px rgba(40, 215, 255, 0.15), 0 0 30px rgba(40, 215, 255, 0.12);
}

.ripple-stage {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.ripple {
  position: absolute;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 1px solid rgba(40, 215, 255, 0.65);
  border-radius: 48% 52% 50% 50%;
  animation: rippleOut 1.2s ease-out forwards;
}

.bank-copy.right-bank { margin-left: auto; }
.bank-copy.left-bank { margin-right: auto; }

.vellum-strip {
  position: absolute;
  z-index: 7;
  left: 13vw;
  bottom: 18vh;
  width: min(680px, 72vw);
  padding: 24px 30px;
  color: var(--foam-white);
  background: linear-gradient(100deg, rgba(244, 251, 255, 0.13), rgba(40, 215, 255, 0.08), rgba(16, 43, 70, 0.18));
  border: 1px solid rgba(244, 251, 255, 0.12);
  border-radius: 42% 58% 54% 46% / 18% 22% 78% 82%;
  box-shadow: 0 18px 70px rgba(6, 16, 24, 0.38), inset 0 0 40px rgba(40, 215, 255, 0.08);
  transform: rotate(-3deg);
}

.vellum-strip strong { display: block; margin-top: 10px; font-size: clamp(22px, 3vw, 42px); font-family: var(--serif); font-weight: 400; }

.pebble-field { position: absolute; inset: auto 8vw 11vh auto; z-index: 7; display: flex; gap: 18px; }
.pebble {
  width: 76px;
  height: 54px;
  border-radius: 54% 46% 55% 45%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  color: var(--abyss-ink);
  background: radial-gradient(circle at 38% 28%, var(--foam-white), var(--phosphor-mint));
  box-shadow: 0 0 26px rgba(156, 255, 203, 0.34);
  animation: pebbleBob 4.2s ease-in-out infinite;
}
.pebble:nth-child(2) { animation-delay: -1.4s; }
.pebble:nth-child(3) { animation-delay: -2.8s; }

.branch-labels span {
  position: absolute;
  z-index: 7;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--silt-gold);
  padding: 10px 14px;
  border: 1px solid rgba(216, 182, 106, 0.22);
  border-radius: 999px;
  background: rgba(6, 16, 24, 0.38);
  backdrop-filter: blur(10px);
}
.branch-labels span:nth-child(1) { left: 34vw; top: 28vh; }
.branch-labels span:nth-child(2) { right: 9vw; top: 48vh; color: var(--phosphor-mint); }
.branch-labels span:nth-child(3) { left: 46vw; bottom: 18vh; color: var(--thought-violet); }

.bubble-cluster span {
  position: absolute;
  z-index: 7;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  font-family: var(--mono);
  color: var(--foam-white);
  border: 1px solid rgba(244, 251, 255, 0.24);
  background: radial-gradient(circle at 34% 24%, rgba(244, 251, 255, 0.46), rgba(40, 215, 255, 0.10) 42%, rgba(123, 97, 255, 0.08));
  box-shadow: inset 0 0 22px rgba(244, 251, 255, 0.12), 0 0 28px rgba(40, 215, 255, 0.12);
  animation: bubbleRise 7s ease-in-out infinite;
}
.bubble-cluster span:nth-child(1) { left: 55%; top: 20%; animation-delay: -1s; }
.bubble-cluster span:nth-child(2) { left: 70%; top: 34%; animation-delay: -3s; }
.bubble-cluster span:nth-child(3) { left: 47%; top: 52%; animation-delay: -5s; }
.bubble-cluster span:nth-child(4) { left: 82%; top: 66%; animation-delay: -2s; }
.bubble-cluster span:nth-child(5) { left: 36%; top: 74%; animation-delay: -4s; }
.bubble-cluster span:nth-child(6) { left: 63%; top: 80%; animation-delay: -6s; }

.revision-vessel {
  position: absolute;
  z-index: 7;
  left: 10vw;
  bottom: 16vh;
  width: min(720px, 78vw);
  min-height: 210px;
  padding: 36px;
  border-radius: 38px 80px 44px 94px;
  background: linear-gradient(145deg, rgba(16, 43, 70, 0.65), rgba(6, 16, 24, 0.25));
  border: 1px solid rgba(123, 97, 255, 0.24);
  box-shadow: inset 0 0 50px rgba(123, 97, 255, 0.12), 0 20px 80px rgba(6, 16, 24, 0.45);
}

.revision-vessel p {
  font-family: var(--serif);
  font-size: clamp(38px, 5vw, 72px);
  margin: 0;
  line-height: 1;
}

.flawed-line { color: rgba(244, 251, 255, 0.28); text-decoration: line-through; animation: pullBack 5s ease-in-out infinite; }
.corrected-line { color: var(--phosphor-mint); margin-top: 18px !important; text-shadow: 0 0 24px rgba(156, 255, 203, 0.28); animation: clarify 5s ease-in-out infinite; }
.caveat-note { font-family: var(--hand); color: var(--silt-gold); font-size: 30px; position: absolute; right: 34px; bottom: 18px; transform: rotate(-5deg); }

.horizon-glow {
  position: absolute;
  left: -10vw;
  right: -10vw;
  bottom: 0;
  height: 52vh;
  background: radial-gradient(ellipse at 50% 100%, rgba(244, 251, 255, 0.28), rgba(156, 255, 203, 0.14) 26%, rgba(40, 215, 255, 0.08) 52%, transparent 75%);
}

.final-copy { margin: 0 auto; text-align: center; transform: translateY(-10vh); }
.sandbar-thought {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 20vh;
  transform: translateX(-50%);
  width: min(900px, 82vw);
  padding: 26px 38px;
  text-align: center;
  border-radius: 62% 38% 59% 41% / 31% 34% 66% 69%;
  font-family: var(--serif);
  font-size: clamp(34px, 5.2vw, 82px);
  line-height: 0.95;
  color: var(--abyss-ink);
  background: linear-gradient(100deg, var(--silt-gold), var(--foam-white), var(--phosphor-mint));
  box-shadow: 0 0 70px rgba(156, 255, 203, 0.24);
}

.final-stones { position: absolute; z-index: 8; left: 50%; bottom: 8vh; transform: translateX(-50%); display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.final-stones span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--foam-white); border: 1px solid rgba(244, 251, 255, 0.18); border-radius: 999px; padding: 10px 14px; background: rgba(6, 16, 24, 0.34); }

.chapter:not(.in-view) .bank-copy,
.chapter:not(.in-view) .vellum-strip,
.chapter:not(.in-view) .branch-labels,
.chapter:not(.in-view) .revision-vessel,
.chapter:not(.in-view) .final-copy,
.chapter:not(.in-view) .sandbar-thought {
  opacity: 0.18;
  filter: blur(5px);
  transform: translateY(36px);
}

.chapter.in-view .bank-copy,
.chapter.in-view .vellum-strip,
.chapter.in-view .branch-labels,
.chapter.in-view .revision-vessel,
.chapter.in-view .final-copy,
.chapter.in-view .sandbar-thought {
  opacity: 1;
  filter: blur(0);
  transition: opacity 1s ease, filter 1s ease, transform 1s ease;
}

@keyframes causticDrift { 0% { transform: translate3d(0,0,0); } 50% { transform: translate3d(-3%,2%,0); } 100% { transform: translate3d(0,0,0); } }
@keyframes slowTurn { to { transform: rotate(360deg); } }
@keyframes buoyDrift { 0%,100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-12px) rotate(7deg); } }
@keyframes syllableFloat { 0%,100% { transform: translate3d(0,0,0) rotate(-2deg); opacity: 0.32; } 50% { transform: translate3d(22px,-32px,0) rotate(8deg); opacity: 0.95; } }
@keyframes rippleOut { to { width: 260px; height: 260px; margin: -130px 0 0 -130px; opacity: 0; border-radius: 50%; } }
@keyframes pebbleBob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-16px) rotate(5deg); } }
@keyframes bubbleRise { 0%,100% { transform: translateY(24px) scale(0.9); opacity: 0.42; } 50% { transform: translateY(-34px) scale(1.08); opacity: 0.92; } }
@keyframes pullBack { 0%,100% { transform: translateX(0); opacity: 0.32; } 50% { transform: translateX(-34px); opacity: 0.12; } }
@keyframes clarify { 0%,100% { filter: blur(2px); opacity: 0.64; } 50% { filter: blur(0); opacity: 1; } }

@media (max-width: 760px) {
  .chapter { padding: 8vh 7vw 12vh; }
  .depth-nav { display: none; }
  .drift-buoy { width: 62px; height: 62px; right: 16px; bottom: 16px; }
  .chapter-copy h1 { font-size: clamp(68px, 22vw, 120px); }
  .chapter-copy h2 { font-size: clamp(58px, 18vw, 100px); }
  .vellum-strip, .revision-vessel { left: 6vw; width: 88vw; }
  .pebble-field { right: 5vw; bottom: 6vh; }
  .branch-labels span { left: 8vw !important; right: auto !important; }
  .branch-labels span:nth-child(2) { top: 58vh; }
  .branch-labels span:nth-child(3) { bottom: 10vh; }
}
