/**
 * HG Automotive — vehicle archive layout and controls.
 *
 * @package HG_Automotive
 * @since 0.2.0
 */

.hg-auto-vehicle-archive {
	--hg-auto-vehicle-cols: 3;
}

.hg-auto-vehicle-archive__description {
	margin-top: var(--hg-auto-space-3);
	max-width: 48rem;
	color: var(--hg-auto-color-steel);
}

.hg-auto-vehicle-results__layout {
	display: grid;
	gap: var(--hg-auto-space-5);
	align-items: start;
}

.hg-auto-vehicle-results__layout.is-results-loading .hg-auto-vehicle-results__main {
	opacity: 0.55;
	transition: opacity 0.15s ease;
	pointer-events: none;
}

.hg-auto-vehicle-results__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: var(--hg-auto-space-3);
	margin-bottom: var(--hg-auto-space-4);
}

.hg-auto-vehicle-results__filters-toggle {
	display: none;
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	font: inherit;
}

.hg-auto-archive-controls__layout-btn.hg-auto-vehicle-results__filters-toggle {
	border: 0;
	background: transparent;
}

.hg-auto-vehicle-results__drawer-header {
	display: none;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin: -1rem -1rem 0.85rem;
	padding: 0.95rem 1rem;
	background: var(--hg-color-footer);
	color: #fff;
	border-radius: 18px 18px 0 0;
}

.hg-auto-vehicle-results__drawer-heading {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	min-width: 0;
}

.hg-auto-vehicle-results__drawer-title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
	color: inherit;
}

.hg-auto-vehicle-results__drawer-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.4rem;
	height: 1.4rem;
	padding: 0 0.35rem;
	border-radius: 999px;
	background: var(--hg-color-primary);
	color: #fff;
	font-size: 0.72rem;
	font-weight: 700;
	line-height: 1;
}

.hg-auto-vehicle-results__drawer-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	margin: 0;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.28);
	border-radius: 999px;
	background: transparent;
	color: #fff;
	cursor: pointer;
}

.hg-auto-vehicle-results__drawer-close:hover,
.hg-auto-vehicle-results__drawer-close:focus-visible {
	background: rgba(255, 255, 255, 0.12);
	outline: none;
}

.hg-auto-vehicle-results__sidebar .hg-auto-search {
	margin: 0;
	/* Desktop default: content-height, page scroll only (no nested sidebar scroll). */
	position: static;
	height: auto;
	max-height: none;
	overflow: visible;
	display: block;
}

.hg-auto-vehicle-results__sidebar .hg-auto-search__form {
	display: block;
	min-height: 0;
}

.hg-auto-vehicle-results__sidebar .hg-auto-search__scroll {
	overflow: visible;
	padding-right: 0;
}

.hg-auto-vehicle-results__sidebar .hg-auto-search__actions {
	position: static;
	z-index: auto;
	margin-top: 0.85rem;
	padding: 0.85rem 0 0;
	background: transparent;
}

.hg-auto-vehicle-results__sidebar .hg-auto-search__row {
	flex-direction: column;
}

.hg-auto-vehicle-results__sidebar .hg-auto-search__field {
	flex: 0 0 auto;
	width: 100%;
	min-width: 0;
}

.hg-auto-vehicle-results__sidebar .hg-auto-search__pair .hg-auto-search__field {
	width: auto;
}

.hg-auto-archive-controls {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0.55rem;
	flex: 1 1 16rem;
	margin: 0;
	padding: 0 0 0.85rem;
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	border-bottom: 1px solid var(--hg-auto-color-border);
}

.hg-auto-archive-controls__heading {
	margin: 0;
	font-size: clamp(1.35rem, 1.1rem + 0.6vw, 1.75rem);
	font-weight: 700;
	line-height: 1.2;
	color: var(--hg-auto-color-ink);
}

.hg-auto-archive-controls__row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.65rem 1.25rem;
	width: 100%;
}

.hg-auto-archive-controls__count {
	margin: 0;
	color: var(--hg-auto-color-muted);
	font-size: 0.9375rem;
	font-weight: 500;
	line-height: 1.3;
}

.hg-auto-archive-controls__tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 0.85rem 1.15rem;
	margin-left: auto;
}

.hg-auto-archive-controls__sort {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--hg-auto-space-3);
	position: relative;
	z-index: 5;
}

.hg-auto-sort {
	position: relative;
	display: inline-flex;
	flex-direction: column;
	align-items: flex-start;
}

.hg-auto-sort__trigger {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	min-height: 0;
	padding: 0.15rem 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--hg-auto-color-ink);
	font: inherit;
	font-size: 0.9375rem;
	font-weight: 500;
	line-height: 1.3;
	cursor: pointer;
	transition: color 0.15s ease;
}

.hg-auto-sort__trigger:hover,
.hg-auto-sort__trigger:focus-visible,
.hg-auto-sort.is-open .hg-auto-sort__trigger {
	background: transparent;
	border-color: transparent;
	color: var(--hg-auto-color-accent);
	outline: none;
	box-shadow: none;
}

.hg-auto-sort__trigger:focus-visible {
	outline: 2px solid var(--hg-auto-color-accent);
	outline-offset: 3px;
}

.hg-auto-sort__trigger-icon {
	display: inline-flex;
	line-height: 0;
	color: inherit;
}

.hg-auto-sort__trigger-caret {
	display: inline-block;
	width: 0;
	height: 0;
	margin-left: 0.15rem;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid currentColor;
}

.hg-auto-sort__menu {
	position: absolute;
	top: calc(100% + 0.4rem);
	left: 0;
	z-index: 40;
	min-width: 15.5rem;
	max-width: min(20rem, 90vw);
	padding: 0.4rem 0;
	margin: 0;
	border: 1px solid var(--hg-auto-color-border);
	border-radius: 12px;
	background: var(--hg-auto-color-surface-elevated, #fff);
	box-shadow: 0 10px 28px color-mix(in srgb, var(--hg-auto-color-ink) 14%, transparent);
}

.hg-auto-sort__menu[hidden] {
	display: none !important;
}

.hg-auto-sort__option {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	width: 100%;
	margin: 0;
	padding: 0.65rem 0.95rem;
	border: 0;
	background: transparent;
	color: var(--hg-auto-color-ink);
	font: inherit;
	font-size: 0.9375rem;
	font-weight: 500;
	text-align: left;
	text-decoration: none;
	cursor: pointer;
	box-sizing: border-box;
}

.hg-auto-sort__option:hover,
.hg-auto-sort__option:focus-visible {
	background: color-mix(in srgb, var(--hg-auto-color-ink) 6%, transparent);
	outline: none;
}

.hg-auto-sort__radio {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 1.1rem;
	width: 1.1rem;
	height: 1.1rem;
	border: 1.5px solid color-mix(in srgb, var(--hg-auto-color-ink) 35%, transparent);
	border-radius: 999px;
	background: transparent;
	box-sizing: border-box;
}

.hg-auto-sort__option.is-selected .hg-auto-sort__radio {
	border-color: var(--hg-auto-color-ink);
	background: var(--hg-auto-color-ink);
}

.hg-auto-archive-controls__submit {
	min-height: 2.75rem;
}

.hg-auto-archive-controls__layout {
	display: inline-flex;
	align-items: center;
	gap: 0.85rem;
}

.hg-auto-archive-controls__layout-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	min-height: 0;
	padding: 0.15rem 0;
	border: 0;
	border-bottom: 2px solid transparent;
	border-radius: 0;
	background: transparent;
	color: var(--hg-auto-color-muted);
	text-decoration: none;
	font-size: 0.9375rem;
	font-weight: 500;
	line-height: 1.3;
}

.hg-auto-archive-controls__layout-btn:hover,
.hg-auto-archive-controls__layout-btn:focus-visible {
	border-color: transparent;
	color: var(--hg-auto-color-accent);
	outline: none;
}

.hg-auto-archive-controls__layout-btn:focus-visible {
	outline: 2px solid var(--hg-auto-color-accent);
	outline-offset: 3px;
}

.hg-auto-archive-controls__layout-btn.is-active {
	border-bottom-color: var(--hg-auto-color-accent);
	color: var(--hg-auto-color-accent);
	font-weight: 700;
}

.hg-auto-vehicle-grid {
	display: grid;
	gap: var(--hg-auto-space-5);
	grid-template-columns: minmax(0, 1fr);
}

.hg-auto-vehicle-list {
	display: grid;
	gap: var(--hg-auto-space-4);
}

.hg-auto-vehicle-pagination {
	margin-top: var(--hg-auto-space-6);
}

.hg-auto-vehicle-pagination ul.page-numbers {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.3rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.hg-auto-vehicle-pagination ul.page-numbers > li {
	display: inline-flex;
	margin: 0;
	padding: 0;
	list-style: none;
}

.hg-auto-vehicle-pagination a.page-numbers,
.hg-auto-vehicle-pagination span.page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.5rem;
	min-height: 2.5rem;
	padding: 0.35rem 0.65rem;
	margin: 0;
	border: 1px solid var(--hg-auto-color-border);
	border-radius: var(--hg-auto-radius);
	color: var(--hg-auto-color-ink);
	text-decoration: none;
	font-weight: 600;
	list-style: none;
}

.hg-auto-vehicle-pagination a.page-numbers.current,
.hg-auto-vehicle-pagination span.page-numbers.current,
.hg-auto-vehicle-pagination a.page-numbers:hover,
.hg-auto-vehicle-pagination a.page-numbers:focus-visible {
	background: var(--hg-auto-color-accent);
	border-color: var(--hg-auto-color-accent);
	color: #fff;
}

@media (min-width: 640px) {
	.hg-auto-vehicle-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 960px) {
	.hg-auto-vehicle-results__layout {
		grid-template-columns: minmax(17.5rem, 20rem) minmax(0, 1fr);
	}

	.hg-auto-vehicle-results__filters-toggle {
		display: none !important;
	}

	.hg-auto-vehicle-results__drawer-header {
		display: none !important;
	}

	.hg-auto-vehicle-grid {
		grid-template-columns: repeat(var(--hg-auto-vehicle-cols, 3), minmax(0, 1fr));
	}

	.hg-auto-archive-controls__label {
		width: auto;
		margin-bottom: var(--hg-auto-space-2);
	}
}

@media (max-width: 959px) {
	.hg-auto-vehicle-results__toolbar {
		flex-direction: column;
		align-items: stretch;
		gap: var(--hg-auto-space-3);
	}

	.hg-auto-vehicle-results__filters-toggle {
		display: inline-flex;
		width: auto;
		justify-content: center;
	}

	.hg-auto-archive-controls {
		flex: 1 1 auto;
		width: 100%;
		min-width: 0;
	}

	.hg-auto-vehicle-results__filters {
		position: fixed;
		inset: 0;
		z-index: 1000;
		display: none;
	}

	.hg-auto-vehicle-results__filters.is-open {
		display: block;
	}

	.hg-auto-vehicle-results__filters-backdrop {
		display: block !important;
		position: absolute;
		inset: 0;
		background: rgba(5, 55, 66, 0.48);
	}

	.hg-auto-vehicle-results__sidebar {
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		display: flex;
		flex-direction: column;
		max-height: min(92vh, 52rem);
		overflow: hidden;
		padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
		border-radius: 18px 18px 0 0;
		background: var(--hg-color-bg-subtle, #f7f7f6);
		box-shadow: 0 -12px 32px rgba(5, 55, 66, 0.2);
	}

	.hg-auto-vehicle-results__drawer-header {
		display: flex;
		flex: 0 0 auto;
	}

	.hg-auto-vehicle-results__sidebar .hg-auto-search {
		position: static;
		flex: 1 1 auto;
		min-height: 0;
		max-height: none;
		display: flex;
		flex-direction: column;
		overflow: hidden;
		box-shadow: none;
		border: 0;
		padding: 0;
		background: transparent;
		border-radius: 0;
	}

	.hg-auto-vehicle-results__sidebar .hg-auto-search__form {
		flex: 1 1 auto;
		min-height: 0;
		display: flex;
		flex-direction: column;
	}

	.hg-auto-vehicle-results__sidebar .hg-auto-search__scroll {
		flex: 1 1 auto;
		min-height: 0;
		overflow: auto;
		padding-right: 0.15rem;
	}

	.hg-auto-vehicle-results__sidebar .hg-auto-search__actions {
		flex: 0 0 auto;
		position: sticky;
		bottom: 0;
		z-index: 2;
		margin-top: 0.35rem;
		padding: 0.75rem 0 env(safe-area-inset-bottom, 0px);
		background: linear-gradient(180deg, rgba(247, 247, 246, 0.92) 0%, var(--hg-color-bg-subtle, #f7f7f6) 35%);
	}
}

html.hg-auto-results-drawer-open,
html.hg-auto-results-drawer-open body {
	overflow: hidden;
}

@media (max-width: 767px) {
	.hg-auto-archive-controls__row {
		flex-direction: column;
		align-items: stretch;
		gap: 0.55rem;
	}

	.hg-auto-archive-controls__count {
		width: 100%;
	}

	.hg-auto-archive-controls__tools {
		margin-left: 0;
		width: 100%;
		flex-wrap: wrap;
		justify-content: flex-start;
		gap: 0.65rem 1rem;
	}

	.hg-auto-archive-controls__sort {
		min-width: 0;
		flex: 1 1 auto;
		max-width: 100%;
	}

	.hg-auto-sort,
	.hg-auto-sort__trigger {
		max-width: 100%;
	}

	.hg-auto-sort__trigger-text {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.hg-auto-archive-controls__layout {
		width: auto;
		flex: 0 0 auto;
		justify-content: flex-start;
		gap: 0.75rem;
	}

	.hg-auto-archive-controls__layout-btn {
		flex: 0 0 auto;
		justify-content: center;
		padding-left: 0;
		padding-right: 0;
	}

	.hg-auto-archive-controls__layout-btn.hg-auto-vehicle-results__filters-toggle {
		margin: 0;
		box-shadow: none;
	}
}

/* ——— Featured Vehicles carousel ——— */
.hg-auto-vehicle-results__inventory-heading {
	margin: 0 0 var(--hg-auto-space-3);
	font-family: var(--hg-auto-font-sans, var(--hg-auto-font-display));
	font-size: 1.125rem;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--hg-auto-color-ink);
}

.hg-sponsored-section--carousel {
	--hg-featured-gap: var(--hg-auto-space-4);
	/*
	 * Mobile: ~1.3 visible cards → one full card + ~25–30% of the next
	 * (after gap) as a swipe cue. Do not use 1.0 (full-bleed single card).
	 */
	--hg-featured-visible: 1.3;
	--hg-featured-card-max: 22.5rem; /* ~360px — matches a healthy grid card width */
	margin: 0 0 var(--hg-auto-space-5);
	padding: 0 0 var(--hg-auto-space-5);
	border-bottom: 1px solid var(--hg-auto-color-border);
}

.hg-sponsored-section--grid .hg-sponsored-section__track {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
	gap: var(--hg-auto-space-4);
	overflow: visible;
	scroll-snap-type: none;
}

.hg-sponsored-section--grid .hg-sponsored-section__slide {
	flex: none;
	width: auto;
	scroll-snap-align: none;
}

.hg-sponsored-section__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--hg-auto-space-3);
	margin-bottom: var(--hg-auto-space-3);
}

.hg-sponsored-section--carousel .hg-sponsored-section__heading {
	margin: 0;
	font-family: var(--hg-auto-font-sans, var(--hg-auto-font-display));
	font-size: 1.125rem;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--hg-auto-color-ink);
}

.hg-sponsored-section__heading-spacer {
	flex: 1 1 auto;
}

.hg-sponsored-section__controls {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
}

/* Mobile: peek is the primary swipe cue — hide arrow chrome. */
@media (max-width: 639px) {
	.hg-sponsored-section--carousel .hg-sponsored-section__controls {
		display: none;
	}
}

.hg-sponsored-section__nav {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	margin: 0;
	padding: 0;
	border: 1px solid var(--hg-auto-color-border);
	border-radius: 999px;
	background: var(--hg-auto-color-surface-elevated);
	color: var(--hg-auto-color-ink);
	cursor: pointer;
	transition:
		border-color var(--hg-auto-transition, 160ms ease),
		color var(--hg-auto-transition, 160ms ease),
		background var(--hg-auto-transition, 160ms ease);
}

.hg-sponsored-section__nav:hover,
.hg-sponsored-section__nav:focus-visible {
	border-color: var(--hg-auto-color-accent);
	color: var(--hg-auto-color-accent);
	outline: none;
}

.hg-sponsored-section__nav:disabled {
	opacity: 0.35;
	cursor: default;
	pointer-events: none;
}

.hg-sponsored-section__viewport {
	overflow: hidden;
	max-width: 100%;
}

.hg-sponsored-section__track {
	display: flex;
	gap: var(--hg-featured-gap);
	margin: 0;
	padding: 0 0 0.25rem;
	list-style: none;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.hg-sponsored-section__track::-webkit-scrollbar {
	display: none;
}

.hg-sponsored-section__slide {
	flex: 0 0 calc((100% - (var(--hg-featured-gap) * (var(--hg-featured-visible) - 1))) / var(--hg-featured-visible));
	min-width: 0;
	scroll-snap-align: start;
	scroll-snap-stop: always;
}

/* One featured card: use a real grid-card width, not an empty multi-column slot. */
.hg-sponsored-section--carousel[data-hg-featured-count="1"] .hg-sponsored-section__slide {
	flex-basis: min(100%, var(--hg-featured-card-max));
	max-width: min(100%, var(--hg-featured-card-max));
}

.hg-sponsored-section__slide .hg-auto-vehicle-card {
	height: 100%;
	width: 100%;
	max-width: 100%;
}

@media (min-width: 640px) {
	.hg-sponsored-section--carousel {
		/* Tablet: ~1.5–2.5 cards with natural next-card peek. */
		--hg-featured-visible: min(2.2, var(--hg-featured-desktop-cols, 2));
	}
}

@media (min-width: 1024px) {
	.hg-sponsored-section--carousel {
		/* Desktop: 3–4 cards aligned with desktop-cols (capped by card count). */
		--hg-featured-visible: var(--hg-featured-desktop-cols, 3);
	}
}

@media (prefers-reduced-motion: reduce) {
	.hg-sponsored-section__track {
		scroll-behavior: auto;
	}
}
