/**
 * Viewport reveal system.
 *
 * The initial hidden state is declared in CSS, so it applies from the very
 * first paint - no flash of visible content while the deferred script boots.
 * The whole system is wrapped in `prefers-reduced-motion: no-preference`, so a
 * reduced-motion user gets no hiding and no animation at all.
 *
 * reveal.js adds `data-rv` (animation type) and `.is-revealed` per element,
 * driven by IntersectionObserver on the element itself - never by scroll
 * position - so nothing waits for the user to finish scrolling.
 *
 * Only opacity and transform animate, which keeps CLS at 0.
 */

:root {
  --rv-shift: 18px;
  --rv-shift-card: 28px;
  --rv-shift-row: 12px;
  --rv-scale-card: 0.985;
  --rv-scale-media: 1.04;
  --rv-duration: 620ms;
  --rv-duration-card: 720ms;
  --rv-duration-media: 900ms;
  --rv-duration-row: 560ms;
  --rv-duration-fade: 1200ms;
  --rv-duration-line: 700ms;
  --rv-line-offset: 90ms;
  --rv-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Media wrappers need a clip so the scale settle cannot bleed out. */
.wl-hero__media,
.wl-sound-design__media {
  overflow: hidden;
}

@media (prefers-reduced-motion: no-preference) {
  /* 1. Initial state - one list, applied before any script runs. */
  .wl-has-js
    :is(
      .wl-hero__eyebrow,
      .wl-hero__title,
      .wl-hero__description,
      .wl-hero__actions .wl-btn,
      .wl-services__title,
      .wl-services__description,
      .wl-showrooms__watermark,
      .wl-service-card,
      .wl-sound-design__title,
      .wl-sound-design__description,
      .wl-sound-design__link,
      .wl-sound-design__media,
      .wl-sound-design__block-heading,
      .wl-sound-design__tile,
      .wl-sound-design__card,
      .wl-sound-design__project-gallery,
      .wl-sound-design__actions,
      .wl-sound-design__project-media,
      .wl-sound-design__project-content,
      .wl-projects__title,
      .wl-projects__stage,
      .wl-projects__more,
      .wl-faq__title,
      .wl-faq__item,
      .wl-contact__title,
      .wl-contact__description,
      .wl-contact__channels,
      .wl-contact__addresses,
      .wl-contact__socials,
      .wl-contact__form-panel,
      .wl-kb-section__eyebrow,
      .wl-kb-section__title,
      .wl-kb-section__lead,
      .wl-kb-section__link,
      .wl-kb-card,
      .wl-project-gallery__title,
      .wl-project-gallery__item,
      .wl-footer__title,
      .wl-footer__description,
      .wl-footer__invitation .wl-footer__contacts,
      .wl-footer__form-panel,
      .wl-footer__brand,
      .wl-footer__col,
      .wl-footer__maps,
      .wl-footer__legal
    ) {
    opacity: 0;
  }

  /* 2. Start offsets. The hero background is the LCP candidate: it settles from
        a slight over-scale but is never faded out, so paint timing is intact. */
  .wl-has-js .wl-hero__media {
    transform: scale(var(--rv-scale-media));
  }

  .wl-has-js [data-rv='up'] {
    transform: translate3d(0, var(--rv-shift), 0);
  }

  .wl-has-js [data-rv='card'] {
    transform: translate3d(0, var(--rv-shift-card), 0)
      scale(var(--rv-scale-card));
    --rv-type-duration: var(--rv-duration-card);
  }

  .wl-has-js [data-rv='media'] {
    transform: scale(var(--rv-scale-media));
    --rv-type-duration: var(--rv-duration-media);
  }

  .wl-has-js [data-rv='row'] {
    transform: translate3d(0, var(--rv-shift-row), 0);
    --rv-type-duration: var(--rv-duration-row);
  }

  .wl-has-js [data-rv='fade'] {
    --rv-type-duration: var(--rv-duration-fade);
  }

  /* 3. Ended state. The transition lives here only, so applying the start state
        can never animate backwards. */
  .wl-has-js [data-rv].is-revealed {
    opacity: 1;
    transform: none;
    transition:
      opacity var(--rv-type-duration, var(--rv-duration)) var(--rv-ease)
        var(--rv-delay, 0ms),
      transform var(--rv-type-duration, var(--rv-duration)) var(--rv-ease)
        var(--rv-delay, 0ms);
  }

  /* Title hairlines draw from the reading edge, just after the title lands. */
  .wl-has-js [data-rv-line]::after {
    transform: scaleX(0);
    transform-origin: 0 50%;
  }

  .wl-has-js [data-rv-line].is-revealed::after {
    transform: scaleX(1);
    transition: transform var(--rv-duration-line) var(--rv-ease)
      calc(var(--rv-delay, 0ms) + var(--rv-line-offset));
  }
}
