/**
 * AestheticX — product card component (Phase 7A).
 *
 * ONE card for every WooCommerce loop: shop/category archives, PDP related +
 * upsells, cart "You may also like", thank-you recommendations, My Account
 * "Continue shopping", search. Loaded wherever a loop renders (body class
 * `ax-cards`, inc/product-card.php); each page stylesheet only sets its grid.
 *
 * Anatomy (native WC loop markup):
 *   li.product
 *     button.ax-wishlist-btn--card   heart, top-right (styled in wishlist.css)
 *     a.woocommerce-loop-product__link
 *       .ax-gold-badge--card          top-left
 *       img                           square
 *       span.onsale                   top-left, under the gold badge if both
 *       h2.woocommerce-loop-product__title   max 2 lines
 *       span.price
 *     a.button                        full width, one line, pinned to the foot
 *
 * `html body.ax-cards … li.product.product` out-ranks Astra's `.woocommerce(-page) ul.products …`.
 */

html body.ax-cards ul.products li.product.product {
	position: relative;
	display: flex;
	flex-direction: column;
	float: none;
	clear: none;
	width: auto;
	min-width: 0;
	margin: 0;
	padding: 0;
	text-align: left;
	background-color: var(--ax-surface);
	border: 1px solid var(--ax-border);
	border-radius: var(--ax-radius);
	box-shadow: var(--ax-shadow);
	overflow: hidden;
	transition: border-color var(--ax-transition), box-shadow var(--ax-transition), transform var(--ax-transition);
}

html body.ax-cards ul.products li.product.product::before,
html body.ax-cards ul.products li.product.product::after {
	display: none;
}

@media (hover: hover) and (pointer: fine) {
	html body.ax-cards ul.products li.product.product:hover {
		border-color: var(--ax-sage-soft);
		box-shadow: var(--ax-shadow-hover);
		transform: translateY(-4px);
	}
}

html body.ax-cards ul.products li.product.product > a.woocommerce-loop-product__link {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	color: inherit;
	text-decoration: none;
}

html body.ax-cards ul.products li.product.product a.woocommerce-loop-product__link img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	margin: 0 0 0.85rem;
	border-radius: 0;
	background-color: var(--ax-base);
	object-fit: cover;
	transition: transform 0.45s ease;
}

@media (hover: hover) and (pointer: fine) {
	html body.ax-cards ul.products li.product.product:hover a.woocommerce-loop-product__link img {
		transform: scale(1.035);
	}
}

/* Badges: gold pill top-left; the sale pill stacks under it (custom.css
   handles the "both" offset) — never on the heart's side. */
html body.ax-cards ul.products li.product.product span.onsale {
	position: absolute;
	top: 0.75rem;
	left: 0.75rem;
	right: auto;
	z-index: 3;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0.42em 0.7em;
	border-radius: 999px;
	background-color: var(--ax-accent);
	color: var(--ax-on-accent);
	font-family: var(--ax-font-heading);
	font-size: 0.68rem;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
}

html body.ax-cards ul.products li.product.product .ax-gold-badge--card {
	max-width: calc(100% - 4.5rem);
	white-space: nowrap;
}

html body.ax-cards ul.products li.product.product .woocommerce-loop-product__title {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	margin: 0 0 0.4rem;
	padding: 0 1rem;
	font-family: var(--ax-font-heading);
	font-size: clamp(0.88rem, 1.8vw, 1rem);
	font-weight: 600;
	line-height: 1.4;
	color: var(--ax-text);
	transition: color var(--ax-transition);
}

html body.ax-cards ul.products li.product.product:hover .woocommerce-loop-product__title {
	color: var(--ax-accent-hover);
}

html body.ax-cards ul.products li.product.product .price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.15rem 0.45rem;
	margin: 0 0 0.9rem;
	padding: 0 1rem;
	font-family: var(--ax-font-heading);
	font-size: 0.94rem;
	font-weight: 600;
	color: var(--ax-text);
}

html body.ax-cards ul.products li.product.product .price del {
	order: 2;
	font-size: 0.85em;
	font-weight: 400;
	color: var(--ax-muted);
	opacity: 0.8;
}

html body.ax-cards ul.products li.product.product .price ins {
	order: 1;
	text-decoration: none;
}

/* Add to cart: full width, one line, at the card foot. */
html body.ax-cards ul.products li.product.product a.button,
html body.ax-cards ul.products li.product.product a.added_to_cart {
	display: flex;
	align-items: center;
	justify-content: center;
	align-self: stretch;
	min-height: 2.6rem;
	margin: auto 0.85rem 0.85rem;
	padding: 0.6em 0.8em;
	border: 1px solid var(--ax-accent);
	border-radius: 999px;
	background-color: var(--ax-accent);
	color: var(--ax-on-accent);
	font-family: var(--ax-font-heading);
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	line-height: 1.1;
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	box-shadow: none;
	transition: background-color var(--ax-transition), border-color var(--ax-transition), box-shadow var(--ax-transition), transform var(--ax-transition);
}

html body.ax-cards ul.products li.product.product a.button:hover,
html body.ax-cards ul.products li.product.product a.button:focus-visible {
	border-color: var(--ax-accent-hover);
	background-color: var(--ax-accent-hover);
	color: var(--ax-on-accent);
	box-shadow: 0 8px 20px var(--ax-accent-shadow);
	transform: translateY(-2px);
}

html body.ax-cards ul.products li.product.product a.button.product_type_variable,
html body.ax-cards ul.products li.product.product a.button.product_type_grouped,
html body.ax-cards ul.products li.product.product a.button.product_type_external,
html body.ax-cards ul.products li.product.product a.added_to_cart {
	border-color: var(--ax-border);
	background-color: transparent;
	color: var(--ax-text);
}

/* "View cart" link WC appends after an AJAX add (when shown). */
html body.ax-cards ul.products li.product.product a.added_to_cart {
	margin-top: 0;
}

html body.ax-cards ul.products li.product.product a.button.ax-added {
	border-color: var(--ax-gold-deep);
	background-color: var(--ax-gold-deep);
	color: var(--ax-on-accent);
}

html body.ax-cards ul.products li.product.product a.button.loading {
	opacity: 0.8;
}

@media (max-width: 380px) {
	html body.ax-cards ul.products li.product.product a.button {
		font-size: 0.72rem;
		letter-spacing: 0;
		margin: auto 0.6rem 0.6rem;
	}
	html body.ax-cards ul.products li.product.product .woocommerce-loop-product__title,
	html body.ax-cards ul.products li.product.product .price {
		padding: 0 0.75rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	html body.ax-cards ul.products li.product.product,
	html body.ax-cards ul.products li.product.product a.woocommerce-loop-product__link img,
	html body.ax-cards ul.products li.product.product a.button {
		transition: none !important;
	}
	html body.ax-cards ul.products li.product.product:hover,
	html body.ax-cards ul.products li.product.product:hover a.woocommerce-loop-product__link img {
		transform: none;
	}
}
