/* ============================================================================
   ANIMATION — entrance effects, view transitions, reduced-motion guards

   Two entrance effects only: .fadeInUpSmall and .blurInUpSmall. Don't add a
   third without a reason you can state.

   Every animation and transition on the site must be inert under
   prefers-reduced-motion: reduce. The guard at the bottom of this file is the
   backstop; a new motion rule still wants its own thought.
   ============================================================================ */

/* Cross-document view transitions, for any full page load. Client-side
   navigations in React Router don't use this opt-in — those morph through
   `viewTransition` on the Link (see ProductCard.jsx), which calls
   document.startViewTransition. Unsupported browsers ignore both. */
@view-transition {
	navigation: auto;
}

@layer utilities {

@keyframes fadeInUpSmall {
	from { opacity: 0; translate: 0 var(--space-s); }
	to   { opacity: 1; translate: 0 0; }
}

@keyframes blurInUpSmall {
	from { opacity: 0; translate: 0 var(--space-s); filter: blur(6px); }
	to   { opacity: 1; translate: 0 0; filter: blur(0); }
}

.fadeInUpSmall {
	animation: fadeInUpSmall var(--duration-slow) var(--ease-out) both;
}

.blurInUpSmall {
	animation: blurInUpSmall var(--duration-slow) var(--ease-out) both;
}

/* Not an entrance — cause and effect. A new variant's photograph opens out
   in a circle from the swatch that was tapped (--x, --y, set inline by
   BuyMedia), over the old one. */
@keyframes variantReveal {
	from { clip-path: circle(0 at var(--x, 50%) var(--y, 50%)); }
	to   { clip-path: circle(150vmax at var(--x, 50%) var(--y, 50%)); }
}

/* Not an entrance — a counter turning over: the homepage's chapter marker
   rolls up as each section arrives. */
@keyframes markerRoll {
	from { opacity: 0; translate: 0 0.6em; }
	to   { opacity: 1; translate: 0 0; }
}

/* Not an entrance — feedback. The bag badge pops once when its count
   changes, so an add from anywhere on the page registers in the header. */
@keyframes badgePop {
	0%   { scale: 0.4; }
	45%  { scale: 1.25; }
	100% { scale: 1; }
}

.delay1 { animation-delay: 80ms; }
.delay2 { animation-delay: 160ms; }
.delay3 { animation-delay: 240ms; }
.delay4 { animation-delay: 320ms; }

/* ── View transitions ─────────────────────────────────────────────────────────
   The product image morph: a card image and the PDP hero share a
   view-transition-name (product-<handle>, set inline on the markup) and the
   class below. Identity lives on the element; the timing lives here, once. */

::view-transition-group(.productImage) {
	animation-duration: var(--duration-base);
	animation-timing-function: var(--ease-out);
}

/* The homepage-to-PDP morph: the photograph and the product name travel on
   the sheet curve — slower than a card, because they cross the screen. */
::view-transition-group(*) {
	animation-timing-function: var(--ease-sheet);
}

/* The header never moves between pages. Pinned out of the root crossfade, or
   the bar flickers between two pixel-identical copies. */
::view-transition-old(siteHeader),
::view-transition-new(siteHeader),
::view-transition-old(siteHeaderGround),
::view-transition-new(siteHeaderGround) {
	animation: none;
	mix-blend-mode: normal;
}

/* The bar can differ between the two pages (condensed on one, full on the
   other, a different ground): show only the incoming one, or the two
   wordmarks sit on top of each other for the length of the transition. */
::view-transition-old(siteHeader),
::view-transition-old(siteHeaderGround) {
	display: none;
}

::view-transition-old(root),
::view-transition-new(root) {
	animation-duration: var(--duration-fast);
}

} /* @layer utilities */


/* ── Reduced motion — the backstop ────────────────────────────────────────────
   Unlayered on purpose: unlayered styles beat every layer, so nothing
   declared in a component can re-enable motion for someone who asked for
   none. This is the one place that exception is used. */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: 1ms;
		animation-iteration-count: 1;
		animation-delay: 0ms;
		transition-duration: 1ms;
		transition-delay: 0ms;
		scroll-behavior: auto;
	}

	::view-transition-group(*),
	::view-transition-old(*),
	::view-transition-new(*) {
		animation: none;
	}
}
