/* =========================================================
   MOTION v12 — modern, dependency-free motion layer
   · split-text heading rise          (.motion — set by motion.js)
   · scroll-driven animations          (animation-timeline, native CSS)
   · view transitions                  (filters, product → modal morph)
   · smooth <details>                  (::details-content)
   Everything is off under prefers-reduced-motion.
   ========================================================= */

:root { --ease-out-expo: cubic-bezier(.19, 1, .22, 1); }

/* ---------- Headings: words rise out of a mask ---------- */
.motion .split.reveal { opacity: 1; transform: none; }
.split .w {
  display: inline-block; vertical-align: top;
  overflow: clip; overflow-clip-margin: .12em;
  padding-bottom: .1em; margin-bottom: -.1em;
}
.split .wi {
  display: inline-block;
  transform: translateY(110%) rotate(3deg);
  transform-origin: 0 100%;
  filter: blur(4px);
  transition:
    transform 1.2s var(--ease-out-expo),
    filter 1.2s var(--ease-out-expo);
  transition-delay: calc(var(--w, 0) * 55ms + var(--d, 0s));
}
.split.is-in .wi { transform: none; filter: none; }
.split[data-delay="1"] { --d: .12s; }
.split[data-delay="2"] { --d: .24s; }
.split[data-delay="3"] { --d: .36s; }

/* ---------- Header: hides while reading, returns on scroll up ---------- */
.motion .site-header {
  transition: background .4s var(--ease), color .4s var(--ease), box-shadow .4s var(--ease),
              padding .4s var(--ease), translate .6s var(--ease-out-expo);
}
.site-header.is-hidden { translate: 0 -105%; }

/* ---------- Buttons: magnetic, with springy return ---------- */
.motion .btn, .motion .modal-close {
  transition: background .35s var(--ease), color .35s var(--ease), border-color .35s var(--ease),
              transform .35s var(--ease), translate .6s cubic-bezier(.3, 1.6, .5, 1);
}


/* ---------- Dark sections: pointer spotlight ---------- */
.spot {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(520px circle at var(--sx, 50%) var(--sy, 30%), rgba(241, 226, 196, .13), rgba(241, 226, 196, 0) 65%);
  opacity: 0; transition: opacity .6s var(--ease);
}
.journey:hover .spot, .contact:hover .spot { opacity: 1; }
.journey > .wrap, .contact > .wrap { position: relative; z-index: 1; }

/* ---------- FAQ: answers open and close smoothly ---------- */
@supports selector(::details-content) {
  .faq-list { interpolate-size: allow-keywords; }
  .faq-list details::details-content {
    height: 0; overflow: clip; opacity: 0;
    transition: height .55s var(--ease), opacity .45s var(--ease), content-visibility .55s allow-discrete;
  }
  .faq-list details[open]::details-content { height: auto; opacity: 1; }
  .faq-list details[open] p { animation: none; }
}

/* ---------- View transitions: filters re-flow, product → modal morph ---------- */
::view-transition-group(*) {
  animation-duration: .65s;
  animation-timing-function: cubic-bezier(.2, .7, .2, 1);
}
::view-transition-old(product-hero), ::view-transition-new(product-hero) {
  height: 100%; object-fit: contain;
}
::view-transition-group(product-photo) { overflow: clip; border-radius: 12px; }
::view-transition-old(product-photo), ::view-transition-new(product-photo) {
  width: 100%; height: 100%; object-fit: cover;
}
.modal.vt[open] { animation: none; }

/* ---------- Scroll-driven animations (native, runs off the main thread) ---------- */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {

    /* hero: copy drifts up and softens, photo pushes in as you leave */
    .hero { view-timeline: --hero; }
    .hero-copy {
      animation: hero-copy-out linear both;
      animation-timeline: --hero; animation-range: exit 0% exit 75%;
    }
    @keyframes hero-copy-out { to { opacity: 0; translate: 0 -70px; } }
    .hero-bg {
      animation: hero-bg-out linear both;
      animation-timeline: --hero; animation-range: exit 0% exit 100%;
    }
    @keyframes hero-bg-out { to { scale: 1.12; translate: 0 10%; } }
    .hero-visual--poster {
      animation: hero-badge-out linear both;
      animation-timeline: --hero; animation-range: exit 0% exit 60%;
    }
    @keyframes hero-badge-out { to { rotate: 40deg; scale: .8; opacity: 0; } }

    /* dark bands open like a curtain as they arrive */
    .marquee, .journey, .contact {
      animation: curtain linear both;
      animation-timeline: view(); animation-range: entry 0% entry 55%;
    }
    @keyframes curtain {
      from { clip-path: inset(0 4vw round 48px); }
      to   { clip-path: inset(0 0 round 0); }
    }

    /* photos settle from a slow zoom while they cross the viewport */
    .fx:not(.arch) {
      animation: settle linear both;
      animation-timeline: view(); animation-range: entry 0% cover 60%;
    }
    @keyframes settle { from { --s: 1.32; } to { --s: 1.06; } }

    /* brand marks turn with the page */
    .journey .bg-mark, .hero-mark {
      animation: mark-turn linear both;
      animation-timeline: view();
    }
    @keyframes mark-turn { from { rotate: -14deg; } to { rotate: 14deg; } }

    /* journey line draws itself as you read the steps */
    .steps { view-timeline: --steps; }
    .steps::before {
      animation: draw-x linear both;
      animation-timeline: --steps; animation-range: entry 30% cover 55%;
    }
    @keyframes draw-x { from { scale: 0 1; } to { scale: 1 1; } }
    @media (max-width: 1080px) {
      .steps::before { transform-origin: top; animation-name: draw-y; }
      @keyframes draw-y { from { scale: 1 0; } to { scale: 1 1; } }
    }

    /* section numbers and eyebrows: gentle parallax */
    .principle .num, .service .num {
      animation: num-float linear both;
      animation-timeline: view();
    }
    @keyframes num-float { from { translate: 0 18px; } to { translate: 0 -18px; } }

    /* membership card swings in */
    .mcard-scene {
      animation: card-swing linear both;
      animation-timeline: view(); animation-range: entry 0% cover 45%;
    }
    @keyframes card-swing { from { translate: 0 80px; scale: .9; } to { translate: 0 0; scale: 1; } }
  }
}

@media (prefers-reduced-motion: reduce) {
  .split .wi { transform: none; filter: none; transition: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
