:root {
  color-scheme: dark;
  --ink: #edf4e6;
  --muted: #82918b;
  --dim: #56625e;
  --night: #071011;
  --night-2: #0b1818;
  --line: rgba(213, 235, 219, 0.14);
  --acid: #d8ff73;
  --water: #5de1d1;
  --violet: #a98dff;
  --orange: #ff895d;
  --page-pad: clamp(18px, 3.6vw, 56px);
  --serif: Iowan Old Style, Palatino Linotype, Book Antiqua, Palatino, Georgia, serif;
  --sans: Arial Narrow, Helvetica Neue, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--night); }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 76% 18%, rgba(43, 100, 93, 0.16), transparent 31rem),
    radial-gradient(circle at 14% 63%, rgba(118, 90, 173, 0.08), transparent 28rem),
    var(--night);
  color: var(--ink);
  font-family: var(--sans);
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }

.shell {
  position: relative;
  min-height: 100vh;
  padding: 0 var(--page-pad);
  isolation: isolate;
}

.shell::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.28;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.series {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.series-dot,
.privacy-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 14px rgba(216, 255, 115, 0.6);
}

.privacy-mark {
  display: flex;
  gap: 9px;
  align-items: center;
}

.privacy-pulse {
  width: 5px;
  height: 5px;
  background: var(--water);
  box-shadow: 0 0 12px rgba(93, 225, 209, 0.7);
}

.opening {
  display: grid;
  grid-template-columns: minmax(250px, 0.75fr) minmax(540px, 1.75fr);
  gap: clamp(36px, 5vw, 86px);
  align-items: center;
  min-height: calc(100svh - 72px);
  padding: clamp(48px, 8vh, 100px) 0;
}

.opening-copy { align-self: center; }

.kicker,
.portrait-label,
.observation-cap,
.inspector-kind {
  margin: 0 0 12px;
  color: var(--water);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

h1 {
  max-width: 8ch;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3.4rem, 6vw, 7.4rem);
  font-weight: 400;
  letter-spacing: -0.058em;
  line-height: 0.83;
}

.lede {
  max-width: 35ch;
  margin: clamp(26px, 4vh, 44px) 0 0;
  color: #b2c0b9;
  font-family: var(--serif);
  font-size: clamp(1rem, 1.35vw, 1.26rem);
  line-height: 1.55;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  margin-top: 28px;
}

.file-button,
.text-button {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.file-button {
  display: inline-flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  min-width: 230px;
  padding: 0 18px 0 22px;
  background: var(--acid);
  color: #15200c;
  box-shadow: 0 10px 32px rgba(156, 201, 74, 0.12);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.file-button:hover { transform: translateY(-2px); box-shadow: 0 14px 38px rgba(156, 201, 74, 0.2); }

.text-button {
  padding: 0 2px;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: rgba(130, 145, 139, 0.35);
  text-underline-offset: 5px;
}

.text-button:hover { color: var(--ink); }

.file-button:focus-visible,
.text-button:focus-visible,
.feature:focus-visible,
.inspector-close:focus-visible,
.series:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 4px;
}

.privacy-copy {
  max-width: 44ch;
  margin: 18px 0 0;
  color: var(--dim);
  font-size: 0.72rem;
  line-height: 1.55;
}

.privacy-copy strong { color: var(--muted); }

.portrait-wrap {
  position: relative;
  min-width: 0;
  padding: clamp(22px, 3vw, 38px);
  overflow: hidden;
  border: 1px solid rgba(213, 235, 219, 0.12);
  border-radius: 2px;
  background:
    linear-gradient(180deg, rgba(17, 36, 35, 0.8), rgba(5, 14, 15, 0.86)),
    var(--night-2);
  box-shadow: 0 40px 110px rgba(0, 0, 0, 0.42), inset 0 1px rgba(255, 255, 255, 0.025);
}

.portrait-wrap::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background: linear-gradient(105deg, transparent 0 56%, rgba(216, 255, 115, 0.025) 56.2%, transparent 57%);
}

.portrait-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.portrait-label { margin-bottom: 6px; color: var(--muted); }

.portrait-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.6rem, 2.8vw, 3.1rem);
  font-weight: 400;
  letter-spacing: -0.035em;
}

.portrait-count {
  max-width: 20ch;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-align: right;
  text-transform: uppercase;
}

.time-ruler {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin: 18px 2px 4px 68px;
  color: var(--dim);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.time-ruler span:last-child { text-align: right; }

.portrait {
  position: relative;
  height: min(58vh, 560px);
  min-height: 420px;
}

#river-canvas,
.streams {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#river-canvas { opacity: 0.92; }

.streams {
  z-index: 1;
  display: grid;
  grid-template-rows: repeat(7, 1fr);
}

.stream {
  position: relative;
  min-height: 0;
}

.stream:not(:last-child)::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 68px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(213, 235, 219, 0.07) 8%, rgba(213, 235, 219, 0.07) 90%, transparent);
}

.day-label {
  position: absolute;
  top: 50%;
  left: 0;
  display: flex;
  width: 48px;
  transform: translateY(-50%);
  flex-direction: column;
  gap: 3px;
  color: var(--muted);
}

.day-label strong {
  color: #cbd6ce;
  font-family: var(--serif);
  font-size: 0.92rem;
  font-weight: 400;
  letter-spacing: 0.03em;
}

.day-label span {
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.river {
  position: absolute;
  inset: 6px 0 6px 68px;
  overflow: hidden;
  background-image: linear-gradient(90deg, rgba(213, 235, 219, 0.055) 1px, transparent 1px);
  background-size: 25% 100%;
}

.strand {
  position: absolute;
  right: 0;
  left: 0;
  top: var(--strand-y);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(210, 231, 218, 0.14) 5%, rgba(210, 231, 218, 0.1) 95%, transparent);
}

.strand::before {
  position: absolute;
  left: -5px;
  width: 3px;
  height: 3px;
  transform: translateY(-1px);
  border-radius: 50%;
  background: rgba(210, 231, 218, 0.35);
  content: "";
}

.feature {
  position: absolute;
  z-index: 2;
  top: calc(var(--strand-y) - 9px);
  left: var(--x);
  width: max(var(--w), 12px);
  height: 19px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
}

.feature::before {
  position: absolute;
  top: 7px;
  right: 0;
  bottom: 7px;
  left: 0;
  border-radius: inherit;
  background: var(--feature-color, var(--water));
  box-shadow: 0 0 10px color-mix(in srgb, var(--feature-color, var(--water)) 60%, transparent);
  content: "";
  opacity: 0.78;
  transition: opacity 140ms ease, top 140ms ease, bottom 140ms ease;
}

.feature:hover::before,
.feature:focus-visible::before {
  top: 5px;
  bottom: 5px;
  opacity: 1;
}

.feature-event { transition: opacity 180ms ease; }
.feature-event.is-muted { opacity: 0.14; }
.feature-event.is-related::before {
  top: 3px;
  bottom: 3px;
  opacity: 1;
  box-shadow: 0 0 18px color-mix(in srgb, var(--feature-color, var(--water)) 78%, transparent);
}

.feature-basin {
  z-index: 1;
  min-width: 30px;
}

.feature-basin::before {
  top: 2px;
  bottom: 2px;
  border: 1px solid rgba(216, 255, 115, 0.56);
  background: rgba(216, 255, 115, 0.025);
  box-shadow: inset 0 0 14px rgba(216, 255, 115, 0.08), 0 0 18px rgba(216, 255, 115, 0.08);
}

.feature-basin::after {
  position: absolute;
  top: 50%;
  left: 8px;
  padding: 2px 5px;
  transform: translateY(-50%);
  background: #152019;
  color: var(--acid);
  content: attr(data-label);
  font-size: clamp(0.42rem, 0.66vw, 0.59rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.seam-callout {
  position: absolute;
  z-index: 5;
  top: 5px;
  right: 2px;
  max-width: 24ch;
  padding: 7px 9px;
  transform: translateY(-5px);
  border: 1px solid rgba(255, 137, 93, 0.32);
  background: rgba(7, 16, 17, 0.9);
  color: #ffb29a;
  font-size: 0.54rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  line-height: 1.35;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.seam-callout.is-visible { transform: translateY(0); opacity: 1; }

.portrait.is-revealing .strand { animation: strand-in 820ms cubic-bezier(.16, .84, .29, 1) both; animation-delay: calc(var(--i) * 28ms); }
.portrait.is-revealing .feature { animation: feature-in 620ms cubic-bezier(.22, .9, .31, 1.2) both; animation-delay: calc(140ms + var(--i) * 22ms); }

@keyframes strand-in { from { opacity: 0; transform: scaleX(0.2); transform-origin: left; } }
@keyframes feature-in { from { opacity: 0; transform: translateY(8px) scaleX(0.35); } }

.portrait-foot {
  display: flex;
  gap: 24px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.portrait-foot p { display: flex; gap: 8px; align-items: center; margin: 0; }

.legend-line { display: inline-block; width: 18px; height: 3px; border-radius: 8px; background: var(--water); }
.legend-free { height: 9px; border: 1px solid var(--acid); background: transparent; }

.reading {
  padding: clamp(72px, 12vh, 150px) 0 clamp(90px, 14vh, 170px);
  border-top: 1px solid var(--line);
}

.reading > .kicker { margin-bottom: 28px; }

.reading-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.3fr) repeat(2, minmax(190px, 0.7fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.observation {
  min-height: 220px;
  padding: clamp(26px, 4vw, 56px);
}

.observation + .observation { border-left: 1px solid var(--line); }

.observation-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-content: center;
  align-items: baseline;
}

.observation-number {
  margin: 0;
  color: var(--acid);
  font-family: var(--serif);
  font-size: clamp(4rem, 8vw, 8.2rem);
  font-weight: 400;
  letter-spacing: -0.07em;
  line-height: 0.75;
  text-shadow: 0 0 32px rgba(216, 255, 115, 0.12);
}

.observation-text {
  max-width: 30ch;
  margin: 0;
  color: #bec9c2;
  font-family: var(--serif);
  font-size: clamp(1.05rem, 1.55vw, 1.42rem);
  line-height: 1.45;
}

.observation-cap { color: var(--muted); }

.inspector {
  position: fixed;
  z-index: 20;
  right: var(--page-pad);
  bottom: 22px;
  width: min(390px, calc(100vw - 36px));
  padding: 24px 54px 24px 24px;
  transform: translateY(calc(100% + 46px));
  border: 1px solid rgba(216, 255, 115, 0.24);
  background: rgba(11, 24, 24, 0.96);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
  opacity: 0;
  transition: transform 240ms ease, opacity 240ms ease;
  backdrop-filter: blur(14px);
}

.inspector.is-open { transform: translateY(0); opacity: 1; }
.inspector-kind { margin-bottom: 7px; color: var(--acid); }
.inspector-title { margin: 0; font-family: var(--serif); font-size: 1.35rem; line-height: 1.25; }
.inspector-time { margin: 8px 0 0; color: var(--muted); font-size: 0.76rem; letter-spacing: 0.05em; }
.inspector-close { position: absolute; top: 9px; right: 11px; width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.5rem; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 0 38px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

footer p { margin: 0; }

@media (max-width: 980px) {
  .opening { grid-template-columns: 1fr; min-height: auto; padding-top: 70px; }
  .opening-copy { display: grid; grid-template-columns: 1fr 1fr; column-gap: 34px; }
  .opening-copy .kicker, .opening-copy h1 { grid-column: 1; }
  .lede, .actions, .privacy-copy { grid-column: 2; }
  .lede { grid-row: 1 / span 2; align-self: end; margin-top: 0; }
  .actions { align-self: start; }
  .portrait-wrap { grid-column: 1 / -1; }
  .reading-grid { grid-template-columns: 1fr 1fr; }
  .observation-main { grid-column: 1 / -1; }
  .observation:nth-child(2) { border-left: 0; border-top: 1px solid var(--line); }
  .observation:nth-child(3) { border-top: 1px solid var(--line); }
}

@media (max-width: 620px) {
  .masthead { min-height: 58px; font-size: 0.59rem; letter-spacing: 0.1em; }
  .opening { display: flex; gap: 0; flex-direction: column; padding: 46px 0 68px; }
  .opening-copy { display: contents; }
  .opening-copy .kicker { order: 1; }
  h1 { order: 2; font-size: clamp(3.65rem, 18vw, 5.25rem); }
  .portrait-wrap { order: 3; margin: 34px calc(var(--page-pad) * -1) 42px; padding: 24px var(--page-pad); border-right: 0; border-left: 0; }
  .lede { order: 4; margin-top: 0; }
  .actions { order: 5; align-items: stretch; flex-direction: column; }
  .privacy-copy { order: 6; }
  .file-button { width: 100%; }
  .text-button { width: max-content; padding: 0; text-align: left; }
  .portrait-head { align-items: start; }
  .portrait-count { max-width: 13ch; font-size: 0.57rem; }
  .time-ruler { margin-left: 48px; }
  .portrait { min-height: 470px; height: 62svh; max-height: 540px; }
  .stream:not(:last-child)::after { left: 48px; }
  .day-label { width: 38px; }
  .day-label strong { font-size: 0.78rem; }
  .day-label span { font-size: 0.44rem; }
  .river { left: 48px; }
  .feature { min-width: 10px; }
  .feature-basin::after { left: 5px; font-size: 0.43rem; letter-spacing: 0.04em; }
  .seam-callout { top: 2px; font-size: 0.47rem; }
  .portrait-foot { justify-content: flex-start; gap: 16px; }
  .reading { padding-top: 86px; }
  .reading-grid { grid-template-columns: 1fr; }
  .observation { min-height: 180px; }
  .observation-main { grid-column: auto; grid-template-columns: 1fr; gap: 18px; }
  .observation + .observation { border-top: 1px solid var(--line); border-left: 0; }
  .observation-number { font-size: 5.8rem; }
  .inspector { right: 18px; bottom: 14px; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
