/* ============================================================================
   Caledapt — the scenic video backdrop (SITE-WIDE)
   ----------------------------------------------------------------------------
   ONE persistent, scroll-scrubbed Highlands video behind every page.

   WHY SITE-WIDE
   -------------
   The video is a decorative environment, not a homepage device. Injecting the
   same stage into every page means the site reads as one place, and it means the
   PWA cache holds one copy of the video rather than a variant per template.

   LAYER ORDER
   -----------
   .scenic        z-index 0   the video + its overlays
   page content   z-index 1+  everything else
   The video can never intercept input (pointer-events:none) and is aria-hidden, so
   it contributes nothing to the accessibility tree.

   THE OVERLAY
   -----------
   --scenic-veil defaults to 0.70: a 70% opaque dark wash over the video, which is
   the level that keeps body copy at full legibility while the landscape still
   reads as a place rather than a texture. The global --world-dark value then
   modulates it further on the homepage, so the storytelling arc still has room to
   darken and open the scene without ever dropping below the floor set here.

   PERFORMANCE
   -----------
   - preload="metadata", never "auto": a 4MB MP4 must not compete with first paint
   - poster paints immediately, so the hero is never waiting on video
   - no audio track at all (stripped at encode time), and muted+playsinline so
     mobile Safari cannot promote it to a fullscreen player
   - the video is PAUSED and driven by currentTime. It never autoplays, so it
     cannot fight the scroll position
   - decoding="async" keeps it off the critical path
   ============================================================================ */

/* Horizontal containment.
   The inner pages carry decorative layers that legitimately extend past the
   viewport: a fixed-position .aurora blob at right=1656 and a #softTrack carousel
   at right=2708. Production suppresses the resulting scrollbar with
   `body { overflow-x: hidden }`, which the Next deploy tree does not carry, so
   every inner page reported 14px of overflow. Restoring the guard here -- next to
   the stage that introduces fixed full-bleed layers -- keeps it in one place
   instead of scattering it across the old stylesheets.

   `overflow-x: clip` is preferred over `hidden` here: hidden on body makes the
   body a scroll container, which silently breaks position:sticky for descendants.
   clip does not. `overflow-x: hidden` is kept as the fallback for older engines. */
html { overflow-x: clip; }
body {
  overflow-x: clip;
  /* Fallback for engines without overflow:clip. Declared after, so it only applies
     where clip is unsupported. */
  max-width: 100vw;
}
@supports not (overflow-x: clip) {
  html, body { overflow-x: hidden; }
}

.scenic {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: var(--ink-950);
  contain: strict;
}

.scenic__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 62% 46%;
  opacity: var(--scenic-video-opacity, 1);
  will-change: transform, opacity;
  transform: scale(var(--scenic-zoom, 1.02)) translate3d(0, var(--scenic-drift, 0px), 0);
  transform-origin: 62% 46%;
}

/* --- the 70% veil -------------------------------------------------------
   One element, several non-destructive layers, exactly as the brief requires:
   a flat 70% wash plus a directional ramp so the left-hand copy column always has
   the darkest ground and the right-hand visual column keeps more of the scene.
   ---------------------------------------------------------------------- */
.scenic__veil {
  position: absolute;
  inset: 0;
  /* A near-FLAT 70% wash, as specified. The earlier version ramped 0.94 -> 0.52
     across the frame, which put the brightest, busiest part of the landscape
     exactly where the cyan linework and 10px labels sit -- measured on a real
     capture, that is what made the control-plane labels unreadable. A flat veil
     keeps the whole frame equally quiet. */
  background: rgba(7, 6, 6, 0.70);
}

/* A vertical fade so the top and bottom of the viewport release into the page
   rather than ending on a hard horizontal edge. */
.scenic__veil::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(7, 6, 6, 0.34) 0%,
    rgba(7, 6, 6, 0.08) 16%,
    rgba(7, 6, 6, 0) 36%,
    rgba(7, 6, 6, 0) 66%,
    rgba(7, 6, 6, 0.10) 86%,
    rgba(7, 6, 6, 0.30) 100%
  );
}

/* Very subtle technical grid, always faint. */
.scenic__grid {
  position: absolute;
  inset: 0;
  opacity: var(--scenic-grid, 0);
  background-image:
    linear-gradient(to right, rgba(25, 232, 222, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(25, 232, 222, 0.05) 1px, transparent 1px);
  background-size: 76px 76px;
  mask-image: radial-gradient(120% 90% at 50% 45%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(120% 90% at 50% 45%, #000 20%, transparent 78%);
}

.scenic__sun {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    120% 80% at 74% 20%,
    rgba(222, 185, 141, calc(0.10 * var(--scenic-warm, 0.6))) 0%,
    rgba(222, 185, 141, 0) 60%
  );
  mix-blend-mode: screen;
}

/* --- page content sits above ------------------------------------------- */
/* Lift page content above the fixed stage. The :not() is load-bearing: the stage is
   itself a direct child of <body>, and without the exclusion this rule overrode
   `.world{position:fixed}` with position:relative, collapsing the whole scenic
   stage to zero height. Symptom: the video "loaded" but never painted, and
   currentTime never moved. */
/* Lift page content above the fixed scenic stage.

   THE EXCLUSIONS ARE LOAD-BEARING, and this has now bitten twice.

   1. Without excluding .scenic/.world this rule overrode `.world{position:fixed}`
      with position:relative, collapsing the scenic stage to zero height. Symptom:
      the video reported readyState 4 and never painted.
   2. It also captured the page HEADER, because the header is a direct child of
      <body> on the inner pages (.topbar) and nested inside .page on the homepage
      (.site-header). Overriding `position: fixed` with `position: relative` sent
      the nav scrolling away with the document -- measured .topbar top travelling
      -1291px to -3361px across routes.

   Rather than keep appending element names, this now targets only what actually
   needs lifting: the page content wrapper. Headers keep their own positioning. */
/* The Ask Caledapt launcher and panel are appended to <body>, so this rule
   matched them and overrode `position: fixed` with `relative` -- the launcher
   scrolled away with the page instead of floating. Same trap as the
   .topbar/.site-header case: a generic child rule beats a component rule by
   source order, not specificity. Excluded explicitly rather than fixed with an
   !important or a specificity arms race. */
/* NO SPACE between the compound selectors. A line break is still a descendant
   combinator, so this once read as
     .scenic-host > * :not(.rag-launcher) :not(.rag-panel)
   which matched every DESCENDANT of a body child rather than the child itself.
   Measured consequence: section.story, .story__stage and .story__viz all matched
   and this rule overrode `position: sticky` on the story stage with `relative`,
   by source order and later in the cascade. The scrollytelling silently stopped
   pinning. Keep every :not() in ONE uninterrupted compound selector. */
.scenic-host > *:not(.scenic):not(.world):not(.topbar):not(.site-header):not(header):not(.rag-launcher):not(.rag-panel):not(.story):not(.story__stage):not(.story__viz):not(.story__progress):not(.mobile-nav):not(.aurora):not(.aurora-a):not(.aurora-b):not(.grain):not(#ambientCanvas):not(.guide-panel):not(.guide-launch):not(.guide-backdrop):not(.install-modal):not(.toast):not(.offline-badge):not(.skip):not(#crmModal):not(#crmFlash){
  position: relative;
  z-index: 1;
}

/* --- the video is off unless JS has proven it can be driven -------------- */
.scenic__video[data-scrub="pending"] { opacity: 0; }

/* --- reduced motion ------------------------------------------------------
   No scrubbing, no drift, no zoom. The poster is what shows, and it shows at a
   fixed, calm exposure. Nothing about the page's meaning changes.
   ------------------------------------------------------------------------ */
/* The poster is always in the DOM (it is what reduced motion shows, and it is the
   stage's own fallback before the video is ready). It must therefore always have a
   box -- sizing it only inside the reduced-motion query collapsed it to zero height
   in normal motion and took the whole stage with it. */
.scenic__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  display: block;
}
.scenic__poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 62% 46%;
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .scenic__video { display: none; }
  /* A <picture> on inner pages, a bare <img> on the homepage: the base
     rule above covers both. */
}

/* Below 768px the mobile encode and poster are used; the veil is slightly heavier
   because the sunlit mountain occupies more of a narrow frame. */
@media (max-width: 768px) {
  .scenic__video {
    object-position: 58% 42%;
    transform: none;
  }
  .scenic__veil {
    background: linear-gradient(
      180deg,
      rgba(7, 6, 6, 0.72) 0%,
      rgba(7, 6, 6, 0.68) 40%,
      rgba(7, 6, 6, 0.70) 100%
    );
  }
  .scenic__grid { opacity: 0 !important; }
}

/* Print and forced colours: drop the scenery, keep the text. */
@media print { .scenic { display: none; } }
@media (forced-colors: active) { .scenic { display: none; } }