/* Motion core (03-MOTION-SPEC.md sections 4, 5, 9.5, 12, 14.4). Tokens live in tokens.css.
   Hidden start states apply only under html.motion-ok (set by the inline gate). */

/* ---------------------------------------------------------------- Hero entrance (pure CSS, 4.2) */
[data-hero-item] {
	animation: sth-hero-rise var(--dur-hero) var(--ease-spring) both;
	animation-delay: var(--d, 0ms);
}
[data-hero-item="crumb"] { --d: 0ms; animation-name: sth-hero-fade8; animation-duration: 600ms; animation-timing-function: var(--ease-out-quart); }
[data-hero-item="h1"] { --d: 40ms; animation-name: sth-hero-rise-solid; }
[data-hero-item="sub"] { --d: 160ms; }
[data-hero-item="btns"] { --d: 240ms; animation-name: sth-hero-rise12; }
[data-hero-item="tags"] { --d: 320ms; animation-name: sth-hero-fade8; animation-duration: 600ms; animation-timing-function: var(--ease-out-quart); }
/* Visual: transform only (it may be the LCP element). Direction per layout (4.4). */
[data-hero-item="visual"] { --d: 120ms; animation-name: sth-hero-x; --vx: 24px; --vy: 0px; }
.hero--rsplit [data-hero-item="visual"], [data-scene-pos="flip"] { --vx: -24px; }
.hero--frame [data-hero-item="visual"], .hero--centered [data-hero-item="visual"], .hero--editorial [data-hero-item="visual"], [data-scene-pos="below"] { --vx: 0px; --vy: 24px; }
.hero--editorial [data-hero-item="visual"] { animation: none; }
.imgcard--hero img { animation: sth-settle var(--dur-settle) var(--ease-out-expo) 120ms both; }
.ftag { animation: sth-hero-fade12 600ms var(--ease-out-quart) 400ms both; }
/* Scene card contents start 300ms after the card (4.4 kinds). */
[data-scene] .scene__card { animation: sth-hero-x var(--dur-hero) var(--ease-spring) 200ms both; }
[data-scene] .scene__row, [data-scene] .scene__tile, [data-scene] .scene__checks li,
[data-scene] .scene__tier, [data-scene] .scene__pill {
	animation: sth-row-in 600ms var(--ease-out-quart) both;
	animation-delay: calc(420ms + var(--i, 0) * 70ms);
}
[data-scene] .scene__step { animation: sth-row-in 600ms var(--ease-out-quart) both; animation-delay: calc(420ms + var(--i, 0) * 120ms); }
[data-scene] .scene__step .scene__num { animation: sth-pop 500ms var(--ease-spring-ui) both; animation-delay: calc(480ms + var(--i, 0) * 120ms); }
/* Flow: soft pulse ring on the active node while in view (loop, paused when hidden). */
[data-scene="flow"] .scene__step.is-active .scene__num { position: relative; }
[data-scene="flow"] .scene__step.is-active .scene__num::after {
	content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 2px var(--c-blue);
	opacity: 0; animation: sth-pulse 2.4s var(--ease-out-quart) 1.2s infinite;
}
@keyframes sth-hero-rise { from { opacity: 0; transform: translateY(var(--dist-hero-item)); } to { opacity: 1; transform: none; } }
@keyframes sth-hero-rise12 { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes sth-hero-rise-solid { from { transform: translateY(var(--dist-hero-h1)); } to { transform: none; } }
@keyframes sth-hero-fade8 { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sth-hero-fade12 { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes sth-hero-x { from { transform: translate(var(--vx, 24px), var(--vy, 0px)); } to { transform: none; } }
@keyframes sth-settle { from { transform: scale(1.06); } to { transform: none; } }
@keyframes sth-row-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes sth-pop { from { transform: scale(.6); } to { transform: none; } }
@keyframes sth-pulse { 0% { opacity: .4; transform: scale(1); } 100% { opacity: 0; transform: scale(1.8); } }

/* ---------------------------------------------------------------- Scroll reveals (5.1, 5.2) */
html.motion-ok [data-reveal]:not(.is-in) { opacity: 0; }
html.motion-ok [data-reveal="up"]:not(.is-in) { transform: translateY(var(--dist-reveal)); }
html.motion-ok [data-reveal="left"]:not(.is-in) { transform: translateX(calc(var(--dist-side) * -1)); }
html.motion-ok [data-reveal="right"]:not(.is-in) { transform: translateX(var(--dist-side)); }
html.motion-ok [data-reveal="scale"]:not(.is-in) { opacity: 1; transform: scale(.94); }
html.motion-ok [data-reveal="none"]:not(.is-in) { opacity: 1; transform: none; }
/* Focus inside a block that has not revealed yet: show it at once (WCAG 2.4.7, audit A2-04).
   A block can also take focus while its reveal is still running or waiting out its stagger delay
   (.is-in without .is-done, typically the later cards of a row): for keyboard focus only, drop the
   transition so the block jumps to its end state. Both rules stop applying once the block is done. */
html.motion-ok [data-reveal]:not(.is-in):focus-within { opacity: 1; transform: none; transition: none; }
html.motion-ok [data-reveal].is-in:not(.is-done):is(:focus-visible, :has(:focus-visible)) { transition: none; }
html.motion-ok [data-reveal] {
	transition:
		opacity calc(var(--dur-reveal) * .8) var(--ease-out-quart),
		transform var(--dur-reveal) var(--ease-spring),
		box-shadow var(--dur-hover) var(--ease-out-quart);
	transition-delay: min(calc(var(--i, 0) * var(--stagger, 0ms) + var(--extra, 0ms)), var(--stagger-cap));
}
html.motion-ok [data-reveal].is-in.is-done { transition-delay: 0ms; }
html.motion-ok [data-reveal="fade"] { transition-duration: 700ms; }
[data-stagger="pair"] { --stagger: var(--stagger-pair); }
[data-stagger="grid"] { --stagger: var(--stagger-grid); }
[data-stagger="list"] { --stagger: var(--stagger-list); }
[data-stagger="chip"] { --stagger: var(--stagger-chip); }
.head + [data-stagger] > [data-reveal] { --extra: var(--lead-gap); }
.is-in.is-instant { transition: none !important; }
@media (max-width: 1023px) {
	html.motion-ok [data-reveal="left"]:not(.is-in),
	html.motion-ok [data-reveal="right"]:not(.is-in) { transform: translateY(var(--dist-reveal)); }
}
@media (max-width: 767px) { :root { --dur-reveal: var(--dur-reveal-m); } }

/* Still pages (spec 11): no scroll reveals in body content; only cta, cards, related and
   list sections reveal. motion.js marks the rest .is-in; this rule avoids a hidden flash. */
html.motion-ok [data-motion="still"] [data-reveal]:not(:is([data-sec="cta"], [data-sec="cards"], [data-sec="related"], [data-sec="list"]) *):not(.is-in) { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- Word reveal (5.2 `words`, 10, 14.4)
   Statement and quote are split server side (data-words-split, words() in template-tags.php);
   other `words` blocks are split by motion.js. The block stays visible; its words animate.
   Phones: blur 6px, cap 24; tablets: blur 8px, cap 32; desktop: 10px, 40. */
.w { display: inline-block; }
:root { --word-blur: 6px; --word-cap: 24; }
@media (min-width: 768px) { :root { --word-blur: 8px; --word-cap: 32; } }
@media (min-width: 1024px) { :root { --word-blur: 10px; --word-cap: 40; } }
html.motion-ok [data-reveal="words"]:not(.is-in) { opacity: 1; transform: none; }
html.motion-ok [data-reveal="words"] .w {
	opacity: 0; transform: translateY(var(--dist-word)); filter: blur(var(--word-blur));
	transition:
		opacity var(--dur-words) var(--ease-out-expo),
		transform var(--dur-words) var(--ease-out-expo),
		filter var(--dur-words) var(--ease-out-expo);
	transition-delay: calc(min(var(--wi), var(--word-cap)) * var(--stagger-word));
}
html.motion-ok [data-reveal="words"].is-in .w { opacity: 1; transform: none; filter: none; }
html.motion-ok [data-reveal="words"].is-instant .w { transition: none; }
html.motion-paused .w, html.motion-failed .w { opacity: 1 !important; transform: none !important; filter: none !important; }

/* ---------------------------------------------------------------- FAQ accordion (9.5, 14.8) */
@supports (interpolate-size: allow-keywords) {
	.faq { interpolate-size: allow-keywords; }
	.faq__item::details-content {
		height: 0; overflow: clip;
		transition: height var(--dur-panel-out) var(--ease-out-quart), content-visibility var(--dur-panel-out) allow-discrete;
	}
	.faq__item[open]::details-content { height: auto; transition-duration: var(--dur-panel); }
}
.faq__a { opacity: 0; transform: translateY(-4px); transition: opacity 150ms, transform 300ms var(--ease-out-quart); }
.faq__item[open] .faq__a { opacity: 1; transform: none; transition-delay: 80ms; transition-duration: 300ms; }
/* Script fallback where interpolate-size is unsupported: grid rows wrapper. */
.faq__item.is-anim .faq__a { display: grid; }

/* ---------------------------------------------------------------- Loops only in view */
[data-loop] *, [data-scene] .scene__num::after { animation-play-state: paused; }
html.motion-ok [data-loop].is-inview *, html.motion-ok [data-scene].is-inview .scene__num::after { animation-play-state: running; }

/* Loops end by themselves within 5s (WCAG 2.2.2): motion.js trims each loop through the Web
   Animations API; engines without it get .sth-still on the element 4.2s after it starts. */
.sth-still, .sth-still::before, .sth-still::after { animation: none !important; }

/* ---------------------------------------------------------------- Reduced motion, paused, failed, print (12.1) */
html.motion-paused *, html.motion-paused *::before, html.motion-paused *::after,
html.motion-failed [data-reveal] {
	animation: none !important;
	transition-duration: 1ms !important;
	transition-delay: 0ms !important;
}
html.motion-paused [data-reveal], html.motion-failed [data-reveal] { opacity: 1 !important; transform: none !important; filter: none !important; }
html.motion-paused [data-card-link]:hover, html.motion-paused .btn:hover { transform: none !important; }
@media (prefers-reduced-motion: reduce) {
	[data-hero-item], .imgcard--hero img, .ftag, [data-scene] * { animation: none !important; }
}
@media print {
	*, *::before, *::after { animation: none !important; transition: none !important; opacity: 1 !important; transform: none !important; filter: none !important; }
	.site-header, .mega-backdrop { display: none !important; }
}
