/*
 * Motion: reveal states driven by classes (block markup cannot carry data attributes)
 * and the marquee loop. Elements hide only when JavaScript runs (html.js) and the
 * visitor allows motion; without either, everything is visible from the first paint.
 *
 * kchsi-animate            reveal this element when it scrolls into view
 * kchsi-animate--stagger   reveal the direct children one after another
 * kchsi-animate--load      run at page load instead of on scroll
 * kchsi-animate--pop       scale in instead of sliding up (stickers)
 * kchsi-animate--late      wait one slow beat before starting
 *
 * Plain CSS loops: the live dot on .kchsi-chip--live, the slow drift of the ambient orbs.
 */

@media (prefers-reduced-motion: no-preference) {
	.js .kchsi-animate:not(.kchsi-animate--stagger):not(.is-visible),
	.js .kchsi-animate--stagger > :not(.is-visible) {
		opacity: 0;
		transform: translateY(var(--wp--custom--motion--distance));
	}

	.js .kchsi-animate--pop:not(.is-visible) {
		transform: scale(0.8);
	}

	/* Safety net: if the motion script never runs (html.js without html.is-motion),
	   everything appears after four slow beats. */
	.js:not(.is-motion) .kchsi-animate:not(.kchsi-animate--stagger),
	.js:not(.is-motion) .kchsi-animate--stagger > * {
		animation: kchsi-safety 1ms linear calc(var(--wp--custom--motion--duration--slow) * 4) forwards;
	}

	.js .kchsi-marquee__track {
		animation: kchsi-marquee var(--wp--custom--motion--marquee) linear infinite;
	}

	.kchsi-marquee:hover .kchsi-marquee__track {
		animation-play-state: paused;
	}

	.kchsi-chip--live::before {
		animation: kchsi-ping calc(var(--wp--custom--motion--duration--slow) * 4) var(--wp--custom--motion--ease--out) infinite;
	}

	/* Orbs drift a little around their place; the layer overshoots so its edge never shows. */
	.kchsi-ambient::before {
		inset: calc(-1 * var(--wp--custom--ambient--drift));
		animation: kchsi-drift var(--wp--custom--ambient--drift-duration) var(--wp--custom--motion--ease--in-out) infinite alternate;
	}
}

@keyframes kchsi-safety {
	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes kchsi-marquee {
	to {
		transform: translateX(-50%);
	}
}

@keyframes kchsi-ping {
	0% {
		box-shadow: 0 0 0 0 var(--wp--custom--ambient--teal), 0 0 0 0 color-mix(in srgb, var(--wp--custom--color--bg--brand) 45%, transparent);
	}

	100% {
		box-shadow: 0 0 0 0 var(--wp--custom--ambient--teal), 0 0 0 var(--wp--custom--spacing--2) transparent;
	}
}

@keyframes kchsi-drift {
	to {
		transform: translate(var(--wp--custom--ambient--drift), var(--wp--custom--ambient--drift)) scale(1.04);
	}
}
