/* Cleartop's motion, shared by every page. Load it after the page's other stylesheets.
   One vocabulary for the whole site, so nothing on it ever cuts from one state to the next:
   - Things arrive with a fast start and a long, soft landing (--m-out), and leave quicker than they came (--m-in).
   - Things the visitor moves themselves (a press, a switch, a panel) overshoot a touch and settle (--m-spring).
   - Every state change has a duration: hovers --m-fast, swaps --m-base, entrances and pages --m-slow.
   Reduce Motion turns all of it off at the bottom of this file. */
:root {
  --m-out: cubic-bezier(.16, 1, .3, 1);
  --m-in: cubic-bezier(.5, 0, .75, 0);
  --m-in-out: cubic-bezier(.65, 0, .35, 1);
  --m-spring: cubic-bezier(.3, 1.3, .5, 1);
  --m-fast: .2s;
  --m-base: .34s;
  --m-slow: .6s;
}

/* Going from one page to the next: the page you leave dims and softens, the next one comes up out of it, a beat
   later, so the two overlap instead of cutting. In-page links glide instead of jumping. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  html { scroll-behavior: smooth; }
}
::view-transition-old(root) { animation: m-page-out .28s var(--m-in) both; }
::view-transition-new(root) { animation: m-page-in .62s var(--m-out) .08s both; }
@keyframes m-page-out { to { opacity: 0; filter: blur(6px); transform: scale(.988); } }
@keyframes m-page-in { from { opacity: 0; filter: blur(8px); transform: scale(1.012); } }

/* Hover and focus never snap: colour, fill and light ease in and out. :where() keeps this a default, so any
   control with its own transition keeps it. */
:where(a, button, summary, input, select, textarea, label) {
  transition: color var(--m-fast) ease, background-color var(--m-fast) ease, border-color var(--m-fast) ease,
    box-shadow var(--m-base) var(--m-out), text-decoration-color var(--m-fast) ease, opacity var(--m-fast) ease, filter var(--m-fast) ease;
}

/* The app's own controls (they reset everything with all: unset, so they're named here). A press sinks the
   button a little, the anticipation before it acts, and letting go springs it back. */
.pb, .wl-go, .m, .xp, .heard button, .sheet .tid {
  transition: background-color var(--m-fast) ease, color var(--m-fast) ease, border-color var(--m-fast) ease,
    box-shadow var(--m-base) var(--m-out), scale .38s var(--m-spring);
}
.pb:active, .wl-go:active, .m:active, .xp:active, .sheet .tid:active, .btn:active { scale: .965; transition-duration: .08s; }
.switch { transition: background-color .28s ease; }
.switch::after { transition: transform .42s var(--m-spring); }
.switch:active::after { width: 18px; }
.switch[aria-checked="true"]:active::after { transform: translateX(10px); }

/* Anything that appears when the page's state changes (a message, a form, a box for another payment method) rises
   out of a soft blur. A CSS animation replays whenever an element goes from hidden to shown, so this needs no script. */
.m-enter { animation: m-enter .55s var(--m-out) both; }
@keyframes m-enter { from { opacity: 0; transform: translateY(10px); filter: blur(5px); } }
@keyframes m-fade { from { opacity: 0; } }

/* Dialogs: the dimmed backdrop fades in under the sheet instead of appearing at once. */
.sheet, .sysdlg { animation: m-fade .3s ease both; }
.sysdlg > div { animation: m-enter .5s var(--m-spring) .04s both; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  .m-enter, .sheet, .sysdlg, .sysdlg > div { animation: none; }
  .pb:active, .wl-go:active, .m:active, .xp:active, .sheet .tid:active, .btn:active { scale: 1; }
  .switch::after { transition-duration: .01s; }
}
