/* Motion system – rules (tokens in theme.css, logic in public/js/motion.js). Only transform / opacity; nothing loops except the skeleton shimmer.
   Motion level: html[data-motion="full" | "reduced" | "off"] (user menu; OS reduce motion = off). */

/* ---------- enter / rows / flash ---------- */
@keyframes m-enter { from { opacity: 0; transform: translateY(var(--m-rise)); } }
@keyframes m-row { from { opacity: 0; transform: translateY(calc(var(--m-rise) * .66)); } }
@keyframes m-fade { from { opacity: 0; } }
@keyframes m-flash { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }
@keyframes m-ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 75% { transform: rotate(2deg); } }
@keyframes m-pop { from { opacity: 0; transform: scale(.94); } }
.m-enter { animation: m-enter var(--dur-3) var(--ease-gentle) var(--m-delay, 0ms) backwards; }
.m-row { animation: m-row var(--dur-3) var(--ease-gentle) var(--m-delay, 0ms) backwards; }
.m-flash { position: relative; }
.m-flash::after { content: ''; position: absolute; inset: -2px -6px; border-radius: 6px; background: color-mix(in srgb, var(--primary) 16%, transparent); pointer-events: none; opacity: 0;
  animation: m-flash 900ms var(--ease-out); }
.m-ring { animation: m-ring 700ms var(--ease-out); transform-origin: 50% 2px; }

/* ---------- press squish, hover lift + brand ring, icon micro-interactions ---------- */
.btn, .m-press { transition: background .12s, border-color .12s, color .12s, box-shadow var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-snappy); }
.btn:active:not(:disabled), .m-press:active { transform: scale(var(--m-press)); transition-duration: 60ms; }
.m-lift { transition: transform var(--dur-3) var(--ease-snappy), box-shadow var(--dur-3) var(--ease-out), border-color var(--dur-2) var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .m-lift:hover { transform: translateY(var(--m-lift)); border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
    box-shadow: 0 16px 32px -14px rgba(15, 23, 42, .22), 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent); }
  [data-mode="dark"] .m-lift:hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 40%, transparent); }
  .m-lift:active { transform: translateY(0) scale(var(--m-press)); }
  .m-arrow { transition: transform var(--dur-2) var(--ease-snappy); }
  a:hover > .m-arrow, button:hover > .m-arrow, .m-lift:hover .m-arrow { transform: translateX(3px); }
  .m-icon-pop .icon { transition: transform var(--dur-2) var(--ease-snappy); }
  .m-icon-pop:hover .icon { transform: scale(1.08); }
}

/* ---------- sliding pills (segmented controls, chips, tabs, side navigation) ---------- */
/* :where() = zero specificity: a host that is already positioned (sticky side navigation, fixed off-canvas menu) keeps its own position –
   a plain .m-pill-host { position: relative } here (loaded last) once made the side navigation scroll away with the page */
:where(.m-pill-host) { position: relative; } .m-pill-host { isolation: isolate; }
.m-pill { position: absolute; left: 0; top: 0; z-index: -1; pointer-events: none; transform-origin: 0 0; opacity: 0; transition: opacity var(--dur-1); }
.m-pill--fill { border-radius: calc(var(--radius-control) - 1px); background: var(--surface); box-shadow: var(--shadow-sm); }
.seg.m-pill-on > button[aria-pressed="true"] { background: transparent; box-shadow: none; }
.m-pill--underline { top: auto !important; bottom: 0; height: 2px; border-radius: 2px; background: var(--primary); }
.tabs.m-pill-on > a.active, .tabs.m-pill-on > button.active { border-bottom-color: transparent; }
.tabs.m-pill-host { isolation: auto; }
.tabs .m-pill--underline { z-index: 1; }
/* side navigation: one highlight slides ("liquid") between the items – host = the nav's own scroll area (.gw-navscroll) */
.m-pill--liquid { z-index: 0; border-radius: 8px; background: var(--nav-active-bg); box-shadow: var(--nav-active-ring); }
.gw-navscroll.m-pill-on .nav-link[aria-current="page"] { background: transparent; box-shadow: none; }
.sidenav .nav-link { position: relative; z-index: 1; }

/* ---------- theme switch (View Transitions circle reveal) ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 2; }

/* ---------- skeleton (shown after 80 ms only, in the final size) ---------- */
.skel { animation-duration: 1.4s; }

/* ---------- levels ---------- */
[data-motion="reduced"] .m-enter, [data-motion="reduced"] .m-row { animation-name: m-fade; }
[data-motion="off"] *, [data-motion="off"] *::before, [data-motion="off"] *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important;
  transition-duration: .01ms !important; transition-delay: 0ms !important; }
[data-motion="off"] .skel { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skel { animation: none !important; }
}
