/*
  Motion layer — entrances, reveals and scroll-linked depth.

  Three families, each on its own CSS properties so they never fight:
  1. Opening choreography  → @keyframes on opacity / translate / scale (CSS only, plays on load).
  2. Reveals               → .mo + .is-in transitions on opacity / translate / clip-path (motion.js).
  3. Scroll-linked depth   → transform driven by --mo-exit / --mo-enter / --mo-through (motion.js).

  The scroll properties fall back to their resting values without JavaScript.
*/

:root {
  --mo-ease: cubic-bezier(.2, .72, .2, 1);
  --mo-ease-wipe: cubic-bezier(.65, 0, .15, 1);
  --mo-exit: 0;
  --mo-enter: 1;
  --mo-through: .5;
}

@keyframes mo-rise {
  from { opacity: 0; translate: 0 26px; }
}

@keyframes home-arrive {
  from {
    opacity: var(--home-arrive-opacity);
    translate: 0 var(--home-arrive-offset);
  }
}

@keyframes mo-settle {
  from { scale: 1.07; }
}

@media screen and (prefers-reduced-motion: no-preference) {
  /* Calls to action change tone instead of snapping (the press scale stays). */
  :is(.button-link, .header-cta, .footer-action) {
    transition:
      scale 150ms var(--motion-out, ease-out),
      background-color 240ms ease,
      border-color 240ms ease,
      color 240ms ease;
  }
  :is(.text-link, .button-link, .footer-action) svg { transition: transform 240ms var(--mo-ease); }
  @media (hover: hover) and (pointer: fine) {
    :is(.text-link, .button-link, .footer-action):hover svg { transform: translateX(4px); }
  }

  /* ── 1. Opening choreography ─────────────────────────────────────────── */

  .home-hero .hero-copy h1 > span {
    --home-arrive-opacity: .52;
    --home-arrive-offset: clamp(12px, 1.4vw, 20px);
    animation: home-arrive 570ms var(--motion-out) backwards;
  }

  .home-hero .hero-copy .hero-title-subject {
    --home-arrive-offset: 15px;
    animation-delay: 75ms;
  }

  .home-hero .hero-copy .hero-title-place {
    --home-arrive-opacity: .72;
    --home-arrive-offset: 8px;
    animation-duration: 460ms;
    animation-delay: 140ms;
  }

  .home-hero .home-hero-board {
    --home-arrive-opacity: .66;
    --home-arrive-offset: clamp(8px, 1.2vw, 16px);
    animation: home-arrive 640ms var(--motion-out) 60ms backwards;
  }

  .home-hero .hero-bottom > p {
    --home-arrive-opacity: .76;
    --home-arrive-offset: 8px;
    animation: home-arrive 510ms var(--motion-out) 110ms backwards;
  }

  .photo-fade-hero:not(.product-hero) .photo-fade-copy > * { animation: mo-rise 900ms var(--mo-ease) 120ms backwards; }
  .photo-fade-hero:not(.product-hero) .photo-fade-copy > :nth-child(2) { animation-delay: 230ms; }
  .photo-fade-hero:not(.product-hero) .photo-fade-copy > :nth-child(3) { animation-delay: 330ms; }
  .photo-fade-hero:not(.product-hero) .photo-fade-copy > :nth-child(n + 4) { animation-delay: 420ms; }
  .photo-fade-hero:not(.product-hero) > figure:not(.heritage-cover) img {
    animation: mo-settle 2400ms cubic-bezier(.16, .6, .2, 1) backwards;
  }

  /* ── 2. Reveals ──────────────────────────────────────────────────────── */

  .has-motion .mo { opacity: 0; translate: 0 28px; }
  .has-motion .mo.is-in {
    opacity: 1;
    translate: none;
    transition:
      opacity 640ms var(--mo-ease) var(--mo-delay, 0ms),
      translate 1000ms var(--mo-ease) var(--mo-delay, 0ms);
  }

  /* Display titles rise out of their baseline. */
  .has-motion .mo.mo--title { translate: 0 .4em; clip-path: inset(-.15em -.25em 100% -.25em); }
  .has-motion .mo.mo--title.is-in {
    clip-path: inset(-.15em -.25em -.35em -.25em);
    transition:
      opacity 520ms var(--mo-ease) var(--mo-delay, 0ms),
      translate 1000ms var(--mo-ease) var(--mo-delay, 0ms),
      clip-path 1000ms var(--mo-ease) var(--mo-delay, 0ms);
  }

  /* Photographs are uncovered, not faded. */
  .has-motion .mo.mo--wipe { opacity: 1; translate: none; clip-path: inset(0 100% 0 0); }
  .has-motion .mo.mo--wipe.is-in {
    clip-path: inset(0);
    transition: clip-path 1300ms var(--mo-ease-wipe) var(--mo-delay, 0ms);
  }

  /* The quiver: each board rises upright, then leans into its angle. */
  .has-motion .home-page .home-family-media { animation: none; }
  .has-motion .mo.mo--board { opacity: 1; translate: none; }
  .has-motion .mo.mo--board .home-family-media {
    opacity: 0;
    translate: 0 76px;
    rotate: calc(var(--board-angle, 0deg) * -1);
  }
  .has-motion .mo.mo--board .home-family-copy { opacity: 0; translate: 0 18px; }
  .has-motion .mo.mo--board.is-in .home-family-media {
    opacity: 1;
    translate: none;
    rotate: none;
    transition:
      opacity 520ms var(--mo-ease) var(--mo-delay, 0ms),
      translate 1200ms var(--mo-ease) var(--mo-delay, 0ms),
      rotate 1500ms cubic-bezier(.3, .9, .3, 1) calc(var(--mo-delay, 0ms) + 120ms);
  }
  .has-motion .mo.mo--board.is-in .home-family-copy {
    opacity: 1;
    translate: none;
    transition:
      opacity 600ms var(--mo-ease) calc(var(--mo-delay, 0ms) + 220ms),
      translate 900ms var(--mo-ease) calc(var(--mo-delay, 0ms) + 220ms);
  }

  /* ── 3. Scroll-linked depth ──────────────────────────────────────────── */

  /* The title lifts while the board lingers and the controls stay in place. */
  .home-hero .hero-copy h1 {
    transform: translate3d(0, calc(var(--mo-exit) * clamp(-24px, -2vw, -12px)), 0);
  }
  .home-hero .home-hero-object {
    transform: translate3d(0, calc(var(--mo-exit) * 84px), 0) rotate(calc(var(--mo-exit) * -4deg));
  }

  @supports not ((animation-timeline: view()) and (animation-range: exit 0% exit 90%)) {
    .hero-screen {
      transform: translate3d(0, calc(var(--mo-exit) * var(--film-travel, 58px)), 0);
      opacity: calc(1 - var(--mo-exit) * .52);
    }
  }

  /* Interior openings: photograph and copy part ways. */
  .photo-fade-hero:not(.product-hero) > figure img {
    transform: translate3d(0, calc(var(--mo-exit) * 6%), 0) scale(calc(1 + var(--mo-exit) * .05));
  }
  .photo-fade-hero:not(.product-hero) .photo-fade-copy {
    transform: translate3d(0, calc(var(--mo-exit) * -36px), 0);
    opacity: calc(1.6 - var(--mo-exit) * 2);
  }

  /* Showcase: the dark stage opens to full bleed as it arrives. */
  .home-board-showcase {
    clip-path: inset(calc((1 - var(--mo-enter)) * 5.5%) calc((1 - var(--mo-enter)) * 4%));
  }
  .home-showcase-photo img { scale: calc(1.16 - var(--mo-enter) * .16); }
  .home-showcase-board { transform: translate3d(calc((1 - var(--mo-enter)) * 9%), 0, 0); }

  /* Workshop: the photo drifts inside its frame, the detail floats ahead of it. */
  .has-motion .home-page .home-heritage-detail { animation: none; }
  .home-page .home-heritage-photo { overflow: hidden; }
  .home-page .home-heritage-photo img {
    transform: scale(1.12) translate3d(0, calc((var(--mo-through) - .5) * 8%), 0);
  }
  .home-page .home-heritage-brief .home-heritage-detail {
    transform: translate3d(0, calc((.5 - var(--mo-through)) * 96px), 0);
  }

  /* Closing photograph settles as the invitation appears. */
  .footer-visual img {
    transform: scale(calc(1.14 - var(--mo-enter) * .14));
    transform-origin: 60% 60%;
  }

  @media (max-width: 759px) {
    .home-hero .home-hero-object {
      transform: translate3d(0, calc(var(--mo-exit) * 36px), 0) rotate(calc(var(--mo-exit) * -3deg));
    }
    .home-board-showcase {
      clip-path: inset(calc((1 - var(--mo-enter)) * 3%) calc((1 - var(--mo-enter)) * 3.5%));
    }
    .home-showcase-board { transform: translate3d(0, calc((1 - var(--mo-enter)) * 28px), 0); }
    .home-page .home-heritage-brief .home-heritage-detail {
      transform: translate3d(0, calc((.5 - var(--mo-through)) * 44px), 0);
    }
    .has-motion .mo.mo--board .home-family-media { translate: 0 44px; }
  }
}

@media print {
  .mo { opacity: 1 !important; translate: none !important; clip-path: none !important; }
}
