/**
 * Product card — redesign V1 (template-parts/components/product-card-v2.php).
 * Values from the approved prototype tests/visual/product-card-redesign-v1.html.
 * Every rule is scoped to .bsmarty-pc so older card styles are not affected.
 */

.bsmarty-pc {
	--card-radius: 10px;
	--image-radius: 7px;
	--media-height: 191px;
	--image-zoom: 117%;

	--bsmarty-pc-purple: #6d28d9;
	--bsmarty-pc-purple-dark: #5b21b6;
	/* Clean palette: dark text on light surfaces, separation by luminance + a hairline border. */
	--bsmarty-pc-ink: #17181c;
	--bsmarty-pc-price: #17181c;
	--bsmarty-pc-muted: #646a73;
	--bsmarty-pc-border: #e5e7eb;
	--bsmarty-pc-border-hover: #d1d5db;
	--bsmarty-pc-image-bg: #fafafb;
	--bsmarty-pc-green: #15803d;
	/* Reserved price-area heights (measured from the labelled sale layouts). */
	--bsmarty-pc-price-h-stacked: 39.4px; /* PRP + price / Nou + price, badge beside row 1 */
	--bsmarty-pc-price-h-above: 33.4px; /* label row + values row, badge centred on both */
	/* Stars: filled 3.2:1 on white (was 2.1:1), empty clearly visible (was 1.2:1). */
	--bsmarty-pc-star: #d97706;
	--bsmarty-pc-star-empty: #cbd5e1;
	--bsmarty-pc-fav-active: #ff7e86;

	/* Containing block + stacking context that the removed backdrop-filter used to create:
	   keeps absolutely positioned parts (e.g. the .sr-only savings label) inside horizontal
	   scroll rows and keeps the card's z-indexes local. No visual effect. */
	position: relative;
	isolation: isolate;
	display: flex;
	flex-direction: column;
	min-width: 0;
	height: 100%;
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	/* Clean surface: white card, hairline border, near-zero shadow (no gradient, no blur, no glow). */
	background: #fff;
	border: 1px solid var(--bsmarty-pc-border);
	border-radius: var(--card-radius);
	box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
	transition: border-color 150ms ease, box-shadow 150ms ease;
	font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
	/* Same base line-height as the prototype (the theme body uses 1.5). */
	line-height: normal;
	text-align: left;
}

/* Hover: very subtle lift of the shadow and border only, no movement. */
@media (hover: hover) {
	.bsmarty-pc:hover {
		border-color: var(--bsmarty-pc-border-hover);
		box-shadow: 0 4px 14px rgba(17, 24, 39, 0.08);
	}
}

.bsmarty-pc *,
.bsmarty-pc *::before,
.bsmarty-pc *::after {
	box-sizing: border-box;
}

/* ---------- Image frame (values of the existing card frame) ---------- */
.bsmarty-pc .bsmarty-pc__mat {
	position: relative;
	/* 18px top: a strip above the image for brand (left) and age (right) with 5px air under them.
	   The image is 4px lower than the 14/8 split; the 4px come from the bottom padding, so the
	   card height and everything below the image stay where they were. */
	padding: 18px 8px 4px;
	overflow: hidden;
	border-radius: calc(var(--card-radius) - 1px) calc(var(--card-radius) - 1px) 0 0;
	background: #fff;
}

.bsmarty-pc .bsmarty-pc__media {
	position: relative;
	height: var(--media-height);
	overflow: hidden;
	/* Transparent border keeps the exact box size of the approved V1 (no layout shift). */
	border: 1px solid transparent;
	border-radius: var(--image-radius);
	background: var(--bsmarty-pc-image-bg);
	box-shadow: none;
}

.bsmarty-pc .bsmarty-pc__media-link {
	position: absolute;
	inset: 0;
	display: block;
}

.bsmarty-pc .bsmarty-pc__image {
	position: absolute;
	inset: 0;
	width: 100%;
	max-width: none;
	height: 100%;
	object-fit: contain;
	scale: var(--image-zoom);
	transform-origin: 50% 50%;
}

.bsmarty-pc .bsmarty-pc__brand,
.bsmarty-pc .bsmarty-pc__age {
	position: absolute;
	/* In the strip above the image (positioned on the frame, not over the photo). */
	top: 3px;
	z-index: 2;
	margin: 0;
	font-size: 10px;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.01em;
	white-space: nowrap;
	pointer-events: none;
}

.bsmarty-pc .bsmarty-pc__brand {
	left: 8px;
	max-width: calc(100% - 70px);
	overflow: hidden;
	text-overflow: ellipsis;
	color: var(--bsmarty-pc-muted);
}

/* Brand colour kept, but darkened (same hue/chroma, OKLCH lightness capped at 0.52) so every
   featured brand reaches at least 4.5:1 on the white frame. Brands without a colour and browsers
   without relative colour syntax use the muted text colour above. */
@supports (color: oklch(from red l c h)) {
	.bsmarty-pc .bsmarty-pc__brand {
		color: oklch(from var(--bsmarty-pc-brand-color, var(--bsmarty-pc-muted)) min(l, 0.52) c h);
	}
}

.bsmarty-pc .bsmarty-pc__age {
	right: 8px;
	color: var(--bsmarty-pc-purple);
}

/* ---------- Favorite + Buy, stacked bottom-right ---------- */
.bsmarty-pc .bsmarty-pc__actions {
	position: absolute;
	right: 3px;
	bottom: 3px;
	z-index: 3;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
}

.bsmarty-pc .bsmarty-pc__icon-btn {
	position: static;
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 9999px;
	background: rgba(255, 255, 255, 0.9);
	box-shadow: none;
	color: var(--bsmarty-pc-purple);
	text-decoration: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

/* Buy = primary CTA: strongest contrast in the card (solid purple, white icon). */
.bsmarty-pc .bsmarty-pc__buy {
	background: var(--bsmarty-pc-purple);
	color: #fff;
}

.bsmarty-pc .bsmarty-pc__icon-btn svg {
	display: block;
	width: 18px;
	height: 18px;
	transform-origin: 50% 50%;
}

.bsmarty-pc .bsmarty-pc__icon-btn:hover,
.bsmarty-pc .bsmarty-pc__icon-btn:focus-visible,
.bsmarty-pc .bsmarty-pc__icon-btn:active {
	background: var(--bsmarty-pc-purple);
	color: #fff;
	outline: none;
}

.bsmarty-pc .bsmarty-pc__buy:hover,
.bsmarty-pc .bsmarty-pc__buy:focus-visible,
.bsmarty-pc .bsmarty-pc__buy:active {
	background: var(--bsmarty-pc-purple-dark);
}

/* Keyboard focus is distinct from hover: an inner white ring + a 2px purple outer ring
   (fits inside the 3px gap to the image edge, which clips anything larger). */
.bsmarty-pc .bsmarty-pc__icon-btn:focus-visible {
	box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--bsmarty-pc-purple);
}

/* Favorite active: existing behaviour (filled heart #ff7e86). */
.bsmarty-pc .bsmarty-pc__fav.is-active,
.bsmarty-pc .bsmarty-pc__fav[aria-pressed="true"] {
	color: var(--bsmarty-pc-fav-active);
}

.bsmarty-pc .bsmarty-pc__fav.is-active svg path,
.bsmarty-pc .bsmarty-pc__fav[aria-pressed="true"] svg path {
	fill: currentColor;
}

.bsmarty-pc .bsmarty-pc__fav.is-active:hover,
.bsmarty-pc .bsmarty-pc__fav.is-active:focus-visible,
.bsmarty-pc .bsmarty-pc__fav.is-active:active,
.bsmarty-pc .bsmarty-pc__fav[aria-pressed="true"]:hover,
.bsmarty-pc .bsmarty-pc__fav[aria-pressed="true"]:focus-visible,
.bsmarty-pc .bsmarty-pc__fav[aria-pressed="true"]:active {
	color: #fff;
}

.bsmarty-pc .bsmarty-pc__buy.is-disabled,
.bsmarty-pc .bsmarty-pc__buy[disabled] {
	opacity: 0.45;
	cursor: not-allowed;
}

.bsmarty-pc .bsmarty-pc__buy.is-disabled:hover,
.bsmarty-pc .bsmarty-pc__buy[disabled]:hover {
	background: var(--bsmarty-pc-purple);
	color: #fff;
}

/* WooCommerce inserts a "View cart" link after an AJAX add; the header cart already reflects it. */
.bsmarty-pc .bsmarty-pc__actions .added_to_cart {
	display: none !important;
}

/* ---------- Body ---------- */
.bsmarty-pc .bsmarty-pc__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 6px;
	padding: 8px 8px 7px;
	/* The price-label layout below follows the card's own width (container queries). */
	container: bsmarty-pc-body / inline-size;
}

.bsmarty-pc .bsmarty-pc__title {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	min-height: calc(2 * 1.35em);
	margin: 0;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.35;
	color: var(--bsmarty-pc-ink);
	text-decoration: none;
	overflow-wrap: anywhere;
}

.bsmarty-pc .bsmarty-pc__title:hover {
	color: var(--bsmarty-pc-purple);
}

/* Prices: one row when it fits; savings wraps to row 2 (right-aligned) otherwise. */
.bsmarty-pc .bsmarty-pc__price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: 5px;
	row-gap: 1px;
	min-height: 22px;
	font-family: Jost, Inter, sans-serif;
	font-weight: 400;
	white-space: nowrap;
}

.bsmarty-pc .bsmarty-pc__price .woocommerce-Price-amount,
.bsmarty-pc .bsmarty-pc__price bdi {
	font: inherit;
	color: inherit;
}

.bsmarty-pc .bsmarty-pc__old {
	font-size: 11px;
	color: var(--bsmarty-pc-muted);
	text-decoration: line-through;
	text-decoration-thickness: 1px;
	text-decoration-color: currentColor;
}

.bsmarty-pc .bsmarty-pc__now {
	font-size: 17px;
	line-height: 1.2;
	color: var(--bsmarty-pc-price);
	letter-spacing: 0.005em;
}

/* Price labels + discount badge (sale products only): "PRP" with the struck price, "Nou" with
   the current price, a green price tag with "%" on the right. The layout follows the card's
   own width (container queries on the card body):
   - stacked (default):  PRP + struck price / Nou + current price, badge right of row 1;
   - above   (wide enough): PRP and Nou above their prices, badge right, centred on both rows.
   Thresholds below come from the measured widest prices (see the badge release notes). */
.bsmarty-pc .bsmarty-pc__label {
	font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 10px;
	font-weight: 500;
	line-height: 1.2;
	letter-spacing: 0.02em;
	color: var(--bsmarty-pc-muted);
}

.bsmarty-pc .bsmarty-pc__label--old {
	grid-area: lo;
}

.bsmarty-pc .bsmarty-pc__label--now {
	grid-area: ln;
	color: var(--bsmarty-pc-purple); /* theme purple, 7.1:1 on white */
}

.bsmarty-pc .bsmarty-pc__deal {
	display: block;
	grid-area: deal;
	align-self: center; /* an icon has no text baseline */
	justify-self: end;
	line-height: 0;
	color: var(--bsmarty-pc-green);
	translate: 0 4px; /* 4px lower, visual only (no layout change) */
}

.bsmarty-pc .bsmarty-pc__deal svg {
	display: block;
	width: 27px;
	height: 18px;
}

.bsmarty-pc .bsmarty-pc__price.has-labels {
	display: grid;
	grid-template-columns: auto auto minmax(0, 1fr);
	grid-template-areas:
		"lo old deal"
		"ln now now";
	align-items: baseline;
}

.bsmarty-pc .bsmarty-pc__price.has-labels .bsmarty-pc__old {
	grid-area: old;
}

.bsmarty-pc .bsmarty-pc__price.has-labels .bsmarty-pc__now {
	grid-area: now;
}

/* Widest prices measured (clean card, 11/17px Jost): labels-above needs 162.2px for 3-digit prices
   and 183.1px for 4-digit ones; the stacked layout needs 115.4px. */
@container bsmarty-pc-body (min-width: 164px) {
	.bsmarty-pc .bsmarty-pc__price.has-labels:not(.has-long-price) {
		grid-template-areas:
			"lo ln deal"
			"old now deal";
	}
}

@container bsmarty-pc-body (min-width: 185px) {
	.bsmarty-pc .bsmarty-pc__price.has-labels.has-long-price {
		grid-template-areas:
			"lo ln deal"
			"old now deal";
	}
}

/* ---------- hAIo | stars ---------- */
.bsmarty-pc .bsmarty-pc__meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 4px;
	min-height: 16px;
	margin-top: auto;
	/* The theme's inherited line-height (1.5 → 24px) would make this row 24px instead of 16px. */
	line-height: 1;
}

.bsmarty-pc .bsmarty-eval-card-action {
	display: flex;
	align-items: center;
	width: auto;
	min-width: 0;
	margin: 0;
}

.bsmarty-pc .bsmarty-eval-compact-btn {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
	font: inherit;
	font-size: 11px;
	line-height: 1;
	color: var(--bsmarty-pc-purple);
	cursor: pointer;
}

.bsmarty-pc .bsmarty-eval-compact-btn svg {
	flex: none;
	width: 13px;
	height: 13px;
}

.bsmarty-pc .bsmarty-eval-compact-btn__label {
	font-weight: 600;
}

.bsmarty-pc .bsmarty-eval-compact-btn:focus-visible {
	outline: 2px solid var(--bsmarty-pc-purple);
	outline-offset: 2px;
	border-radius: 3px;
}

.bsmarty-pc .bsmarty-eval-compact-btn.is-disabled {
	color: var(--bsmarty-pc-muted);
	cursor: not-allowed;
}

.bsmarty-pc .bsmarty-pc__sep {
	flex: none;
	width: 1px;
	height: 12px;
	background: var(--bsmarty-pc-border);
}

.bsmarty-pc .bsmarty-pc__stars {
	display: inline-flex;
	flex: none;
	gap: 0.1rem;
}

.bsmarty-pc .bsmarty-pc__star {
	font-size: 13px;
	line-height: 1;
	color: var(--bsmarty-pc-star-empty);
}

.bsmarty-pc .bsmarty-pc__star.is-filled {
	color: var(--bsmarty-pc-star);
}

.bsmarty-pc .bsmarty-pc__rating-value {
	align-self: center;
	margin-left: 0.2rem;
	font-size: 0.75rem;
	line-height: 1;
	color: var(--bsmarty-pc-muted);
}

@media (max-width: 374px) {
	.bsmarty-pc .bsmarty-pc__stars {
		gap: 0;
	}
}

/* Same price-area height on every card of the same width (sale and non-sale), sized to the
   labelled sale layout of that width, so cards stay equally tall. */
.bsmarty-pc .bsmarty-pc__price {
	align-content: start;
	min-height: var(--bsmarty-pc-price-h-stacked);
}

/* From 185px every sale card (4-digit prices included) uses the labels-above layout. */
@container bsmarty-pc-body (min-width: 185px) {
	.bsmarty-pc .bsmarty-pc__price {
		min-height: var(--bsmarty-pc-price-h-above);
	}
}

@media (min-width: 1024px) {
	.bsmarty-pc .bsmarty-pc__body {
		padding: 9px 8px 8px;
	}
}
