/*
 * Cross-document page transitions. Both pages of a navigation must opt in, so the cart,
 * checkout and account pages (which do not load this file) simply load without one.
 * Everything is inside the reduced-motion query: with "reduce" the rule is not active.
 */

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

	/* The header keeps its place while the content cross-fades under it. */
	.tm-header {
		view-transition-name: tm-header;
	}

	::view-transition-old(root),
	::view-transition-new(root) {
		animation-duration: 280ms;
		animation-timing-function: ease;
	}

	/*
	 * Named elements (a card's photo, which morphs into the product page's main photo) use
	 * the browser's own group animation, a little slower and gentler than the fade.
	 * The header does not move, so it takes the fade's timing.
	 */
	::view-transition-group(*) {
		animation-duration: 380ms;
		animation-timing-function: cubic-bezier(0.3, 0.1, 0.2, 1);
	}

	/*
	 * A grid photo is cropped to the card while the main photo keeps its own shape, so both
	 * snapshots fill the moving box and crop rather than stretch.
	 */
	::view-transition-old(*),
	::view-transition-new(*) {
		height: 100%;
		object-fit: cover;
	}

	::view-transition-group(root),
	::view-transition-group(tm-header) {
		animation-duration: 280ms;
		animation-timing-function: ease;
	}
}
