/* Entrance and parallax system (every page). /js/motion.js tags elements with data-mx="<variant>" and adds .mx-in once,
   when they enter the viewport. html.mx is set in <head> only when the visitor allows motion, so without JS or with
   reduced motion nothing here applies and every element renders in its final state.
   Only opacity, clip-path and the individual transform properties (translate / scale / rotate) move: they compose
   with each component's own transform and hover rules instead of replacing them. Hidden states sit on
   :not(.mx-in), so the end state is always the component's natural style. */
:root {
  --mx-ease: cubic-bezier(.16, 1, .3, 1);      /* expo out: fast start, long settle */
  --mx-ease-io: cubic-bezier(.65, 0, .35, 1);  /* in-out for masks and line draws */
  --mx-dur: .9s;
  --mx-y: 28px;
  --mx-x: 48px;
}
@media (max-width: 767px) { :root { --mx-dur: .75s; --mx-y: 18px; } }

@media (prefers-reduced-motion: no-preference) {
  /* transitions live on the revealed state only: tagging hides at once (no fade-out), revealing animates */
  .mx [data-mx].mx-in {
    transition: opacity var(--mx-dur) var(--mx-ease), translate var(--mx-dur) var(--mx-ease), scale var(--mx-dur) var(--mx-ease),
      rotate var(--mx-dur) var(--mx-ease), clip-path calc(var(--mx-dur) * 1.3) var(--mx-ease-io);
    transition-delay: var(--mx-d, 0ms);
  }
  .mx [data-mx=up]:not(.mx-in) { opacity: 0; translate: 0 var(--mx-y); }
  .mx [data-mx=left]:not(.mx-in) { opacity: 0; translate: calc(var(--mx-x) * -1) 0; }
  .mx [data-mx=right]:not(.mx-in) { opacity: 0; translate: var(--mx-x) 0; }
  .mx [data-mx=scale]:not(.mx-in) { opacity: 0; scale: .94; translate: 0 calc(var(--mx-y) * .5); }
  .mx [data-mx=fade]:not(.mx-in) { opacity: 0; }
  .mx [data-mx=pop]:not(.mx-in) { opacity: 0; scale: .4; rotate: -14deg; }
  .mx svg [data-mx] { transform-box: fill-box; transform-origin: center; }
  /* masks: clip-path cannot interpolate to none, so the revealed state is an inset wide enough to never clip */
  .mx [data-mx=wipe], .mx [data-mx=mask-x] { clip-path: inset(-1.5em -1.5em -1.5em -1.5em); }
  .mx [data-mx=wipe]:not(.mx-in), .mx [data-mx=mask-x]:not(.mx-in) { clip-path: inset(0 100% 0 0); }
  .mx [data-mx=mask] { clip-path: inset(-1.5em -1.5em -1.5em -1.5em); }
  .mx [data-mx=mask]:not(.mx-in) { clip-path: inset(100% 0 0 0); }
  /* the photo settles inside its mask; zoom is the same settle for images that are not masked */
  .mx [data-mx=mask].mx-in img, .mx img[data-mx=zoom].mx-in { transition: scale 1.6s var(--mx-ease) var(--mx-d, 0ms); }
  .mx [data-mx=mask]:not(.mx-in) img, .mx img[data-mx=zoom]:not(.mx-in) { scale: 1.18; }
  /* headings by line: every word rises out of its own mask; motion.js gives each word its line index (--l) */
  .mx .mx-w { display: inline-block; overflow: clip; padding: .12em .2em .16em; margin: -.12em -.2em -.16em; vertical-align: top; }
  .mx .mx-w > span { display: inline-block; }
  .mx .mx-in .mx-w > span { transition: translate 1s var(--mx-ease) calc(var(--mx-d, 0ms) + var(--l, 0) * 90ms); }
  .mx [data-mx=lines]:not(.mx-in) .mx-w > span { translate: 0 115%; }
  /* process line: drawn once (the prototype's version is scrubbed to the scroll and runs backwards) */
  .mx .sf-timeline::before { animation: none; transform-origin: left; }
  .mx .sf-timeline.mx-in::before { transition: scale 1.5s var(--mx-ease-io) var(--mx-d, 0ms); }
  .mx .sf-timeline[data-mx=draw]:not(.mx-in)::before { scale: 0 1; }
  /* the prototype's scrubbed mask reveals would fight the one-shot masks above */
  .mx .sf-reveal { animation: none; }

  /* hero = first block of every page. Its text and calls to action are never hidden: they are what the visitor came
     for and the H1 can be the LCP element (audit MOT-001). Only the photo settles, and scale never hides anything. */
  .mx :is(.pg-hero__img, .qt-hero__img) { animation: mx-settle 2.4s var(--mx-ease) backwards; }
  @keyframes mx-settle { from { scale: 1.08; } }

  /* parallax: tied to the scroll on the compositor (no scroll listeners); browsers without scroll timelines skip it.
     The photos sit in overflow:hidden boxes, which are scroll containers of their own, so view() on the photo would
     track a box that never scrolls: the timeline is named on the box, which does move with the page. */
  @supports (animation-timeline: view()) {
    .mx :is(.pg-hero, .qt-hero) { view-timeline: --mx-hero; }
    .mx .pg-final { view-timeline: --mx-final; }
    .mx .pg-exp__main { view-timeline: --mx-exp; }
    .mx :is(.pg-hero__img, .qt-hero__img) { animation: mx-settle 2.4s var(--mx-ease) backwards, mx-drift linear both; animation-timeline: auto, --mx-hero; animation-range: normal, exit 0% exit 100%; }
    @keyframes mx-drift { to { translate: 0 14%; } }
    .mx .pg-final__img { animation: mx-px linear both; animation-timeline: --mx-final; animation-range: cover; }
    @keyframes mx-px { from { translate: 0 -6%; scale: 1.14; } to { translate: 0 6%; scale: 1.14; } }
    .mx .pg-exp__main img { animation: mx-px-s linear both; animation-timeline: --mx-exp; animation-range: cover; }
    @keyframes mx-px-s { from { translate: 0 -4%; scale: 1.1; } to { translate: 0 4%; scale: 1.1; } }
  }
}
@media (max-width: 899px) and (prefers-reduced-motion: no-preference) {
  .mx .sf-timeline::before { transform-origin: top; }
  .mx .sf-timeline[data-mx=draw]:not(.mx-in)::before { scale: 1 0; }
}
@media print { .mx [data-mx] { opacity: 1 !important; translate: none !important; scale: none !important; rotate: none !important; clip-path: none !important; } }
