/**
 * Heritage Shop — motion layer.
 *
 * Rules of this file:
 *
 * 1. Only transform, opacity and colour are animated. Nothing here touches
 *    width, height, margin or padding, so the layer cannot shift the page:
 *    cumulative layout shift stays at zero and scrolling never reflows.
 * 2. Every rule is scoped under `html.hs-motion`, a class added by a script.
 *    Without JavaScript the layer is inert and nothing stays hidden.
 * 3. `prefers-reduced-motion: reduce` switches it all off, whatever the site
 *    setting says.
 *
 * The two levels change distance and duration only — never which effects exist.
 */

:root {
	--hs-anim-shift: 10px;
	--hs-anim-duration: 420ms;
	--hs-anim-stagger: 50ms;
	--hs-anim-ease: cubic-bezier(.22, .61, .36, 1);
}

html.hs-motion--full {
	--hs-anim-shift: 16px;
	--hs-anim-duration: 620ms;
	--hs-anim-stagger: 80ms;
}

/* ========================================================= 1. scroll reveal */

.hs-motion .hs-reveal {
	opacity: 0;
	transform: translateY(var(--hs-anim-shift));
}

/*
 * The transition sits on the revealed state, and the script strips both classes
 * once it has played. Leaving them on would keep the stagger delay attached and
 * slow down a hover effect on the same element afterwards.
 */
.hs-motion .hs-reveal.is-in {
	opacity: 1;
	transform: none;
	transition:
		opacity var(--hs-anim-duration) var(--hs-anim-ease) var(--hs-anim-delay, 0ms),
		transform var(--hs-anim-duration) var(--hs-anim-ease) var(--hs-anim-delay, 0ms);
}

/* ========================================================= 2. sticky header */

/*
 * The shadow is a gradient strip that fades in, not an animated box-shadow:
 * interpolating a shadow repaints the whole header on every frame, while this
 * is one composited layer.
 */
.hs-motion .hs-header[data-hs-sticky]::after {
	content: "";
	position: absolute;
	inset: 100% 0 auto;
	height: 18px;
	background: linear-gradient(to bottom, rgb(28 26 23 / 10%), rgb(28 26 23 / 0%));
	opacity: 0;
	pointer-events: none;
	transition: opacity 280ms var(--hs-anim-ease);
}

.hs-motion .hs-header[data-hs-sticky].is-stuck::after { opacity: 1; }

/* The strip replaces the shadow the base stylesheet paints in one step. */
.hs-motion .hs-header[data-hs-sticky].is-stuck { box-shadow: none; }

/* ============================================ 3. menu underline, button fill */

@media (min-width: 1024px) {
	.hs-motion .hs-menu > li > a { position: relative; }

	.hs-motion .hs-menu > li > a::after {
		content: "";
		position: absolute;
		right: 0;
		bottom: 0;
		left: 0;
		height: 2px;
		background: var(--hs-accent);
		transform: scaleX(0);
		transform-origin: center;
		transition: transform 260ms var(--hs-anim-ease);
	}

	.hs-motion .hs-menu > li > a:hover::after,
	.hs-motion .hs-menu > li > a:focus-visible::after,
	.hs-motion .hs-menu > .current-menu-item > a::after,
	.hs-motion .hs-menu > .current-menu-parent > a::after { transform: scaleX(1); }
}

/*
 * Primary button: the accent fill sweeps in from the left instead of swapping
 * colour in one step. Painted as a background gradient because a pseudo-element
 * would sit over the label.
 *
 * The hover state redeclares the whole background: the base stylesheet uses the
 * `background` shorthand there, which would otherwise reset the gradient away.
 */
.hs-motion .hs-btn:not(.hs-btn--ghost) {
	background-image: linear-gradient(var(--hs-accent), var(--hs-accent));
	background-repeat: no-repeat;
	background-position: left center;
	background-size: 0 100%;
	transition:
		background-size 320ms var(--hs-anim-ease),
		color 200ms ease,
		transform 120ms ease;
}

.hs-motion .hs-btn:not(.hs-btn--ghost):hover,
.hs-motion .hs-btn:not(.hs-btn--ghost):focus-visible {
	background-color: var(--hs-brand);
	background-image: linear-gradient(var(--hs-accent), var(--hs-accent));
	background-repeat: no-repeat;
	background-position: left center;
	background-size: 100% 100%;
}

/*
 * Ghost buttons carry most of the calls to action on the front page. They fill
 * with the brand colour on hover already; the sweep turns that fill into a wipe.
 * The label fades to white over the same window so it is never left sitting on
 * the empty half of the button.
 */
.hs-motion .hs-btn--ghost {
	background-image: linear-gradient(var(--hs-brand), var(--hs-brand));
	background-repeat: no-repeat;
	background-position: left center;
	background-size: 0 100%;
	transition:
		background-size 320ms var(--hs-anim-ease),
		color 260ms ease,
		border-color 260ms ease;
}

.hs-motion .hs-btn--ghost:hover,
.hs-motion .hs-btn--ghost:focus-visible {
	background-color: transparent;
	background-image: linear-gradient(var(--hs-brand), var(--hs-brand));
	background-repeat: no-repeat;
	background-position: left center;
	background-size: 100% 100%;
	border-color: var(--hs-brand);
	color: #fff;
}

/*
 * WooCommerce buttons own their colours in the storefront stylesheet, which
 * marks the brand fill `!important`. They are left alone apart from gaining the
 * transition they never had, so the colour change eases instead of snapping.
 *
 * Scoped on the loop and the storefront wrapper rather than on a `woocommerce`
 * body class: the front page's product grid is not a WooCommerce page, and
 * keying off that class silently skipped every card there.
 */
.hs-motion ul.products li.product .button,
.hs-motion ul.products li.product .added_to_cart,
.hs-motion .hs-shop .button,
.hs-motion .hs-shop a.button {
	transition:
		background-color 260ms var(--hs-anim-ease),
		color 200ms ease,
		transform 140ms ease;
}

/* ===================================================== 4. product card hover */

/*
 * Deliberately empty.
 *
 * The storefront already has this effect exactly right: the photo scales by
 * 1.04 inside an `overflow: hidden` link, which also clips the hairline that
 * frames the tile, so the frame appears to dissolve as the photo grows. The
 * only thing that moves is the photo.
 *
 * An earlier version of this file lifted the whole `li.product` by 3px and gave
 * it a shadow. That dragged the title, the price and the button up with the
 * photo, and the shadow drew a line back under the card the hairline had just
 * faded out - strictly worse than doing nothing. Card-level hover effects are
 * left to the storefront stylesheet.
 */

/*
 * Collection tiles already zoom their image on hover; the caption lifts with it
 * so the whole tile reads as one object rather than a picture with a label.
 */
.hs-motion .hs-collection:hover .hs-collection__body {
	transform: translateY(-4px);
}

.hs-motion .hs-collection__body {
	transition: transform 300ms var(--hs-anim-ease);
}

/* ======================================================= 5. image fade-in */

/*
 * An animation rather than a transition, deliberately: the product images
 * already carry a transform transition for the hover zoom, and declaring
 * `transition` here would replace it and make that zoom snap.
 */
.hs-motion .hs-fade-image { opacity: 0; }

.hs-motion .hs-fade-image.is-loaded {
	opacity: 1;
	animation: hs-image-in 420ms var(--hs-anim-ease);
}

@keyframes hs-image-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

/* ==================================================== 6. add-to-cart pulse */

@keyframes hs-cart-pulse {
	0% { transform: scale(1); }
	35% { transform: scale(1.35); }
	100% { transform: scale(1); }
}

.hs-motion .hs-actions__count {
	display: inline-block;
}

.hs-motion .hs-actions__count.is-pulse {
	animation: hs-cart-pulse 620ms var(--hs-anim-ease);
}

/* ============================================================ reduced motion */

/*
 * The script already stands down, but this is the guarantee: if anything above
 * still runs — a cached script, a child theme, a browser that ignores the
 * matchMedia query — no motion reaches the visitor.
 */
@media (prefers-reduced-motion: reduce) {
	.hs-motion .hs-reveal {
		opacity: 1;
		transform: none;
	}

	.hs-motion .hs-reveal.is-in,
	.hs-motion .hs-header[data-hs-sticky]::after,
	.hs-motion .hs-menu > li > a::after,
	.hs-motion .hs-btn:not(.hs-btn--ghost),
	.hs-motion .hs-btn--ghost,
	.hs-motion .hs-collection__body,
	.hs-motion ul.products li.product .button,
	.hs-motion .hs-shop .button {
		transition: none;
	}

	.hs-motion .hs-fade-image { opacity: 1; }

	.hs-motion .hs-fade-image.is-loaded,
	.hs-motion .hs-actions__count.is-pulse { animation: none; }
}
