/**
 * Sport Automobile – Fahrzeugliste (Filter) und Detailseite eines Fahrzeugs.
 * Wird nur auf der Seite Fahrzeuge und den Detailseiten geladen; Tokens,
 * Buttons und Karten kommen aus style.css.
 */

/* ==========================================================================
   Liste: Filter und Sortierung
   ========================================================================== */

.filter {
	margin: 0 0 clamp(28px, 3vw, 44px);
	padding: clamp(20px, 2.4vw, 32px);
	border-top: 2px solid var(--bronze);
	background: var(--panel);
}

.filter__fields {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: 16px var(--gap);
}

/* Sieben Filter (mit Getriebe): zwei Reihen statt einem einzelnen Feld auf der zweiten Zeile */
@media (min-width: 900px) {
	.filter__fields:has(> :nth-child(7)) {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

@media (min-width: 600px) and (max-width: 899.98px) {
	.filter__fields:has(> :nth-child(7)) {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.filter__fields:has(> :nth-child(7)) > :last-child:nth-child(3n + 1) {
		grid-column: 1 / -1;
	}
}

.filter__label {
	display: block;
	margin: 0 0 8px;
	color: var(--sand);
	font-size: 0.6875rem;
	font-stretch: 125%;
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: 0.18em;
	text-transform: uppercase;
}

.filter__select {
	position: relative;
	display: block;
}

.filter__select select {
	width: 100%;
	height: 52px;
	padding: 0 44px 0 16px;
	border: 1px solid var(--line-sand);
	border-radius: 0;
	background: var(--black);
	color: var(--white);
	font: inherit;
	font-size: 0.9375rem;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.filter__select select:hover {
	border-color: rgba(234, 227, 214, 0.6);
}

.filter__select .icon {
	position: absolute;
	top: 50%;
	right: 14px;
	width: 18px;
	height: 18px;
	color: var(--sand);
	stroke-width: 1.8;
	transform: translateY(-50%);
	pointer-events: none;
}

.filter__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 28px;
	margin-top: 22px;
	padding-top: 18px;
	border-top: 1px solid var(--line);
}

.filter__count {
	margin: 0;
	font-size: 0.9375rem;
	font-weight: 600;
}

.filter__reset {
	color: var(--soft);
	font-size: 0.875rem;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.3em;
}

.filter__reset:hover {
	color: var(--white);
	text-decoration-color: var(--red);
}

.filter__reset[hidden] {
	display: none;
}

.filter__submit {
	min-height: 44px;
	margin-left: auto;
}

/* Handy: zwei Filter nebeneinander, damit die Liste rasch sichtbar ist */
@media (max-width: 599.98px) {
	.filter {
		padding: 18px 16px 16px;
	}

	.filter__fields {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 14px 10px;
	}

	/* Ungerade Anzahl: das letzte Feld (Sortierung) über die ganze Breite */
	.filter__fields > :last-child:nth-child(odd) {
		grid-column: 1 / -1;
	}

	.filter__label {
		letter-spacing: 0.12em;
	}

	.filter__select select {
		height: 46px;
		padding: 0 34px 0 12px;
		font-size: 0.875rem;
	}

	.filter__select .icon {
		right: 10px;
	}

	.filter__foot {
		margin-top: 16px;
		padding-top: 14px;
	}
}

.cars > li[hidden] {
	display: none;
}

.listing__empty,
.listing__nomatch {
	max-width: 760px;
	padding: clamp(28px, 4vw, 48px);
	border-top: 2px solid var(--bronze);
	background: var(--panel);
	color: var(--soft);
}

.listing__nomatch[hidden] {
	display: none;
}

.listing__empty p,
.listing__nomatch p {
	margin: 0 0 24px;
	font-size: 1.0625rem;
}

.listing__nomatch-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

/* ==========================================================================
   Detailseite
   ========================================================================== */

.vehicle-back {
	margin: clamp(20px, 2.4vw, 32px) 0 clamp(16px, 2vw, 24px);
}

.vehicle-back a {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	color: var(--soft);
	font-size: 0.9375rem;
	font-weight: 500;
	text-decoration: none;
}

.vehicle-back .icon {
	width: 20px;
	height: 20px;
	color: var(--red);
	stroke-width: 1.8;
}

.vehicle-back a:hover {
	color: var(--white);
}

.vehicle-back a:hover span {
	text-decoration: underline;
	text-decoration-color: var(--red);
	text-underline-offset: 0.3em;
}

.vehicle-sold {
	margin: 0 0 20px;
	padding: 14px 18px;
	border-left: 2px solid var(--red);
	background: var(--panel);
	font-weight: 600;
}

/* --- Galerie: Hauptbild gross, rechts drei Vorschaubilder --------------- */

.gallery {
	position: relative;
}

.gallery__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.gallery__btn {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	padding: 0;
	overflow: hidden;
	border: 0;
	background: var(--panel-2);
	color: var(--white);
	font: inherit;
	cursor: zoom-in;
}

.gallery__btn:focus-visible {
	outline-offset: -4px;
}

.gallery__img {
	position: relative;
	width: 100%;
	height: 100%;
	object-fit: cover;
	filter: brightness(0.92);
	transition: filter 0.3s ease;
}

.gallery__btn:hover .gallery__img {
	filter: brightness(1);
}

/* Nur ein Bild: ganz sichtbar auf einer unscharfen Kopie */
.gallery__backdrop {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	filter: blur(36px) brightness(0.42);
	transform: scale(1.2);
}

.gallery--1 .gallery__img {
	object-fit: contain;
}

/* «+ 8 Bilder» auf dem letzten Vorschaubild */
.gallery__more {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(10, 10, 10, 0.6);
	font-size: clamp(1rem, 0.8rem + 0.6vw, 1.375rem);
	font-stretch: 110%;
	font-weight: 650;
	letter-spacing: 0.01em;
}

.gallery__count {
	position: absolute;
	right: 12px;
	bottom: 12px;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 7px 12px;
	background: rgba(10, 10, 10, 0.72);
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1;
	pointer-events: none;
}

.gallery__count .icon {
	width: 18px;
	height: 18px;
	stroke-width: 1.6;
}

@media (min-width: 700px) {
	.gallery__list {
		display: grid;
		grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
		grid-template-rows: repeat(3, minmax(0, 1fr));
		gap: 8px;
		height: clamp(340px, 62vh, 660px);
	}

	.gallery__item:first-child {
		grid-row: 1 / -1;
	}

	.gallery__item:nth-child(n + 5) {
		display: none;
	}

	.gallery--1 .gallery__list {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: minmax(0, 1fr);
	}

	.gallery__count {
		display: none;
	}
}

/* Handy: über die ganze Breite, zum Blättern wischen */
@media (max-width: 699.98px) {
	.gallery {
		margin-inline: calc(-1 * var(--gutter));
	}

	.gallery__list {
		display: flex;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scrollbar-width: none;
	}

	.gallery__list::-webkit-scrollbar {
		display: none;
	}

	.gallery__item {
		flex: 0 0 100%;
		aspect-ratio: 3 / 2;
		scroll-snap-align: start;
	}

	.gallery__more,
	.gallery__backdrop {
		display: none;
	}

	.gallery--1 .gallery__img {
		object-fit: cover;
	}
}

/* --- Titel und Preis ---------------------------------------------------- */

.vehicle-head {
	display: grid;
	gap: 14px 48px;
	margin-top: clamp(24px, 3vw, 44px);
	padding-bottom: clamp(24px, 2.6vw, 36px);
	border-bottom: 1px solid var(--line);
}

@media (min-width: 900px) {
	.vehicle-head {
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: end;
	}
}

.vehicle-head__title {
	margin: 0;
	font-size: clamp(1.875rem, 1.1rem + 2.6vw, 3.5rem);
	font-stretch: 110%;
	font-weight: 720;
	line-height: 1.04;
	letter-spacing: -0.025em;
	text-wrap: balance;
}

.vehicle-head__sub {
	max-width: 60ch;
	margin: 14px 0 0;
	color: var(--soft);
	font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.25rem);
	line-height: 1.5;
	text-wrap: pretty;
}

.vehicle-head__price {
	margin: 0;
	font-size: clamp(1.75rem, 1.2rem + 1.8vw, 2.75rem);
	font-stretch: 110%;
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: -0.01em;
	white-space: nowrap;
}

.vehicle-head__sold {
	display: inline-block;
	margin-left: 12px;
	padding: 5px 9px 4px;
	background: var(--red);
	font-size: 0.6875rem;
	font-stretch: 125%;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	vertical-align: middle;
}

/* --- Aufbau: Inhalte links, Kontaktbox rechts mitlaufend ----------------- */

.vehicle-layout {
	display: grid;
	gap: clamp(40px, 5vw, 64px);
	margin-top: clamp(24px, 3vw, 48px);
}

@media (min-width: 1000px) {
	.vehicle-layout {
		grid-template-columns: minmax(0, 8fr) minmax(320px, 4fr);
		align-items: start;
		column-gap: clamp(40px, 5vw, 96px);
	}

	.vehicle-contact {
		position: sticky;
		top: calc(var(--header-h) + var(--top) + 24px);
		grid-column: 2;
		grid-row: 1;
	}

	.vehicle-main {
		grid-column: 1;
		grid-row: 1;
	}
}

.vehicle-contact {
	padding: clamp(24px, 2.4vw, 36px);
	border-top: 2px solid var(--bronze);
	background: var(--panel);
}

.vehicle-contact__label {
	margin: 0 0 6px;
	color: var(--sand);
	font-size: 0.75rem;
	font-stretch: 125%;
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: 0.22em;
	text-transform: uppercase;
}

.vehicle-contact__phone {
	display: inline-block;
	margin: 0 0 22px;
	font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
	font-stretch: 108%;
	font-weight: 700;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
}

.vehicle-contact__phone:hover {
	color: var(--red);
}

.vehicle-contact__actions {
	display: grid;
	gap: 10px;
}

.vehicle-contact__actions .btn {
	width: 100%;
	padding-inline: 18px;
}

/* Bis Tablet: Anrufen und WhatsApp nebeneinander, Anfrage darunter */
@media (min-width: 360px) and (max-width: 999.98px) {
	.vehicle-contact__actions {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.vehicle-contact__request {
		grid-column: 1 / -1;
	}
}

/* --- Blöcke: Fahrzeugdaten, Ausstattung, MFK, Beschreibung --------------- */

.vehicle-block {
	margin-bottom: clamp(48px, 5vw, 72px);
}

.vehicle-block__title {
	margin: 0 0 clamp(16px, 2vw, 24px);
	font-size: clamp(1.5rem, 1.1rem + 1.2vw, 2.125rem);
	font-stretch: 110%;
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: -0.015em;
}

.specs {
	display: grid;
	margin: 0;
	border-top: 1px solid var(--line);
}

@media (min-width: 600px) {
	.specs {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: clamp(28px, 3.5vw, 56px);
		border-top: 0;
	}

	.specs__row:nth-child(-n + 2) {
		border-top: 1px solid var(--line);
	}
}

.specs__row {
	display: grid;
	grid-template-columns: 28px minmax(0, 1fr) auto;
	align-items: center;
	gap: 16px;
	padding: 16px 0;
	border-bottom: 1px solid var(--line);
}

.specs__row .icon {
	width: 28px;
	height: 28px;
	color: var(--sand);
	stroke-width: 1.3;
}

.specs dt {
	color: var(--mute);
	font-size: 0.9375rem;
}

.specs dd {
	margin: 0;
	font-weight: 600;
	text-align: right;
	overflow-wrap: anywhere;
}

.equipment {
	display: grid;
	margin: 0;
	padding: 0;
	list-style: none;
	border-top: 1px solid var(--line);
}

@media (min-width: 600px) {
	.equipment {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: clamp(28px, 3.5vw, 56px);
		border-top: 0;
	}

	.equipment li:nth-child(-n + 2) {
		border-top: 1px solid var(--line);
	}
}

.equipment li {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 12px 0;
	border-bottom: 1px solid var(--line);
	line-height: 1.45;
}

.equipment .icon {
	flex: none;
	width: 18px;
	height: 18px;
	margin-top: 2px;
	color: var(--red);
	stroke-width: 2.2;
}

/* Inhalt eines Pakets: kleine zweite Zeile */
.equipment__sub {
	display: block;
	margin-top: 4px;
	color: var(--mute);
	font-size: 0.8125rem;
	line-height: 1.5;
}

/* Zugeklappt (nur mit JavaScript, sonst ist alles sichtbar) */
.js .specs:not(.is-open) .is-extra,
.js .equipment:not(.is-open) .is-extra {
	display: none;
}

.more-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	margin-top: 14px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--white);
	font: inherit;
	font-size: 0.9375rem;
	font-weight: 600;
	cursor: pointer;
}

.more-toggle span {
	text-decoration: underline;
	text-decoration-color: var(--red);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.3em;
}

.more-toggle .icon {
	width: 18px;
	height: 18px;
	color: var(--red);
	stroke-width: 2;
	transition: transform 0.2s ease;
}

.more-toggle[aria-expanded="true"] .icon {
	transform: rotate(180deg);
}

.more-toggle[hidden] {
	display: none;
}

.assurance {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: var(--gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.assurance__item {
	display: grid;
	grid-template-columns: 36px minmax(0, 1fr);
	align-items: center;
	column-gap: 16px;
	padding: 20px 22px;
	background: var(--panel);
}

.assurance__item .icon {
	grid-row: span 2;
	width: 36px;
	height: 36px;
	color: var(--red);
	stroke-width: 1.2;
}

.assurance__title {
	font-size: 1.0625rem;
	font-stretch: 106%;
	font-weight: 650;
}

.assurance__text {
	color: var(--soft);
	font-size: 0.9375rem;
}

.vehicle-desc {
	max-width: 72ch;
	color: var(--soft);
	line-height: 1.75;
	overflow-wrap: break-word;
}

.vehicle-desc > :last-child {
	margin-bottom: 0;
}

.vehicle-desc ul {
	padding-left: 1.2em;
}

.js .vehicle-desc.is-clamped:not(.is-open) {
	max-height: 14em;
	overflow: hidden;
	-webkit-mask-image: linear-gradient(180deg, #000 55%, transparent);
	mask-image: linear-gradient(180deg, #000 55%, transparent);
}

.vehicle-as24 {
	margin: 0 0 clamp(64px, 7vw, 112px);
	font-size: 0.8125rem;
}

.vehicle-as24 a {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--mute);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.3em;
}

.vehicle-as24 a:hover {
	color: var(--white);
	text-decoration-color: var(--red);
}

.vehicle-as24 .icon {
	width: 14px;
	height: 14px;
	stroke-width: 2;
}

/* --- Weitere Fahrzeuge -------------------------------------------------- */

.vehicles--more {
	padding-block: clamp(64px, 7vw, 120px);
	border-top: 1px solid var(--line);
}

@media (min-width: 1080px) {
	.cars--3 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* ==========================================================================
   Vollbild-Galerie: wischen, Pfeile, Tastatur
   ========================================================================== */

.lightbox {
	position: fixed;
	inset: 0;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	background: #050505;
	color: var(--white);
}

.lightbox[open] {
	display: flex;
	flex-direction: column;
}

.lightbox::backdrop {
	background: rgba(0, 0, 0, 0.92);
}

.lightbox__bar {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: space-between;
	height: 64px;
	padding: 0 8px 0 clamp(16px, 3vw, 32px);
}

.lightbox__count {
	font-size: 0.875rem;
	font-weight: 600;
	letter-spacing: 0.04em;
}

.lightbox__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--white);
	cursor: pointer;
}

.lightbox__close .icon {
	width: 28px;
	height: 28px;
	stroke-width: 1.6;
}

.lightbox__close:hover {
	color: var(--red);
}

.lightbox__track {
	display: flex;
	flex: 1 1 auto;
	min-height: 0;
	margin: 0;
	padding: 0;
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	list-style: none;
}

.lightbox__track::-webkit-scrollbar {
	display: none;
}

.lightbox__track:focus-visible {
	outline-offset: -4px;
}

.lightbox__slide {
	display: flex;
	flex: 0 0 100%;
	align-items: center;
	justify-content: center;
	min-width: 0;
	padding: 0 clamp(0px, 7vw, 112px) clamp(12px, 3vw, 40px);
	scroll-snap-align: center;
	scroll-snap-stop: always;
}

.lightbox__slide img {
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: 100%;
	object-fit: contain;
}

.lightbox__nav {
	position: absolute;
	top: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.24);
	background: rgba(16, 16, 16, 0.7);
	color: var(--white);
	cursor: pointer;
	transform: translateY(-50%);
}

.lightbox__nav .icon {
	width: 24px;
	height: 24px;
	stroke-width: 1.8;
}

.lightbox__nav:hover {
	border-color: var(--red-fill);
	background: var(--red-fill);
}

.lightbox__nav:disabled {
	opacity: 0.3;
	pointer-events: none;
}

.lightbox__nav--prev {
	left: clamp(8px, 2vw, 32px);
}

.lightbox__nav--next {
	right: clamp(8px, 2vw, 32px);
}

@media (max-width: 699.98px) {
	.lightbox__nav {
		top: auto;
		bottom: 20px;
		width: 48px;
		height: 48px;
		transform: none;
	}

	.lightbox__slide {
		padding-bottom: 88px;
	}
}
