/* ================= the moving background =================
   Sits behind everything the page draws. The still background the site already
   carries stays underneath it as the thing people see before the animation has
   loaded, and while it is loading — so there is never a bare white flash. */
#bg-stage {
  position: fixed; inset: 0; z-index: -1;
  /* The artwork inside is fitted and centred against the small viewport (see
     background.js), so the stage it is centred in must be the small viewport
     too — a fixed inset:0 box is the TALL one on a phone, and the artwork
     would sit (lvh - svh)/2 below the visible centre. When the browser bar
     folds away, the strip underneath is the body's own teal. */
  height: 100%;
  height: 100svh;
  overflow: hidden; pointer-events: none;
  opacity: 0; transition: opacity 0.5s ease;
}
body.has-moving-background #bg-stage { opacity: 1; }

/* Once the animation is live, the still webp underneath must go away — not fade,
   GO. On real Chrome the fixed webp layer could end up painted over the stage,
   leaving exactly one frozen frame visible while the animation ran beneath it.
   The delayed discrete switch keeps the webp as the backdrop during the half-
   second fade-in, then removes it entirely. */
body.has-moving-background::before {
  visibility: hidden;
  transition: visibility 0s linear 0.6s;
}
#bg-stage .bg-box { position: absolute; opacity: 0; }
#bg-stage .bg-box.is-live { opacity: 1; }
#bg-stage svg, #bg-stage canvas { display: block; width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) {
  #bg-stage { transition: none; }
}
