:root {
  --ink: #1b2430;
  --paper: #f3ece0;
  --paper-2: #e8dfcf;
  --muted: #5d6673;
  --accent: #a3262a;       /* deep crimson, used sparingly */
  --deep: #10233a;         /* the water the works rise from */
  --deep-2: #1b3a57;
  --foam: #e9f1f4;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }

/* ---------- masthead ---------- */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding: 28px clamp(16px, 4vw, 56px) 20px;
  border-bottom: 1px solid var(--ink);
}
.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(44px, 7vw, 88px);
  line-height: .9;
  letter-spacing: -.01em;
}
.tally { text-align: right; }
.tally__drops { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.drop {
  width: 14px; height: 18px;
  border: 1.5px solid var(--ink);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  border-top-left-radius: 0;
  transform: rotate(45deg) scale(.8);
  transition: background .5s ease, transform .5s cubic-bezier(.3,1.6,.5,1);
}
.drop.is-full { background: var(--deep-2); border-color: var(--deep-2); transform: rotate(45deg) scale(1); }
.tally__label { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- stage ---------- */
.stage { position: relative; background: #1c2a3f; }
.scene { display: block; width: 100%; height: auto; max-height: calc(100vh - 40px); margin: 0 auto; cursor: crosshair; }

.intro {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 32px;
  padding: 22px clamp(16px, 4vw, 56px) 26px;
  font-family: var(--serif);
  font-size: clamp(18px, 1.6vw, 22px);
  line-height: 1.4;
}
.intro p { margin: 0; max-width: 680px; }
.hint { font-family: var(--sans); font-size: 13px; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; opacity: .9; }
.hint { flex-shrink: 0; color: var(--muted); }
.hint__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--deep-2); box-shadow: 0 0 0 0 rgba(27,58,87,.6); animation: pulse 2.4s infinite; }

/* ---------- scene interaction ---------- */
.water { cursor: pointer; outline: none; }
.water .hit { fill: transparent; }
.water > *:not(.tag):not(.beacon) { transition: filter .4s ease; }
.water:hover > *:not(.tag):not(.beacon),
.water:focus-visible > *:not(.tag):not(.beacon),
.water.is-hot > *:not(.tag):not(.beacon) { filter: brightness(1.12) saturate(1.1); }

.tag { opacity: 0; transform-box: fill-box; transition: opacity .3s ease, transform .3s ease; pointer-events: none; }
.tag rect { fill: var(--paper); stroke: var(--ink); stroke-width: 1; }
.tag text { font-family: var(--serif); font-size: 21px; font-weight: 600; fill: var(--ink); text-anchor: middle; }
.water:hover .tag, .water:focus-visible .tag, .water.is-hot .tag { opacity: 1; }
.water:focus-visible .tag rect { stroke: var(--accent); stroke-width: 2.5; }

.beacon circle { fill: var(--foam); }
.beacon .pulse { fill: none; stroke: var(--foam); stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: beacon 2.6s ease-out infinite; }
.water.is-visited .beacon > circle:first-child { fill: var(--deep-2); stroke: var(--foam); stroke-width: 2; }
.water:hover .beacon .pulse { animation-duration: 1.2s; }

/* ambient motion */
.wave { animation: drift 9s linear infinite; }
.wave--b { animation-duration: 13s; animation-direction: reverse; }
.moonpath rect { animation: glint 3.2s ease-in-out infinite; }
.moonpath rect:nth-child(2n) { animation-delay: -1.6s; }
.moon-glow { animation: breathe 7s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.stars circle { animation: glint 4s ease-in-out infinite; }
.stars circle:nth-child(3n) { animation-delay: -2s; }
.rain line { animation: fall 1.1s linear infinite; }
.rain line:nth-child(2n) { animation-delay: -.4s; }
.rain line:nth-child(3n) { animation-delay: -.75s; }
.current path { stroke-dasharray: 14 22; animation: flow 3s linear infinite; }
.current path:nth-child(2) { animation-duration: 4s; }
.pipe-flow { stroke-dasharray: 3 26; animation: flow 2.2s linear infinite; }
.water:hover .pipe-flow { animation-duration: .9s; }
.ring { transform-box: fill-box; transform-origin: center; animation: ring 4.5s ease-out infinite; }
.ring--2 { animation-delay: -1.5s; }
.ring--3 { animation-delay: -3s; }
.pot, .rope { transition: transform .6s cubic-bezier(.4,1.4,.5,1); }
.water[data-id="well"]:hover .pot { transform: translateY(-46px); }
.water[data-id="well"]:hover .rope { transform: scaleY(.42); transform-box: fill-box; transform-origin: top; }
.cloud { transition: transform .8s ease; }
.water[data-id="rain"]:hover .cloud { transform: translateX(10px); }
.water[data-id="rain"]:hover .rain line { animation-duration: .6s; }

/* a ripple wherever the visitor touches the scene */
.touch-ripple { fill: none; stroke: var(--foam); stroke-width: 2; pointer-events: none; transform-box: fill-box; transform-origin: center; animation: touch 1.1s ease-out forwards; }

@keyframes drift { to { transform: translateX(-96px); } }
@keyframes glint { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes breathe { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.08); opacity: 1; } }
@keyframes fall { from { transform: translateY(-20px); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(300px); opacity: 0; } }
@keyframes flow { to { stroke-dashoffset: -72; } }
@keyframes ring { from { transform: scale(.3); opacity: .9; } to { transform: scale(3); opacity: 0; } }
@keyframes beacon { from { transform: scale(1); opacity: .9; } to { transform: scale(3.4); opacity: 0; } }
@keyframes touch { from { transform: scale(.2); opacity: .9; } to { transform: scale(4); opacity: 0; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(27,58,87,.6); } 80%,100% { box-shadow: 0 0 0 12px rgba(27,58,87,0); } }

/* ---------- index ---------- */
.index { padding: 40px clamp(16px, 4vw, 56px) 24px; }
.index h2 {
  margin: 0 0 16px;
  font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.index ol {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
}
.index li { border-bottom: 1px solid #cfc4b1; }
.index li:nth-child(3n+1), .index li:nth-child(3n+2) { border-right: 1px solid #cfc4b1; }
.index button {
  display: grid; grid-template-columns: 44px 1fr; gap: 4px 12px; align-items: baseline;
  width: 100%; padding: 18px 16px; text-align: left; background: none; border: 0; cursor: pointer;
  transition: background .25s ease;
}
.index button:hover, .index button:focus-visible { background: var(--paper-2); outline: none; }
.index .num { font-family: var(--serif); font-size: 22px; color: var(--accent); grid-row: span 2; }
.index .w { font-family: var(--serif); font-size: 24px; font-weight: 500; line-height: 1.1; }
.index .t { font-size: 13px; color: var(--muted); line-height: 1.4; }
.index li.is-visited .w::after { content: " ●"; font-size: 10px; color: var(--deep-2); vertical-align: middle; }

.colophon { padding: 8px clamp(16px, 4vw, 56px) 40px; font-size: 12px; color: var(--muted); max-width: 820px; }

/* ---------- flood + viewer ---------- */
.flood {
  position: fixed; inset: 0; z-index: 20; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 0%, var(--deep-2), var(--deep) 70%);
  clip-path: circle(0 at var(--x, 50%) var(--y, 50%));
  transition: clip-path .9s cubic-bezier(.65,0,.35,1);
}
.flood.is-open { clip-path: circle(150% at var(--x, 50%) var(--y, 50%)); }

.viewer {
  position: fixed; inset: 0; z-index: 30;
  overflow-y: auto;
  color: var(--foam);
  background: transparent;
}
.viewer[hidden] { display: none; }
.viewer__close {
  position: sticky; top: 0; z-index: 2;
  display: block; margin-left: auto;
  padding: 18px clamp(16px, 4vw, 56px);
  background: none; border: 0; cursor: pointer;
  font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--foam); opacity: .8;
}
.viewer__close:hover, .viewer__close:focus-visible { opacity: 1; text-decoration: underline; outline: none; }
.viewer__inner {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 72px);
  align-items: start;
  padding: 0 clamp(16px, 4vw, 56px) 64px;
  max-width: 1400px; margin: 0 auto;
}
.viewer__figure { margin: 0; position: sticky; top: 64px; }
.viewer__frame {
  display: flex; align-items: center; justify-content: center;
  min-height: min(70vh, 640px);
}
.viewer__frame img {
  display: block; max-width: 100%; max-height: 72vh;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.6);
  opacity: 0; transform: translateY(40px) scale(.98);
  transition: opacity 1.2s ease, transform 1.4s cubic-bezier(.2,.8,.2,1);
}
.viewer__frame img.is-restricted { height: min(384px, 60vh); width: auto; }
.viewer.is-surfaced .viewer__frame img { opacity: 1; transform: none; }
.viewer__note { margin-top: 12px; font-size: 12px; opacity: .65; text-align: center; }

.viewer__text > * { opacity: 0; transform: translateY(14px); transition: opacity .8s ease, transform .8s ease; }
.viewer.is-surfaced .viewer__text > * { opacity: 1; transform: none; }
.viewer.is-surfaced .viewer__text > :nth-child(2) { transition-delay: .1s; }
.viewer.is-surfaced .viewer__text > :nth-child(3) { transition-delay: .18s; }
.viewer.is-surfaced .viewer__text > :nth-child(4) { transition-delay: .28s; }
.viewer.is-surfaced .viewer__text > :nth-child(n+5) { transition-delay: .4s; }

.viewer__water { margin: 0 0 12px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: #a9c3d3; }
.viewer__title { margin: 0; font-family: var(--serif); font-weight: 500; font-size: clamp(30px, 3.4vw, 46px); line-height: 1.08; }
.viewer__artist { margin: 12px 0 28px; font-family: var(--serif); font-style: italic; font-size: 21px; color: #cfdde5; }
.viewer__body p { margin: 0 0 1em; font-family: var(--serif); font-size: clamp(18px, 1.5vw, 21px); line-height: 1.55; color: #e9eef0; }
.viewer__meta {
  display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px;
  margin: 28px 0 22px; padding-top: 18px; border-top: 1px solid rgba(233,241,244,.25);
  font-size: 13px;
}
.viewer__meta dt { color: #a9c3d3; }
.viewer__meta dd { margin: 0; color: #dde6ea; }
.viewer__link { color: var(--foam); font-size: 14px; text-underline-offset: 4px; }
.viewer__nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; }
.navbtn {
  padding: 12px 18px; border: 1px solid rgba(233,241,244,.4); border-radius: 999px;
  background: none; cursor: pointer; color: var(--foam); font-size: 14px;
  transition: background .25s ease, border-color .25s ease;
}
.navbtn:hover, .navbtn:focus-visible { background: rgba(233,241,244,.1); border-color: var(--foam); outline: none; }

body.is-viewing { overflow: hidden; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .masthead { flex-direction: column; align-items: flex-start; }
  .tally { text-align: left; }
  .tally__drops { justify-content: flex-start; }
  .intro { flex-direction: column; align-items: flex-start; gap: 12px; }
  .scene { max-height: none; }
  .index ol { grid-template-columns: 1fr; }
  .index li { border-right: 0 !important; }
  .viewer__inner { grid-template-columns: 1fr; }
  .viewer__figure { position: static; }
  .viewer__frame { min-height: 0; }
  .tag text { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}
