/* Shared motion for every page (linked in each page's <head>; behaviour lives in fx.js).
   Page changes cross-fade, clicks leave a red ring, content rises in as it scrolls into view,
   and a thin red bar at the top shows how far down the page you are. All of it switches off for reduced motion. */

/* Cross-document page transition (Chrome, Edge, Safari 18.2+; other browsers just load the page normally). */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: fx-out .22s ease both; }
::view-transition-new(root) { animation: fx-rise .38s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes fx-out { to { opacity: 0; transform: scale(.985); } }
@keyframes fx-rise { from { opacity: 0; transform: translateY(14px); } }

/* Fallback fade for browsers without view transitions (fx.js adds the class just before leaving). */
html.fx-leave body { opacity: 0; transition: opacity .18s ease; }

/* Click ring. */
.fx-ring { position: fixed; z-index: 99; width: 12px; height: 12px; margin: -6px 0 0 -6px; border: 1.5px solid #C8262E; border-radius: 50%;
  pointer-events: none; animation: fx-ring .55s cubic-bezier(.2, .7, .2, 1) forwards; }
@keyframes fx-ring { from { transform: scale(.2); opacity: 1; } to { transform: scale(4.5); opacity: 0; } }

/* Reading bar. */
.fx-bar { position: fixed; top: 0; left: 0; z-index: 98; width: 100%; height: 2px; background: #C8262E; transform-origin: 0 50%; transform: scaleX(0); pointer-events: none; }

/* Scroll reveal: uses `translate`, not `transform`, so it never fights an element's own rotate or scale. */
.fx-r { opacity: 0; translate: 0 18px; transition: opacity .6s ease, translate .7s cubic-bezier(.2, .7, .2, 1); transition-delay: var(--fx-d, 0s); }
.fx-r.fx-in { opacity: 1; translate: none; }

/* Everything clickable answers the pointer: colours ease instead of snapping, buttons press in. */
/* `scale` (not `transform`) so a button's own positioning transform is left alone. */
a, button, summary, select, input { transition: color .2s, background-color .2s, border-color .2s, text-decoration-color .2s, opacity .2s, scale .15s; }
button:not([disabled]):active, summary:active { scale: .96; }
:focus-visible { outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  .fx-r { opacity: 1; translate: none; transition: none; }
  .fx-ring { display: none; }
}
