/* ==========================================================================
   AIRO motion: entry animations + micro-interactions. CSS only, no JS.
   Every class and keyframe is prefixed mo-. Final state = the normal style;
   keyframes only define `from`. Loaded on the front end only (inc/motion.php).
   ========================================================================== */

:root {
	--mo-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
	--mo-bounce: cubic-bezier(0.3, 1.4, 0.4, 1);
	--mo-bounce-soft: cubic-bezier(0.3, 1.3, 0.4, 1);
	--mo-step: 70ms;
	--mo-row: 45ms;
}

/* ---------- Keyframes ---------- */
@keyframes mo-page-in { from { opacity: 0; filter: blur(6px); } }
@keyframes mo-page-in-lite { from { opacity: 0; } }
@keyframes mo-rise { from { opacity: 0; transform: translateY(16px) scale(0.97); } }
@keyframes mo-reveal { from { opacity: 0; filter: blur(6px); transform: translateY(4px); } }
@keyframes mo-row-in { from { opacity: 0; transform: translateX(-8px); } }
@keyframes mo-pop { from { opacity: 0; transform: translateY(14px) scale(0.85); } }
@keyframes mo-glow { 50% { transform: scale(1.9); opacity: 0; } }
@keyframes mo-fade { from { opacity: 0; } }
@keyframes mo-draw { from { stroke-dashoffset: 1; } }
@keyframes mo-arc { from { stroke-dashoffset: 100; } }
@keyframes mo-underline { from { transform: scaleX(0); } }
@keyframes mo-slide-left { from { transform: translateX(-100%); } }
@keyframes mo-slide-right { from { transform: translateX(100%); } }
@keyframes mo-drop { from { opacity: 0; transform: translateY(-16px); } }

/* ---------- 1. Page entry ----------
   Each direct child of <main class="mo-page"> fades in, in cascade.
   The first child (hero, product gallery = LCP) is not delayed or hidden.
   Fixed bars (sticky add-to-cart) are excluded. */
.mo-page > * { animation: mo-page-in 480ms ease backwards; }
.mo-page > :first-child,
.mo-page > .sticky-atc,
.mo-page > script,
.mo-page > style { animation: none; }
.mo-page > :nth-child(2) { animation-delay: 70ms; }
.mo-page > :nth-child(3) { animation-delay: 140ms; }
.mo-page > :nth-child(n + 4) { animation-delay: 210ms; }
/* Big blurred sections are slow on low-end phones: opacity only there. */
@media (max-width: 860px) {
	.mo-page > * { animation-name: mo-page-in-lite; }
}

/* ---------- 2. Indices ---------- */
.mo-i-0 { --i: 0; } .mo-i-1 { --i: 1; } .mo-i-2 { --i: 2; } .mo-i-3 { --i: 3; }
.mo-i-4 { --i: 4; } .mo-i-5 { --i: 5; } .mo-i-6 { --i: 6; } .mo-i-7 { --i: 7; }
.mo-i-8 { --i: 8; } .mo-i-9 { --i: 9; } .mo-i-10 { --i: 10; } .mo-i-11 { --i: 11; }

/* Automatic index from the position inside the parent (grids, lists). */
.mo-auto-i > :nth-child(1), .mo-auto-rise > :nth-child(1) { --i: 0; }
.mo-auto-i > :nth-child(2), .mo-auto-rise > :nth-child(2) { --i: 1; }
.mo-auto-i > :nth-child(3), .mo-auto-rise > :nth-child(3) { --i: 2; }
.mo-auto-i > :nth-child(4), .mo-auto-rise > :nth-child(4) { --i: 3; }
.mo-auto-i > :nth-child(5), .mo-auto-rise > :nth-child(5) { --i: 4; }
.mo-auto-i > :nth-child(6), .mo-auto-rise > :nth-child(6) { --i: 5; }
.mo-auto-i > :nth-child(7), .mo-auto-rise > :nth-child(7) { --i: 6; }
.mo-auto-i > :nth-child(8), .mo-auto-rise > :nth-child(8) { --i: 7; }
.mo-auto-i > :nth-child(9), .mo-auto-rise > :nth-child(9) { --i: 8; }
.mo-auto-i > :nth-child(10), .mo-auto-rise > :nth-child(10) { --i: 9; }
.mo-auto-i > :nth-child(11), .mo-auto-rise > :nth-child(11) { --i: 10; }
.mo-auto-i > :nth-child(12), .mo-auto-rise > :nth-child(12) { --i: 11; }
.mo-auto-i > :nth-child(n + 13), .mo-auto-rise > :nth-child(n + 13) { --i: 12; }

/* ---------- 3. Card: the box lands, then its content comes into focus ---------- */
.mo-rise,
.mo-auto-rise > * {
	animation: mo-rise 620ms var(--mo-ease) backwards;
	animation-delay: calc(var(--i, 0) * var(--mo-step));
}
.mo-rise > *,
.mo-auto-rise > * > * {
	animation: mo-reveal 520ms ease backwards;
	animation-delay: calc(var(--i, 0) * var(--mo-step) + 240ms);
}
/* Product card: media/body/footer reveal, but not the whole <a> media block blurred twice. */
.mo-rise.pcard > *,
.mo-auto-rise > .pcard > * { animation-name: mo-reveal; }

/* Light reveal for a single block of text (no card box). */
.mo-in {
	animation: mo-reveal 520ms ease backwards;
	animation-delay: calc(var(--i, 0) * var(--mo-step) + 120ms);
}

/* ---------- 4. Rows enter one after another (static, read-only lists) ---------- */
.mo-stagger > *,
.mo-stagger > tbody > tr {
	animation: mo-row-in 420ms var(--mo-ease) backwards;
	animation-delay: calc(var(--i, 0) * var(--mo-step) + 300ms + var(--k, 12) * var(--mo-row));
}
.mo-stagger > :nth-child(1), .mo-stagger > tbody > tr:nth-child(1) { --k: 0; }
.mo-stagger > :nth-child(2), .mo-stagger > tbody > tr:nth-child(2) { --k: 1; }
.mo-stagger > :nth-child(3), .mo-stagger > tbody > tr:nth-child(3) { --k: 2; }
.mo-stagger > :nth-child(4), .mo-stagger > tbody > tr:nth-child(4) { --k: 3; }
.mo-stagger > :nth-child(5), .mo-stagger > tbody > tr:nth-child(5) { --k: 4; }
.mo-stagger > :nth-child(6), .mo-stagger > tbody > tr:nth-child(6) { --k: 5; }
.mo-stagger > :nth-child(7), .mo-stagger > tbody > tr:nth-child(7) { --k: 6; }
.mo-stagger > :nth-child(8), .mo-stagger > tbody > tr:nth-child(8) { --k: 7; }
.mo-stagger > :nth-child(9), .mo-stagger > tbody > tr:nth-child(9) { --k: 8; }
.mo-stagger > :nth-child(10), .mo-stagger > tbody > tr:nth-child(10) { --k: 9; }
.mo-stagger > :nth-child(11), .mo-stagger > tbody > tr:nth-child(11) { --k: 10; }
.mo-stagger > :nth-child(12), .mo-stagger > tbody > tr:nth-child(12) { --k: 11; }
/* A table only staggers its body rows, not the <thead>/<tbody> wrappers. */
table.mo-stagger > thead, table.mo-stagger > tbody { animation: none; }

/* ---------- 5. Pop with bounce (icons, numbers, small badges) ---------- */
.mo-pop {
	animation: mo-pop 560ms var(--mo-bounce) backwards;
	animation-delay: calc(var(--i, 0) * var(--mo-step) + 420ms);
}
/* Inside a card that already reveals its children, the pop wins. */
.mo-rise > .mo-pop,
.mo-auto-rise > * > .mo-pop { animation-name: mo-pop; animation-duration: 560ms; animation-timing-function: var(--mo-bounce); animation-delay: calc(var(--i, 0) * var(--mo-step) + 420ms); }

/* ---------- 6. Pulsing halo on status dots (In stock, Released) ---------- */
.mo-glow.pill-dot::before { position: relative; }
.mo-glow.pill-dot { position: relative; }
.mo-glow.pill-dot::after {
	content: "";
	position: absolute;
	left: 12px; top: 50%;
	width: 6px; height: 6px; margin-top: -3px;
	border-radius: 50%;
	background: currentColor;
	opacity: 0.45;
	animation: mo-glow 3.2s ease-in-out infinite;
	pointer-events: none;
}

/* ---------- 7. Hover: lift (pointer devices only) ---------- */
@media (hover: hover) {
	.mo-lift { transition: transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 220ms ease; }
	.mo-lift:hover { transform: translateY(-4px); box-shadow: var(--sh-lg, 0 16px 44px rgba(20, 20, 20, 0.13)); }
	.mo-lift .ico, .mo-lift .ic { transition: transform 300ms var(--mo-bounce-soft); }
	.mo-lift:hover .ico, .mo-lift:hover .ic { transform: rotate(-6deg) scale(1.1); }
	.mo-lift .pcard-media img { transition: transform 300ms var(--mo-ease); }
	.mo-arrow svg { transition: transform 200ms var(--mo-ease); }
	.mo-arrow:hover svg { transform: translate(2px, -2px); }
}
/* The theme's .pcard lifts on hover everywhere; keep it to mouse/trackpad only. */
@media (hover: none) {
	.pcard.mo-lift:hover { transform: none; }
}

/* ---------- 8. Number that counts up (no JS). Integers only. ---------- */
@property --mo-n { syntax: "<integer>"; inherits: false; initial-value: 0; }
.mo-count {
	--mo-n: var(--to);
	counter-reset: mo-n var(--mo-n);
	animation: mo-count 1600ms cubic-bezier(0.15, 0.6, 0.2, 1) both;
	animation-delay: calc(var(--i, 0) * var(--mo-step) + 240ms);
	font-variant-numeric: tabular-nums;
}
@keyframes mo-count { from { --mo-n: 0; } }
.mo-count::after { content: attr(data-prefix) counter(mo-n) attr(data-suffix); }

/* ---------- 9. SVG line that draws itself ---------- */
.mo-draw { stroke-dasharray: 1; stroke-dashoffset: 0; animation: mo-draw 1400ms cubic-bezier(0.3, 0.6, 0.2, 1) both; animation-delay: calc(var(--i, 0) * var(--mo-step) + 500ms); }

/* ---------- 10. Progress ring ---------- */
.mo-ring { display: inline-grid; place-items: center; position: relative; vertical-align: middle; }
.mo-ring svg { transform: rotate(-90deg); display: block; }
.mo-ring-track { stroke: var(--line, rgba(32, 32, 32, 0.09)); }
.mo-ring-val { stroke: var(--mo-ring-color, var(--green, #34b27b)); }
.mo-ring-label { position: absolute; font-family: var(--mono, monospace); font-size: 13px; font-weight: 500; }
.mo-arc { stroke-dasharray: 100; animation: mo-arc 1300ms cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--i, 0) * var(--mo-step) + 450ms); }

/* ---------- 11. Simple fade ---------- */
.mo-fade { animation: mo-fade 900ms ease 900ms both; }

/* ---------- 12. Overlays opened by removing [hidden] (animations replay on open) ---------- */
.mnav:not([hidden]) .scrim,
.search-ov:not([hidden]) .scrim,
.drawer-wrap:not([hidden]) .scrim { animation: mo-fade 240ms ease both; }
.mnav:not([hidden]) .mnav-panel { animation: mo-slide-left 340ms cubic-bezier(0.2, 0.9, 0.2, 1) both; }
.search-ov:not([hidden]) .search-panel { animation: mo-drop 340ms cubic-bezier(0.2, 0.9, 0.2, 1) both; }
.drawer-wrap:not([hidden]) .drawer { animation: mo-slide-right 340ms cubic-bezier(0.2, 0.9, 0.2, 1) both; }

/* ---------- 13. Active menu item: underline grows on load ---------- */
.mo-nav a[aria-current="page"] { position: relative; }
.mo-nav a[aria-current="page"]::after {
	content: "";
	position: absolute;
	left: 14px; right: 14px; bottom: 4px;
	height: 2px;
	border-radius: 2px;
	background: var(--blue, #4a7ff8);
	transform-origin: left center;
	animation: mo-underline 500ms var(--mo-bounce-soft) 200ms both;
}

/* ---------- 14. Micro-interactions ---------- */
.btn, .button, .chip { transition: transform 150ms ease, box-shadow 150ms ease, background-color 300ms, color 300ms, border-color 300ms; }
.btn:active, .button:active, .chip:active { transform: scale(0.95); }
@media (hover: hover) {
	.icon-btn svg { transition: transform 200ms var(--mo-ease); }
	.icon-btn:hover svg { transform: scale(1.1); }
}

/* ---------- 15. Reduced motion: everything jumps to its final state ---------- */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: 0.01ms !important;
		animation-delay: 0s !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
	.mo-glow.pill-dot::after { animation: none !important; display: none; }
}
