/* ==========================================================================
   UNIRAY - motion primitives.
   GSAP drives the timelines; this file holds the initial states, the CSS-only
   animations, and the reduced-motion contract.
   ========================================================================== */
@layer motion {

  /* ---- reveal states ------------------------------------------------------
     Gated on .js-motion, NOT on .js. core.js adds .js-motion only once it has
     an IntersectionObserver and no reduced-motion preference, and removes it
     again if wiring the observer throws. Pass 2 gated these on .js, so the
     content was hidden from first paint and stayed hidden whenever the
     animation library was late or the trigger never fired.
     These are plain CSS transitions: they do not depend on GSAP, which is
     loaded off the critical path and arrives seconds later. */
  .js-motion [data-anim]:not(.is-in) { will-change: transform, opacity; }
  .js-motion [data-anim] {
    transition:
      opacity .7s var(--ease-out),
      transform .75s var(--ease-out),
      clip-path .9s var(--ease-out);
  }

  .js-motion [data-anim='rise'] { opacity: 0; transform: translateY(26px); }
  .js-motion [data-anim='fade'] { opacity: 0; }
  .js-motion [data-anim='scale'] { opacity: 0; transform: scale(.96); }
  .js-motion [data-anim='clip'] { clip-path: inset(100% 0 0 0); }
  /* headings wipe up behind their own edge - the same read as the pass-2
     SplitText line mask, without rewriting the heading's DOM (which is what
     stranded them: the split ran, the tween that was meant to bring the lines
     back never did). */
  .js-motion [data-anim='lines'] {
    opacity: 0;
    transform: translateY(.18em);
    clip-path: inset(0 0 106% 0);
  }

  .js-motion [data-anim].is-in { opacity: 1; transform: none; }
  .js-motion [data-anim='clip'].is-in { clip-path: inset(0 0 0 0); }
  /* negative insets so descenders and the lime glow are never clipped */
  .js-motion [data-anim='lines'].is-in { clip-path: inset(-18% -12% -28% -12%); }

  /* image reveal wrapper */
  .reveal { overflow: hidden; }
  .js-motion .reveal > img,
  .js-motion .reveal > picture > img {
    transform: scale(1.08);
    transition: transform 1.15s var(--ease-out);
  }
  .js-motion .reveal.is-in > img,
  .js-motion .reveal.is-in > picture > img { transform: none; }

  /* magnetic buttons (pointer: fine only, set by motion.js) */
  @media (hover: hover) and (pointer: fine) {
    .magnetic { transition: transform .35s var(--ease-out); }
  }

  /* page-leave wipe */
  .page-wipe {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-preloader) - 1);
    background: var(--lime-soft);
    clip-path: inset(0 0 100% 0);
    pointer-events: none;
  }
  .page-wipe.is-active { pointer-events: auto; }

  /* View Transitions as progressive enhancement */
  @media (prefers-reduced-motion: no-preference) {
    @view-transition { navigation: auto; }
  }

  /* fly-to-inquiry ghost */
  .fly-ghost {
    position: fixed;
    z-index: var(--z-toast);
    border-radius: var(--radius-xs);
    background: var(--paper);
    object-fit: contain;
    pointer-events: none;
    will-change: transform, opacity;
  }

  @keyframes badge-bounce {
    0%, 100% { transform: scale(1); }
    35% { transform: scale(1.35); }
    65% { transform: scale(.92); }
  }
  .is-bouncing { animation: badge-bounce .5s var(--ease-out); }

  /* odometer counters */
  .odo { display: inline-flex; overflow: hidden; height: 1em; line-height: 1; }
  .odo__col { display: flex; flex-direction: column; will-change: transform; }

  /* ---- reduced motion: strip everything non-essential --------------------- */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: .001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: .001ms !important;
      scroll-behavior: auto !important;
    }
    /* belt and braces: .js-motion is never added under reduced motion, but if
       the preference changes after load nothing may be left hidden. */
    [data-anim] {
      opacity: 1 !important;
      transform: none !important;
      clip-path: none !important;
    }
    .reveal > img, .reveal > picture > img { transform: none !important; }
    .marquee__track { animation: none !important; }
    .fab-assistant::before { animation: none !important; }
    .fab-assistant__spark { animation: none !important; }
    .banner__scroll .icon { animation: none !important; }
    @view-transition { navigation: none; }
  }
}
