/**
 * Car listing components: card, price, status pill and the swipeable rail.
 * Shared by the homepage, Current Stock / Sold Out and the single car page.
 *
 * Facebook Sync photos are 2:3 designed posters with the car in the middle;
 * cards crop them to 4:5 around the centre. One card implementation for every
 * listing; grids and rails control columns and the image ratio.
 */

/* ---------- Card ---------- */

/* A lit shell with the photo set in as a rounded inner panel, like an app
   tile. Layout (columns, image ratio) belongs to the surrounding grid or rail
   via --nscb-card-ratio and --nscb-card-title-min. */
.nscb-car-card {
	--nscb-card-inset: 0.5rem;
	--nscb-card-radius: 1.75rem;
	position: relative;
	isolation: isolate;
	display: flex;
	flex-direction: column;
	height: 100%;
	padding: var(--nscb-card-inset);
	border: 1px solid var(--nscb-edge);
	border-radius: var(--nscb-card-radius);
	background: var(--nscb-surface-card);
	box-shadow: var(--nscb-edge-light), var(--nscb-shadow-card);
	transition:
		transform var(--nscb-duration-base) var(--nscb-ease-out),
		box-shadow var(--nscb-duration-base) var(--nscb-ease-out),
		border-color var(--nscb-duration-base) var(--nscb-ease-out);
	-webkit-tap-highlight-color: transparent;
}

/* Image ratio is set by the surrounding layout via --nscb-card-ratio (default 4:5). */
.nscb-car-card__media {
	position: relative;
	aspect-ratio: var(--nscb-card-ratio, 4 / 5);
	overflow: hidden;
	border-radius: calc(var(--nscb-card-radius) - var(--nscb-card-inset));
	background-color: var(--nscb-color-bg);
}

/* No photo: a quiet framed placeholder state, not a stand-in image. */
.nscb-car-card__media--empty {
	display: grid;
	place-items: center;
	background-image: radial-gradient(circle at 50% 45%, var(--nscb-color-surface), var(--nscb-color-bg-secondary) 70%);
}

.nscb-car-card__no-photo {
	width: 2rem;
	height: 2rem;
	color: var(--nscb-color-text-secondary);
	opacity: 0.45;
}

/* Floor shade so the pills read over any poster. */
.nscb-car-card__media::after {
	content: "";
	position: absolute;
	inset: auto 0 0;
	height: 32%;
	background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--nscb-color-bg) 55%, transparent));
	pointer-events: none;
}

.nscb-car-card .nscb-car-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: 50% 50%;
	transition: transform var(--nscb-duration-slow) var(--nscb-ease-out);
}

.nscb-car-card .nscb-status {
	position: absolute;
	top: var(--nscb-space-3);
	left: var(--nscb-space-3);
	z-index: 1;
}

.nscb-car-card__photos {
	position: absolute;
	right: var(--nscb-space-3);
	bottom: var(--nscb-space-3);
	z-index: 1;
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	padding: 0.4rem 0.7rem;
	border: 1px solid var(--nscb-edge);
	border-radius: var(--nscb-radius-pill);
	background-color: color-mix(in srgb, var(--nscb-color-bg) 80%, transparent);
	color: var(--nscb-color-text);
	font-size: var(--nscb-text-xs);
	font-weight: 600;
	line-height: 1;
}

.nscb-car-card__photos .nscb-icon {
	width: 0.875rem;
	height: 0.875rem;
}

.nscb-car-card__body {
	display: grid;
	flex: 1 1 auto;
	gap: var(--nscb-space-3);
	padding: var(--nscb-space-4) var(--nscb-space-3) var(--nscb-space-2);
}

.nscb-car-card__title {
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	min-height: var(--nscb-card-title-min, calc(2em * var(--nscb-leading-snug)));
	font-size: var(--nscb-text-md);
	font-weight: 700;
	line-height: var(--nscb-leading-snug);
	letter-spacing: -0.015em;
}

.nscb-car-card__link {
	color: var(--nscb-color-text);
	text-decoration: none;
}

/* Whole card is the link target. */
.nscb-car-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
}

.nscb-car-card__link:focus-visible {
	outline: none;
}

.nscb-car-card:focus-within {
	outline: 2px solid var(--nscb-color-highlight);
	outline-offset: 3px;
}

/* Price and a round highlight action on one row (the action is decorative:
   the whole card is already one link). */
.nscb-car-card__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--nscb-space-3);
	margin-top: auto;
}

.nscb-car-card .nscb-price {
	color: var(--nscb-color-highlight);
	font-size: var(--nscb-text-xl);
	font-weight: 800;
	letter-spacing: -0.03em;
}

.nscb-car-card__go {
	display: inline-grid;
	flex: none;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	margin-inline-start: auto;
	border-radius: 50%;
	background-color: var(--nscb-color-highlight);
	box-shadow: inset 0 1px 0 color-mix(in srgb, #FFFFFF 35%, transparent), 0 8px 20px -10px var(--nscb-highlight-glow);
	color: var(--nscb-color-highlight-text);
	transition: transform var(--nscb-duration-base) var(--nscb-ease-out);
}

.nscb-car-card__go .nscb-icon {
	width: 1.125rem;
	height: 1.125rem;
	transform: rotate(-45deg);
	transition: transform var(--nscb-duration-base) var(--nscb-ease-out);
}

/* Tap feedback on touch; lift on hover for pointers. */
.nscb-car-card:active {
	transform: scale(0.985);
}

@media (hover: hover) and (pointer: fine) {
	.nscb-car-card:hover {
		border-color: color-mix(in srgb, var(--nscb-color-highlight) 40%, var(--nscb-edge));
		box-shadow: var(--nscb-edge-light), var(--nscb-shadow-lift);
		transform: translateY(-4px);
	}

	.nscb-car-card:hover .nscb-car-card__go .nscb-icon {
		transform: rotate(0deg);
	}

	.nscb-car-card:hover .nscb-car-image {
		transform: scale(1.04);
	}
}

/* Sold: a flatter shell, a desaturated photo (static: no animated filter), a
   muted price and a quiet outline action, so it never reads as available. */
.nscb-car-card--sold {
	background: var(--nscb-color-bg-secondary);
	box-shadow: var(--nscb-edge-light);
}

.nscb-car-card--sold .nscb-car-image {
	filter: grayscale(0.6) brightness(0.8);
}

.nscb-car-card--sold .nscb-car-card__media::after {
	height: 100%;
	background: linear-gradient(180deg, color-mix(in srgb, var(--nscb-color-bg) 20%, transparent), color-mix(in srgb, var(--nscb-color-bg) 55%, transparent));
}

.nscb-car-card--sold .nscb-price {
	color: var(--nscb-color-text-secondary);
	font-weight: 700;
}

.nscb-car-card--sold .nscb-car-card__go {
	border: 1px solid var(--nscb-edge-strong);
	background-color: transparent;
	box-shadow: none;
	color: var(--nscb-color-text-secondary);
}

@media (hover: hover) and (pointer: fine) {
	.nscb-car-card--sold:hover {
		border-color: var(--nscb-edge-strong);
		box-shadow: var(--nscb-edge-light), var(--nscb-shadow-card);
	}
}

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

.nscb-price {
	color: var(--nscb-color-text);
	font-family: var(--nscb-font-heading);
	font-size: var(--nscb-text-lg);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.01em;
	line-height: 1.1;
}

.nscb-price--lg {
	font-size: var(--nscb-text-3xl);
	font-weight: 600;
	letter-spacing: -0.02em;
}

/* ---------- Status pill ---------- */

.nscb-status {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.4rem 0.75rem;
	border: 1px solid color-mix(in srgb, var(--nscb-color-text) 14%, transparent);
	border-radius: var(--nscb-radius-pill);
	background-color: color-mix(in srgb, var(--nscb-color-bg) 80%, transparent);
	color: var(--nscb-color-text);
	font-size: var(--nscb-text-xs);
	font-weight: 600;
	letter-spacing: 0.04em;
	line-height: 1;
	white-space: nowrap;
}

.nscb-status::before {
	content: "";
	width: 0.4rem;
	height: 0.4rem;
	border-radius: 50%;
	background-color: var(--nscb-color-highlight);
	box-shadow: 0 0 0 3px var(--nscb-highlight-soft);
}

.nscb-status--sold {
	color: var(--nscb-color-text-secondary);
}

.nscb-status--sold::before {
	background-color: var(--nscb-color-text-secondary);
	box-shadow: none;
	opacity: 0.6;
}

/* ---------- Rail: horizontal scroll-snap list, aligned to the container ---------- */

.nscb-rail {
	--nscb-rail-pad: max(var(--nscb-gutter), calc((100% - var(--nscb-container-xl)) / 2));
	position: relative;
}

.nscb-rail__track {
	display: grid;
	grid-auto-columns: min(78vw, 20rem);
	grid-auto-flow: column;
	gap: var(--nscb-space-4);
	margin: 0;
	padding: var(--nscb-space-2) var(--nscb-rail-pad) var(--nscb-space-6);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	list-style: none;
	scroll-padding-inline: var(--nscb-rail-pad);
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.nscb-rail__track::-webkit-scrollbar {
	display: none;
}

.nscb-rail__item {
	scroll-snap-align: start;
}

.nscb-rail__controls {
	display: flex;
	justify-content: flex-end;
	gap: var(--nscb-space-2);
}

.nscb-rail__controls[hidden] {
	display: none;
}

.nscb-rail__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	padding: 0;
	border: 1px solid var(--nscb-edge-strong);
	border-radius: 50%;
	background-color: var(--nscb-surface-raised);
	box-shadow: var(--nscb-edge-light);
	color: var(--nscb-color-text);
	transition:
		color var(--nscb-duration-fast) var(--nscb-ease-standard),
		border-color var(--nscb-duration-fast) var(--nscb-ease-standard),
		background-color var(--nscb-duration-fast) var(--nscb-ease-standard),
		opacity var(--nscb-duration-fast) var(--nscb-ease-standard),
		transform var(--nscb-duration-fast) var(--nscb-ease-standard);
}

.nscb-rail__btn:active:not(:disabled) {
	transform: scale(0.94);
}

.nscb-rail__btn:hover:not(:disabled) {
	border-color: transparent;
	background-color: var(--nscb-color-highlight);
	color: var(--nscb-color-highlight-text);
}

.nscb-rail__btn:disabled {
	opacity: 0.35;
	cursor: default;
}

.nscb-rail__btn .nscb-icon {
	width: 1.125rem;
	height: 1.125rem;
}

@media (min-width: 48rem) {
	.nscb-rail__track {
		grid-auto-columns: min(40vw, 19rem);
		gap: var(--nscb-space-5);
	}
}

@media (min-width: 64rem) {
	.nscb-rail__track {
		grid-auto-columns: 18.5rem;
	}

	/* Grid variant: a plain grid on large screens instead of a scroller. */
	.nscb-rail--grid .nscb-rail__track {
		grid-auto-flow: row;
		grid-template-columns: repeat(3, minmax(0, 1fr));
		max-width: calc(var(--nscb-container-xl) + 2 * var(--nscb-gutter));
		margin-inline: auto;
		padding-inline: var(--nscb-gutter);
		overflow: visible;
	}
}

@media (min-width: 80rem) {
	.nscb-rail__track {
		grid-auto-columns: calc((min(100vw, var(--nscb-container-xl)) - 3 * var(--nscb-space-5)) / 4);
	}
}
