/* ═══════════════════════════════════════════════════════════════════
   MOTION — keyframes + utility classes
   Only `transform` and `opacity` are animated so everything stays on
   the compositor. Every animation is wrapped in @media screen so
   print output is untouched, and the reduced-motion block at the
   bottom switches the whole system off.
   ═══════════════════════════════════════════════════════════════════ */

@media screen {

/* ── Keyframes ──────────────────────────────────────────────────────── */

@keyframes ui-enter {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}

@keyframes ui-enter-sm {
	from { opacity: 0; transform: translateY(4px); }
	to   { opacity: 1; transform: none; }
}

@keyframes ui-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes ui-pop {
	from { opacity: 0; transform: scale(.96); }
	to   { opacity: 1; transform: scale(1); }
}

@keyframes ui-pop-out {
	from { opacity: 1; transform: scale(1); }
	to   { opacity: 0; transform: scale(.96); }
}

@keyframes ui-slide-up {
	from { opacity: 0; transform: translateY(100%); }
	to   { opacity: 1; transform: translateY(0); }
}

@keyframes ui-slide-in-right {
	from { opacity: 0; transform: translateX(24px); }
	to   { opacity: 1; transform: none; }
}

@keyframes ui-spin {
	to { transform: rotate(360deg); }
}

@keyframes ui-shimmer {
	from { background-position: -160% 0; }
	to   { background-position: 260% 0; }
}

@keyframes ui-pulse-ring {
	0%   { box-shadow: 0 0 0 0   rgba(126,232,162,.6); }
	70%  { box-shadow: 0 0 0 6px rgba(126,232,162,0);  }
	100% { box-shadow: 0 0 0 0   rgba(126,232,162,0);  }
}

@keyframes ui-badge-pop {
	0%   { transform: scale(1); }
	40%  { transform: scale(1.25); }
	100% { transform: scale(1); }
}

@keyframes ui-shake {
	10%, 90% { transform: translateX(-1px); }
	20%, 80% { transform: translateX(2px); }
	30%, 50%, 70% { transform: translateX(-4px); }
	40%, 60% { transform: translateX(4px); }
}

@keyframes ui-bump {
	0%   { transform: scale(1); }
	35%  { transform: scale(1.06); }
	100% { transform: scale(1); }
}

@keyframes ui-ripple {
	to { transform: scale(2.4); opacity: 0; }
}

@keyframes ui-grow-x {
	from { transform: scaleX(0); }
	to   { transform: scaleX(1); }
}

/* Dropdown panels (select menus, pickers). Short travel from above, so
   the panel reads as unfolding from the control that opened it. */
@keyframes ui-dropdown-in {
	from { opacity: 0; transform: translateY(-4px) scale(.985); }
	to   { opacity: 1; transform: none; }
}


/* ── Utilities ──────────────────────────────────────────────────────── */

/* One-shot entrance. `backwards` keeps the element invisible during
   any delay so staggering never flashes unstyled content. */
.ui-enter {
	animation: ui-enter var(--dur-3) var(--ease-out) backwards;
}

.ui-pop {
	animation: ui-pop var(--dur-2) var(--ease-spring) backwards;
}

.ui-fade {
	animation: ui-fade var(--dur-2) var(--ease-out) backwards;
}

/* Stagger container: children animate in sequence. `--i` is set by
   ui-motion.js (or inline) and caps the cascade at ~12 items. */
.ui-stagger > * {
	animation: ui-enter var(--dur-3) var(--ease-out) backwards;
	animation-delay: calc(var(--i, 0) * 38ms);
}

.ui-stagger-sm > * {
	animation: ui-enter-sm var(--dur-2) var(--ease-out) backwards;
	animation-delay: calc(var(--i, 0) * 28ms);
}

/* Listing rows. `tables/get_results` injects the table *into* the results
   container, so the rows are grandchildren — a `> *` stagger on the
   container would only move the table and the pager as two blocks.
   ui-motion.js sets `--i` on each row, capped so long pages don't crawl. */
.ui-stagger-rows tbody > tr {
	animation: ui-enter-sm var(--dur-2) var(--ease-out) backwards;
	animation-delay: calc(var(--i, 0) * 28ms);
}

/* Reveal-on-scroll — ui-motion.js adds .is-visible via IntersectionObserver.
   Driven by an animation, not a transition, on purpose: the elements it
   targets (home cards) already declare their own `transition` for hover
   with higher specificity, which silently replaced a transition-based
   reveal and made its delay leak into every later hover. An animation
   runs once and leaves the element's own transitions alone.
   Falls back to visible when the script never runs (see .no-motion). */
.ui-reveal {
	opacity: 0;
}

.ui-reveal.is-visible {
	opacity: 1;
	animation: ui-enter var(--dur-4) var(--ease-out) backwards;
	animation-delay: calc(var(--i, 0) * 40ms);
}

/* Shimmer placeholder for skeletons */
.ui-shimmer {
	background-image: linear-gradient(
		90deg,
		var(--bg-sunken) 0%,
		#f7f9fb 50%,
		var(--bg-sunken) 100%
	);
	background-size: 200% 100%;
	animation: ui-shimmer 1.4s linear infinite;
}

/* Ring spinner — replaces load.gif / fa-spinner */
.ui-spinner {
	display: inline-block;
	width: 18px;
	height: 18px;
	border: 2px solid var(--brand-100);
	border-top-color: var(--brand-500);
	border-radius: 50%;
	animation: ui-spin .7s linear infinite;
	vertical-align: middle;
}

.ui-spinner--lg { width: 44px; height: 44px; border-width: 3px; }
.ui-spinner--on-brand {
	border-color: rgba(255,255,255,.3);
	border-top-color: #fff;
}

/* Ripple dot injected by ui-motion.js on .btn press */
.ui-ripple {
	position: absolute;
	border-radius: 50%;
	pointer-events: none;
	background: rgba(255,255,255,.45);
	transform: scale(0);
	animation: ui-ripple var(--dur-4) var(--ease-out) forwards;
}

/* Global AJAX progress bar (ui-motion.js) */
#ui-progress {
	position: fixed;
	top: 0; left: 0;
	height: 3px;
	width: 0;
	z-index: 2147483000;
	background: var(--brand-500);
	box-shadow: 0 0 8px rgba(64,136,146,.6);
	opacity: 0;
	transition: width var(--dur-3) var(--ease-out), opacity var(--dur-2) linear;
	pointer-events: none;
}

#ui-progress.is-active { opacity: 1; }

} /* @media screen */


/* ── Reduced motion ─────────────────────────────────────────────────── */
/* Anyone who asked the OS for less movement gets the static layout.
   Reveal elements must be forced visible or content would disappear. */
@media (prefers-reduced-motion: reduce) {

	*,
	*::before,
	*::after {
		animation-duration: .001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .001ms !important;
		scroll-behavior: auto !important;
	}

	.ui-reveal,
	.ui-reveal.is-visible {
		opacity: 1 !important;
		animation: none !important;
	}

	.ui-shimmer { animation: none !important; }
	.ui-ripple  { display: none !important; }
}

/* Same guarantee when JS is absent or errored before observing */
.no-motion .ui-reveal {
	opacity: 1;
	animation: none;
}
