/*
 * Product card (woocommerce/content-product.php) and its grid (woocommerce/loop/loop-start.php).
 *
 * Layout: the grid has no breakpoints. Columns follow the width it is given, so the same
 * component fits the full-width home page, a category page next to its filters and a product
 * page's related products; each card then adapts to its own width with a container query.
 *
 * Specificity: every card rule is scoped under `.lp-card-grid.products .lp-card` (3 classes).
 * That fixed base wins over WooCommerce's loop rules (`.woocommerce ul.products li.product …`)
 * and Elementor's global typography, with no !important. The `products` / `product` classes
 * are kept because JetSmartFilters uses them to find the list and its items.
 */

.lp-card-grid.products {
	--lp-card-min-width: clamp(9.5rem, 30%, 16.25rem);
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(var(--lp-card-min-width), 1fr));
	gap: clamp(0.75rem, 2vw, 1.25rem);
	margin: 0 0 2rem;
	padding: 0;
	list-style: none;
}

/* WooCommerce's clearfix pseudo-elements would otherwise become empty grid cells. */
:is(.woocommerce, .woocommerce-page) .lp-card-grid.products::before,
:is(.woocommerce, .woocommerce-page) .lp-card-grid.products::after {
	content: none;
}

/* Card */

.lp-card-grid.products .lp-card.product {
	container-type: inline-size;
	position: relative;
	display: flex;
	flex-direction: column;
	float: none;
	width: auto;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 1px solid var(--lp-border);
	border-radius: var(--lp-radius);
	background: var(--lp-surface);
	color: var(--lp-text);
	text-align: left;
	transition: border-color 0.2s, box-shadow 0.2s;
}

.lp-card-grid.products .lp-card.product:hover {
	border-color: var(--lp-teal);
	box-shadow: var(--lp-shadow-hover);
}

/* The focus ring surrounds the card, which the stretched title link covers. */
.lp-card-grid.products .lp-card.product:has(.lp-card__link:focus-visible) {
	outline: 2px solid var(--lp-text);
	outline-offset: 2px;
}

/* Media */

.lp-card-grid.products .lp-card .lp-card__media {
	position: relative;
	aspect-ratio: 1;
	padding: 0.75rem;
	background: var(--lp-surface);
}

.lp-card-grid.products .lp-card .lp-card__image {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: contain;
}

.lp-card-grid.products .lp-card .lp-card__badges {
	position: absolute;
	top: 0.5rem;
	left: 0.5rem;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.lp-card-grid.products .lp-card .lp-card__badge {
	margin: 0;
	padding: 0.2rem 0.5rem;
	border-radius: 4px;
	background: var(--lp-text);
	font-family: var(--lp-font-body);
	font-size: 0.7rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--lp-on-teal);
}

.lp-card-grid.products .lp-card .lp-card__badge--sale {
	background: var(--lp-danger);
}

.lp-card-grid.products .lp-card .lp-card__badge--store {
	background: var(--lp-teal-text);
}

/* Body */

.lp-card-grid.products .lp-card .lp-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 0.3rem;
	padding: 0.75rem 1rem 1rem;
	border-top: 1px solid var(--lp-border);
}

.lp-card-grid.products .lp-card .lp-card__brand {
	margin: 0;
	font-family: var(--lp-font-body);
	font-size: 0.7rem;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--lp-muted);
}

.lp-card-grid.products .lp-card .lp-card__title {
	display: -webkit-box;
	margin: 0;
	padding: 0;
	overflow: hidden;
	font-family: var(--lp-font-heading);
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.25;
	letter-spacing: normal;
	text-transform: none;
	color: var(--lp-text);
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
}

.lp-card-grid.products .lp-card .lp-card__link {
	color: inherit;
	text-decoration: none;
}

.lp-card-grid.products .lp-card .lp-card__link:focus-visible {
	outline: none;
}

/* Stretches the title link over the whole card. */
.lp-card-grid.products .lp-card .lp-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

/* Pushed to the bottom so prices and buttons line up across a row of cards. */
.lp-card-grid.products .lp-card .lp-card__footer {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	margin-top: auto;
	padding-top: 0.35rem;
}

/* Price */

.lp-card-grid.products .lp-card .lp-card__price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0 0.4rem;
	font-family: var(--lp-font-body);
	font-size: 1.15rem;
	font-weight: 700;
	line-height: 1.2;
	color: var(--lp-teal-dark);
}

.lp-card-grid.products .lp-card .lp-card__price :is(.amount, ins) {
	background: none;
	font-weight: inherit;
	color: inherit;
	text-decoration: none;
}

.lp-card-grid.products .lp-card .lp-card__price del,
.lp-card-grid.products .lp-card .lp-card__price del .amount {
	font-size: 0.8rem;
	font-weight: 400;
	color: var(--lp-muted);
	opacity: 1;
}

.lp-card-grid.products .lp-card .lp-card__price .lp-price-from {
	flex-basis: 100%;
	font-size: 0.75rem;
	font-weight: 500;
	color: var(--lp-muted);
}

/* Availability */

.lp-card-grid.products .lp-card .lp-card__availability {
	margin: 0;
	font-family: var(--lp-font-body);
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1.3;
	color: var(--lp-success);
}

.lp-card-grid.products .lp-card .lp-card__availability--backorder {
	color: var(--lp-warning);
}

.lp-card-grid.products .lp-card .lp-card__availability--out {
	color: var(--lp-danger);
}

/* Actions: above the stretched link, so the button keeps its own target. */

.lp-card-grid.products .lp-card .lp-card__actions {
	position: relative;
	z-index: 2;
	margin-top: 0.4rem;
}

.lp-card-grid.products .lp-card .lp-card__actions .button {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 0.6rem 0.75rem;
	border: 1px solid var(--lp-teal);
	border-radius: var(--lp-radius);
	background: var(--lp-teal);
	font-family: var(--lp-font-body);
	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	color: var(--lp-on-teal);
	transition: background 0.2s, color 0.2s;
}

.lp-card-grid.products .lp-card .lp-card__actions .button:hover {
	background: var(--lp-teal-dark);
	color: var(--lp-on-teal);
}

/*
 * After an AJAX add to cart, the "View cart" link (css/buttons.css) takes the button's place,
 * so the card keeps a single, explicit next step.
 */
.lp-card-grid.products .lp-card .lp-card__actions .button.added {
	display: none;
}

/* Quote and store-exclusive products only lead to another page: secondary style. */
.lp-card-grid.products .lp-card .lp-card__actions .button:not(.add_to_cart_button) {
	border-color: var(--lp-teal-text);
	background: var(--lp-surface);
	color: var(--lp-teal-text);
}

.lp-card-grid.products .lp-card .lp-card__actions .button:not(.add_to_cart_button):hover {
	background: var(--lp-bg-light);
	color: var(--lp-teal-text);
}

.lp-card-grid.products .lp-card .lp-card__actions .button:focus-visible {
	outline: 2px solid var(--lp-text);
	outline-offset: 2px;
}

/* Narrow cards (two columns on phones). */
@container (max-width: 13rem) {
	.lp-card-grid.products .lp-card .lp-card__media {
		padding: 0.5rem;
	}

	.lp-card-grid.products .lp-card .lp-card__body {
		padding: 0.6rem 0.65rem 0.75rem;
	}

	.lp-card-grid.products .lp-card .lp-card__title {
		font-size: 0.9rem;
	}

	.lp-card-grid.products .lp-card .lp-card__price {
		font-size: 1rem;
	}

	.lp-card-grid.products .lp-card .lp-card__actions :is(.button, .added_to_cart) {
		padding-inline: 0.5rem;
		font-size: 0.8rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.lp-card-grid.products .lp-card.product,
	.lp-card-grid.products .lp-card .lp-card__actions .button {
		transition: none;
	}
}
