/* ==========================================================
   Motion: micro-interactions, scroll reveals, hero entrance,
   page transitions. Timings/easings come from tokens.css.
   Only transform + opacity animate (no layout shift).
   ========================================================== */

/* ---- Micro-interactions ---- */

/* Buttons press in slightly. */
.ganz-btn,
.single-product div.product form.cart .single_add_to_cart_button,
.ganz-product-card__cta {
	transition-property: background-color, border-color, color, transform;
}

.ganz-btn:active,
.single-product div.product form.cart .single_add_to_cart_button:active,
ul.products li.product .ganz-product-card .ganz-product-card__body .ganz-product-card__cta.button:active {
	transform: scale(0.98);
	transition-duration: var(--ganz-duration-fast);
}

/* Text links: underline draws in from the left. */
.ganz-section-heading__link span:first-child,
.ganz-site-footer__nav a,
.ganz-breadcrumb a,
.ganz-editorial .ganz-btn--link span:first-child {
	background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
	transition: background-size var(--ganz-duration-slow) var(--ganz-ease-out), color var(--ganz-duration) var(--ganz-ease);
}

.ganz-section-heading__link:hover span:first-child,
.ganz-section-heading__link:focus-visible span:first-child,
.ganz-site-footer__nav a:hover,
.ganz-site-footer__nav a:focus-visible,
.ganz-breadcrumb a:hover,
.ganz-breadcrumb a:focus-visible,
.ganz-editorial .ganz-btn--link:hover span:first-child {
	background-size: 100% 1px;
}

.ganz-editorial .ganz-btn--link {
	text-decoration: none;
}

/* Main navigation: accent underline grows from the centre. */
.main-header-menu .menu-item > .menu-link {
	position: relative;
}

.main-header-menu .menu-item > .menu-link::after {
	background: var(--ganz-color-accent);
	bottom: 10px;
	content: "";
	height: 1px;
	left: 17px;
	position: absolute;
	right: 17px;
	transform: scaleX(0);
	transition: transform var(--ganz-duration-slow) var(--ganz-ease-out);
}

.main-header-menu .menu-item > .menu-link:hover::after,
.main-header-menu .menu-item > .menu-link:focus-visible::after,
.main-header-menu .current-menu-item > .menu-link::after {
	transform: scaleX(1);
}

/* Product card: second photo cross-fades in on hover. */
.ganz-product-card__image--hover {
	inset: 0;
	opacity: 0;
	position: absolute;
	transition: opacity var(--ganz-duration-reveal) var(--ganz-ease-out), transform var(--ganz-duration-slow) var(--ganz-ease);
}

.ganz-product-card:hover .ganz-product-card__image--hover,
.ganz-product-card:focus-within .ganz-product-card__image--hover {
	opacity: 1;
}

/* Category card: arrow slides on hover. */
.ganz-category-card__arrow .ganz-icon {
	transition: transform var(--ganz-duration-slow) var(--ganz-ease-out);
}

.ganz-category-card:hover .ganz-category-card__arrow .ganz-icon,
.ganz-category-card:focus-visible .ganz-category-card__arrow .ganz-icon {
	transform: translateX(2px);
}

/* Form fields: focus changes ease in. */
:where(input, select, textarea) {
	transition: border-color var(--ganz-duration) var(--ganz-ease), box-shadow var(--ganz-duration) var(--ganz-ease);
}

/* ---- Scroll reveals (assets/js/motion.js). Only active once <html> has
   .ganz-motion, which inc/motion.php sets before first paint. ---- */
.ganz-motion [data-reveal] {
	opacity: 0;
	transform: translate3d(0, var(--ganz-reveal-distance), 0);
	transition:
		opacity var(--ganz-duration-reveal) var(--ganz-ease-out),
		transform var(--ganz-duration-reveal) var(--ganz-ease-out);
	transition-delay: calc(var(--ganz-reveal-index, 0) * var(--ganz-stagger));
}

/* Sideways reveals only where columns sit side by side; on phones the offset
   would widen the page and let it pan horizontally, so they rise instead. */
@media (min-width: 922px) {
	.ganz-motion [data-reveal="left"] {
		transform: translate3d(calc(var(--ganz-reveal-distance) * -2), 0, 0);
	}

	.ganz-motion [data-reveal="right"] {
		transform: translate3d(calc(var(--ganz-reveal-distance) * 2), 0, 0);
	}
}

.ganz-motion [data-reveal].is-revealed {
	opacity: 1;
	transform: none;
}

/* Section heading: the accent rule draws across after the title arrives. */
.ganz-motion .ganz-section-heading[data-reveal] .ganz-section-heading__accent {
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform var(--ganz-duration-reveal) var(--ganz-ease-out) 200ms;
}

.ganz-motion .ganz-section-heading[data-reveal].is-revealed .ganz-section-heading__accent {
	transform: scaleX(1);
}

/* ---- Page-load hero entrance (CSS only). The hero image never fades
   (it is usually the LCP element); it only settles from a slight zoom. ---- */
@keyframes ganz-rise {
	from {
		opacity: 0;
		transform: translate3d(0, var(--ganz-reveal-distance), 0);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes ganz-fade-in {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@keyframes ganz-settle {
	from {
		transform: scale(1.04);
	}

	to {
		transform: scale(1);
	}
}

@keyframes ganz-draw {
	from {
		clip-path: inset(0 100% 0 0);
	}

	to {
		clip-path: inset(0 0 0 0);
	}
}

.ganz-motion :is(.ganz-hero__copy, .ganz-shop-hero__copy, .ganz-about-hero__copy) > * {
	animation: ganz-rise var(--ganz-duration-reveal) var(--ganz-ease-out) both;
}

.ganz-motion :is(.ganz-hero__copy, .ganz-shop-hero__copy, .ganz-about-hero__copy) > :nth-child(2) { animation-delay: 80ms; }
.ganz-motion :is(.ganz-hero__copy, .ganz-shop-hero__copy, .ganz-about-hero__copy) > :nth-child(3) { animation-delay: 160ms; }
.ganz-motion :is(.ganz-hero__copy, .ganz-shop-hero__copy, .ganz-about-hero__copy) > :nth-child(4) { animation-delay: 240ms; }
.ganz-motion :is(.ganz-hero__copy, .ganz-shop-hero__copy, .ganz-about-hero__copy) > :nth-child(5) { animation-delay: 320ms; }
.ganz-motion :is(.ganz-hero__copy, .ganz-shop-hero__copy, .ganz-about-hero__copy) > :nth-child(n + 6) { animation-delay: 400ms; }

.ganz-motion :is(.ganz-hero__image, .ganz-shop-hero__visual img, .ganz-about-hero__image) {
	animation: ganz-settle 1.4s var(--ganz-ease-out) both;
}

/* Handwritten note fades in (keeps its rotation), then its swash draws itself. */
.ganz-motion .ganz-note {
	animation: ganz-fade-in var(--ganz-duration-reveal) var(--ganz-ease-out) 450ms both;
}

.ganz-motion .ganz-note::after {
	animation: ganz-draw 900ms var(--ganz-ease-in-out) 900ms both;
}

/* Notes inside a scroll-revealed block wait for their block. */
.ganz-motion [data-reveal]:not(.is-revealed) .ganz-note,
.ganz-motion [data-reveal]:not(.is-revealed) .ganz-note::after {
	animation-play-state: paused;
}

/* ---- Shopping feedback (assets/js/motion.js) ---- */
@keyframes ganz-spin {
	to {
		transform: rotate(360deg);
	}
}

@keyframes ganz-bump {
	0%,
	100% {
		transform: scale(1);
	}

	40% {
		transform: scale(1.35);
	}
}

@keyframes ganz-highlight {
	from {
		background-color: var(--ganz-color-accent-soft);
	}

	to {
		background-color: transparent;
	}
}

/* Add-to-cart spinner (product page submit, WooCommerce AJAX .loading). */
.single-product div.product form.cart .single_add_to_cart_button.is-loading,
ul.products li.product .ganz-product-card .ganz-product-card__body .ganz-product-card__cta.button.loading {
	color: transparent;
	pointer-events: none;
	position: relative;
}

.single-product div.product form.cart .single_add_to_cart_button.is-loading::after,
ul.products li.product .ganz-product-card .ganz-product-card__body .ganz-product-card__cta.button.loading::after {
	animation: ganz-spin 700ms linear infinite;
	border: 2px solid var(--ganz-color-on-dark);
	border-radius: var(--ganz-radius-round);
	border-top-color: transparent;
	content: "";
	height: 18px;
	inset: 0;
	margin: auto;
	position: absolute;
	width: 18px;
}

ul.products li.product .ganz-product-card .ganz-product-card__body .ganz-product-card__cta.button.loading::after {
	border-color: var(--ganz-color-accent);
	border-top-color: transparent;
}

/* Header cart count bumps when something is added. */
.ganz-cart-bump i.astra-icon::after {
	animation: ganz-bump var(--ganz-duration-reveal) var(--ganz-ease-out);
}

/* Cart: removed row fades back while WooCommerce updates. */
.woocommerce-cart-form tr.cart_item {
	transition: opacity var(--ganz-duration-slow) var(--ganz-ease);
}

.woocommerce-cart-form tr.cart_item.is-removing {
	opacity: 0.35;
}

/* Cart: total flashes softly when it changes. */
.cart_totals .order-total.is-updated th,
.cart_totals .order-total.is-updated td {
	animation: ganz-highlight 1.2s var(--ganz-ease-out);
}

/* Product page: main image cross-fades on variation change. */
.woocommerce-product-gallery__image.is-swapping img {
	animation: ganz-fade-in var(--ganz-duration-slow) var(--ganz-ease-out);
}

/* ---- Page transitions (cross-document View Transitions; browsers without
   support navigate normally). A clicked product card's photo morphs into the
   product page's main image (name set on click in assets/js/motion.js). ---- */
@media (prefers-reduced-motion: no-preference) {
	@view-transition {
		navigation: auto;
	}
}

::view-transition-old(root),
::view-transition-new(root) {
	animation-duration: var(--ganz-duration-slow);
	animation-timing-function: var(--ganz-ease-out);
}

.single-product .woocommerce-product-gallery__image:first-child img.wp-post-image {
	view-transition-name: ganz-product-image;
}

::view-transition-group(ganz-product-image) {
	animation-duration: 450ms;
	animation-timing-function: var(--ganz-ease-out);
}

/* ---- Reduced motion: remove movement everywhere (last-resort !important). ---- */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		scroll-behavior: auto !important;
		transition-duration: 0.01ms !important;
	}
}
