/**
 * Page transitions (optional component)
 *
 * Cross-document View Transitions: when the visitor moves to another page of
 * the same site, the old content fades out and up and the new content fades
 * in from slightly below. Pure CSS, no JS. The browser starts the animation
 * once the new page is ready to render, so navigation is never delayed.
 * Back and forward navigations animate too; reloads and address-bar
 * navigations do not. Browsers without support change pages normally.
 *
 * The header, the mobile header and the admin bar get their own transition
 * names, so they stay put while the content changes (identical pixels
 * cross-fade invisibly). Each name must be unique on the page; hidden
 * elements (display: none) are not captured, so the desktop and mobile
 * headers never clash.
 *
 * The overlay is painted with the page background so the short gap between
 * the outgoing and incoming content never flashes the browser's default.
 *
 * Switch: Sivuston asetukset → Yleiset → Sivunvaihdot (page-transitions.php
 * enqueues this file only when on). Docs: page-transitions.md.
 */

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

	/* The name makes the header a stacking context, so GP's sticky
	   navigation inside it (z-index 10000) would only stack within the
	   header and the content below would paint over the stuck bar. The
	   header itself is lifted to the bar's level (GP positions it). */
	.site-header {
		view-transition-name: site-header;
		z-index: 10000;
	}

	#mobile-header {
		view-transition-name: mobile-header;
	}

	#wpadminbar {
		view-transition-name: wp-admin-bar;
	}

	::view-transition {
		background-color: var(--body-bg-clr);
	}

	::view-transition-old(root) {
		animation: applari-page-out 160ms ease-in both;
	}

	::view-transition-new(root) {
		animation: applari-page-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1) 100ms both;
	}
}

@keyframes applari-page-out {
	to {
		opacity: 0;
		transform: translateY(-12px);
	}
}

@keyframes applari-page-in {
	from {
		opacity: 0;
		transform: translateY(16px);
	}
}
