/* Motion layer, loaded last on every page.
   Page-to-page crossfade, theme reveal, scroll reveal and press feedback.
   Values follow the `animate` skill (.agents/skills/animate). */

:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

/* Page to page: the new page settles in over the old one; the header stays put.
   The names apply only during a transition: a named header is a backdrop root,
   which would stop the phone tab bar inside it from blurring the page behind. */
@view-transition { navigation: auto; }

html:active-view-transition header.topbar { view-transition-name: site-header; }
@media (max-width: 640px) {
  html:active-view-transition[data-theme] body.unified-navbar .topbar-links { view-transition-name: site-tabs; }
}

::view-transition-old(root) { animation: none; }
::view-transition-new(root) { animation: mo-page-in 280ms var(--ease-out) both; }

@keyframes mo-page-in {
  from { opacity: 0; transform: translateY(8px); }
}

/* Theme switch: motion.js grows the new theme out of the switch as a circle. */
html.mo-theme-vt header.topbar,
html.mo-theme-vt body.unified-navbar .topbar-links { view-transition-name: none !important; }
html.mo-theme-vt::view-transition-old(root),
html.mo-theme-vt::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* Scroll reveal: motion.js marks sections below the fold, then reveals each once. */
.mo-reveal {
  opacity: 0;
  translate: 0 12px;
  transition:
    opacity 500ms var(--ease-out) var(--mo-delay, 0ms),
    translate 500ms var(--ease-out) var(--mo-delay, 0ms);
}
.mo-reveal.is-in { opacity: 1; translate: none; }

/* Press feedback for controls that had none. */
.sp-copy,
.sp-hero-link,
.sp-rbi-link,
.up-share,
.up-filter-btn,
.hm-more,
.reset-button { transition: scale 140ms var(--ease-out); }

.sp-copy:active,
.sp-hero-link:active,
.sp-rbi-link:active,
.up-share:active,
.up-filter-btn:active,
.hm-more:active,
.reset-button:active,
.quick:active { scale: 0.97; }

/* Links and buttons: one hover and press language across the site.
   Dark text links fade a little on hover, grey ones brighten; pressing dims them; nothing is drawn around them.
   Pressing anything clickable also shrinks it a touch. */
:is(a:not([class]), .hm-more, .sp-rbi-link, .up-archive-link, .gf-totop, .disclaimer-link) {
  transition: opacity 160ms var(--ease-out), color 160ms var(--ease-out), scale 140ms var(--ease-out);
}
@media (hover: hover) {
  :is(a:not([class]), .hm-more, .sp-rbi-link, .disclaimer-link):not(.gf a):hover { opacity: 0.68; }
  /* Grey links (footer, updates archive) brighten to full text colour instead of fading. */
  .gf a:hover, .up-archive-link:hover { color: var(--text); }
  /* The fade replaces the old hover underlines (footer, breadcrumbs, thicker review links). */
  .gf-column a:hover,
  .gf-bottom-links a:hover,
  .site-crumbs a:hover { text-decoration-color: transparent !important; }
  .rv-article a:not(.rv-btn):hover { text-decoration-thickness: from-font !important; }
}
/* The footer link for the open page shows as selected by its full text colour, not an underline. */
.gf-column a[aria-current],
.gf-bottom-links a[aria-current] { text-decoration-color: transparent; }
:is(a:not([class]), .hm-more, .sp-rbi-link, .up-archive-link, .gf-totop, .disclaimer-link):active { opacity: 0.5; }
:where(a, button, summary) { -webkit-tap-highlight-color: transparent; }
@media (prefers-reduced-motion: no-preference) {
  :where(a, button:not(:disabled), summary):active { scale: 0.97; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-new(root) { animation-name: mo-fade-in; animation-duration: 180ms; }
  @keyframes mo-fade-in { from { opacity: 0; } }
  .mo-reveal { translate: none; transition-duration: 240ms; }
}

@media print {
  .mo-reveal { opacity: 1 !important; translate: none !important; }
}

/* Shotcraft "digit roll" (motion.js): each digit is a 0-9 strip that rolls to its value. */
.mo-roll { display: inline-flex; align-items: flex-end; }
.mo-roll-d { display: inline-block; height: 1em; overflow: hidden; }
.mo-roll-s > span { display: block; height: 1em; line-height: 1em; }
.mo-roll-s {
  display: flex;
  flex-direction: column;
  transform: translateY(calc(var(--to, 0) * -1em));
  transition: transform 1100ms cubic-bezier(0.25, 0.8, 0.25, 1) calc(var(--d, 0) * 70ms);
}

/* Shotcraft "sheen": one light band across the review card image, once (motion.js). */
.rv-hero-card .mo-sheen {
  position: absolute;
  inset: 0 0 auto 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  pointer-events: none;
}
.rv-hero-card .mo-sheen::before {
  content: "";
  position: absolute;
  top: -50%;
  bottom: -50%;
  left: -80%;
  width: 60%;
  background: linear-gradient(105deg, transparent 0%, rgb(255 255 255 / 0.1) 35%, rgb(255 255 255 / 0.55) 50%, rgb(255 255 255 / 0.1) 65%, transparent 100%);
  mix-blend-mode: screen;
  transform: skewX(-12deg);
}
.rv-hero-card .mo-sheen.is-on::before { animation: mo-sheen 1100ms cubic-bezier(0.4, 0, 0.2, 1) forwards; }
@keyframes mo-sheen { to { left: 140%; } }
@media (prefers-reduced-motion: reduce) {
  .mo-roll-s { transition: none; }
  .rv-hero-card .mo-sheen { display: none; }
}
