/*
 * Plan My Wed: motion. Scroll reveals and the hero's slow feather drift.
 *
 * The rules that keep this safe:
 * - Content is hidden only when ALL of these hold: JavaScript set the `js` class, main.js started the reveal and set
 *   `reveal-on` (so a script that fails to load hides nothing), and the visitor has not asked for reduced motion.
 *   Without any one of them, every [data-reveal] element is plain, visible content. Print shows everything too.
 * - Elements already on screen when the page loads get `is-in is-seen` from the script and are never hidden or animated.
 * - Only opacity and transform animate, as CSS animations (never transitions), so layout never moves and nothing
 *   repaints. Nothing here sets `translate` (the service cards lift with it), a `transition`, `will-change`
 *   (the browser promotes an element only while it animates) or `overflow` (the sticky heading in #how needs every
 *   ancestor visible).
 * - [data-reveal] picks the variant: empty or "up" (rise), "fade" (opacity only), "scale" (grow a little).
 *   The script sets --reveal-delay so elements that enter together arrive one after another.
 */

@keyframes pmw-reveal-up {
	from {
		opacity: 0;
		transform: translate3d(0, 1.5rem, 0);
	}
}

@keyframes pmw-reveal-fade {
	from {
		opacity: 0;
	}
}

@keyframes pmw-reveal-scale {
	from {
		opacity: 0;
		transform: scale(0.94);
	}
}

/* The hero's swirl drifts and its peacock sways, slowly: a held breath, not a performance. */
@keyframes pmw-swirl {
	from {
		transform: translate3d(-1.5%, 1%, 0) rotate(-1deg) scale(1.08);
	}

	to {
		transform: translate3d(1.5%, -1.5%, 0) rotate(1.2deg) scale(1.16);
	}
}

@keyframes pmw-sway {
	from {
		transform: translate3d(0, 0, 0) rotate(-1.6deg);
	}

	to {
		transform: translate3d(0, -0.4rem, 0) rotate(1.6deg);
	}
}

/* The art trails the page a little as it scrolls away, so the hero has depth. */
@keyframes pmw-art-lag {
	to {
		transform: translate3d(0, 2.5rem, 0);
	}
}

@media (prefers-reduced-motion: no-preference) {
	/* ---------- Reveal on scroll ---------- */

	html.js.reveal-on [data-reveal]:not(.is-in) {
		opacity: 0;
	}

	/* "backwards": the first frame holds through the delay, and afterwards the element is simply itself,
	 * so a card's own hover transform or lift is never overridden by a held animation. */
	html.js.reveal-on [data-reveal].is-in:not(.is-seen) {
		animation: pmw-reveal-up 0.9s var(--ease) var(--reveal-delay, 0s) backwards;
	}

	html.js.reveal-on [data-reveal="fade"].is-in:not(.is-seen) {
		animation-name: pmw-reveal-fade;
	}

	html.js.reveal-on [data-reveal="scale"].is-in:not(.is-seen) {
		animation-name: pmw-reveal-scale;
	}

	/* ---------- Hero: feather drift ---------- */

	.hero::before {
		animation: pmw-swirl 34s ease-in-out infinite alternate;
	}

	.hero__peacock {
		transform-origin: 50% 100%;
		animation: pmw-sway 8s ease-in-out infinite alternate;
	}

	/* main.js adds is-away while the hero is off screen: nothing animates that nobody can see. */
	.hero.is-away::before,
	.hero.is-away .hero__peacock,
	.hero.is-away .hero__toggle.is-needed {
		animation-play-state: paused;
	}

	@supports (animation-timeline: scroll()) {
		.hero__art {
			animation: pmw-art-lag linear both;
			animation-timeline: scroll(root block);
			animation-range: 0 90vh;
		}
	}
}

/* Safety net: whatever else changes, reduced motion never animates this file's elements. */
@media (prefers-reduced-motion: reduce) {
	[data-reveal],
	.hero::before,
	.hero__peacock,
	.hero__art {
		animation: none !important;
		transition-duration: 0.01ms !important;
	}
}

/* Paper has no scroll: show everything, even if the page was printed before it was read. */
@media print {
	html.js.reveal-on [data-reveal] {
		opacity: 1 !important;
		animation: none !important;
	}
}
