/* =====================================================================
   VF MOTION FIX -CSS safety net
   ---------------------------------------------------------------------
   motion-guard.js does the real work (it disarms the
   prefers-reduced-motion freeze blocks so animations keep their
   original authored timings). This stylesheet only covers the case
   where that script never runs at all -blocked by a corporate proxy,
   stripped by an aggressive content filter, or disabled JS.

   Rule of the house: a visitor must never be shown a blank section.
   Animation is a nice-to-have; content is not.

   Load this AFTER every other stylesheet.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. No-JS / script-blocked failsafe.
   [data-reveal] starts at opacity:0 in ranking-service.css and waits
   for JS. If JS never arrives, this brings it back after a short beat.
   The .no-js class is set by the <html> tag; the <noscript> path and
   the delayed animation both converge on "visible".
   --------------------------------------------------------------------- */
html.no-js [data-reveal] {
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
}

/* ---------------------------------------------------------------------
   2. Explicit user opt-out.
   Set via ?motion=off or localStorage. When a visitor has genuinely
   asked for calm, we give them calm -but we still never hide content.
   --------------------------------------------------------------------- */
html.vf-motion-off *,
html.vf-motion-off *::before,
html.vf-motion-off *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
html.vf-motion-off [data-reveal] {
  opacity: 1 !important;
  transform: none !important;
}

/* ---------------------------------------------------------------------
   3. Hard backstop for the freeze blocks, used only if motion-guard.js
      could not rewrite the media conditions (very old engines refuse
      to let scripts mutate mediaText).

      Specificity note: the strongest selector inside any of the
      reduced-motion blocks is `[data-rail] .grs-visual *` = (0,2,0).
      Repeating the class on <html> gives (0,3,1), which wins on
      specificity rather than relying on source order. The repetition
      is deliberate, not a typo.

      This restores MOVEMENT but not the original per-element timings,
      which is why it is a backstop and not the primary mechanism.
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html.vf-motion-on.vf-motion-on.vf-motion-on .grs-visual *,
  html.vf-motion-on.vf-motion-on.vf-motion-on .rc45-visual *,
  html.vf-motion-on.vf-motion-on.vf-motion-on .fsr-visual *,
  html.vf-motion-on.vf-motion-on.vf-motion-on .ty-hero *,
  html.vf-motion-on.vf-motion-on.vf-motion-on .vx *::after {
    animation-iteration-count: infinite !important;
  }

  html.vf-motion-on.vf-motion-on.vf-motion-on [data-reveal] {
    transition: opacity 700ms cubic-bezier(0, 0, 0.2, 1),
                transform 700ms cubic-bezier(0, 0, 0.2, 1) !important;
  }
}

/* ---------------------------------------------------------------------
   4. Reduce repaint cost on low-power office hardware.
      Integrated-GPU desktops behind RDP/VDI are the machines most
      likely to have motion switched off in the first place, so keep
      the restored animations cheap: promote only the elements that
      actually move, and let the browser drop the layer afterwards.
   --------------------------------------------------------------------- */
html.vf-motion-on [data-reveal] {
  will-change: opacity, transform;
}
html.vf-motion-on [data-reveal].is-revealed {
  will-change: auto;
}
