/*
  Lun's motion system, for the web.

  The app's is Motion in Sources/Search/Design.swift (petterblaasmo/lun):
  one spring for anything that moves between two places (glide), one for
  anything that arrives or leaves (settle), quick for what answers the
  pointer, dissolve for one thing fading into another, and slow for what
  is meant to be watched. Using the same few everywhere is most of why a
  thing feels like a single piece of software rather than a pile of views,
  so css/site.css and js/site.js write no length or curve of their own:
  each is one of these, by name. scripts/check.mjs fails if one creeps in.

  Each kind is a length and a curve, to drop into a transition:
    transition: transform var(--glide), opacity var(--dissolve)
  and its length alone is --t-<kind>, for a delay or for the script
  (Motion.ms('glide') in js/motion.js).

  Reduce Motion: what moves is there at once, and fades stay, as in the
  app. A fade is what Reduce Motion asks for in place of movement.
*/
:root{
  /* Curves. A spring has no bezier: linear() traces SwiftUI's, point by
     point (scripts/springs.mjs). Core Animation's ease-out and ease-in-out
     are CSS's own. */
  --e-out:ease-out;
  --e-inout:ease-in-out;
  /* What follows the scroll step for step, with no curve of its own */
  --e-track:linear;
  /* Arriving: a long, even slowing all the way in (an ease-out-cubic) */
  --e-arrive:cubic-bezier(.33,1,.68,1);
  --e-settle:linear(0,0.0324,0.1107,0.2128,0.3237,0.4333,0.5356,0.6272,0.7066,0.7737,0.829,0.8738,0.9092,0.9367,0.9576,0.9732,0.9845,0.9925,0.9979,1.0014,1.0035,1.0046,1.005,1.0049,1.0046,1.0041,1.0036,1.003,1.0025,1.002,1.0016,1.0012,1);
  --e-glide:linear(0,0.0346,0.1184,0.2275,0.3456,0.4617,0.5691,0.6642,0.7454,0.8126,0.8669,0.9094,0.9419,0.9661,0.9834,0.9953,1.0031,1.0077,1.0102,1.0111,1.0109,1.0101,1.0089,1.0076,1.0063,1.0051,1.004,1.0031,1.0023,1.0016,1.0011,1.0007,1);
  /* Glide with its overshoot held back, for what must not pass its place:
     a side of the bar that shrinks, the face scaled inside it */
  --e-glide-held:linear(0,0.0346,0.1184,0.2275,0.3456,0.4617,0.5691,0.6642,0.7454,0.8126,0.8669,0.9094,0.9419,0.9661,0.9834,0.9953,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);

  /* Lengths: Motion.duration, and each spring's until it is at rest */
  --t-quick:.14s;
  --t-settle:0.42s;
  --t-glide:0.49s;
  --t-dissolve:.2s;
  --t-reveal:.12s;
  --t-slow:.45s;
  --t-drawn:.9s;
  --t-carry:.22s;
  --t-shake:.5s;

  /* Under the press, and "something just arrived here" (Motion.give, Motion.pulse) */
  --give:.97;
  --pulse:1.35;

  /* What goes round (Motion.Loop) */
  --loop-spin:.85s;
  --loop-sweep:1.3s;
  --loop-breathe:2.6s;

  /* The page's own lengths, each tuned where it is used and kept here so
     the switch reaches it: a list's rows arriving one after another, the
     tabs dozing off one after another, the caret's blink, and how long
     each feature's demo takes to go round once. */
  --t-stagger:.06s;
  /* A scroll to a section: the least it takes, as much again for every
     thousand pixels it goes, and the most, so a long way is still watched
     going by rather than flashed past. On slow's curve. */
  --t-scroll:.5s;
  --t-scroll-per:.16s;
  --t-scroll-most:1.4s;
  --t-doze:.14s;
  /* The page arriving: the hero's pieces fading in one after another on
     load, and each block below the fold as it is reached. Longer than
     dissolve, since nothing is being swapped: the page is only being met.
     The fade takes enter; the move takes arrive, long and soft, slowing
     all the way in, so nothing lands with a snap. */
  --t-enter:1s;
  --t-arrive:1.3s;
  --t-enter-step:.12s;
  /* One shown thing giving way to another in the same place (a feature for
     the next): the old fades as the new comes, each with a short sink, the
     new a beat behind so the two are never at full strength together. The
     fade on an in-out, the move on arrive's long slowing. */
  --t-swap:.55s;
  --t-swap-move:.8s;
  --t-swap-wait:.18s;
  --t-cap:.25s;
  /* The bar changing shape (full, pill, menu): slower than anything in the
     app's own chrome, since it is watched more than used. The bar's size on
     glide's spring drawn out; the old face leaving, the new one fading and
     unblurring in, and its settle, each stretched to match. */
  --t-morph:1.2s;
  --t-morph-out:.3s;
  --t-morph-in:.6s;
  --t-morph-settle:1s;
  --loop-blink:1s;
  --loop-fold:7s;
  --loop-split:8s;
  --loop-read:8s;
  --loop-ads:7s;
  --loop-peek:7s;
  --loop-video:9s;
  /* The hero's drawn film, once across the fjord */
  --loop-film:16s;
  /* How long the features section shows one feature, playing by itself */
  --t-dwell:8s;
  --loop-hide:8s;
  --loop-sleep:10s;
  /* Private's wires: written in a beat after the map arrives; a spark's
     run along one, out or back */
  --t-wire-wait:.5s;
  /* Everything's small pictures: one loop for all, and the step between
     pieces that go one after another */
  --loop-ill:6s;
  --t-ill-step:.5s;
  /* Everything's cards, one after another as a kind changes */
  --t-card-step:.12s;
  --t-spark:.9s;
}

/* A browser without linear() takes the curve AppKit runs both springs on
   (Motion.timing), at the length Motion gives it there. */
@supports not (transition-timing-function:linear(0,1)){:root{
  --e-settle:cubic-bezier(.22,1,.36,1);
  --e-glide:cubic-bezier(.22,1,.36,1);
  --e-glide-held:cubic-bezier(.22,1,.36,1);
  --t-settle:.3s;
  --t-glide:.34s;
}}

/* Under Reduce Motion nothing moves; dissolve and reveal are fades and stay */
@media (prefers-reduced-motion:reduce){:root{
  --t-quick:0s;
  --t-settle:0s;
  --t-glide:0s;
  --t-slow:0s;
  --t-drawn:0s;
  --t-carry:0s;
  --t-shake:0s;
  --t-stagger:0s;
  --t-scroll:0s;
  --t-scroll-per:0s;
  --t-scroll-most:0s;
  --t-doze:0s;
  --t-enter-step:0s;
  --t-swap-move:0s;
  --t-swap-wait:0s;
  --t-card-step:0s;
  --t-arrive:0s;
  --t-morph:0s;
  --t-morph-settle:0s;
  --t-spark:0s;
  --give:1;
  --pulse:1;
}}

/* Each kind as a length and a curve, put together from whichever of the
   lengths above apply: under Reduce Motion, --glide is 0s on its spring. */
:root{
  --quick:var(--t-quick) var(--e-out);
  --settle:var(--t-settle) var(--e-settle);
  --glide:var(--t-glide) var(--e-glide);
  --glide-held:var(--t-glide) var(--e-glide-held);
  --dissolve:var(--t-dissolve) var(--e-out);
  --enter:var(--t-enter) var(--e-out);
  --arrive:var(--t-arrive) var(--e-arrive);
  --swap:var(--t-swap) var(--e-inout);
  --swap-move:var(--t-swap-move) var(--e-arrive);
  --cap:var(--t-cap) var(--e-out);
  --spark:var(--t-spark) var(--e-inout);
  --morph:var(--t-morph) var(--e-glide);
  --morph-held:var(--t-morph) var(--e-glide-held);
  --morph-out:var(--t-morph-out) var(--e-out);
  --morph-in:var(--t-morph-in) var(--e-out);
  --morph-settle:var(--t-morph-settle) var(--e-settle);
  --reveal:var(--t-reveal) var(--e-out);
  --slow:var(--t-slow) var(--e-inout);
  --drawn:var(--t-drawn) var(--e-inout);
  --carry:var(--t-carry) var(--e-out);
  --shake:var(--t-shake) var(--e-out);
}
