/* ==========================================================================
   Cybernetic Motion Layer - Calm Dignified Motion Standard
   CSS-native viewport reveals, kinetic typography primitives, continuous marquee,
   and spatial transitions. Zero !important.

   Reduced motion: every movement opts in under
   @media (prefers-reduced-motion: no-preference). The static base is the
   final state, so reduced-motion visitors see all text and cards at once.
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
	@view-transition { navigation: auto; }
}

@layer components {
	/* 1. Static base (always on: final state, layout only) */
	.ebg-marquee,
	.marquee { overflow: hidden; }
	.ebg-marquee__track,
	.marquee__track {
		display: flex;
		width: max-content;
	}
	.anim-mask,
	.anim-word-mask {
		display: inline-block;
		overflow: hidden;
		vertical-align: top;
		white-space: nowrap;
	}
	span.anim-char,
	span.anim-word { display: inline-block; }
	.anim-char:not([data-split-ready]),
	.anim-word:not([data-split-ready]) {
		visibility: visible;
	}

	@keyframes anim-rise {
		from {
			opacity: 0;
			transform: translate3d(0, 14px, 0);
		}
		to {
			opacity: 1;
			transform: none;
		}
	}
	@keyframes marquee-scroll {
		from { transform: translate3d(0, 0, 0); }
		to { transform: translate3d(-50%, 0, 0); }
	}

	/* 2. Motion (opt-in only) */
	@media (prefers-reduced-motion: no-preference) {
		/* Entrance & stagger viewport reveals */
		.reveal,
		.ebg-reveal {
			animation: anim-rise var(--dur-slow, 0.4s) var(--ease-snap, cubic-bezier(0.16, 1, 0.3, 1)) backwards;
		}
		.reveal--1,
		.ebg-reveal--1 { animation-delay: 0ms; }
		.reveal--2,
		.ebg-reveal--2 { animation-delay: 80ms; }
		.reveal--3,
		.ebg-reveal--3 { animation-delay: 160ms; }
		.reveal--4,
		.ebg-reveal--4 { animation-delay: 240ms; }

		/* Continuous marquee: pauses on hover/focus, never moves under reduced motion. */
		.ebg-marquee__track,
		.marquee__track {
			will-change: transform;
			animation: marquee-scroll 28s linear infinite;
		}
		.ebg-marquee:is(:hover, :focus-within) .ebg-marquee__track,
		.marquee:is(:hover, :focus-within) .marquee__track {
			animation-play-state: paused;
		}

		/* Kinetic typography, gated per heading by IntersectionObserver (.is-inview) */
		span.anim-char {
			transform: translateY(115%);
			opacity: 0;
			will-change: transform, opacity;
			transition: transform 0.35s var(--ease-snap, cubic-bezier(0.16, 1, 0.3, 1)), opacity 0.25s ease;
			transition-delay: calc(0.02s + var(--char-idx, 0) * 0.012s);
		}
		span.anim-word {
			transform: translateY(125%) rotate(2.5deg);
			transform-origin: 0% 100%;
			opacity: 0;
			will-change: transform, opacity;
			transition: transform 0.45s var(--ease-snap, cubic-bezier(0.16, 1, 0.3, 1)), opacity 0.35s ease;
			transition-delay: calc(0.04s + var(--word-idx, 0) * 0.05s);
		}
		.is-inview {
			span.anim-char {
				transform: translateY(0);
				opacity: 1;
			}
			span.anim-word {
				transform: translateY(0) rotate(0deg);
				opacity: 1;
			}
		}

		[data-reveal] {
			transition-property: opacity, transform;
			transition-duration: var(--dur-slow, 0.4s);
			transition-timing-function: var(--ease-snap, cubic-bezier(0.16, 1, 0.3, 1));
			will-change: transform, opacity;
		}
		[data-reveal*="no"] {
			opacity: 0.001;
			transform: translateY(20px);
		}
		[data-reveal*="yes"] {
			opacity: 1;
			transform: none;
		}
		[data-reveal*="yes:1"] { transition-delay: 0ms; }
		[data-reveal*="yes:2"] { transition-delay: 100ms; }
		[data-reveal*="yes:3"] { transition-delay: 200ms; }
		[data-reveal*="yes:4"] { transition-delay: 300ms; }

		/* Phones: kinetic text off, masks open (later rule, same specificity) */
		@media (max-width: 48em) {
			.title-anim-chars,
			.title-anim-words,
			.ebg-banner__title,
			span.anim-char,
			span.anim-word {
				transform: none;
				opacity: 1;
				transition: none;
				animation: none;
			}
			.anim-mask,
			.anim-word-mask { overflow: visible; }
		}
	}
}
