:root {
  --lagoon-ink: #123047;
  --emerald-current: #008F7A;
  --sapphire-harbor: #2454D8;
  --amethyst-failover: #7B2CBF;
  --coral-packet: #FF6B6B;
  --sunlit-mango: #FFB84D;
  --paper-shell: #FFF7E8;
  --display: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito Sans", "Segoe UI", system-ui, sans-serif;
  --accent: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--paper-shell); color: var(--lagoon-ink); }

body { font-family: var(--body); overflow: hidden; }

.daybook { height: 100vh; width: 100vw; overflow-y: auto; scroll-snap-type: y mandatory; scroll-behavior: smooth; background: radial-gradient(circle at 12% 8%, rgba(255,184,77,.26), transparent 25%), linear-gradient(90deg, var(--paper-shell), #fff2d7 48%, #dff8ee 100%); }

.daybook::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .28; background-image: radial-gradient(var(--lagoon-ink) .7px, transparent .8px); background-size: 18px 18px; mix-blend-mode: multiply; z-index: 2; }

.chapter { min-height: 100vh; width: 100%; display: grid; grid-template-columns: 52% 48%; align-items: stretch; scroll-snap-align: start; position: relative; overflow: hidden; }
.chapter.diagram-wide { grid-template-columns: 40% 60%; }
.chapter.text-wide { grid-template-columns: 58% 42%; }

.editorial { padding: clamp(44px, 7vw, 94px) clamp(34px, 7vw, 112px); display: flex; flex-direction: column; justify-content: center; gap: 20px; position: relative; z-index: 3; }
.editorial::before { content: ""; position: absolute; width: 135px; height: 135px; border: 3px solid rgba(18,48,71,.12); border-radius: 42% 58% 54% 46%; top: 9%; left: 8%; transform: rotate(-12deg); }

.kicker { font-family: var(--display); margin: 0; color: var(--amethyst-failover); font-size: clamp(1rem, 1.5vw, 1.25rem); letter-spacing: .055em; text-transform: uppercase; }
.wordmark { font-family: var(--display); color: var(--sapphire-harbor); font-size: clamp(4.4rem, 10vw, 10.8rem); letter-spacing: -.045em; line-height: .75; text-shadow: 5px 5px 0 rgba(255,184,77,.62); }
h1, h2 { font-family: var(--display); margin: 0; max-width: 780px; font-weight: 800; line-height: .88; letter-spacing: -.035em; }
h1 { font-size: clamp(3.8rem, 7.6vw, 8rem); }
h2 { font-size: clamp(3.2rem, 6.2vw, 6.8rem); color: var(--lagoon-ink); }
.copy { max-width: 560px; margin: 0; font-size: clamp(1.06rem, 1.45vw, 1.42rem); line-height: 1.55; font-weight: 700; }
blockquote { margin: 6px 0 0; max-width: 520px; padding: 20px 28px; border-left: 0; border-radius: 28px 28px 28px 8px; background: rgba(255,255,255,.62); box-shadow: inset 0 0 0 2px rgba(18,48,71,.08), 0 18px 38px rgba(18,48,71,.08); font-family: var(--accent); font-size: clamp(1.25rem, 2vw, 2.15rem); line-height: 1.14; color: var(--emerald-current); font-style: italic; }
.annotations { display: flex; gap: 12px; flex-wrap: wrap; max-width: 560px; }
.annotations span, .shell-log { font-family: var(--display); border: 2px solid var(--lagoon-ink); border-radius: 999px 999px 999px 12px; padding: 9px 15px; background: var(--sunlit-mango); color: var(--lagoon-ink); box-shadow: 4px 5px 0 rgba(18,48,71,.18); transform-origin: left bottom; }
.shell-log { max-width: 480px; background: #fffaf0; border-radius: 36px 36px 12px 36px; }

.reef { margin: clamp(22px, 4vw, 62px); border-radius: 50px; position: relative; display: grid; place-items: center; overflow: hidden; box-shadow: inset 0 0 0 3px rgba(255,247,232,.68), 0 30px 70px rgba(18,48,71,.19); z-index: 1; }
.water-panel { position: absolute; inset: 0; background: linear-gradient(145deg, rgba(36,84,216,.95), rgba(0,143,122,.82)); }
.reef::before { content: ""; position: absolute; inset: 8%; border: 3px dashed rgba(255,247,232,.36); border-radius: 42px; z-index: 1; }
.reef svg { width: min(92%, 860px); height: min(84%, 720px); position: relative; z-index: 2; overflow: visible; }
.reef-sunset .water-panel { background: linear-gradient(145deg, var(--sunlit-mango), var(--coral-packet) 45%, var(--sapphire-harbor)); }
.reef-fail .water-panel { background: linear-gradient(145deg, var(--sapphire-harbor), var(--amethyst-failover) 52%, var(--emerald-current)); }
.reef-night .water-panel { background: linear-gradient(145deg, var(--amethyst-failover), var(--lagoon-ink) 72%); }
.reef-bright .water-panel { background: linear-gradient(145deg, #56d8c8, var(--emerald-current) 36%, var(--sapphire-harbor)); }

.route { fill: none; stroke-width: 12; stroke-linecap: round; stroke-dasharray: 18 26; filter: drop-shadow(0 8px 0 rgba(18,48,71,.12)); animation: currentDrift 6s linear infinite; }
.route.emerald { stroke: var(--emerald-current); }
.route.sapphire { stroke: var(--sapphire-harbor); }
.route.amethyst { stroke: var(--amethyst-failover); }
.route.mango { stroke: var(--sunlit-mango); }
.route.muted { stroke: rgba(255,247,232,.45); }
.r2 { animation-duration: 7.8s; animation-direction: reverse; }
.r3 { animation-duration: 9.3s; }

.coral circle { fill: var(--paper-shell); stroke: var(--lagoon-ink); stroke-width: 5; opacity: .95; }
.c1 circle { fill: var(--coral-packet); }
.c2 circle { fill: var(--sunlit-mango); }
.c3 circle { fill: var(--emerald-current); }
.coral.sick circle { fill: var(--amethyst-failover); animation: amethystFlicker 1.2s ease-in-out infinite; }
.coral.dark circle { fill: #0b2038; stroke: #FFF7E8; }
.pearl { fill: var(--paper-shell); stroke: var(--emerald-current); stroke-width: 4; animation: pearlBlink 2.4s ease-in-out infinite; }
.pearl.alert { stroke: var(--coral-packet); fill: var(--sunlit-mango); animation-duration: .8s; }
.bubble { fill: rgba(255,247,232,.74); animation: bubbleRise 4s ease-in-out infinite; }

.fish { transform-box: fill-box; transform-origin: center; opacity: 0; }
.fish path:first-child { fill: var(--coral-packet); stroke: var(--lagoon-ink); stroke-width: 4; }
.fish path:nth-child(2) { fill: var(--sunlit-mango); stroke: var(--lagoon-ink); stroke-width: 4; }
.fish circle { fill: var(--lagoon-ink); }
.fish rect { fill: var(--paper-shell); stroke: var(--lagoon-ink); stroke-width: 3; }
.angel path:first-child { fill: var(--sunlit-mango); }
.ribbon path:first-child { fill: var(--amethyst-failover); }
.clown path:first-child { fill: var(--coral-packet); }
.chapter.active .fish { animation: fishBounce .9s cubic-bezier(.22,1.65,.42,1) forwards, finWiggle 1.5s ease-in-out infinite .9s; }
.f1 { transform: translate(120px, 455px) rotate(-12deg); animation-delay: .12s, 1s !important; }
.f2 { transform: translate(452px, 248px) rotate(10deg); animation-delay: .28s, 1.1s !important; }
.f3 { transform: translate(318px, 124px) rotate(-5deg); animation-delay: .44s, 1.2s !important; }
.f4 { transform: translate(568px, 430px) rotate(-16deg); animation-delay: .6s, 1.3s !important; }

.buoy { animation: buoyBob 2.8s ease-in-out infinite; transform-origin: center; }
.buoy path { fill: var(--sunlit-mango); stroke: var(--lagoon-ink); stroke-width: 5; }
.buoy text { font-family: var(--display); font-size: 22px; font-weight: 800; text-anchor: middle; fill: var(--lagoon-ink); text-transform: uppercase; }
.b2 { animation-delay: .8s; }

.chapter-tabs { position: fixed; left: 24px; bottom: 22px; z-index: 12; display: flex; gap: 9px; flex-wrap: wrap; max-width: calc(50vw - 60px); }
.chapter-tab { appearance: none; border: 2px solid var(--lagoon-ink); background: var(--paper-shell); color: var(--lagoon-ink); font-family: var(--display); font-weight: 800; padding: 8px 14px; border-radius: 999px 999px 999px 8px; box-shadow: 3px 4px 0 rgba(18,48,71,.18); cursor: pointer; transition: transform .22s cubic-bezier(.22,1.65,.42,1), background .2s ease, color .2s ease; }
.chapter-tab.active { background: var(--sunlit-mango); transform: translateY(-5px) rotate(-2deg); }
.chapter-tab:hover { transform: translateY(-4px); }

.tide-seam { position: fixed; top: 0; bottom: 0; left: 50%; width: 74px; transform: translateX(-50%); z-index: 10; pointer-events: none; display: grid; place-items: center; }
.tide-seam::before { content: ""; position: absolute; top: 22px; bottom: 22px; width: 38px; border-radius: 999px; background: var(--paper-shell); border: 3px solid var(--lagoon-ink); box-shadow: 0 0 0 8px rgba(255,247,232,.35), 0 18px 50px rgba(18,48,71,.18); }
.tide-track { position: absolute; top: 48px; bottom: 48px; width: 18px; border-radius: 999px; overflow: hidden; background: rgba(18,48,71,.12); }
.tide-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 18%; border-radius: 999px; background: linear-gradient(0deg, var(--sapphire-harbor), var(--emerald-current), var(--sunlit-mango)); transition: height .65s cubic-bezier(.22,1.25,.42,1); }
.tick { position: absolute; right: 7px; width: 24px; height: 3px; border-radius: 5px; background: var(--lagoon-ink); box-shadow: -46px 0 0 var(--lagoon-ink); opacity: .76; }
.t1 { top: 18%; } .t2 { top: 34%; } .t3 { top: 50%; } .t4 { top: 66%; } .t5 { top: 82%; }
.seam-label { position: absolute; font-family: var(--display); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--lagoon-ink); background: var(--sunlit-mango); border: 2px solid var(--lagoon-ink); border-radius: 999px; padding: 5px 9px; transform: rotate(-90deg); }
.seam-label.top { top: 64px; } .seam-label.bottom { bottom: 70px; }
.seam-fish { position: absolute; width: 24px; height: 13px; border-radius: 60% 45% 45% 60%; background: var(--coral-packet); border: 2px solid var(--lagoon-ink); animation: seamSwim 5s ease-in-out infinite; }
.seam-fish::before { content: ""; position: absolute; left: -9px; top: 2px; border-right: 10px solid var(--sunlit-mango); border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.sf1 { top: 25%; animation-delay: 0s; } .sf2 { top: 51%; animation-delay: 1.5s; } .sf3 { top: 76%; animation-delay: 2.7s; }

.chapter .editorial > * { opacity: 0; transform: translateY(26px) scale(.98); }
.chapter.active .editorial > * { animation: editorialBounce .72s cubic-bezier(.22,1.55,.42,1) forwards; }
.chapter.active .editorial > *:nth-child(2) { animation-delay: .08s; }
.chapter.active .editorial > *:nth-child(3) { animation-delay: .16s; }
.chapter.active .editorial > *:nth-child(4) { animation-delay: .24s; }
.chapter.active .editorial > *:nth-child(5) { animation-delay: .32s; }
.chapter.active .reef { animation: reefPop .85s cubic-bezier(.22,1.45,.42,1) both; }

.dawn { background: linear-gradient(90deg, var(--paper-shell) 0 58%, rgba(255,184,77,.2) 58% 100%); }
.midday { background: linear-gradient(90deg, rgba(0,143,122,.12) 0 40%, var(--paper-shell) 40% 100%); }
.failover { background: linear-gradient(90deg, var(--paper-shell) 0 58%, rgba(123,44,191,.16) 58% 100%); }
.sunset { background: linear-gradient(90deg, rgba(255,184,77,.18) 0 40%, var(--paper-shell) 40% 100%); }
.night { background: linear-gradient(90deg, #182943 0 58%, #101f38 58% 100%); color: var(--paper-shell); }
.night h2, .night .copy, .night .kicker { color: var(--paper-shell); }
.night blockquote { background: rgba(255,247,232,.12); color: var(--sunlit-mango); box-shadow: inset 0 0 0 2px rgba(255,247,232,.2); }
.night .annotations span { background: var(--amethyst-failover); color: var(--paper-shell); border-color: var(--paper-shell); }

@keyframes currentDrift { to { stroke-dashoffset: -88; } }
@keyframes fishBounce { 0% { opacity: 0; translate: 0 130px; scale: .72 1.18; } 64% { opacity: 1; translate: 0 -12px; scale: 1.08 .88; } 100% { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes finWiggle { 0%,100% { rotate: 0deg; } 50% { rotate: 4deg; } }
@keyframes buoyBob { 0%,100% { translate: 0 0; rotate: -1deg; } 50% { translate: 0 -12px; rotate: 2deg; } }
@keyframes pearlBlink { 0%,100% { opacity: .35; scale: .9; } 45% { opacity: 1; scale: 1.2; } }
@keyframes bubbleRise { 0%,100% { translate: 0 18px; opacity: .3; } 50% { translate: 0 -18px; opacity: .9; } }
@keyframes amethystFlicker { 0%,100% { filter: drop-shadow(0 0 0 rgba(255,107,107,0)); } 50% { filter: drop-shadow(0 0 18px var(--coral-packet)); } }
@keyframes seamSwim { 0%,100% { transform: translateX(-21px) rotate(0deg); } 50% { transform: translateX(21px) rotate(8deg); } }
@keyframes editorialBounce { 0% { opacity: 0; transform: translateY(34px) scale(.96); } 70% { opacity: 1; transform: translateY(-6px) scale(1.015); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes reefPop { 0% { opacity: .35; transform: translateY(34px) scale(.96); } 72% { opacity: 1; transform: translateY(-8px) scale(1.012); } 100% { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-width: 900px) {
  body { overflow: auto; }
  .daybook { overflow-y: auto; }
  .chapter, .chapter.diagram-wide, .chapter.text-wide { grid-template-columns: 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
  .editorial { padding: 72px 28px 22px; }
  .reef { min-height: 42vh; margin: 18px 22px 84px; border-radius: 34px; }
  .tide-seam { left: auto; right: 10px; transform: none; width: 54px; }
  .chapter-tabs { max-width: calc(100vw - 32px); left: 16px; bottom: 12px; }
  .wordmark { font-size: clamp(4rem, 20vw, 7rem); }
  h1, h2 { font-size: clamp(3rem, 14vw, 5.2rem); }
}
