/* =====================================================================
   FlyForms — one entrance motion for every page.
   Headings rise word by word out of a mask, descriptions fade up out of
   a light blur, and main images rise, settle and sharpen. It plays on
   first load and again every time an element comes back into view.
   motion.js marks the elements ([data-mo]) and adds .mo-in while each is
   on screen. Nothing is hidden unless motion.js is running (html.mo-on),
   and nothing moves with reduced motion.
   ===================================================================== */

:root {
  --mo-ease: cubic-bezier(.16, 1, .3, 1);   /* the site's slow ease-out */
  --mo-text: .9s;
  --mo-media: 1.15s;
  --mo-word-gap: 55ms;                       /* stagger between words */
}

/* Until motion.js has marked the page, keep the likely targets hidden so nothing flashes and then hides. */
html.mo-on:not(.mo-ready) :is(main, #app, .hv) :is(h1, h2, h3, p, img, figure, .hv-frame, .ill-panel, .ill-article, .rw-stage) { opacity: 0; }

/* The older one-time reveal steps aside: its wrappers stay put, and the new motion runs inside them.
   If motion.js never started (html.mo-off), they are simply shown. */
html.mo-on .flyforms-arrive, html.mo-off .flyforms-arrive { opacity: 1; transform: none; filter: none; transition: none; will-change: auto; }

/* ---------- Descriptions, kickers, buttons ---------- */

html.mo-on [data-mo=text] {
  transition: opacity var(--mo-text) var(--mo-ease), transform var(--mo-text) var(--mo-ease), filter var(--mo-text) var(--mo-ease);
  transition-delay: var(--mo-d, 0ms);
}
html.mo-on [data-mo=text]:not(.mo-in) { opacity: 0; transform: translate3d(0, 18px, 0); filter: blur(5px); }

/* ---------- Main images ---------- */

html.mo-on [data-mo=media] {
  transition: opacity var(--mo-media) var(--mo-ease), transform var(--mo-media) var(--mo-ease), filter var(--mo-media) var(--mo-ease);
  transition-delay: var(--mo-d, 0ms);
}
html.mo-on [data-mo=media]:not(.mo-in) { opacity: 0; transform: translate3d(0, 44px, 0) scale(.965); filter: blur(8px); }

/* ---------- Headings: each word rises out of its own mask ---------- */

.mo-mask {
  display: inline-block; overflow: hidden; vertical-align: bottom;
  padding: .08em .02em .14em; margin: -.08em -.02em -.14em;   /* room for ascenders and descenders, with no change to the layout */
}
html.mo-on .mo-w {
  display: inline-block;
  transition: transform var(--mo-text) var(--mo-ease), opacity calc(var(--mo-text) * .8) var(--mo-ease), filter var(--mo-text) var(--mo-ease);
  transition-delay: calc(var(--mo-d, 0ms) + min(var(--wi, 0) * var(--mo-word-gap), 700ms));
}
html.mo-on [data-mo=words]:not(.mo-in) .mo-w { opacity: 0; transform: translate3d(0, 105%, 0); filter: blur(6px); }
/* A highlighted word or a decoration has its own box, so it rises and fades rather than sliding out of a mask. */
html.mo-on [data-mo=words]:not(.mo-in) .mo-atom { transform: translate3d(0, .35em, 0) scale(.96); }

/* Leaving the screen resets instantly, so the next arrival plays from the start. */
html.mo-on .mo-reset, html.mo-on .mo-reset .mo-w { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  html.mo-on [data-mo], html.mo-on [data-mo] .mo-w { opacity: 1 !important; transform: none !important; filter: none !important; transition: none !important; }
}
