* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* derived from the real Vidi Vaka navy #1f2d48 -- darker for chrome, lighter/teal for content */
  --navy: #1f2d48;
  --bg: #0a1420;
  --text: #e6eef2;
  --muted: #8ea3ae;
  --accent: #3d7ea6;      /* lake-blue, lighter derivative of --navy */
  --accent-2: #6fb7c9;    /* lighter still, for highlights/numbers */
  --card-bg: rgba(10, 20, 32, 0.88);
  /* yellow kept only for the rare link back to vidivaka.mk -- never used in scene content */
  --brand-yellow: #f8d147;
}

html { scroll-behavior: auto; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, 'Times New Roman', serif;
  overflow-x: hidden;
  overflow-anchor: none;
}

/* ---------- scroll progress ---------- */
#progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--accent-2);
  z-index: 60;
}

/* ---------- sticky graphic ---------- */
#graphic {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  z-index: 0;
  background: radial-gradient(ellipse at 50% 30%, #0f2233 0%, var(--bg) 70%);
}

#graphic > div { font-family: 'Segoe UI', system-ui, sans-serif; }

/* generic placeholder block used wherever a real photo/satellite asset is still missing */
.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    repeating-linear-gradient(45deg, rgba(110,183,201,0.06) 0 12px, rgba(110,183,201,0.02) 12px 24px),
    linear-gradient(160deg, #0d1c2b, #142f42);
  border: 1px dashed rgba(110, 183, 201, 0.35);
  color: var(--muted);
}
.ph-label { font-size: 13px; line-height: 1.5; padding: 12px; max-width: 80%; }

/* ================= steps 0-4: opening illustration ================= */
#opening { position: absolute; inset: 0; opacity: 1; transition: opacity 1s ease; pointer-events: none; }
body:not([data-scene="0"]):not([data-scene="1"]):not([data-scene="2"]):not([data-scene="3"]):not([data-scene="4"]) #opening {
  opacity: 0;
}
/* wraps the raster illustration + its SVG line-overlay as one unit. On mobile
   (.op-cammode below) both children get fixed to the illustration's native 1375x768
   pixel size and this wrapper's own transform (translate+scale, driven by
   opSetView/opFlyTo in main.js) pans/zooms them together -- since they start pixel-
   locked 1:1, a single transform keeps the drawn lines glued to the shore they trace
   at any zoom level. Desktop leaves it as a plain full-size no-op wrapper. */
.op-cam { position: absolute; inset: 0; transform-origin: 0 0; }
.op-illustration-img {
  position: absolute; inset: 0;
  background-image: url('../img/hero-illustration.png');
  background-size: cover;
  background-repeat: no-repeat;
  /* "left" (not "center") to match the SVG's xMinYMid alignment exactly -- same
     reasoning: on a container wider than the image's own ratio this crops top/bottom
     only and "left" is a no-op, so this is safe unconditionally, not just on mobile. */
  background-position: left center;
  background-color: #16283a; /* fallback tint until the real file is dropped in */
}
.op-lines-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* shoreline-retreat lines: drawn progressively via stroke-dasharray/offset (see main.js).
   Curved paths that echo the shore's own contour, not straight distance-markers. */
.op-line path { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.55)); }
.op-illus-note-fo { overflow: visible; }
.op-illus-note {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  font-style: italic;
  color: var(--text);
  text-align: center;
  line-height: 1.5;
  background: rgba(8, 16, 26, 0.6);
  border: 1px solid rgba(110, 183, 201, 0.2);
  border-radius: 4px;
  padding: 8px 12px;
  opacity: 0;
  transition: opacity 0.6s ease;
}
body:is([data-scene="1"],[data-scene="2"],[data-scene="3"],[data-scene="4"]) .op-illus-note { opacity: 1; }
.op-line text {
  fill: #fff;
  font-family: Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  text-anchor: middle;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}

.op-numwrap-fo { overflow: visible; }
.op-numwrap {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
body[data-scene="4"] .op-numwrap { opacity: 1; }
.op-num { font-family: Georgia, serif; font-size: 110px; font-weight: 700; color: #fff; line-height: 0.9;
  text-shadow: 0 0 50px rgba(61,126,166,0.85), 0 2px 14px rgba(0,0,0,0.55); }
.op-num-val::before { content: '~'; font-size: 0.55em; vertical-align: 0.2em; color: var(--accent-2); }
.op-numcap { font-size: 21px; color: var(--text); margin-top: 10px; text-shadow: 0 1px 6px rgba(0,0,0,0.7), 0 0 18px rgba(0,0,0,0.5); }

/* ================= steps 5-6: the real photo ================= */
#photo { position: absolute; inset: 0; opacity: 0; transition: opacity 1.1s ease; pointer-events: none; }
body:is([data-scene="5"],[data-scene="6"]) #photo { opacity: 1; }
#photo .photo-img {
  position: absolute; inset: 0;
  background-image: url('../img/hero-photo.webp');
  background-size: cover;
  background-repeat: no-repeat;
  /* same shore-stays-in-frame reasoning as .op-illustration-img -- the shore/lines in
     this photo sit in the same left-of-center composition as the illustration. */
  background-position: left center;
  background-color: #10202f; /* visible fallback tint until the real file is dropped in */
}
#photo .photo-credit {
  position: absolute;
  right: 16px; bottom: 14px;
  font-size: 10px;
  color: rgba(230,238,242,0.7);
  background: rgba(10,20,32,0.55);
  padding: 4px 9px;
  border-radius: 3px;
  transition: opacity 0.6s ease;
}

/* ================= steps 6-8 (zoomed to villages) + 39-42 (zoomed to basin): real map ================= */
#basinMap { position: absolute; inset: 0; opacity: 0; transition: opacity 1s ease; pointer-events: none; }
body:is([data-scene="7"],[data-scene="8"],[data-scene="36"],[data-scene="39"],[data-scene="40"],[data-scene="41"],[data-scene="42"]) #basinMap { opacity: 1; }
#basinMap .bm-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#basinMap .bm-country { stroke: rgba(230,238,242,0.4); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
/* base (rest state) shades -- three distinct lightness steps of the SAME hue, not three
   different hues. The scroll-scrubbed convergence toward one shared shade (scenes 39-42)
   is driven entirely by JS (setCountryUnity in main.js), which overwrites these via
   inline style.fill as the reader scrolls -- no CSS transition here, since a timed
   transition would fight a value that's already being updated every scroll frame. */
#basinMap .bm-mk { fill: rgba(58, 102, 133, 0.5); }
#basinMap .bm-al { fill: rgba(93, 148, 175, 0.5); }
#basinMap .bm-el { fill: rgba(139, 190, 208, 0.5); }
#basinMap .bm-lake { fill: #0a1420; stroke: var(--accent-2); stroke-width: 2; vector-effect: non-scaling-stroke; transition: filter 1.2s ease; }
/* hidden by default, shown only for the village scenes (7-8) -- opt-in rather than a
   single-scene exclusion, so it can't flash back into view mid-fade on any OTHER scene
   transition the way the old "hide only on scene 32" rule did when leaving scene 32 */
#basinMap .bm-pin-dot { fill: var(--accent-2); stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; display: none; }
body:is([data-scene="7"],[data-scene="8"]) #basinMap .bm-pin-dot { display: block; }

/* Once the countries have fully converged to one shade (see setCountryUnity in main.js,
   which toggles this class only once its scroll-driven blend actually reaches t=1), give
   the united basin a gentle shared breathing glow -- a visual echo of "модел на европска
   соработка". Gated on the class rather than a scene number so the pulse's opacity swing
   can never land mid-blend, where it read as the colors flashing/jumping instead of
   sliding smoothly into one. */
#basinMap.bm-united .bm-country {
  animation: basinUnitePulse 4.5s ease-in-out infinite;
}
#basinMap.bm-united .bm-lake {
  animation: basinLakePulse 4.5s ease-in-out infinite;
}
/* 0%/100% deliberately match each element's un-animated rest value (opacity:1, no
   filter) -- a CSS animation snaps straight to its 0% keyframe the instant it's
   attached, with no transition-in from whatever the element looked like a moment
   before. Starting the keyframe anywhere else (e.g. opacity:0.6) reproduced exactly
   the "flash to a darker shade" bug, just moved to the instant .bm-united turns on
   instead of happening mid-blend. */
@keyframes basinUnitePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}
@keyframes basinLakePulse {
  0%, 100% { filter: none; }
  50% { filter: drop-shadow(0 0 20px rgba(110,183,201,0.9)); }
}

/* village labels: HTML overlay, positioned via computed screen %, NOT inside the zoomed SVG group
   (so text size stays constant and legible regardless of map zoom level) */
#basinMap .bm-labels { position: absolute; inset: 0; opacity: 0; transition: opacity 0.5s ease; pointer-events: none; }
body:is([data-scene="7"],[data-scene="8"]) #basinMap .bm-labels { opacity: 1; }
#basinMap .bm-label {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -160%);
  font-size: 13px; color: #fff;
  background: rgba(10,20,32,0.7);
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid rgba(110,183,201,0.5);
  opacity: 0; transition: opacity 0.5s ease;
  white-space: nowrap;
}
#basinMap .bm-label.shown { opacity: 1; }

/* country labels: shown only at the zoomed-out basin view (scenes 39-42) */
#basinMap .bm-country-labels { position: absolute; inset: 0; opacity: 0; transition: opacity 0.6s ease; pointer-events: none; }
body:is([data-scene="39"],[data-scene="40"],[data-scene="41"],[data-scene="42"]) #basinMap .bm-country-labels { opacity: 1; }
#basinMap .bm-country-label {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -50%);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px; letter-spacing: 0.05em; color: var(--text);
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  white-space: nowrap;
}

#basinMap .bm-note {
  position: absolute; left: 16px; bottom: 14px;
  font-size: 10px; color: var(--muted);
}

/* ---------- scene 9: Landsat before/after ---------- */
#landsat {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 0.9s ease;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
body:is([data-scene="9"],[data-scene="10"],[data-scene="11"]) #landsat { opacity: 1; }
#landsat .landsat-pair { display: flex; gap: 3vw; width: 82vw; max-width: 900px; }
#landsat .landsat-img {
  /* matches the source Landsat crops' own portrait ratio (~0.76-0.78) so cover
     barely has to crop anything, instead of forcing them into a wide 4:3 box */
  flex: 1; aspect-ratio: 3/4; position: relative;
  background-size: cover; background-position: center;
  border-radius: 4px;
  box-shadow: 0 6px 26px rgba(0,0,0,0.45);
}
#landsat .ph-1984 { background-image: url('../img/landsat-1984.png'); }
#landsat .ph-2020 { background-image: url('../img/landsat-2020.png'); }
#landsat .landsat-cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 8px 10px 7px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px; line-height: 1.4; color: #fff;
  text-align: center;
  background: linear-gradient(to top, rgba(5,10,16,0.85), rgba(5,10,16,0));
  border-radius: 0 0 4px 4px;
}
#landsat .landsat-note { margin-top: 18px; font-size: 13px; color: var(--muted); }
#landsat .landsat-note a, #threeanswers .ta-src a, .closing-card .cite a {
  color: var(--accent-2); text-decoration: underline; text-decoration-color: rgba(110,183,201,0.4); text-underline-offset: 2px;
  pointer-events: auto;
}
#landsat .landsat-note a:hover, #threeanswers .ta-src a:hover, .closing-card .cite a:hover { text-decoration-color: var(--accent-2); }

/* payoff callout on the 2020 image, right of the lake -- mirrors the opening's "~9m"
   reveal, but scoped to step 10 only (hidden again on steps 9 and 11). */
#landsat .landsat-callout {
  position: absolute; top: 24%; right: 6%; text-align: right;
  font-family: Georgia, serif; color: #fff;
}
#landsat .lc-line {
  opacity: 0; transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  margin-bottom: 14px;
  /* dark pill behind the number -- text-shadow alone wasn't reliable against the
     satellite image's own varying terrain colors (green/brown patches under the
     glow read as low-contrast); a solid backing guarantees legibility regardless
     of what's under it, same pattern as .bm-label/.c-txt elsewhere on the map. */
  background: rgba(8, 16, 26, 0.64);
  border: 1px solid rgba(110, 183, 201, 0.25);
  border-radius: 4px;
  padding: 10px 18px;
  backdrop-filter: blur(3px);
}
#landsat .lc-line.shown { opacity: 1; transform: translateY(0); }
#landsat .lc-num { font-size: 40px; font-weight: 700; }
#landsat .lc-unit { font-size: 22px; font-weight: 700; }
#landsat .lc-label {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 12px; color: var(--text);
}

/* ---------- scenes 12-14: volume vs surface ---------- */
#volume {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 0.9s ease;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
body:is([data-scene="12"],[data-scene="13"],[data-scene="14"]) #volume { opacity: 1; }
#volume .volume-title { font-size: 15px; color: var(--text); margin-bottom: 10px; }
#volume .volume-svg { width: min(520px, 70vw); }
#volume .volume-src { font-size: 11px; color: var(--muted); margin-top: 10px; }
#volume .vbar-label { fill: var(--text); font-size: 15px; }
#volume .vbar-pct { fill: #fff; font-size: 22px; font-weight: 700; font-family: Georgia, serif; }

/* ---------- scenes 15-21: timeline (shared, scroll-scrubbed) ---------- */
#timeline {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 0.9s ease;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
body:is([data-scene="15"],[data-scene="16"],[data-scene="17"],[data-scene="18"],[data-scene="19"],[data-scene="20"],[data-scene="21"]) #timeline { opacity: 1; }
#timeline .timeline-title { font-size: 14px; color: var(--text); margin-bottom: 8px; text-align: center; }
#timeline .timeline-svg { width: min(760px, 84vw); }
#timeline .timeline-readout { font-size: 13px; color: var(--accent-2); margin-top: 8px; min-height: 18px; }
#timeline .timeline-src { font-size: 11px; color: var(--muted); margin-top: 6px; }
#timeline .t-axis text { font-size: 11px; fill: var(--muted); }
#timeline .t-axis line, #timeline .t-grid line { stroke: rgba(230, 238, 242, 0.08); }
#timeline .t-line { fill: none; stroke: var(--accent-2); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#timeline .t-dot { fill: var(--accent-2); }
#timeline .t-band { fill: rgba(226, 90, 90, 0.22); }
#timeline .t-band-label { fill: #e2a35a; font-size: 11px; }

/* ---------- step 22: big faint question mark behind the "we asked too" intro line ---------- */
#introMark {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 0.8s ease;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
body[data-scene="22"] #introMark { opacity: 1; }
.introq-mark {
  font-family: Georgia, serif; font-size: clamp(180px, 24vw, 340px); font-weight: 700;
  color: var(--accent-2); opacity: 0.14; line-height: 1;
  text-shadow: 0 0 0 rgba(110, 183, 201, 0);
}

/* ---------- steps 23-26: claim signature (icon + full citation, no chart backs these claims) ---------- */
#claimSig {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 0.8s ease;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
  padding: 0 6vw;
}
body:is([data-scene="23"],[data-scene="24"],[data-scene="25"],[data-scene="26"]) #claimSig { opacity: 1; }
.claimsig-heading {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 22px; text-align: center;
}
.claimsig-icon {
  width: 100px; height: auto; display: none; margin-bottom: 24px;
  fill: none; stroke: var(--accent-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0.45;
}
.claimsig-dot { fill: var(--accent-2); stroke: none; r: 1.6; }
body[data-scene="23"] .claimsig-climate { display: block; }
body[data-scene="24"] .claimsig-inflow { display: block; }
body:is([data-scene="25"],[data-scene="26"]) .claimsig-irrigation { display: block; }
.claimsig-block {
  display: none; text-align: center; max-width: 460px;
  opacity: 0; transition: opacity 0.6s ease;
}
body[data-scene="23"] .claimsig-block-mes { display: block; opacity: 0.85; }
body[data-scene="24"] .claimsig-block-gfa { display: block; opacity: 0.85; }
body:is([data-scene="25"],[data-scene="26"]) .claimsig-block-vds { display: block; opacity: 0.85; }
.claimsig-title {
  font-family: Georgia, serif; font-style: italic;
  font-size: 17px; color: var(--text); line-height: 1.4;
}
.claimsig-author {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px; color: var(--muted); margin-top: 8px;
}
.claimsig-label {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent-2); margin-top: 8px;
}
.claimsig-label a { color: inherit; pointer-events: auto; text-decoration: underline; text-decoration-color: rgba(110,183,201,0.4); text-underline-offset: 3px; }
.claimsig-label a:hover { text-decoration-color: var(--accent-2); }

/* ---------- step 29: conclusion -- climate<->human-factor needle gauge ---------- */
#claimCompass {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 0.8s ease;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
body[data-scene="29"] #claimCompass.cc-ready { opacity: 1; }
.compass-heading {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 18px; text-align: center; max-width: 360px;
}
.compass-svg { width: min(460px, 78vw); overflow: visible; }
.compass-arc { fill: none; stroke: rgba(110,183,201,0.3); stroke-width: 1.5; stroke-dasharray: 2 4; }
.compass-pole { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 9px; letter-spacing: 0.1em; fill: var(--muted); }
.compass-pole-climate { text-anchor: start; }
.compass-pole-human { text-anchor: end; }
.compass-pivot { fill: var(--muted); }
.compass-needle { stroke-width: 2.4; stroke-linecap: round; transform-box: view-box; transform-origin: 150px 150px; }
.compass-needle-mes { stroke: var(--accent-2); animation: needleDrift1 5.5s ease-in-out infinite; }
.compass-needle-gfa { stroke: var(--accent); animation: needleDrift2 6.5s ease-in-out infinite; }
.compass-needle-soria { stroke: #e2a35a; animation: needleDrift3 4.8s ease-in-out infinite; }
.compass-needle-vds { stroke: #c04b5e; animation: needleDrift1 7.2s ease-in-out infinite reverse; }
@keyframes needleDrift1 { 0%,100% { transform: rotate(-1.6deg); } 50% { transform: rotate(1.6deg); } }
@keyframes needleDrift2 { 0%,100% { transform: rotate(1.4deg); } 50% { transform: rotate(-1.4deg); } }
@keyframes needleDrift3 { 0%,100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
.compass-legend { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; max-width: 380px; }
.compass-legend .cl-item { display: flex; align-items: flex-start; }
.cl-sw { display: inline-block; width: 14px; height: 2.4px; border-radius: 2px; margin-right: 10px; margin-top: 6px; flex-shrink: 0; }
.cl-sw-mes { background: var(--accent-2); }
.cl-sw-gfa { background: var(--accent); }
.cl-sw-soria { background: #e2a35a; }
.cl-sw-vds { background: #c04b5e; }
.cl-text { display: flex; flex-direction: column; }
.cl-title {
  font-family: Georgia, serif; font-style: italic;
  font-size: 12.5px; color: var(--text); line-height: 1.35;
}
.cl-author { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------- steps 27-28: three answers -- rainfall then temperature, one big chart at a time ---------- */
#threeanswers {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 0.9s ease;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 4vw;
  pointer-events: none;
}
body:is([data-scene="27"],[data-scene="28"]) #threeanswers { opacity: 1; }
#threeanswers .ta-title { font-size: 15px; color: var(--text); margin-bottom: 14px; text-align: center; max-width: 640px; display: none; }
#threeanswers .ta-chart { width: min(720px, 88vw); display: none; }
#threeanswers .ta-legend { display: none; gap: 18px; margin-top: 10px; font-size: 12px; color: var(--muted); }
#threeanswers .ta-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
#threeanswers .sw-stenje { background: var(--accent-2); }
#threeanswers .sw-pretor { background: #7fc9a0; }
#threeanswers .sw-temp { background: #e2a35a; }
#threeanswers .ta-src { font-size: 11px; color: var(--muted); margin-top: 10px; display: none; }
#threeanswers .r-axis text, #threeanswers .r-grid line { font-size: 11px; fill: var(--muted); }
#threeanswers .r-grid line { stroke: rgba(230, 238, 242, 0.08); }
body:is([data-scene="27"],[data-scene="28"]) .ta-src { display: block !important; }
body[data-scene="27"] .ta-title-rain, body[data-scene="27"] .ta-chart-rain { display: block !important; }
body[data-scene="27"] .ta-legend-rain { display: flex !important; }
/* Scene 28 keeps the rain chart standing (rather than leaving a bare "Извор:" line
   with nothing above it -- the temp chart isn't ready yet) until .ta-temp-active
   switches it over, once the temperature chart actually has something to show. */
body[data-scene="28"]:not(.ta-temp-active) .ta-title-rain, body[data-scene="28"]:not(.ta-temp-active) .ta-chart-rain { display: block !important; }
body[data-scene="28"]:not(.ta-temp-active) .ta-legend-rain { display: flex !important; }
body[data-scene="28"].ta-temp-active .ta-title-temp, body[data-scene="28"].ta-temp-active .ta-chart-temp { display: block !important; }
body[data-scene="28"].ta-temp-active .ta-legend-temp { display: flex !important; }

/* ---------- steps 30-31: water balance ---------- */
/* The donut (2%/52%/46% outflow split) and the "72%" figure answer two UNRELATED
   questions (see the step text) -- showing both at full strength at once invited
   readers to try to reconcile 52+46 with 72, which don't relate at all. Now each gets
   its own moment: donut alone on step 30, then it dims back on step 31 as the 72%
   figure (a completely separate stat) takes over -- never competing for attention. */
#waterbalance {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 0.9s ease;
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
  padding-right: 3vw;
  pointer-events: none;
}
body:is([data-scene="30"],[data-scene="31"]) #waterbalance { opacity: 1; }
#waterbalance .wb-flex { display: flex; align-items: center; gap: 3vw; }
#waterbalance .wb-donut { width: min(300px, 36vw); overflow: visible; }
#waterbalance .wb-big { max-width: 260px; opacity: 0; transition: opacity 0.6s ease; }
body[data-scene="31"] #waterbalance .wb-big { opacity: 1; }
#waterbalance .wb-num { font-family: Georgia, serif; font-size: 74px; font-weight: 700; color: #fff; line-height: 1; }
#waterbalance .wb-num-pct { font-size: 32px; color: var(--accent-2); }
#waterbalance .wb-cap { font-size: 15px; color: var(--text); margin-top: 8px; line-height: 1.5; }
#waterbalance .wb-src { font-size: 11px; color: var(--muted); margin-top: 16px; max-width: 340px; text-align: left; align-self: flex-end; }
#waterbalance .wb-seg { stroke: var(--bg); stroke-width: 1.5; transition: opacity 0.8s ease, filter 0.8s ease; }
#waterbalance .wb-pct { transition: opacity 0.8s ease; }
/* step 31: dim everything except the irrigation wedge, and give it a glow -- this is
   the visual thread connecting the tiny 2% slice to the big 72% figure that appears
   right next to it, so the two numbers don't read as unrelated. */
/* :not([data-scene="30"]), not just [data-scene="31"] -- otherwise the moment scene
   switches to 32 these rules stop applying (while #waterbalance is still mid-fade-out),
   and the dimmed segments/callouts flash back to full strength for an instant before
   the section finishes fading away. */
body:not([data-scene="30"]) #waterbalance .wb-seg:not(.wb-seg-irrigation),
body:not([data-scene="30"]) #waterbalance .wb-pct:not(.wb-pct-irrigation) { opacity: 0.25; }
body:not([data-scene="30"]) #waterbalance .wb-callout:not(.wb-callout-2) { display: none; }
body[data-scene="31"] #waterbalance .wb-seg-irrigation { filter: drop-shadow(0 0 8px rgba(192,75,94,0.9)); }
#waterbalance .wb-callout { opacity: 0; transition: opacity 0.5s ease; }
#waterbalance .wb-callout.shown { opacity: 1; }
#waterbalance .wb-callout-line { fill: none; stroke: rgba(230,238,242,0.5); stroke-width: 1; }
#waterbalance .wb-callout-label { font-size: 16px; fill: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; font-weight: 600; }
#waterbalance .wb-callout-line { stroke-width: 1.3; }

/* ---------- scene 32: cascade -- four dependents in a circle around the real lake ---------- */
#cascade { position: absolute; inset: 0; opacity: 0; transition: opacity 0.9s ease; pointer-events: none; }
body[data-scene="36"] #cascade { opacity: 1; }
#cascade .cascade-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
#cascade .cs-line {
  stroke: rgba(110,183,201,0.4); stroke-width: 0.3; stroke-dasharray: 1 1.2;
  opacity: 0; transition: opacity 0.6s ease;
}
#cascade .cs-line.shown { opacity: 1; }
#cascade .c-item {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; gap: 8px; width: 130px;
  transform: translate(-50%, -50%) scale(0.7); opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
}
#cascade .c-item.shown { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#cascade .cs-item-0 { left: 74%; top: 26%; }
#cascade .cs-item-1 { left: 74%; top: 56%; }
#cascade .cs-item-2 { left: 46%; top: 56%; }
#cascade .cs-item-3 { left: 46%; top: 26%; }
#cascade .c-ico { font-size: 48px; filter: drop-shadow(0 0 12px rgba(110, 183, 201, 0.35)); }
#cascade .c-txt { font-size: 14px; color: var(--text); text-align: center; background: rgba(10,20,32,0.55); padding: 3px 10px; border-radius: 999px; }

/* ---------- steps 32-35: the unsolved hydrological puzzle ---------- */
#hydropuzzle {
  position: absolute; inset: 0;
  opacity: 0; transition: opacity 0.9s ease;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
body:is([data-scene="32"],[data-scene="33"],[data-scene="34"],[data-scene="35"]) #hydropuzzle { opacity: 1; }
/* full-bleed (not a centered/margined box) so the Adriatic shape, anchored at the
   viewBox's own right/bottom edge, actually reaches the real edge of the screen --
   "slice" crops any aspect-ratio overflow instead of letterboxing, same tradeoff the
   other full-screen background layers (#basinMap etc.) already make. */
#hydropuzzle .hp-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#hydropuzzle .hp-svg-mobile { display: none; }

/* sizes roughly follow real relative surface area (Prespa ~254km², Ohrid ~358km²,
   Skadar ~370-530km², the Adriatic effectively boundless -- hence no fixed node for
   it at all, just a label opening off the edge of the frame). Golemo Preспа stays the
   visually EMPHASIZED one via glow/color/always-on, not by being the biggest shape --
   that would misrepresent the geography just to flatter "our" lake. */
#hydropuzzle .hp-node {
  rx: 40px; ry: 26px;
  fill: rgba(93, 148, 175, 0.4);
  stroke: rgba(230, 238, 242, 0.5); stroke-width: 1.5;
  opacity: 0; transform-box: fill-box; transform-origin: center;
  transform: scale(0.75);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
#hydropuzzle .hp-node.shown { opacity: 1; transform: scale(1); }
#hydropuzzle .hp-malo { rx: 24px; ry: 16px; }
#hydropuzzle .hp-golemo {
  rx: 48px; ry: 31px;
  fill: rgba(110, 183, 201, 0.5);
  stroke: var(--accent-2); stroke-width: 2;
  filter: drop-shadow(0 0 18px rgba(110, 183, 201, 0.55));
}
#hydropuzzle .hp-ohrid { rx: 57px; ry: 37px; }
#hydropuzzle .hp-skadar { rx: 66px; ry: 43px; }
/* not an ellipse -- a corner-anchored shape running off the edges of the viewBox, so
   it reads as "water leaving the frame" rather than just another same-sized lake.
   Inherits the same reveal opacity/transition as .hp-node. The fixed pixel origin is
   scoped to the desktop variant only -- it's tuned to that SVG's own coordinate space
   (760-1000, 373-520) and would put the mobile sea shape's grow-in animation origin
   somewhere off in empty space if applied there too; the mobile shape just uses the
   inherited fill-box "center" default instead. */
#hydropuzzle .hp-svg-desktop .hp-sea { transform-origin: 900px 450px; }

#hydropuzzle .hp-label {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px; fill: var(--text);
  opacity: 0; transition: opacity 0.6s ease;
}
#hydropuzzle .hp-label.shown { opacity: 1; }
#hydropuzzle .hp-label-home, #hydropuzzle .hp-label-malo,
#hydropuzzle .hp-label-ohrid, #hydropuzzle .hp-label-skadar { font-weight: 700; }
#hydropuzzle .hp-label-home { fill: var(--accent-2); }
/* process labels (annotating a flow/connection, not naming a place) -- smaller,
   italic, muted, same treatment as the Devoll label already had. */
#hydropuzzle .hp-label-devol, #hydropuzzle .hp-label-karst, #hydropuzzle .hp-label-drim {
  font-size: 12px; fill: var(--muted); font-style: italic;
}
#hydropuzzle .hp-label-stopped { font-size: 11px; fill: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
#hydropuzzle .hp-label-sea { fill: var(--accent-2); font-weight: 700; }

/* connector lines: hidden -> fade in, then a continuously-cycling dash offset once
   shown gives a "flowing water" read instead of a static diagram. Karst gets a longer,
   sparser dash (slow, hidden, uncertain seepage) vs. the surface rivers' tighter, faster
   dash (visible, confident flow) -- the animation style itself encodes the difference
   between "measured" and "not precisely measured" the step's own text is making. */
#hydropuzzle .hp-flow {
  fill: none; stroke: var(--accent-2); stroke-width: 2.4; stroke-linecap: round;
  opacity: 0; transition: opacity 0.6s ease;
}
#hydropuzzle .hp-flow.shown { opacity: 0.85; }
#hydropuzzle .hp-devol-river, #hydropuzzle .hp-branch-devol {
  stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 5;
}
#hydropuzzle .hp-karst { stroke-dasharray: 2 9; stroke-width: 2; }
#hydropuzzle .hp-drim, #hydropuzzle .hp-adriatic, #hydropuzzle .hp-conn-malo-golem {
  stroke-dasharray: 7 6;
}
#hydropuzzle .hp-flow.shown:not(.hp-stopped) { animation: hpFlow 2.2s linear infinite; }
#hydropuzzle .hp-karst.shown:not(.hp-stopped) { animation-duration: 4.5s; }
#hydropuzzle .hp-devol-river.shown { animation-duration: 3s; }
@keyframes hpFlow { to { stroke-dashoffset: -24; } }
/* the diversion stopped in 2002 -- freeze the dash instead of looping it, and dim it
   to visually read as "off" rather than just another active flow. */
#hydropuzzle .hp-branch-devol.hp-stopped { opacity: 0.35; }

#hydropuzzle .hp-gate {
  opacity: 0; transition: opacity 0.5s ease;
  fill: var(--bg); stroke: var(--muted); stroke-width: 1.5;
}
#hydropuzzle .hp-gate.shown { opacity: 1; }

/* ---------- scene 17: two gauges ---------- */
#twogauges { position: absolute; inset: 0; opacity: 0; transition: opacity 0.9s ease; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
body:is([data-scene="37"],[data-scene="38"]) #twogauges { opacity: 1; }
#twogauges .tg-title { font-size: 14px; color: var(--text); margin-bottom: 18px; text-align: center; max-width: 500px; }
#twogauges .tg-cards { display: flex; flex-direction: column; align-items: center; gap: 14px; }
#twogauges .tg-card {
  background: var(--card-bg);
  border: 1px solid rgba(110, 183, 201, 0.3);
  border-radius: 8px;
  padding: 22px 40px;
  text-align: center;
  min-width: 220px;
}
#twogauges .tg-src-name { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
#twogauges .tg-val { font-family: Georgia, serif; font-size: 52px; font-weight: 700; color: #fff; }
#twogauges .tg-val-unit { font-size: 20px; color: var(--accent-2); margin-left: 3px; }
#twogauges .tg-val-approx { font-size: 32px; color: #fff; margin-right: 2px; }
#twogauges .tg-vs { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }

/* ---------- legend ---------- */
#legend {
  position: absolute;
  left: 24px;
  bottom: 24px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 11px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}
body:not([data-scene="0"]):not([data-scene="41"]):not([data-scene="42"]) #legend { opacity: 1; }
#legend .legend-title { color: var(--text); font-size: 12px; margin-bottom: 4px; }

/* ---------- scroll steps ---------- */
#scrolly {
  position: relative;
  z-index: 1;
  margin-top: -100vh;
  pointer-events: none;
}

.step {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 0 0 0 6vw;
}
.step.title-step, .step.outro-step { justify-content: center; padding: 0 24px; }
.step.title-step { min-height: 108vh; }

/* opening sequence (steps 1-8): extra scroll room -- more breathing space between beats */
.step.op-step, .step.num-step, .step.credit-step,
.step[data-step="6"], .step.place-step, .step[data-step="8"] {
  min-height: 130vh;
}
.step.op-step .card, .step.credit-step .card { max-width: 360px; }
.step.num-step { justify-content: center; }

.step[data-step="15"], .step[data-step="16"], .step[data-step="17"], .step[data-step="18"], .step[data-step="19"], .step[data-step="20"] { min-height: 115vh; }
/* extra scroll room around the rain->temp chart swap so it isn't so abrupt, and so the
   next step's card doesn't rush in right as the chart finishes drawing */
.step[data-step="27"], .step[data-step="28"] { min-height: 150vh; }
/* extra room so the cascade card fully exits before the hydro-puzzle diagram's own
   card starts entering -- otherwise the two visuals felt like they were overlapping. */
.step[data-step="32"] { min-height: 130vh; }
/* step 21 closes the timeline section -- extra tall AND pinned to the top of that
   extra height (not centered/bottom-anchored like other steps) so the trailing space
   lands AFTER the card exits, not before it enters -- gives the reader a clean,
   uncluttered look at the finished chart before the next scene's visual fades in. */
.step[data-step="21"] { min-height: 270vh; align-items: flex-start !important; padding-top: 8vh; }

.card {
  max-width: 400px;
  background: var(--card-bg);
  border: 1px solid rgba(110, 183, 201, 0.18);
  backdrop-filter: blur(6px);
  padding: 26px 28px;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1.55;
  pointer-events: auto;
}
.card p + p { margin-top: 14px; }
.card strong { color: #fff; }

.title-card {
  position: relative;
  max-width: 640px; text-align: center; background: none; border: none; backdrop-filter: none;
  padding: 56px 40px;
}
.title-card::before {
  content: '';
  position: absolute;
  inset: -10px -50px;
  z-index: -1;
  background: radial-gradient(ellipse at center, rgba(6,14,22,0.62) 0%, rgba(6,14,22,0.42) 45%, rgba(6,14,22,0) 78%);
}
.title-card h1 {
  font-size: clamp(38px, 6.4vw, 72px);
  line-height: 1.1;
  margin: 18px 0 22px;
  color: #fff;
  text-shadow: 0 2px 16px rgba(0,0,0,0.65);
}
.title-card .lede { font-size: 20px; color: var(--text); text-shadow: 0 1px 10px rgba(0,0,0,0.65); }
.kicker {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-2);
  text-shadow: 0 1px 8px rgba(0,0,0,0.7);
}
.hint { margin-top: 46px; color: var(--text); font-size: 15px; text-shadow: 0 1px 8px rgba(0,0,0,0.65); }
.src { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 12px; color: var(--muted); }

.closing-card { max-width: 580px; }
.closing-card h2 { font-size: clamp(24px, 3.2vw, 34px); color: #fff; line-height: 1.2; margin-bottom: 14px; }
.closing-card .cite { margin-top: 18px; border-top: 1px solid rgba(110, 183, 201, 0.18); padding-top: 12px; }
.closing-card .credits { margin-top: 8px; opacity: 0.8; }

@media (max-width: 1100px) {
  #graphic > div:not(#legend) { text-align: center; }
  .step:not(.title-step):not(.outro-step):not(.num-step) { align-items: flex-end; padding: 0 5vw 4vh; }
  .step:not(.title-step):not(.outro-step) .card { font-size: 15px; padding: 18px 20px; }
  #landsat .landsat-pair { flex-direction: column; width: 70vw; }
  /* step 20's card is bottom-anchored (rule above) right up against step 21's card,
     which is top-anchored with only 8vh of its own padding (base rule) -- on a short
     mobile viewport that leaves barely a sliver of the timeline chart visible between
     two long, text-heavy cards. Give step 21 much more headroom on narrow screens so
     the chart actually reads as its own beat, not just a seam between two cards. */
  .step[data-step="21"] { padding-top: 22vh !important; }
  /* the card is now bottom-anchored (rule above) -- the compass gauge+legend were
     still vertically CENTERED, so on a short screen the two fought for the same
     center-to-bottom band and overlapped. Top-anchoring the compass instead gives
     each its own zone: gauge up top, card down bottom, matching the same "text
     doesn't have to sit on top of the visual" idea used for the hydro-puzzle fix. */
  #claimCompass { justify-content: flex-start; padding-top: 8vh; }
}
}

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

@media (max-width: 640px) {
  .step { padding: 0 16px; }
  .step:not(.title-step):not(.outro-step):not(.num-step) { padding: 0 4vw 3vh; }
  .card { max-width: 100%; font-size: 16px; }
  #legend { left: 14px; bottom: 14px; }
  .op-num { font-size: clamp(60px, 22vw, 110px); }
  /* #photo .photo-img: "contain" instead of "cover" -- its own baked-in shore/years
     annotation sits in a wide, left-of-center composition that a portrait crop can't
     hold onto, so show the whole image letterboxed top/bottom instead. (Its
     background-position stays "left center" from the base rule above -- on a
     narrower-than-image container that's a no-op either way, since "contain" already
     shows 100% of the image with zero horizontal letterbox to position within.) */
  #photo .photo-img { background-size: contain; }
  /* .op-illustration-img: switches to the scroll-driven camera instead (see .op-cam
     above + opInitCamera/opSetView/opFlyTo in main.js) -- fixed to the illustration's
     native pixel size so main.js's transform can pan/zoom it. */
  #opening.op-cammode .op-cam { position: absolute; top: 0; left: 0; width: 1375px; height: 768px; }
  #opening.op-cammode .op-illustration-img { position: absolute; top: 0; left: 0; width: 1375px; height: 768px; background-size: 1375px 768px; background-position: 0 0; }
  #opening.op-cammode .op-lines-svg { position: absolute; top: 0; left: 0; width: 1375px; height: 768px; }
  /* extra squeeze on very short phones -- the card for this step is long, so give the
     gauge+legend as much of a head start as possible before the card's bottom-anchored
     bulk reaches it. Doesn't fully eliminate the overlap (the card is always-present
     for the whole step, same as every other scene on this site) but keeps more of the
     legend clear of it for longer. */
  #claimCompass { padding-top: 4vh; }
  .compass-svg { width: min(320px, 62vw); }
  .compass-legend { margin-top: 14px; gap: 8px; }
  /* swap to the purpose-built vertical hydro-puzzle diagram instead of stretching the
     wide desktop one -- see the long comment on the mobile <svg> in index.html. */
  #hydropuzzle .hp-svg-desktop { display: none; }
  #hydropuzzle .hp-svg-mobile { display: block; }
  /* the 19km²/7% callout was sized for the desktop image (much wider in absolute px
     even though both crop to the same 3:4 ratio) -- at mobile's narrower actual pixel
     width the same font-size/padding reads as huge and buries most of the lake under
     the two pills. Shrink both down to something proportionate to the smaller image. */
  #landsat .landsat-callout { top: 20%; right: 5%; }
  #landsat .lc-line { padding: 6px 10px; margin-bottom: 8px; border-radius: 3px; }
  #landsat .lc-num { font-size: 22px; }
  #landsat .lc-unit { font-size: 13px; }
  #landsat .lc-label { font-size: 9px; }
}
