/*!
 * hero-moment-base.css — shared Hero Moment base styles (Lane B1).
 *
 * Contract: design-systems/shared/RUNTIME-INTERFACE.md.
 * Rules:
 *  - Initial (pre-entrance) states exist ONLY under .hm-root.hm-armed and the
 *    runtime is the only writer of that class — so no-JS output, an unknown
 *    contract, and a static_fallback all render the complete settled
 *    composition with zero hidden content (tests 31/52/53).
 *  - .hm-settled always restores the natural static frame.
 *  - Reduced motion forces the settled frame at the CSS layer too (§23).
 *  - Transform-layer wrappers per §19.2: entrance owns .hm-media, ambient
 *    owns .hm-media-camera, scroll owns .hm-media-shell.
 */

/* --- Transform layers (§19.2) --------------------------------------------- */

.hm-root .hm-media-shell {
  position: relative;
  overflow: hidden;
  height: 100%;
  width: 100%;
  will-change: transform;
}

.hm-root .hm-media-camera {
  height: 100%;
  width: 100%;
  will-change: transform;
}

.hm-root .hm-media {
  height: 100%;
  width: 100%;
}

/* --- Armed initial states (runtime-gated; belt-and-braces for the frame
       between class-add and WAAPI fill:'both' application) ------------------ */

.hm-root.hm-armed.hm-anim-fade-in:not(.hm-settled) .hm-media {
  opacity: 0;
}

.hm-root.hm-armed.hm-anim-mask-reveal:not(.hm-settled) .hm-media,
.hm-root.hm-armed.hm-anim-clip-reveal:not(.hm-settled) .hm-media {
  clip-path: inset(0% 100% 0% 0%);
}

.hm-root.hm-armed.hm-anim-focus-resolve:not(.hm-settled) .hm-media {
  filter: blur(var(--hm-focus-resolve-start-blur, 6px));
  transform: scale(var(--hm-focus-resolve-start-scale, 1.04));
}

.hm-root.hm-armed.hm-anim-light-ramp:not(.hm-settled) .hm-media {
  filter: brightness(0.55);
}

.hm-root.hm-armed.hm-anim-panel-converge:not(.hm-settled) .hm-media {
  opacity: 0.72;
}

/* crop_glide is valid as BOTH camera role (.hm-media-camera, ambient/
   secondary framing) AND primary role (.hm-media — spec §26.4/RUNTIME-
   INTERFACE.md §5's expansion-table row: primary entrance ops animate
   hm-media). Both targets get the identical armed/settled treatment so
   whichever layer the runtime actually resolves the operation to (per
   resolveLayer()'s role-first rule) has its belt-and-braces pre-WAAPI
   frame covered — the four-new-primaries gap the WS-B checkpoint closed. */
.hm-root.hm-armed.hm-anim-crop-glide:not(.hm-settled) .hm-media-camera,
.hm-root.hm-armed.hm-anim-crop-glide:not(.hm-settled) .hm-media {
  transform: scale(calc(1 + var(--hm-crop-glide-crop-start-pct, 12) / 100));
}

.hm-root.hm-armed.hm-anim-tracking-resolve:not(.hm-settled) .hm-copy {
  letter-spacing: var(--hm-tracking-resolve-start-tracking, 0.18em);
  opacity: 0.001;
}

.hm-root.hm-armed.hm-anim-proof-cascade:not(.hm-settled) .hm-media > * {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
}

/* --- line_draw decorative rule (exists only when the mechanic is active) --- */

.hm-root.hm-anim-line-draw .hm-copy::after {
  content: "";
  display: block;
  width: 2.5em;
  height: 2px;
  margin-top: 0.75em;
  background: currentColor;
  transform-origin: var(--hm-line-draw-origin, left center);
}

.hm-root.hm-armed.hm-anim-line-draw:not(.hm-settled) .hm-copy::after {
  transform: scaleX(0);
}

/* --- Settled state: the natural static composition -------------------------
       Armed initial states are gated on .hm-armed (removed at settle), so the
       cascade restores each design system's own values. These scoped resets
       only neutralize runtime-owned mechanic states — they never clobber
       per-system styling. Blur/brightness may never persist after settle
       (§24). */

.hm-root.hm-settled.hm-anim-fade-in .hm-media,
.hm-root.hm-settled.hm-anim-panel-converge .hm-media {
  opacity: 1;
}

.hm-root.hm-settled.hm-anim-mask-reveal .hm-media,
.hm-root.hm-settled.hm-anim-clip-reveal .hm-media,
.hm-root.hm-settled.hm-anim-panel-converge .hm-media {
  clip-path: none;
}

.hm-root.hm-settled.hm-anim-focus-resolve .hm-media,
.hm-root.hm-settled.hm-anim-light-ramp .hm-media {
  filter: none;
  transform: none;
}

.hm-root.hm-settled.hm-anim-crop-glide .hm-media-camera,
.hm-root.hm-settled.hm-anim-crop-glide .hm-media {
  transform: none;
}

.hm-root.hm-settled.hm-anim-tracking-resolve .hm-copy {
  letter-spacing: inherit;
  opacity: 1;
}

.hm-root.hm-settled.hm-anim-proof-cascade .hm-media > * {
  opacity: 1;
  transform: none;
}

.hm-root.hm-settled.hm-anim-line-draw .hm-copy::after {
  transform: none;
}

/* --- Reduced motion: settled frame, complete, at the CSS layer too (§23).
       Scoped to runtime-owned states so design styling is untouched. -------- */

@media (prefers-reduced-motion: reduce) {
  .hm-root.hm-armed .hm-media,
  .hm-root.hm-armed .hm-copy,
  .hm-root.hm-armed .hm-media > *,
  .hm-root.hm-armed .hm-copy::after,
  .hm-root.hm-armed .hm-media-camera,
  .hm-root.hm-armed .hm-media-shell {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    clip-path: none !important;
    letter-spacing: inherit !important;
  }
}

/* --- CTA safety: never hidden by any mechanic state (§22) ------------------ */

.hm-root .hm-cta,
.hm-root.hm-armed .hm-cta {
  visibility: visible;
}
