/*
 * Product card — Figma 7:1401 (template-parts/components/product-card.php).
 * Woo's loop classes stay on the element (li.product, .price, .button …); styling hangs off hs-*.
 * Grid wrapper: ul.products.hs-products (3 columns by default; --hs-products-cols to change).
 */

.hs-products {
	display: grid;
	grid-template-columns: repeat(var(--hs-products-cols, 3), minmax(0, 1fr));
	gap: 12px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Woo buttons also carry .wp-element-button, whose theme.json reset (text-transform: inherit,
   same specificity, printed later) beats .hs-btn. Restore the design's capitalised labels. */
.hs-btn.wp-element-button {
	padding-block: 0; /* theme.json's 24px button padding would make it 64px; .hs-btn's min-height sets 59px */
	text-transform: capitalize;
}

/* Same reset paints every .wp-element-button navy/white: restore the outline and light variants. */
.hs-btn.hs-btn--outline.wp-element-button {
	background: transparent;
	color: var(--hs-navy);
}

.hs-btn.hs-btn--outline.wp-element-button:hover,
.hs-btn.hs-btn--light.wp-element-button:hover,
.hs-btn.hs-btn--primary.wp-element-button:hover {
	background: var(--hs-btn-hover);
	border-color: var(--hs-btn-hover);
	color: var(--hs-navy);
}

.hs-btn.hs-btn--light.wp-element-button {
	background: #fff;
	border-color: #fff;
	color: var(--hs-navy);
}

.hs-product-card {
	position: relative;
	display: flex;
	flex-direction: column;
	min-height: 580px; /* Figma 14:2774 */
	margin: 0;
	padding: 12px;
	box-sizing: border-box;
	border-radius: var(--hs-radius-md);
	background: var(--hs-cream);
	color: var(--hs-navy);
	overflow: hidden;
	list-style: none;
}

/* Tile: pillar tone-300 with the illustration centred (or a cover photo). */
.hs-product-card__media {
	position: relative;
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	height: 220px; /* Figma: fixed 220px tile */
	border-radius: var(--hs-radius-md);
	background: var(--tone-300);
	overflow: hidden;
}

.hs-product-card__illustration {
	display: block;
	max-width: 60%;
	max-height: 80%;
	object-fit: contain;
	transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Subsection shop icon (Figma 34:1951): a full-bleed square on the pillar colour, cropped to the
   tile; the GIF (assets/js/shop-icon.js) is laid over the still while the card is hovered. */
.hs-shop-icon {
	position: absolute;
	inset: 0;
}

/* Figma 34:1951 puts the art at ~60% of a 250px tile: the square is 1.6× the tile height, centred;
   any side bands are the same pillar colour, so the square reads as the tile. */
.hs-shop-icon :is(.hs-shop-icon__still, .hs-shop-icon__anim) {
	position: absolute;
	top: 50%;
	left: 50%;
	width: auto;
	max-width: none;
	height: 160%;
	aspect-ratio: 1;
	translate: -50% -50%;
}

/* :root lifts these over motion.css's image reveal (.hs-motion .is-in img). */
:root .hs-shop-icon .hs-shop-icon__anim {
	opacity: 0;
	scale: none;
	transition: none;
}

:root .hs-shop-icon.is-playing .hs-shop-icon__anim {
	opacity: 1;
}

/* Photo mode (Figma 7:832): packshot covers the tile; empty tile is neutral, not the pillar tone. */
.hs-product-card--photo .hs-product-card__media {
	background: #e6e2d9;
}

.hs-product-card__photo {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.hs-product-card:hover .hs-product-card__illustration {
	transform: scale(1.12) rotate(-2deg); /* zoom doubled (design review) */
}

/* motion.css's image reveal (.hs-motion .is-in img) replaces `transition` with scale/opacity only;
   keep those and add transform so the hover eases instead of snapping. */
@media (prefers-reduced-motion: no-preference) {
	:root .hs-product-card .hs-product-card__illustration {
		transition:
			transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
			scale 1.6s cubic-bezier(0.25, 1, 0.5, 1),
			opacity 0.8s ease-out;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hs-product-card .hs-product-card__illustration {
		transition: none;
	}
}

.hs-product-card__body {
	display: flex;
	flex: 1 1 0;
	flex-direction: column;
	justify-content: space-between;
	gap: 12px; /* minimum only; space-between sets the rhythm in the 580px card */
	padding: 24px 16px;
}

.hs-product-card__copy {
	display: flex;
	flex-direction: column;
	gap: 20px; /* Figma 14:2777 */
	word-break: break-word;
}

.hs-product-card__pillar {
	margin: 0;
	font-family: var(--hs-script);
	font-weight: 700;
	font-size: 28px;
	line-height: 1;
	letter-spacing: 0.03em;
	text-transform: capitalize;
	text-box: trim-both cap alphabetic;
	color: var(--tone-700);
}

.hs-product-card.hs-tone--lemon .hs-product-card__pillar {
	color: var(--wp--preset--color--lemon-900);
}

.hs-product-card__info {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.hs-product-card__title {
	margin: 0;
	font-family: var(--hs-serif);
	font-weight: 400;
	font-size: 30px; /* Figma 14:2779 */
	line-height: 1.1;
	color: var(--hs-navy);
}

.hs-product-card__title a {
	color: inherit;
	text-decoration: none;
}

/* Whole card is clickable through the title link. */
.hs-product-card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.hs-product-card__title a:focus-visible {
	outline: none;
}

.hs-product-card:has(.hs-product-card__title a:focus-visible) {
	outline: 3px solid var(--wp--preset--color--sky-500);
	outline-offset: 3px;
}

.hs-product-card__meta {
	margin: 0;
	font-size: 16px;
	line-height: 1.4;
	opacity: 0.6;
}

.hs-product-card__price {
	display: block;
	font-family: var(--hs-serif);
	font-size: 24px;
	line-height: 1.1;
	color: var(--hs-navy);
}

/* Cards keep the unit at the price size ("$30 / classroom"); the buy box shrinks it. */
.hs-product-card .price .hs-price-unit {
	font-size: inherit;
}

.hs-product-card__price del {
	opacity: 0.5;
	font-size: 0.8em;
}

.hs-product-card__price ins {
	text-decoration: none;
}

.hs-product-card__actions {
	position: relative;
	z-index: 2; /* Above the card-wide title link. */
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
}

/* Woo appends "View cart" after an AJAX add. */
.hs-product-card__actions .added_to_cart {
	font-weight: 500;
	color: var(--hs-navy);
	text-decoration: underline;
	text-underline-offset: 4px;
}

.hs-product-card__button.loading {
	opacity: 0.6;
	pointer-events: none;
}

.hs-product-card__button.added::after {
	content: "✓";
	margin-left: 4px;
}

/* Woo sale flash (fired from woocommerce_before_shop_loop_item_title). */
.hs-product-card .onsale {
	position: absolute;
	top: 28px;
	left: 28px;
	z-index: 2;
	padding: 6px 14px;
	border-radius: 999px;
	background: var(--hs-navy);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
}

@media (max-width: 1023px) {
	.hs-products {
		grid-template-columns: repeat(min(var(--hs-products-cols, 3), 2), minmax(0, 1fr));
	}

	.hs-product-card {
		min-height: 560px;
	}
}

@media (max-width: 768px) {
	.hs-products {
		grid-template-columns: minmax(0, 1fr);
	}

	.hs-product-card {
		min-height: 0;
	}

	.hs-product-card__media {
		flex: none;
		height: auto;
		aspect-ratio: 432 / 290;
		min-height: 0;
	}

	.hs-product-card__body {
		padding: 20px 12px 12px;
	}

	.hs-product-card__title {
		font-size: 26px;
	}
}

/* Button hover takes the product's category (pillar) colour. */
.hs-product-card {
	--hs-btn-hover: var(--tone-500);
}
