/*
 * Scroll motion - U5, the operator's request after launch (2026-10-16). The design draws no motion;
 * this is the brief's restrained set, transforms and opacity only, so nothing moves in the layout and
 * every anchor lands where it did. One easing curve and two durations, all in base.css.
 *
 *   on load      the hero copy fades up (headline, description, call to action, 120ms apart) and
 *                the hero photo settles from a 1.05 zoom;
 *   on scroll    each unit once, as it comes 12% into the screen (motion.js): Apie's label, text and
 *                process line; the Projektai heading (title, label, then its line drawn across); the
 *                Vystomi label and its line; each project (the photo settles from a 1.06 zoom inside
 *                its own rounded box, its number and details fade up 200ms later); the Kontaktai
 *                label, heading, email, legal block and the footer line. Units that come in together
 *                are staggered 110ms apart (motion.js sets --inv-batch).
 *
 * NOTHING is hidden unless <html> carries inv-motion. The head script (inc/head.php) puts it there
 * only when JavaScript runs, the visitor has not asked for reduced motion, the browser has
 * IntersectionObserver and the page is not driven by automation (navigator.webdriver, so the gate's
 * captures and the live check read the final page); if motion.js then fails, or is late, the class
 * comes off again (head.php, motion.js). Without the class this file does nothing, so the
 * page is exactly the page without motion, and the block editor (which never has the class) is
 * untouched. Print and reduced motion are outside the query below and always see everything.
 */

@media screen and (prefers-reduced-motion: no-preference) {

	/* Every moving part, the same curve; --inv-delay is each part's own wait (its unit's batch step
	   plus the part's offset inside the unit). */
	.inv-motion :is(
		.inv-hero__headline,
		.inv-hero__support > p,
		.inv-apie__label,
		.inv-apie__text,
		.inv-apie__process,
		.inv-projects__head > *,
		.inv-proj__info,
		.inv-contact__label,
		.inv-contact__heading,
		.inv-contact__email,
		.inv-contact__legal
	) {
		transition:
			opacity var(--inv-motion-text) var(--inv-ease) var(--inv-delay, 0ms),
			transform var(--inv-motion-text) var(--inv-ease) var(--inv-delay, 0ms);
	}

	/* -- Hero, on load (motion.js adds is-in to .inv-hero, and is-photo-in once the photo is decoded,
	   so the zoom never plays over an empty band). */
	.inv-motion .inv-hero__band > .wp-block-cover__image-background {
		transform: scale(1.05);
		transition: transform var(--inv-motion-photo) var(--inv-ease);
	}

	.inv-motion .inv-hero.is-photo-in .inv-hero__band > .wp-block-cover__image-background {
		transform: none;
	}

	.inv-motion .inv-hero:not(.is-in) :is(.inv-hero__headline, .inv-hero__support > p) {
		opacity: 0;
		transform: translateY(20px);
	}

	.inv-motion .inv-hero__headline {
		--inv-delay: 100ms;
	}

	.inv-motion .inv-hero__support > p:first-child {
		--inv-delay: 220ms;
	}

	.inv-motion .inv-hero__support > p:last-child {
		--inv-delay: 340ms;
	}

	/* -- Units that reveal themselves: fade up 20px. */
	.inv-motion :is(
		.inv-apie__label,
		.inv-apie__text,
		.inv-apie__process,
		.inv-contact__label,
		.inv-contact__heading,
		.inv-contact__email,
		.inv-contact__legal
	) {
		--inv-delay: var(--inv-batch, 0ms);
	}

	.inv-motion :is(
		.inv-apie__label,
		.inv-apie__text,
		.inv-apie__process,
		.inv-contact__label,
		.inv-contact__heading,
		.inv-contact__email,
		.inv-contact__legal
	):not(.is-in) {
		opacity: 0;
		transform: translateY(20px);
	}

	/* The footer is the last thing on the page: it only fades, because a footer moved down would
	   lengthen the page until it settled. */
	.inv-motion .inv-contact__footer {
		transition: opacity var(--inv-motion-text) var(--inv-ease) var(--inv-batch, 0ms);
	}

	.inv-motion .inv-contact__footer:not(.is-in) {
		opacity: 0;
	}

	/* -- Projektai heading: the title, then the label, then the 1px line under them drawn across from
	   the left. The border keeps its 1px (nothing moves) but turns transparent; the line in its place
	   is the same colour (--inv-projects-line, projects.css). */
	.inv-motion .inv-projects .inv-projects__head {
		position: relative;
		border-bottom-color: transparent;
	}

	.inv-motion .inv-projects__head > :first-child {
		--inv-delay: var(--inv-batch, 0ms);
	}

	.inv-motion .inv-projects__head > :nth-child(2) {
		--inv-delay: calc(var(--inv-batch, 0ms) + 120ms);
	}

	.inv-motion .inv-projects__head:not(.is-in) > * {
		opacity: 0;
		transform: translateY(20px);
	}

	.inv-motion .inv-projects .inv-projects__head::after,
	.inv-motion .inv-projects .inv-projects__cat::after {
		content: "";
		position: absolute;
		right: 0;
		left: 0;
		height: 1px;
		background: var(--inv-projects-line);
		transform-origin: left center;
		transition: transform var(--inv-motion-photo) var(--inv-ease) calc(var(--inv-batch, 0ms) + 200ms);
	}

	.inv-motion .inv-projects .inv-projects__head::after {
		bottom: -1px;
	}

	.inv-motion .inv-projects .inv-projects__head:not(.is-in)::after,
	.inv-motion .inv-projects .inv-projects__cat:not(.is-in)::after {
		transform: scaleX(0);
	}

	/* -- The Vystomi label row: its line (above the label) draws across and the label fades in. The
	   label does not move: the line belongs to the same box. */
	.inv-motion .inv-projects .inv-projects__cat {
		position: relative;
		border-top-color: transparent;
		transition: opacity var(--inv-motion-text) var(--inv-ease) calc(var(--inv-batch, 0ms) + 120ms);
	}

	.inv-motion .inv-projects .inv-projects__cat::after {
		top: -1px;
	}

	.inv-motion .inv-projects .inv-projects__cat:not(.is-in) {
		opacity: 0;
	}

	/* With no Igyvendinti projects there is no line above Vystomi (projects.css), so none is drawn. */
	.inv-motion .inv-projects--done.inv-projects--empty + .inv-projects--dev .inv-projects__cat::after {
		content: none;
	}

	/* -- Each project as a unit: the photo settles inside its own rounded box, the number and the
	   details fade up a beat later. The box clips the zoom (isolation keeps Safari's rounded clip
	   on a transformed child). */
	.inv-motion .inv-proj-items > li .inv-proj__photo {
		overflow: hidden;
		border-radius: 10px;
		isolation: isolate;
	}

	.inv-motion .inv-proj-items > li .inv-proj__photo img {
		transition:
			opacity var(--inv-motion-photo) var(--inv-ease) var(--inv-batch, 0ms),
			transform var(--inv-motion-photo) var(--inv-ease) var(--inv-batch, 0ms);
	}

	.inv-motion .inv-proj-items > li:not(.is-in) .inv-proj__photo img {
		opacity: 0;
		transform: scale(1.06);
	}

	.inv-motion .inv-proj-items > li .inv-proj__info {
		--inv-delay: calc(var(--inv-batch, 0ms) + 200ms);
	}

	.inv-motion .inv-proj-items > li:not(.is-in) .inv-proj__info {
		opacity: 0;
		transform: translateY(20px);
	}
}
