/**
 * Product card — 1:1 with the design's `.pcard`, built on top of the standard
 * WooCommerce loop output (product link, thumbnail, sale flash, title, price,
 * add-to-cart). Only the wishlist button and the SKU line are theme markup;
 * everything else is styled through the WooCommerce classes it renders.
 *
 * @package Bozpo_Custom
 */

.product-card {
	grid-template-columns: none !important;
	position: relative;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	margin: 0;
	list-style: none;
	background: var(--surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-12);
	transition: box-shadow .15s, transform .15s;
}

.product-card:hover {
	box-shadow: var(--shadow);
	transform: translateY(-3px);
}

/*
 * The WooCommerce permalink wraps thumbnail + SKU + title + price. It fills the
 * card's flexible space so its trailing text block (code/title/price) is pushed
 * to the bottom, sitting right above the add-to-cart button.
 */
.product-card a.woocommerce-loop-product__link,
.product-card a.woocommerce-LoopProduct-link {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-height: 0;
	color: inherit;
}

/*
 * Media — the soft panel behind the thumbnail. Fixed height, auto width (the
 * image keeps its aspect ratio and is centred in the card); margin-bottom: auto
 * absorbs the card's spare height so the trailing text block (code/title/price)
 * stays pinned to the bottom, right above the button.
 */
.product-card a.woocommerce-loop-product__link img,
.product-card img.attachment-woocommerce_thumbnail {
	display: block;
	flex: 0 0 auto;
	align-self: center;
	width: auto;
	max-width: 100%;
	height: 200px;
	margin-bottom: auto;
	padding: var(--space-22);
	object-fit: contain;
	/* background: var(--surface-soft); */
}

/* Sale flash. */
.product-card .onsale {
	position: absolute;
	top: var(--space-10);
	left: var(--space-10);
	z-index: 1;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: var(--space-3) var(--space-8);
	color: var(--on-primary);
	font-size: var(--text-11-5);
	font-weight: 700;
	line-height: var(--leading-tight);
	background: var(--c-accent);
	border-radius: var(--radius-6);
}

/* Wishlist (visual only until a wishlist backend is wired). */
.product-card__wish {
	position: absolute;
	top: var(--space-8);
	right: var(--space-8);
	z-index: 2;
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	padding: 0;
	color: var(--color-muted);
	background: var(--surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-circle);
	opacity: 0;
	transform: translateY(-4px);
	transition: opacity .15s, transform .15s, color .15s, border-color .15s;
}

.product-card:hover .product-card__wish,
.product-card__wish:focus-visible {
	opacity: 1;
	transform: none;
}

.product-card__wish svg {
	width: 17px;
	height: 17px;
	transition: fill .15s;
}

.product-card__wish:hover {
	color: var(--color-primary);
	border-color: var(--color-primary);
}

.product-card__wish[aria-pressed="true"] {
	color: var(--color-primary);
	border-color: var(--color-primary);
	opacity: 1;
	transform: none;
}

.product-card__wish[aria-pressed="true"] svg {
	fill: var(--color-primary);
}

/* Text block. */
.product-card__code {
	padding: var(--space-14) var(--space-14) 0;
	overflow: hidden;
	color: var(--color-muted);
	font-size: var(--text-11-5);
	white-space: nowrap;
	text-overflow: ellipsis;
}

/*
 * Fixed to exactly 2 lines (clamped + reserved min-height) so every card's
 * title block is the same height regardless of how long the product name is —
 * that's what keeps price/button pinned to the same row across a whole card
 * grid instead of drifting with 1- vs 2-line titles.
 */
.product-card .woocommerce-loop-product__title {
	display: -webkit-box;
	overflow: hidden;
	padding: var(--space-14) var(--space-14) 0;
	margin: 0;
	min-height: calc( var(--text-14) * var(--leading-130) * 2 );
	color: var(--color-text);
	font-family: var(--font-body);
	font-size: var(--text-14);
	font-weight: 600;
	line-height: var(--leading-130);
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

/* When a SKU line is present it owns the body's top padding; tighten the title. */
.product-card__code + .woocommerce-loop-product__title {
	padding-top: var(--space-3);
}

.product-card .price {
	display: flex;
	align-items: baseline;
	gap: var(--space-8);
	padding: var(--space-10) var(--space-14) 0;
	margin: 0;
	color: var(--color-primary);
	font-size: var(--text-17);
	font-weight: 700;
}

.product-card .price del {
	color: var(--color-muted);
	font-size: var(--text-12-5);
	font-weight: 400;
}

.product-card .price ins {
	background: none;
	text-decoration: none;
}

/* Rating (shown only when present). */
.product-card .star-rating {
	margin: var(--space-8) var(--space-14) 0;
	font-size: var(--text-12);
}

/* CTA — WooCommerce add-to-cart / select-options button. */
.product-card .button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-8);
	margin: auto var(--space-14) var(--space-16);
	padding: var(--space-11);
	color: var(--on-primary);
	font-size: var(--text-13-5);
	font-weight: 700;
	background: var(--color-addtocart);
	border: 1.5px solid var(--color-addtocart);
	border-radius: var(--radius-9);
	transition: color .15s, background .15s, border-color .15s;
}

.product-card .button:hover {
	color: var(--on-primary);
	background: var(--color-addtocart-strong);
	border-color: var(--color-addtocart-strong);
}

.product-card .button.loading {
	opacity: .75;
}

/* Cart glyph for the simple/AJAX add-to-cart button (recolours with the text). */
.product-card .add_to_cart_button::before {
	content: "";
	width: 17px;
	height: 17px;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='21' r='1'/%3E%3Ccircle cx='18' cy='21' r='1'/%3E%3Cpath d='M2 3h3l2.4 12.4a2 2 0 0 0 2 1.6h8.8a2 2 0 0 0 2-1.6L23 7H6'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='21' r='1'/%3E%3Ccircle cx='18' cy='21' r='1'/%3E%3Cpath d='M2 3h3l2.4 12.4a2 2 0 0 0 2 1.6h8.8a2 2 0 0 0 2-1.6L23 7H6'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* "View cart" link WooCommerce injects after an AJAX add. */
.product-card .added_to_cart {
	display: block;
	margin: 0 var(--space-14) var(--space-14);
	color: var(--color-primary);
	font-size: var(--text-12-5);
	font-weight: 600;
	text-align: center;
}
