/* shared/site/forge-ground.css -- the hub's ground: five VectorForge acts, one scroll.
 *
 * STACK, from the back:
 *   #forge-ground   the fixed stage (negative z-index, so it sits behind every page element)
 *     .fg-act       one act; its own generated SVG, framed and faded by the engine
 *       .fg-plate   the camera: the per-frame pan that every layer in the act shares
 *     .fg-veil      the readability wash; its alpha is one number the engine blends per act
 *
 * WHY THE PAGE'S OWN BACKGROUND IS CLEARED. The stage is behind ALL content, which is only
 * possible if the body stops painting an opaque colour over it. `html` keeps the colour, so a
 * reader with JavaScript off still gets the studio's dark page instead of white.
 *
 * NOTHING HERE MAY TAKE A POINTER, BE READ ALOUD, OR MOVE TEXT. The stage carries aria-hidden
 * and pointer-events: none in the markup the engine builds, and the only properties animated are
 * opacity on an act and transform on a plate -- both are the ground. No rule in this file touches
 * a page element, and the reduced-motion block removes the movement while keeping the acts.
 */

html {
  background: #07090c;
}

body {
  /* The ground is behind everything; an opaque body would hide it. */
  background: transparent;
}

#forge-ground {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background: #07090c;
  /* blended by the engine from each act's own veil value */
  --fg-veil: 0.52;
}

.fg-act {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  will-change: opacity;
  /* framing, written per act by the engine from the generated art's `frame` */
  --fg-s: 1;
  --fg-m: 1;
}

.fg-plate {
  position: absolute;
  inset: 0;
  will-change: transform;
  transform-origin: 50% 50%;
}

.fg-plate > svg {
  display: block;
  width: 100%;
  height: 100%;
  /* Generated art is composed for a hero, not for live text on top of it: the stage takes the
     brightness down before the veil does anything, so the shapes survive and the copy keeps its
     contrast. Static, so it costs one composited layer rather than a per-frame filter. */
  filter: brightness(0.68) saturate(0.94);
  /* The generated scene is 1600x900 and is CROPPED, never letterboxed: a background with bars
     around it is a picture, not a ground. The scale is the act's framing; it also gives the
     travelling layers somewhere to go without exposing an edge. */
  transform: translate(var(--fg-x, 0%), var(--fg-y, 0%)) scale(var(--fg-s, 1)) scaleX(var(--fg-m, 1));
  transform-origin: 50% 50%;
}

.fg-veil {
  position: absolute;
  inset: 0;
  /* A vertical wash plus a top vignette so the wordmark and the hero's display type never sit on
     raw art. The alpha comes from --fg-veil, which the engine blends across an act change. */
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(7, 9, 12, calc(var(--fg-veil) + 0.16)) 0%, rgba(7, 9, 12, 0) 70%),
    linear-gradient(180deg,
      rgba(7, 9, 12, calc(var(--fg-veil) + 0.2)) 0%,
      rgba(7, 9, 12, var(--fg-veil)) 46%,
      rgba(7, 9, 12, calc(var(--fg-veil) + 0.14)) 100%);
}

/* No CSS transition on an act's opacity: the engine writes that number every frame from the
   scroll position, and a transition on top of it would make the ground lag the reader's wheel. */

@media (prefers-reduced-motion: reduce) {
  /* Keep the acts, remove the movement: the engine already skips every transform, and these two
     rules stop the crossfade from being the only motion left. */
  #forge-ground .fg-plate,
  #forge-ground .fg-plate > svg {
    transform: none !important;
  }
  #forge-ground.fg-ready .fg-act {
    transition: none;
  }
}
