/**
 * Product card — woocommerce/content-product.php
 *
 * WooCommerce loads that template for every product loop, so this file styles
 * the card everywhere: homepage grids, shop, category, related and upsells. It
 * also carries the loop container (`ul.products`), because the card only makes
 * sense as a cell of that grid.
 *
 * Mobile-first: two columns below 1024px, never one — a single-column product
 * grid reads as broken on a shop. Below 768px the card takes the responsive
 * mockup's compact internals (its `g2` card); the desktop values come back
 * from --breakpoint-md.
 *
 * @package Printmania
 */

/* =========================================================================
 * Loop container
 * ====================================================================== */

ul.products {
	display: grid;
	grid-template-columns: repeat( 2, 1fr );
	gap: var( --space-10 );
	margin: 0;
	padding: 0;
	list-style: none;
}

ul.products::before,
ul.products::after {
	content: none;
}

/* =========================================================================
 * Card
 * ====================================================================== */

.product-card {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var( --space-5 );
	padding: var( --space-14 );
	border: var( --border-width ) solid var( --color-border );
	border-radius: var( --radius-card );
	background-color: var( --surface );
	text-align: center;
	transition: var( --transition-base );
}

.product-card:hover,
.product-card:focus-within {
	box-shadow: var( --shadow-6 );
	transform: translateY( var( --lift-card ) );
}

/* The whole card above the button is one link — opened and closed by the
   WooCommerce loop hooks, so it is styled by WooCommerce's own class. */
/* Below 768px the link grows so the price can sit at its bottom (the mockup's
   `pprice { margin-top: auto }`); on desktop the button takes that slack. */
.product-card .woocommerce-loop-product__link {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	align-items: center;
	gap: var( --space-5 );
	width: 100%;
	color: inherit;
}

/* --- Badges ------------------------------------------------------------ */

.product-card__badges {
	position: absolute;
	top: var( --space-14 );
	left: var( --space-14 );
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var( --space-5 );
}

.product-card__badges:empty {
	display: none;
}

.product-card__badge {
	display: inline-flex;
	align-items: center;
	gap: var( --space-5 );
	border-radius: var( --radius-pill );
	font-size: var( --text-xs );
	line-height: var( --lh-snug );
	white-space: nowrap;
}

.product-card__badge-icon {
	flex-shrink: 0;
}

.product-card__badge--shipping {
	padding: var( --space-3 ) var( --space-8 );
	background-color: var( --color-secondary );
	font-size: var( --text-badge-sm );
	font-weight: var( --fw-bold );
	letter-spacing: var( --ls-badge-sm );
	text-transform: uppercase;
	color: var( --color-text-invert );
}

.product-card__badge--shipping .product-card__badge-icon {
	display: none;
}

/* `onsale` is WooCommerce's own class; the BEM class carries the styling.
   The doubled selector outranks woocommerce.css `.woocommerce span.onsale`
   (olive circle pushed out of the card's corner). */
.product-card__badge--sale,
.woocommerce span.onsale.product-card__badge--sale {
	position: static;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: var( --space-5 ) var( --space-11 );
	border-radius: var( --radius-pill );
	background-color: var( --color-accent );
	font-size: var( --text-xs );
	font-weight: var( --fw-black );
	line-height: var( --lh-snug );
	text-align: left;
	color: var( --color-text );
}

.product-card__badge--new {
	padding: var( --space-3 ) var( --space-10 );
	background-color: var( --c-blue-600 );
	font-weight: var( --fw-bold );
	letter-spacing: var( --ls-wide );
	text-transform: uppercase;
	color: var( --color-text-invert );
}

/* --- Media ------------------------------------------------------------- */

.product-card__media {
	display: grid;
	place-items: center;
	width: 74%;
	aspect-ratio: 1 / 1;
	margin: var( --space-4 ) 0 var( --space-2 );
	overflow: hidden;
	border-radius: var( --radius-xl );
	background-color: var( --surface-sunken );
}

/* The panel owns the geometry, the photo never does: WooCommerce thumbnails
   come in mixed ratios, so a tall image is letterboxed inside the square
   instead of stretching the panel or being cropped by its overflow.
   `min-width/min-height: 0` clears the automatic minimum size of a grid item,
   without which the row track grows to the image's intrinsic height and
   `max-height: 100%` then resolves against that grown track. The
   `.woocommerce` prefix outranks `woocommerce-general.css`, which forces
   `height: auto` on loop images. That same prefixed selector also clears the
   `margin: 0 0 1em` set by `.woocommerce ul.products li.product a img`, which
   otherwise pushes the photo up inside the panel and leaves a grey band along
   its bottom edge. */
.product-card__media img,
.woocommerce ul.products li.product.product-card .product-card__media img {
	min-width: 0;
	max-width: 100%;
	min-height: 0;
	max-height: 100%;
	width: auto;
	height: auto;
	margin: 0;
	object-fit: contain;
}

/* --- Text -------------------------------------------------------------- */

/* Below 768px the line is plain centred text with the delivery note on a
   line of its own; desktop sets mark and label side by side. */
.product-card__stock {
	display: block;
	align-items: center;
	gap: var( --space-4 );
	font-size: var( --text-xs );
	font-weight: var( --fw-bold );
	line-height: var( --lh-body );
}

.product-card__stock-note {
	display: block;
}

.product-card__stock--in {
	color: var( --color-success );
}

.product-card__stock--restock {
	color: var( --color-tertiary );
}

.product-card__stock--out {
	color: var( --color-text-meta );
}

.product-card__stock--restock .product-card__stock-mark,
.product-card__stock--out .product-card__stock-mark {
	display: none;
}

/* The design gives the title exactly two lines and reserves their height, so
   a short and a long product name produce identically tall cards. Real
   WooCommerce names are longer than the mockup's, hence the clamp. */
.product-card .woocommerce-loop-product__title {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	min-height: var( --space-40 );
	max-height: var( --space-40 );
	margin: 0;
	overflow: hidden;
	font-size: var( --text-base );
	font-weight: var( --fw-bold );
	line-height: var( --lh-snug );
	letter-spacing: var( --ls-body );
	color: var( --color-text );
}

.product-card__chip {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 1px;
	padding: var( --space-6 ) var( --space-14 );
	border-radius: var( --radius-xl );
	background-color: var( --surface-chip );
	font-size: var( --text-xs );
	line-height: var( --lh-snug );
	text-align: center;
	color: var( --color-text-muted );
}

.product-card__chip-value {
	color: var( --color-text );
	text-transform: capitalize;
}

.product-card__spec {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	min-height: calc( 2 * var( --lh-normal ) * 1em );
	overflow: hidden;
	font-size: var( --text-xs );
	line-height: var( --lh-normal );
	color: var( --color-text-meta );
}

/* --- Price ------------------------------------------------------------- */

/* Below 768px `.price` dissolves (`display: contents`) so the struck price
   takes a row of its own and the amount sits beside "s DPH". */
.product-card__pricing {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: center;
	gap: 0 var( --space-5 );
	margin-top: auto;
}

.product-card__pricing .price {
	display: contents;
	flex-wrap: wrap;
	align-items: baseline;
	gap: var( --space-8 );
	margin: 0;
	font-size: var( --text-price-sm );
	font-weight: var( --fw-black );
	line-height: var( --lh-body );
	letter-spacing: var( --ls-tight );
	color: var( --color-text );
}

.product-card__pricing del {
	flex-basis: 100%;
	font-size: var( --text-sm );
	font-weight: var( --fw-regular );
	letter-spacing: var( --ls-body );
	color: var( --color-text-strike );
	text-decoration: line-through;
	opacity: 1;
}

.product-card__pricing ins {
	background: none;
	color: var( --color-primary );
	text-decoration: none;
}

/* Either the theme's own note, or WooCommerce's configured price suffix. */
.product-card__vat,
.product-card__pricing .woocommerce-price-suffix {
	font-size: var( --text-xs );
	font-weight: var( --fw-regular );
	letter-spacing: var( --ls-body );
	color: var( --color-text-meta );
}

/* The design's card shows no star rating; the hook still fires for plugins. */
.product-card__pricing .star-rating,
.product-card__pricing .woocommerce-product-rating {
	display: none;
}

/* --- Add to cart ------------------------------------------------------- */

/* The conversion CTA. The page-level CTAs in pages/home.css use the same
   --gradient-cta-* tokens; extract both once the theme grows a button layer. */
.product-card__cart {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var( --space-9 );
	width: 100%;
	min-height: 44px;
	height: var( --control-height-sm );
	/* Below 768px the price is pinned down instead (see the link above). */
	margin-top: var( --space-6 );
	padding-inline: var( --space-10 );
	border: 0;
	border-radius: var( --radius-control );
	background-image: var( --gradient-cta );
	background-repeat: var( --gradient-cta-repeat );
	background-size: var( --gradient-cta-size );
	background-position: var( --gradient-cta-position );
	box-shadow: var( --shadow-inset-cta );
	font-family: inherit;
	font-size: var( --text-md );
	font-weight: var( --fw-bold );
	line-height: var( --lh-none );
	color: var( --color-text-invert );
	white-space: nowrap;
	text-decoration: none;
	cursor: pointer;
	transition: background-position var( --duration-wipe ) var( --ease-cta );
}

.product-card__cart:hover,
.product-card__cart:focus-visible {
	background-position: var( --gradient-cta-position-hover );
	box-shadow: var( --shadow-2 );
	filter: saturate( 1.25 ) brightness( 1.1 );
	color: var( --color-text-invert );
}

.product-card__cart-icon {
	display: none;
	flex-shrink: 0;
}

.product-card__cart.loading,
.product-card__cart.added {
	opacity: 0.7;
}

/* WooCommerce prints an "added to cart" link after the button. */
.product-card .added_to_cart {
	font-size: var( --text-xs );
	font-weight: var( --fw-bold );
	color: var( --color-primary );
}

/* =========================================================================
 * Foreign stylesheet overrides — WooCommerce pages only
 *
 * The homepage renders this card 1:1 because none of the stylesheets below
 * match there. Every WooCommerce page (`body.woocommerce`: shop, category,
 * related, upsells) additionally loads `woocommerce.css` /
 * `woocommerce-layout.css` and the site-wide
 * `uploads/scorg/css/165-header-compiled.css`, whose descendant selectors
 * out-specify the single-class BEM rules above — and 165 also loads *after*
 * the theme, so a specificity tie loses too.
 *
 * Nothing here is a new design value: each rule restates a value already
 * declared above, at a specificity that wins. The `.woocommerce ul.products
 * li.product.product-card` prefix is (0,4,2) on its own and (0,5,2)+ with a
 * child class, above the strongest foreign selector in play,
 * `.woocommerce ul.products li.product .price` (0,4,2). The prefix also keeps
 * every rule off the homepage grid, which needs none of them.
 * ====================================================================== */

/* `woocommerce-layout.css` floats loop items and gives them a percentage
   width, which breaks the grid. */
.woocommerce ul.products li.product.product-card {
	float: none;
	width: auto;
	margin: 0;
	padding: var( --space-14 );
	clear: none;
	text-align: center;
}

/* woocommerce.css `.woocommerce ul.products li.product a.woocommerce-loop-product__link`
   (0,4,3) forces `display: block`, which drops the card's column flex — and
   with it the --space-9 rhythm and the centred media panel. Only `display` is
   contested; the rest of the rule above still applies. */
.woocommerce ul.products li.product.product-card .woocommerce-loop-product__link {
	display: flex;
}

/* woocommerce.css `.woocommerce ul.products li.product .woocommerce-loop-product__title`
   (0,4,2) adds `padding: .5em 0` and `font-size: 1em`. */
.woocommerce ul.products li.product.product-card .woocommerce-loop-product__title {
	padding: 0;
	font-size: var( --text-base );
}

/* woocommerce.css `.woocommerce ul.products li.product .price` (0,4,2) shrinks
   and un-bolds the price and adds a bottom margin;
   `.woocommerce:where( body:not( .woocommerce-uses-block-theme ) ) ul.products li.product .price`
   (0,4,2 — `:where()` contributes nothing) repaints it olive-yellow. */
.woocommerce ul.products li.product.product-card .product-card__pricing .price {
	display: contents;
	margin: 0;
	font-size: var( --text-price-sm );
	font-weight: var( --fw-black );
	line-height: var( --lh-body );
	color: var( --color-text );
}

/* woocommerce.css `.woocommerce ul.products li.product .price del` (0,5,2)
   forces `color: inherit` and `opacity: .7`; the `ins` twin (0,5,2) forces
   `font-weight: 700`. */
.woocommerce ul.products li.product.product-card .product-card__pricing del {
	color: var( --color-text-strike );
	opacity: 1;
}

.woocommerce ul.products li.product.product-card .product-card__pricing ins {
	font-weight: var( --fw-black );
}

/* woocommerce.css `.woocommerce .products .star-rating` (0,3,0) shows the
   rating the design's card does not carry. */
.woocommerce ul.products li.product.product-card .product-card__pricing .star-rating,
.woocommerce ul.products li.product.product-card .product-card__pricing .woocommerce-product-rating {
	display: none;
}

/* The CTA is out-specified three times over:
   - woocommerce.css `.woocommerce:where( body:not( … ) ) a.button` (0,2,1) —
     a grey fill and grey text with no background image, an inline-block box,
     its own em padding, corner radius and font size, and no box shadow;
   - 165-header-compiled.css `.woocommerce a.button` (0,2,1) — uppercase text,
     a dark grey gradient background with its own position and size, wide
     tracking, and again its own padding, radius and font size;
   - woocommerce.css `.woocommerce ul.products li.product .button` (0,4,2) —
     `display: inline-block` and `margin-top: 1em`, which unpins the button
     from the bottom of the card.
   `background-color` and `letter-spacing` are stated for the first time here:
   the card never had to declare them while nothing set them. */
.woocommerce ul.products li.product.product-card .product-card__cart {
	display: flex;
	margin-top: var( --space-6 );
	padding-block: 0;
	padding-inline: var( --space-10 );
	border-radius: var( --radius-control );
	background-color: transparent;
	background-image: var( --gradient-cta );
	background-repeat: var( --gradient-cta-repeat );
	background-size: var( --gradient-cta-size );
	background-position: var( --gradient-cta-position );
	box-shadow: var( --shadow-inset-cta );
	font-size: var( --text-md );
	line-height: var( --lh-none );
	letter-spacing: inherit;
	color: var( --color-text-invert );
	text-transform: none;
	transition: background-position var( --duration-wipe ) var( --ease-cta );
}

/* woocommerce.css `… a.button:hover` (0,2,2) repaints the hover grey and kills
   the gradient; 165-header-compiled.css `.woocommerce a.button:hover` (0,2,2)
   wipes its own background to `0%`. */
.woocommerce ul.products li.product.product-card .product-card__cart:hover,
.woocommerce ul.products li.product.product-card .product-card__cart:focus-visible {
	background-color: transparent;
	background-image: var( --gradient-cta );
	background-position: var( --gradient-cta-position-hover );
	box-shadow: var( --shadow-2 );
	color: var( --color-text-invert );
}

/* =========================================================================
 * >= 768px (--breakpoint-md) — the desktop card internals
 * ====================================================================== */

@media ( min-width: 768px ) {

	ul.products {
		gap: var( --gap-card );
	}

	.product-card {
		gap: var( --space-9 );
		padding: var( --space-18 );
	}

	.product-card .woocommerce-loop-product__link {
		flex: 0 0 auto;
		gap: var( --space-9 );
	}

	.product-card__badge--shipping {
		padding: var( --space-3 ) var( --space-9 );
		font-size: var( --text-xs );
		letter-spacing: var( --ls-wide );
	}

	.product-card__badge--shipping .product-card__badge-icon {
		display: block;
	}

	.product-card__media {
		width: 62%;
	}

	.product-card__stock {
		display: flex;
		line-height: var( --lh-snug );
	}

	.product-card__stock-note {
		display: inline;
	}

	.product-card__chip {
		flex-direction: row;
		gap: var( --space-6 );
		padding: var( --space-4 ) var( --space-12 );
		border-radius: var( --radius-pill );
		line-height: var( --lh-snug );
		text-align: center;
	}

	.product-card__spec {
		display: block;
		-webkit-line-clamp: none;
		line-clamp: none;
		min-height: var( --space-32 );
		overflow: visible;
	}

	.product-card__pricing {
		gap: var( --space-8 );
		margin-top: 0;
	}

	.product-card__pricing .price,
	.woocommerce ul.products li.product.product-card .product-card__pricing .price {
		display: inline-flex;
		font-size: var( --text-5xl );
		line-height: var( --lh-none );
	}

	.product-card__pricing del {
		flex-basis: auto;
	}

	.product-card__cart,
	.woocommerce ul.products li.product.product-card .product-card__cart {
		/* Real catalogue titles run to three lines where the mockup's ran to two.
		   `auto` pins the button to the bottom so a row of cards stays aligned. */
		margin-top: auto;
		padding-inline: var( --space-14 );
		font-size: var( --text-sm-5 );
		white-space: normal;
	}

	.product-card__cart-icon {
		display: block;
	}

	.woocommerce ul.products li.product.product-card {
		padding: var( --space-18 );
	}
}

/* =========================================================================
 * >= 1024px (--breakpoint-lg) — the mockup's four-up grid
 * ====================================================================== */

@media ( min-width: 1024px ) {

	ul.products.columns-3 {
		grid-template-columns: repeat( 3, 1fr );
	}

	ul.products.columns-4 {
		grid-template-columns: repeat( 4, 1fr );
	}

	ul.products.columns-5 {
		grid-template-columns: repeat( 5, 1fr );
	}
}
