/* ============================================================================
 * The splash — how you arrive at CAUGHT.
 *
 * "/" serves the tool itself (public/map.html). On that one path the splash is
 * painted over it: the name, what the name stands for, one sentence, and the
 * God's Eye film. After ~3.2 s it dissolves and the live map — already loaded
 * and already polling underneath — blooms through. There is no navigation, so
 * there is no loading beat in the middle of the animation and no history entry
 * to trap the back button.
 *
 * THE DISMISSAL IS A CSS ANIMATION, NOT A TIMER. That is deliberate: if
 * splash.js never runs or throws, the splash still animates away on its own and
 * the visitor still reaches the tool. splash.js only adds the nice-to-haves —
 * playing the film, and skipping ahead on the first touch, click, key or scroll.
 *
 * It is armed by ONE attribute, data-splash="on", set on <html> by
 * splash-boot.js before the body paints. Without that attribute (so: /map, or
 * any visitor with JavaScript off) #splash is display:none and costs nothing —
 * not even the poster image, which is a background under the armed selector.
 * ========================================================================== */

#splash { display: none; }

html[data-splash] {
  /* Nothing scrolls behind the splash; released by splash.js when it goes. */
  overflow: hidden;
}

html[data-splash] #splash {
  display: grid;
  position: fixed;
  inset: 0;
  z-index: 2000;                 /* over the header (100) and Leaflet's panes */
  align-items: center;
  overflow: hidden;
  background: #04070d url(/media/godseye-poster.jpg) 58% 50% / cover no-repeat;
  animation: splash-out 1.15s cubic-bezier(0.4, 0, 0.2, 1) 3.25s forwards;
}

/* The film. Starts invisible over the poster and crossfades in once it is
 * actually playing (splash.js adds .is-playing), so a slow connection shows a
 * still frame rather than a black hole. */
.splash-film {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 58% 50%;
  opacity: 0; transition: opacity 700ms ease;
  animation: splash-rise 4.4s cubic-bezier(0.33, 0, 0.1, 1) forwards;
}
.splash-film.is-playing { opacity: 1; }

/* Two gradients: one from the left so the type has a dark field to sit on, one
 * from the bottom so the film doesn't end on a hard edge. */
.splash-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(4,7,13,0.88) 0%, rgba(4,7,13,0.45) 40%, rgba(4,7,13,0) 65%),
    linear-gradient(0deg, #04070d 0%, rgba(4,7,13,0) 22%);
}

.splash-copy {
  position: relative; z-index: 1;
  padding: 0 clamp(20px, 6vw, 96px);
  max-width: 640px;
  color: var(--brand-ink, #e9eef4);
  font-family: var(--font-brand);
  animation: splash-copy-out 0.55s cubic-bezier(0.4, 0, 1, 1) 3s forwards;
}
.splash-copy > * {
  margin: 0;
  opacity: 0;
  animation: splash-copy-in 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
.splash-eyebrow {
  font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: #8595a8; margin-bottom: 1.4em;
  animation-delay: 0.15s;
}
.splash-eyebrow b { color: #e9eef4; font-weight: 700; }
.splash-title {
  font-size: clamp(3.4rem, 11vw, 7.5rem); font-weight: 850;
  letter-spacing: 0.08em; line-height: 1.05; margin-bottom: 0.22em;
  animation-delay: 0.3s;
}
.splash-lede {
  font-size: clamp(1.05rem, 1.7vw, 1.3rem); line-height: 1.55;
  color: #b3c0cf; max-width: 32em;
  animation-delay: 0.5s;
}

/* The one affordance: a thin bar that drains over the dwell, so the hand-over
 * is announced rather than sprung. Its own animation, so it tells the truth
 * about the dismissal even if splash.js never ran. */
.splash-progress {
  position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(90deg, #7fb6e6, rgba(127,182,230,0.25));
  animation: splash-progress 3.25s linear forwards, splash-copy-out 0.4s ease 3s forwards;
}

@keyframes splash-copy-in { to { opacity: 1; transform: none; } }
@keyframes splash-progress { to { transform: scaleX(1); } }

/* Out. pointer-events goes first so the map is usable the instant the fade
 * starts; visibility flips at the end so nothing lingers if splash.js is not
 * there to remove the node. */
@keyframes splash-out {
  0%   { opacity: 1; pointer-events: auto; }
  1%   { pointer-events: none; }
  100% { opacity: 0; visibility: hidden; pointer-events: none; }
}
@keyframes splash-copy-out { to { opacity: 0; transform: translateY(-18px); } }
/* A slow push in across the whole splash, carried on through the fade, so the
 * reveal feels like rising off the water rather than a light switch. */
@keyframes splash-rise { from { transform: scale(1); } to { transform: scale(1.07); } }

/* The copy starts 18px low, matching where splash-copy-out takes it. */
.splash-copy > * { transform: translateY(18px); }
.splash-progress { animation-fill-mode: forwards; }

/* ---- skipped: the visitor touched, clicked, keyed or scrolled -------------
 * Same choreography, no dwell. Re-declared rather than fiddling with delays so
 * the animations restart cleanly from wherever they had got to. */
html[data-splash="off"] #splash { animation: splash-out 0.45s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
html[data-splash="off"] .splash-copy { animation: splash-copy-out 0.3s cubic-bezier(0.4, 0, 1, 1) forwards; }
html[data-splash="off"] .splash-progress { animation: splash-copy-out 0.2s ease forwards; }
html[data-splash="off"] .splash-film { animation-play-state: paused; }

/* ---- phones ---------------------------------------------------------------
 * The film plays at every screen size — it is the thing people remember about
 * this project, and gating it by width would hide it from most visitors. Only
 * the framing changes: the copy sits at the bottom, over a vertical shade. */
@media (max-width: 640px) {
  html[data-splash] #splash { align-items: end; background-position: 60% 40%; }
  .splash-film { object-position: 60% 40%; }
  .splash-copy { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .splash-shade {
    background: linear-gradient(0deg, rgba(4,7,13,0.95) 0%, rgba(4,7,13,0.55) 45%, rgba(4,7,13,0.15) 75%);
  }
}

/* ---- reduced motion -------------------------------------------------------
 * Still a beat of brand, but nothing moves and it clears quickly. splash.js
 * also leaves the film unplayed here, so the poster is all that shows. */
@media (prefers-reduced-motion: reduce) {
  html[data-splash] #splash { animation: splash-out 0.5s ease 1.1s forwards; }
  .splash-film { animation: none; }
  .splash-copy { animation: none; }
  .splash-copy > * { opacity: 1; transform: none; animation: none; }
  .splash-progress { display: none; }
}
