/**
 * HFM Vehicles blocks — shared styles.
 *
 * Two blocks share this stylesheet:
 *   .hfm-vehicles-grid    CSS grid of cards
 *   .hfm-vehicles-slider  Pure-CSS infinite marquee
 *
 * Both render `.hfm-vehicle-card` items via hfm_vehicle_card_html() so
 * any visual tweak to the card lands in one rule block below.
 *
 * Design language matches product-card.css: rounded white cards, subtle
 * border, hover lift, monospaced eyebrow text — kept in sync visually.
 */

/* ─── Shared vehicle card ──────────────────────────────────────────── */

.hfm-vehicle-card {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 10px;
	background: light-dark(#f5f5f5, #1a1a1a);
	border: 1px solid var(--hfm-line, light-dark(#e5e5e5, #262626));
	border-radius: 10px;
	color: inherit;
	text-decoration: none;
	transition: background-color 0.16s ease, transform 0.18s ease, box-shadow 0.18s ease;
	min-width: 0;
}

.hfm-vehicle-card:hover,
.hfm-vehicle-card:focus-visible {
	background: light-dark(#eeeeee, #1f1f1f);
	transform: translateY(-2px);
	box-shadow: 0 8px 24px -12px light-dark(
		color-mix(in srgb, #000 18%, transparent),
		color-mix(in srgb, #000 50%, transparent)
	);
}

.hfm-vehicle-card__media {
	position: relative;
	aspect-ratio: 8 / 3;
	background: #efefef;
	border-radius: 7px;
	overflow: hidden;
}

.hfm-vehicle-card__media img {
	position: absolute;
	inset: 0;
	width: 80%;
	height: auto;
	object-fit: contain !important;
	object-position: left center !important;
	left: -20%;
	display: block;
}

.hfm-vehicle-card__body {
	display: flex;
	flex-direction: column;
	gap: 0;
	min-width: 0;
}

.hfm-vehicle-card__eyebrow {
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--hfm-accent, light-dark(#874da2, #d05aff));
	line-height: 1.2;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hfm-vehicle-card__label {
	font-weight: 800;
	font-size: 14px;
	line-height: 1.2;
	color: var(--wp--preset--color--contrast, light-dark(#191919, #f0f0f0));
	margin-top: 2px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hfm-vehicle-card__sub {
	font-size: 11px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	color: var(--wp--preset--color--grey-600, light-dark(#525252, #909090));
	margin-top: 3px;
	line-height: 1.3;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hfm-vehicle-card--compact {
	padding: 8px;
	gap: 8px;
	border-radius: 8px;
}
.hfm-vehicle-card--compact .hfm-vehicle-card__eyebrow {
	font-size: 8px;
}
.hfm-vehicle-card--compact .hfm-vehicle-card__label {
	font-size: 12.5px;
}
.hfm-vehicle-card--compact .hfm-vehicle-card__sub {
	font-size: 10px;
}

/* ─── Grid block ───────────────────────────────────────────────────── */

.hfm-vehicles-grid {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.hfm-vehicles-grid__heading {
	margin: 0;
	font-size: 22px;
	line-height: 1.2;
	font-weight: 700;
}

.hfm-vehicles-grid__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 12px;
	grid-template-columns: repeat(var(--hfm-vg-cols, 3), minmax(0, 1fr));
}

.hfm-vehicles-grid__item {
	margin: 0;
	display: flex; /* card stretches to row height */
}
.hfm-vehicles-grid__item > .hfm-vehicle-card {
	flex: 1;
}

.hfm-vehicles-grid--cols-1 .hfm-vehicles-grid__list { --hfm-vg-cols: 1; }
.hfm-vehicles-grid--cols-2 .hfm-vehicles-grid__list { --hfm-vg-cols: 2; }
.hfm-vehicles-grid--cols-3 .hfm-vehicles-grid__list { --hfm-vg-cols: 3; }
.hfm-vehicles-grid--cols-4 .hfm-vehicles-grid__list { --hfm-vg-cols: 4; }
.hfm-vehicles-grid--cols-5 .hfm-vehicles-grid__list { --hfm-vg-cols: 5; }
.hfm-vehicles-grid--cols-6 .hfm-vehicles-grid__list { --hfm-vg-cols: 6; }

/* Responsive: collapse to fewer columns on narrow viewports. */
@media (max-width: 900px) {
	.hfm-vehicles-grid__list {
		grid-template-columns: repeat(min(var(--hfm-vg-cols, 3), 3), minmax(0, 1fr));
	}
}
@media (max-width: 600px) {
	.hfm-vehicles-grid__list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

.hfm-vehicles-grid--empty {
	padding: 24px;
	text-align: center;
	color: #666;
	border: 1px dashed #ccc;
	border-radius: 12px;
}

/* ─── Slider block (pure CSS marquee) ──────────────────────────────── */

.hfm-vehicles-slider {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.hfm-vehicles-slider__heading {
	margin: 0 0 4px;
	font-size: 22px;
	line-height: 1.2;
	font-weight: 700;
}

.hfm-vehicles-slider__viewport {
	overflow: hidden;
	/* Soft fade-edges using a mask so cards near the edges feel like
	   they're emerging / disappearing, rather than abruptly clipped. */
	-webkit-mask-image: linear-gradient(to right, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
	mask-image:         linear-gradient(to right, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
}

.hfm-vehicles-slider__track {
	display: flex;
	gap: 12px;
	width: max-content;
	animation: hfm-marquee-left var(--hfm-marquee-duration, 50s) linear infinite;
	will-change: transform;
}

.hfm-vehicles-slider__track > .hfm-vehicle-card,
.hfm-vehicles-slider__dupe > .hfm-vehicle-card {
	flex: 0 0 auto;
	width: 200px; /* compact default */
}

.hfm-vehicles-slider--compact .hfm-vehicles-slider__track > .hfm-vehicle-card,
.hfm-vehicles-slider--compact .hfm-vehicles-slider__dupe  > .hfm-vehicle-card {
	width: 160px;
}
.hfm-vehicles-slider--normal .hfm-vehicles-slider__track > .hfm-vehicle-card,
.hfm-vehicles-slider--normal .hfm-vehicles-slider__dupe  > .hfm-vehicle-card {
	width: 240px;
}

/* The dupe is rendered as a flex child of the track and itself a flex
   row, so its children participate in the same horizontal flow. */
.hfm-vehicles-slider__dupe {
	display: flex;
	gap: 12px;
	margin-left: 12px; /* match the parent gap so spacing is continuous */
}

.hfm-vehicles-slider[data-direction="right"] .hfm-vehicles-slider__track {
	animation-name: hfm-marquee-right;
}

.hfm-vehicles-slider[data-pause-hover="true"]:hover .hfm-vehicles-slider__track,
.hfm-vehicles-slider[data-pause-hover="true"]:focus-within .hfm-vehicles-slider__track {
	animation-play-state: paused;
}

@keyframes hfm-marquee-left {
	from { transform: translate3d(0, 0, 0); }
	to   { transform: translate3d(-50%, 0, 0); }
}
@keyframes hfm-marquee-right {
	from { transform: translate3d(-50%, 0, 0); }
	to   { transform: translate3d(0, 0, 0); }
}

.hfm-vehicles-slider--empty {
	padding: 24px;
	text-align: center;
	color: #666;
	border: 1px dashed #ccc;
	border-radius: 12px;
}

/* Accessibility — kill the animation entirely for visitors who've
   asked the OS to reduce motion. Cards stay in place, no horizontal
   scroll fallback needed (the items remain reachable via Tab). */
@media (prefers-reduced-motion: reduce) {
	.hfm-vehicles-slider__track {
		animation: none !important;
		transform: none !important;
	}
	.hfm-vehicles-slider__viewport {
		overflow-x: auto;
	}
	.hfm-vehicles-slider__dupe {
		display: none; /* avoid duplicate keyboard tab stops */
	}
}
