/*
 * 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;
	display: flex;
	flex-direction: column;
	background: var(--wp--preset--color--base, #fff);
	border: 1px solid var(--wp--preset--color--border, #e2e4e9);
	border-radius: var(--rpc-radius, var(--wp--custom--radius--lg, 12px));
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
	min-width: 0;
}
.rpc-card:hover {
	box-shadow: 0 20px 38px -22px rgba(23, 63, 115, 0.4);
	transform: translateY(-4px);
}

.rpc-card__link {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 10px;
	color: inherit;
	text-decoration: none;
	flex: 1;
}
.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.
   The sweeping shimmer signals "loading" without any JS. Once the image
   arrives it covers the background entirely, so the animation stops
   mattering visually; :has(.img--loaded) silences it for good measure. */
.rpc-card__media {
	display: block;
	position: relative;
	aspect-ratio: 1 / 1;
	background: linear-gradient(
		90deg,
		var(--wp--preset--color--surface, #f7f7f8) 25%,
		rgba(255,255,255,.65) 50%,
		var(--wp--preset--color--surface, #f7f7f8) 75%
	);
	background-size: 300% 100%;
	animation: rpc-shimmer 1.6s ease-in-out infinite;
	border-radius: calc(var(--rpc-radius, var(--wp--custom--radius--lg, 12px)) - 4px);
	overflow: hidden;
}
.rpc-card__media:has(.img--loaded) {
	animation: none;
	background: var(--wp--preset--color--surface, #f7f7f8);
}
@keyframes rpc-shimmer {
	0%   { background-position: 100% 0; }
	100% { background-position: -100% 0; }
}
.rpc-card__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
/* JS (images.php) adds .img--loaded only on images that were still
   downloading when the script ran — cached/fast images are already visible
   and skip the animation so there is no flash. */
.rpc-card__img.img--loaded {
	animation: rpc-img-fade .25s ease;
}
@keyframes rpc-img-fade {
	from { opacity: 0; }
}

/* ─── 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: var(--wp--custom--fw--strong);
	border-radius: var(--wp--custom--radius--sm);
	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: var(--wp--custom--radius--pill);
	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: var(--wp--custom--fw--strong);
	color: var(--wp--preset--color--text-muted, #5b6271);
	background: var(--wp--preset--color--surface, #f7f7f8);
	border-radius: var(--wp--custom--radius--pill);
	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: var(--wp--custom--fw--base);
	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: var(--wp--custom--fw--base);
	text-decoration: line-through;
	line-height: 1.2;
}
.rpc-price-current,
.rpc-price-default {
	color: var(--wp--preset--color--primary, #FF6600);
	font-size: 1.05rem;
	font-weight: var(--wp--custom--fw--strong);
	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: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--primary, #0a66c2);
	color: #fff;
	font-size: 0.7rem;
	font-weight: var(--wp--custom--fw--strong);
	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: var(--wp--custom--radius--sm); }
	.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; }
}
@media (prefers-reduced-motion: reduce) {
	.rpc-card__media { animation: none; }
	.rpc-card__img.img--loaded { animation: none; }
}

/* ---- KT additions: car chips, part code, add-to-cart (prototype look) ---- */

.rpc-card__cars {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	padding: 0;
}
.rpc-card__car-chip {
	display: inline-block;
	font-size: 0.72rem;
	font-weight: var(--wp--custom--fw--strong, 700);
	color: var(--wp--preset--color--accent, #173F73);
	background: #EEF2F8;
	padding: 3px 10px;
	border-radius: var(--wp--custom--radius--pill, 20px);
	line-height: 1.5;
}

.rpc-card__code {
	position: absolute;
	bottom: 8px;
	inset-inline-end: 10px;
	font-family: ui-monospace, Menlo, monospace;
	font-size: 0.66rem;
	color: var(--wp--preset--color--text-muted, #9aa3b2);
	letter-spacing: 0.5px;
	background: rgba(255, 255, 255, 0.82);
	padding: 2px 6px;
	border-radius: 6px;
	pointer-events: none;
}

.rpc-card__add {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: 0 10px 12px;
	padding: 11px;
	border-radius: 11px;
	background: var(--wp--preset--color--accent, #173F73);
	color: #fff;
	font-size: 0.85rem;
	font-weight: var(--wp--custom--fw--strong, 700);
	text-decoration: none;
	transition: background 0.15s ease;
}
.rpc-card__add:hover {
	background: var(--wp--preset--color--primary, #FF6600);
	color: #fff;
	text-decoration: none;
}
.rpc-card__add--oos {
	background: var(--wp--preset--color--surface, #F4F2EE);
	color: var(--wp--preset--color--text-muted, #7C8598);
	cursor: default;
	pointer-events: none;
}

@media (max-width: 768px) {
	.rpc-card__cars { padding-inline: 8px; }
	.rpc-card__add {
		margin: 0 8px 10px;
		padding: 9px;
		font-size: 0.8rem;
	}
}
