/*
 * webseide block animations – engine styles.
 *
 * Everything here applies only while <html class="wsa-js"> is set by the
 * inline head script, so without JavaScript, in print and for reduced-motion
 * users the content is simply visible. Nothing ever drops below 50 % opacity.
 *
 * Markup (written by inc/gutenberg/behavior/behavior.php):
 *   data-wsa="fade-in|fade-up|fade-down|fade-left|fade-right|words"
 *   data-wsa-i="n"          index inside a staggering container
 *   data-wsa-delay="ms"     block setting "Animation delay" (on a container: start of its items' sequence)
 *   data-wsa-speed="fast"   block setting "Animation speed" (faster|fast|slow|slower)
 *   data-wsa-group="rows"   container whose items animate one after another
 * State classes set by animations.js: wsa-split (words wrapped), wsa-in (revealed), wsa-done (finished, no footprint left).
 */
:root {
	--wsa-dur: 600ms;
	--wsa-stagger: 120ms;
	--wsa-dist: 24px;
	--wsa-word: 30ms;
	--wsa-ease: cubic-bezier(.22, .61, .36, 1);
}

/* Per-element duration: the block's speed setting scales the global duration. */
html.wsa-js [data-wsa]                { --wsa-d: var(--wsa-dur); }
html.wsa-js [data-wsa-speed="faster"] { --wsa-d: calc(var(--wsa-dur) * .5); }
html.wsa-js [data-wsa-speed="fast"]   { --wsa-d: calc(var(--wsa-dur) * .75); }
html.wsa-js [data-wsa-speed="slow"]   { --wsa-d: calc(var(--wsa-dur) * 1.5); }
html.wsa-js [data-wsa-speed="slower"] { --wsa-d: calc(var(--wsa-dur) * 2); }

/* Fades: start state until the element is in view, then back to the block's own values. */
html.wsa-js [data-wsa]:not([data-wsa="words"]):not(.wsa-done) {
	transition: opacity var(--wsa-d) var(--wsa-ease), transform var(--wsa-d) var(--wsa-ease);
	transition-delay: var(--wsa-delay, 0ms);
}
html.wsa-js [data-wsa]:not([data-wsa="words"]):not(.wsa-in):not(.wsa-done) { opacity: .5; }
html.wsa-js [data-wsa="fade-up"]:not(.wsa-in):not(.wsa-done)    { transform: translate3d(0, var(--wsa-dist), 0); }
html.wsa-js [data-wsa="fade-down"]:not(.wsa-in):not(.wsa-done)  { transform: translate3d(0, calc(-1 * var(--wsa-dist)), 0); }
html.wsa-js [data-wsa="fade-left"]:not(.wsa-in):not(.wsa-done)  { transform: translate3d(calc(-1 * var(--wsa-dist)), 0, 0); }
html.wsa-js [data-wsa="fade-right"]:not(.wsa-in):not(.wsa-done) { transform: translate3d(var(--wsa-dist), 0, 0); }
/* Table rows: transforms on <tr> are unreliable across browsers – fade only. */
html.wsa-js tr[data-wsa]:not(.wsa-in):not(.wsa-done) { transform: none; }

/* Word reveal: dimmed as a whole until the script has wrapped the words, then word by word. */
html.wsa-js [data-wsa="words"] { transition: none; transform: none; }
html.wsa-js [data-wsa="words"]:not(.wsa-split):not(.wsa-done) { opacity: .5; }
html.wsa-js [data-wsa="words"].wsa-split:not(.wsa-done) .wsa-w {
	transition: opacity calc(var(--wsa-d) * .6) var(--wsa-ease);
	transition-delay: calc(var(--wsa-delay, 0ms) + var(--wsa-i, 0) * var(--wsa-step, var(--wsa-word)));
}
html.wsa-js [data-wsa="words"].wsa-split:not(.wsa-in):not(.wsa-done) .wsa-w { opacity: .5; }

/* Replay (Customizer preview): reset without animating backwards. */
html.wsa-reset [data-wsa],
html.wsa-reset [data-wsa] .wsa-w { transition: none !important; }

/* Failsafe: if the engine never runs (script blocked), show everything after 3 s. */
html.wsa-js:not(.wsa-ready) [data-wsa],
html.wsa-js:not(.wsa-ready) [data-wsa] .wsa-w { animation: wsa-failsafe 1ms 3s forwards; }
@keyframes wsa-failsafe { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
	html.wsa-js [data-wsa],
	html.wsa-js [data-wsa] .wsa-w { opacity: 1 !important; transform: none !important; transition: none !important; animation: none !important; }
}
@media print {
	html.wsa-js [data-wsa],
	html.wsa-js [data-wsa] .wsa-w { opacity: 1 !important; transform: none !important; }
}
