/**
 * motion.css — the animation system.
 *
 * Declarative contracts:
 *   data-reveal="fade|up|zoom|blur|left|right" → reveal on scroll
 *   data-reveal-delay / [data-stagger]          → stagger index (--i)
 *   data-split="chars"                          → per-character reveal
 *   data-parallax="<speed>"                     → scroll parallax (--py)
 *
 * All motion is decorative and can be switched off by the OS setting.
 */

@layer motion {
  /* ── Scroll reveal ─────────────────────────────────────────────── */

  .js [data-reveal] {
    opacity: 0;
    transition:
      opacity var(--reveal-dur) var(--ease-out),
      transform var(--reveal-dur) var(--ease-out),
      filter var(--reveal-dur) var(--ease-out);
    transition-delay: calc(var(--i, 0) * var(--stagger) + var(--reveal-delay, 0ms));
  }

  .js [data-reveal="up"] {
    transform: translate3d(0, 1.7rem, 0);
  }

  .js [data-reveal="zoom"] {
    transform: scale(0.94);
  }

  .js [data-reveal="blur"] {
    transform: translate3d(0, 1rem, 0);
    filter: blur(6px);
  }

  .js [data-reveal="left"] {
    transform: translate3d(-1.6rem, 0, 0);
  }

  .js [data-reveal="right"] {
    transform: translate3d(1.6rem, 0, 0);
  }

  .js [data-reveal].is-in {
    opacity: 1;
    transform: none;
    filter: none;
  }

  /* ── Split text ────────────────────────────────────────────────── */

  .js [data-split] .word {
    display: inline-block;
    white-space: nowrap;
  }

  .js [data-split] .char {
    display: inline-block;
    opacity: 0;
    transform: translate3d(0, 0.6em, 0) rotate(2deg);
    transition:
      opacity 0.8s var(--ease-out),
      transform 0.9s var(--ease-out);
    transition-delay: calc(var(--i, 0) * 28ms);
    will-change: opacity, transform;
  }

  .js [data-split].is-in .char {
    opacity: 1;
    transform: none;
  }

  .js [data-split] .word-space {
    display: inline-block;
    width: 0.28em;
  }

  /* ── Parallax ──────────────────────────────────────────────────── */

  [data-parallax] {
    transform: translate3d(0, var(--py, 0), 0);
    will-change: transform;
  }

  /* ── Keyframes ─────────────────────────────────────────────────── */

  @keyframes char-rise {
    from {
      opacity: 0;
      transform: translate3d(0, 0.55em, 0) rotate(2.5deg);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes btn-sheen {
    0%,
    58% {
      transform: translateX(-75%);
    }
    80%,
    100% {
      transform: translateX(75%);
    }
  }

  @keyframes equalise {
    0%,
    100% {
      transform: scaleY(0.35);
    }
    50% {
      transform: scaleY(1);
    }
  }

  @keyframes petal-fall {
    0% {
      transform: translate3d(0, -10vh, 0) rotate(0deg);
    }
    50% {
      transform: translate3d(var(--drift, 2.5rem), 48vh, 0) rotate(190deg);
    }
    100% {
      transform: translate3d(calc(var(--drift, 2.5rem) * -0.5), 112vh, 0) rotate(360deg);
    }
  }

  @keyframes digit-tick {
    from {
      opacity: 0.1;
      transform: translate3d(0, -0.35em, 0);
      filter: blur(3px);
    }
    to {
      opacity: 1;
      transform: none;
      filter: none;
    }
  }

  @keyframes cue-fall {
    0% {
      transform: translateY(-100%);
    }
    55%,
    100% {
      transform: translateY(100%);
    }
  }

  /* ── Reduced motion ────────────────────────────────────────────── */

  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      animation-delay: 0ms !important;
      transition-duration: 0.01ms !important;
      transition-delay: 0ms !important;
    }

    html {
      scroll-behavior: auto;
    }

    .js [data-reveal],
    .js [data-split] .char,
    .cover__kicker,
    .cover__monogram,
    .cover__lily,
    .cover__date,
    .cover__greeting,
    .cover__ui .btn--open,
    .cover__hint {
      opacity: 1 !important;
      transform: none !important;
      filter: none !important;
    }

    .cover__wreath {
      -webkit-mask-image: none;
      mask-image: none;
    }

    .cover__names .char {
      opacity: 1 !important;
      transform: none !important;
    }

    .ornament__line {
      transform: scaleX(1);
    }

    .ornament__gem {
      scale: 1;
    }

    .timeline::before {
      transform: scaleY(1);
    }

    .timeline__dot {
      scale: 1;
    }

    .petals,
    .btn--primary::before,
    .dock__eq {
      display: none !important;
    }

    [data-parallax] {
      transform: none;
    }
  }
}
