/* UI MOTION — 3.382.0. One way of moving for every page of Dallfy. (Named
   ui-motion because "Motion" alone is the ad product and its checks.)
   (docs/site-motion-mockup.html; the operator: "what kind of navigation,
   button, layout animations we can use so that site look premium?", then
   "apart from explore page i am asking for entire site", then "build it".)

   WHY ONE FILE. Before 3.382.0 the four sheets (styles.css, landing.css,
   help.css, explore.css) used about twenty different durations — .12s,
   .15s, .16s, .18s, .2s, .22s, .35s, 140ms … — nearly all on the browser's
   default `ease`. Each component had picked its own, so nothing on the site
   moved the same way twice, and that unevenness is most of what read as
   "not premium". The answer is a small set of shared values that every
   rule uses, defined once. Copying them into each sheet would be four
   documents stating one rule, which this repo has paid for before (engine
   revisions 4→8); so every page links this file FIRST, and the token check
   (check-css-tokens) accepts a token from any sheet the page links.
   check-ui-motion holds the rest: every shell links this first, and no
   transition in the four sheets writes its own short duration or `ease`.

   THE VALUES.
   - Three speeds by how far a thing moves: --t-fast for a colour or a small
     shift, --t-mid for a panel, a menu or a pill, --t-page for a page or a
     dialog. --t-press is the press itself.
   - Arriving slows down at the end (--arrive); leaving speeds up (--leave)
     and, where a rule has both, takes about two thirds of the time.
   - A press springs back (--spring), a `linear()` curve with one small
     overshoot. Browsers without `linear()` drop that one declaration and
     keep the rest of the rule.
   - Only transform, scale, opacity and colours are animated by these rules;
     a size or position change is left to the layout (it makes a slow phone
     jitter). Anything longer than --t-page in the sheets (a progress bar's
     second, a hero's slow drift) was chosen for itself and keeps its own. */
:root {
  --t-press: 90ms; --t-fast: 160ms; --t-mid: 260ms; --t-page: 360ms; --t-reveal: 560ms;
  --arrive: cubic-bezier(.2, .8, .2, 1);
  --leave: cubic-bezier(.4, 0, 1, 1);
  --spring: cubic-bezier(.2, .8, .2, 1);
  --spring: linear(0, .009, .035 2.1%, .141 4.4%, .723 12.9%, .938 16.7%, 1.017 19.4%, 1.067, 1.099 24.3%, 1.108 26%, 1.104, 1.09 30.6%, 1.035 37.6%, 1.007 44.1%, .993 52.7%, .999 75.8%, 1);
}

/* BETWEEN PAGES: a crossfade instead of a white flash. The browser's own
   View Transitions for a link from one Dallfy page to another (Home →
   Explore → a film → Help → the studio); a browser without them changes
   page as before. The old page leaves fast, the new one arrives. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: var(--t-fast) var(--leave) both mo-out; }
::view-transition-new(root) { animation: var(--t-mid) var(--arrive) both mo-in; }
@keyframes mo-out { to { opacity: 0; } }
@keyframes mo-in { from { opacity: 0; } }

/* A PRESS: every button family shrinks a little while held and springs
   back when let go. `scale` is its own property, so it composes with any
   `transform` a button already has (a centred play button, a lifted card)
   instead of replacing it. The base transitions here have no specificity
   (`:where`), so a button rule that writes its own `transition` keeps it,
   and must list `scale var(--t-mid) var(--spring)` itself (styles.css
   `.btn`). While held, the press is quick and leaves; let go, the rule's own
   list springs it back. */
:where(.btn, .hc-btn, .ex-btn, .ex-chip, .icon-btn) {
  transition: scale var(--t-mid) var(--spring), background-color var(--t-fast) var(--arrive), border-color var(--t-fast) var(--arrive), box-shadow var(--t-fast) var(--arrive), color var(--t-fast) var(--arrive);
}
:where(.btn, .hc-btn, .ex-btn, .ex-chip, .icon-btn):not(:disabled):active {
  scale: .96; transition: scale var(--t-press) var(--leave);
}

/* THE PRIMARY'S LIGHT: a slow sweep across a gradient button on hover,
   drawn on its ::before (::after is the busy spinner's, styles.css
   `.btn.busy::after`). It sits inside the button's own shape and never
   catches a press. */
:where(.btn.primary, .hc-btn.primary) { position: relative; }
:where(.btn.primary, .hc-btn.primary)::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgb(255 255 255 / .28) 50%, transparent 62%) no-repeat;
  background-size: 250% 100%; background-position: 160% 0; opacity: 0;
}
:where(.btn.primary, .hc-btn.primary):not(:disabled):hover::before {
  opacity: 1; background-position: -60% 0;
  transition: background-position 900ms var(--arrive), opacity var(--t-fast) var(--arrive);
}

/* RISE INTO VIEW — 3.383.0, dom.js `riseIntoView`. Hidden only under
   `html.mo-js` (set by that script) and only for a visitor who has not
   asked for less motion; a page without the script shows everything. Each
   piece fades up 18px once, --t-reveal long (a reveal is read, not
   operated, so it is slower than the three speeds), a beat after the piece
   before it; then the script hands it back to its own rules. `translate`
   is its own property, so a piece's own transform is untouched. */
@media (prefers-reduced-motion: no-preference) {
  .mo-js .mo-rise:not(.mo-in) { opacity: 0; translate: 0 18px; }
}
.mo-rise.mo-in { transition: opacity var(--t-reveal) var(--arrive), translate var(--t-reveal) var(--arrive); transition-delay: calc(var(--mo-n, 0) * 60ms); }

/* A visitor who has asked for less motion (their system's setting) gets
   pages that change at once: no crossfade, and every transition finishes
   in a millisecond, so anything that waits for `transitionend` still hears
   it. Animations keep their own rules: a spinner must still say "working",
   and each sheet already says how it stops or slows under this setting. */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { transition-duration: 1ms !important; transition-delay: 0s !important; }
  :where(.btn, .hc-btn, .ex-btn, .ex-chip, .icon-btn):not(:disabled):active { scale: none; }
}
