/*
 * RahkarTheme — shared product card stylesheet.
 *
 * One file, one look, one source of truth. Loaded only on pages whose
 * markup contains a block that registered this style as a dependency
 * (see rahkar_product_card_register_style() in inc/product-card.php).
 *
 * Class prefix `.rpc-*` is intentionally block-agnostic — the same card
 * can sit inside an archive grid, a horizontal slider, a single-product
 * "related" rail, or any future container.
 */

.rpc-card {
	margin: 0;
	background: var(--wp--preset--color--base, #fff);
	border: 1px solid var(--wp--preset--color--border, #e2e4e9);
	border-radius: var(--rpc-radius, 12px);
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
	min-width: 0;
}
.rpc-card:hover {
	box-shadow: var(--wp--preset--shadow--md, 0 8px 24px rgba(0,0,0,.08));
	transform: translateY(-2px);
}

.rpc-card__link {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 10px;
	color: inherit;
	text-decoration: none;
	height: 100%;
}
.rpc-card__link:hover { text-decoration: none; }

/* Media slot — aspect-ratio reserves space so the card doesn't reflow
   when the image loads. Zero CLS on first paint. */
.rpc-card__media {
	display: block;
	position: relative;
	aspect-ratio: 1 / 1;
	background: var(--wp--preset--color--surface, #f7f7f8);
	border-radius: calc(var(--rpc-radius, 12px) - 4px);
	overflow: hidden;
}
.rpc-card__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ─── Top-corner badges ─────────────────────────────────────────────── */
.rpc-card__badges {
	position: absolute;
	top: 8px;
	inset-inline-start: 8px;
	display: flex;
	gap: 4px;
	z-index: 1;
}
.rpc-badge {
	display: inline-flex;
	align-items: center;
	height: 22px;
	padding-inline: 8px;
	font-size: 0.75rem;
	font-weight: 600;
	border-radius: 6px;
	color: #fff;
}
.rpc-badge--new { background: var(--wp--preset--color--success, #198754); }
/* OOS badge: neutral muted dark — signals "inactive" without screaming red
   (red is reserved for the accent role, not catalog status). Sits over the
   image so the contrast stays readable on both dark and light photos. */
.rpc-badge--oos {
	background: rgba(26, 29, 35, 0.78);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
}

/* ─── Out-of-stock card state ──────────────────────────────────────────
   Subtle desaturation + opacity on the image and a muted title color so
   the shopper's eye registers "unavailable" before reading. The price,
   the corner badge, and the swatches stay at full strength: the price
   so the shopper knows what they'd be paying, the badge because that's
   the load-bearing signal, the swatches because color choice is still
   useful info ("would have been available in 3 colors"). */
.rpc-card--oos .rpc-card__img {
	filter: grayscale(0.6);
	opacity: 0.62;
	transition: filter 0.2s ease, opacity 0.2s ease;
}
.rpc-card--oos .rpc-card__title {
	color: var(--wp--preset--color--text-muted, #5b6271);
}
/* Restore the image on hover — shopper is actively interested; reward
   the intent by showing the product in full color. */
.rpc-card--oos:hover .rpc-card__img {
	filter: grayscale(0);
	opacity: 0.88;
}

/* ─── Color swatches row (overlaid on image, bottom-left) ────────────
   Absolutely positioned inside .rpc-card__media so the swatches sit on
   top of the product photo at the visually-bottom-left corner. On RTL
   pages, "bottom-left" maps to inset-inline-end (inline-end = left in
   RTL). A translucent pill background keeps the dots readable against
   both light and dark imagery. Forced LTR keeps "dots → +N" stable. */
.rpc-card__swatches {
	position: absolute;
	bottom: 8px;
	inset-inline-end: 8px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	direction: ltr;
	padding: 4px 6px;
	background: rgba(255, 255, 255, 0.85);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	border-radius: 9999px;
	z-index: 1;
}
.rpc-swatch-dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.10);
	display: inline-block;
	flex-shrink: 0;
}
.rpc-swatch-more {
	display: inline-flex;
	align-items: center;
	height: 14px;
	padding: 0 5px;
	margin-inline-start: 2px;
	font-size: 0.6875rem;
	font-weight: 700;
	color: var(--wp--preset--color--text-muted, #5b6271);
	background: var(--wp--preset--color--surface, #f7f7f8);
	border-radius: 9999px;
	line-height: 1;
}

/* ─── Title ──────────────────────────────────────────────────────────
   Clamps to 2 lines and reserves the 2-line height so single-line titles
   don't make the card jump. */
.rpc-card__title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 0.9rem;
	font-weight: 500;
	line-height: 1.5;
	min-height: 2.85em;
	color: var(--wp--preset--color--text, #1a1d23);
}

/* ─── Price row ──────────────────────────────────────────────────────
   The price stack is right-aligned. On a sale, the struck regular sits on
   top and the discounted price + % badge share the row below, so the badge
   always hugs the discounted price and can't overlap the struck one on
   narrow cards. (The stack is now the only child; row-reverse +
   space-between keeps it pinned to the right edge as before.) */
.rpc-card__price {
	display: flex;
	flex-direction: row-reverse;
	align-items: flex-end;
	justify-content: space-between;
	gap: 6px;
	padding-bottom: 0;
}
.rpc-price-stack {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: flex-end;
	gap: 2px;
	min-width: 0;
	min-height: 2.4em;
}
/* Top row: struck regular price + % badge. The price area is forced LTR
   (see .rpc-card__price), so a normal row puts the struck price first and
   the badge at the right edge — the badge leads on the right, above the
   right-aligned discounted price. */
.rpc-price-row {
	display: flex;
	align-items: center;
	flex-wrap: nowrap;
	gap: 6px;
	white-space: nowrap;
	flex-direction: row-reverse;
}
.rpc-price-original {
	color: var(--wp--preset--color--text-muted, #5b6271);
	font-size: 0.75rem;
	font-weight: 400;
	text-decoration: line-through;
	line-height: 1.2;
}
.rpc-price-current,
.rpc-price-default {
	color: var(--wp--preset--color--contrast, #0f1115);
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.25;
}
.rpc-price-stack .woocommerce-Price-amount,
.rpc-price-stack bdi {
	font-size: inherit;
	font-weight: inherit;
	color: inherit;
}

.rpc-pct-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 22px;
	padding-inline: 8px;
	border-radius: 9999px;
	background: var(--wp--preset--color--primary, #0a66c2);
	color: #fff;
	font-size: 0.7rem;
	font-weight: 700;
	line-height: 1;
	flex-shrink: 0;
}

/* Mobile: edge-to-edge image, tighter type, smaller swatches. */
@media (max-width: 768px) {
	.rpc-card__link  { padding: 0; gap: 4px; }
	.rpc-card__media { border-radius: 0; }
	.rpc-card__title {
		font-size: 0.8rem;
		padding-inline: 8px;
		min-height: 2.4em;
	}
	.rpc-card__price {
		padding-inline: 8px;
		padding-bottom: 8px;
	}
	.rpc-price-original { font-size: 0.7rem; }
	.rpc-price-current,
	.rpc-price-default { font-size: 0.85rem; }
	.rpc-pct-badge { min-width: 32px; height: 20px; padding-inline: 6px; font-size: 0.65rem; }
	.rpc-badge { height: 18px; padding-inline: 6px; font-size: 0.65rem; border-radius: 4px; }
	.rpc-card__badges { top: 6px; inset-inline-start: 6px; }
	.rpc-card__swatches { gap: 3px; padding: 2px 4px; }
	.rpc-swatch-dot { width: 8px; height: 8px; }
	.rpc-swatch-more { font-size: 0.6rem; height: 12px; padding: 0 3px; }
}
@media (hover: none) {
	.rpc-card:hover { transform: none; box-shadow: none; }
}
