/*
 * Autocorso · the one stylesheet for visitors.
 *
 * It follows the theme: font and colour are inherited, one accent colour falls back to the primary
 * colour of theme.json and else to the text colour. Every selector has one class of the plugin: it
 * wins over the element rules of a theme (h1, ul, main *), and a theme overrides it with one class of
 * its own, without !important.
 */

.autocorso-page,
.autocorso-list,
.autocorso-vehicle {
	--autocorso-accent: var(--wp--preset--color--primary, currentColor);
	--autocorso-gap: 1.5rem;
	--autocorso-radius: 4px;
	--autocorso-muted: color-mix(in srgb, currentColor 65%, transparent);
	--autocorso-line: color-mix(in srgb, currentColor 15%, transparent);
	--autocorso-surface: color-mix(in srgb, currentColor 5%, transparent);
}

/* Some themes give every element in main a measure; the detail sets its own widths. */
.autocorso-list,
.autocorso-list :where(div, ul, li, p, h2, a, nav),
.autocorso-vehicle,
.autocorso-vehicle :where(div, section, ul, ol, li, dl, dt, dd, p, h1, h2, h3, a) {
	max-width: none;
}

/* The page in a classic theme. */
.autocorso-page {
	box-sizing: border-box;
	width: 100%;
	max-width: 1200px;
	margin-inline: auto;
	padding-inline: 1rem;
}

/* The detail: gallery, below it the summary on a phone; beside it from a tablet on. */
.autocorso-vehicle {
	display: grid;
	gap: var(--autocorso-gap);
	grid-template-columns: minmax(0, 1fr);
}

/* Two columns only with something on both sides; :where() keeps one class to override. */
@media (min-width: 782px) {
	.autocorso-vehicle--split {
		grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
		align-items: start;
	}

	:where(.autocorso-vehicle--split) > .autocorso-vehicle__gallery {
		grid-column: 1;
		grid-row: 1;
	}

	:where(.autocorso-vehicle--split) > .autocorso-vehicle__aside {
		grid-column: 2;
		grid-row: 1 / span 2;
		position: sticky;
		top: calc(var(--wp-admin--admin-bar--height, 0px) + 1rem);
	}

	:where(.autocorso-vehicle--split) > .autocorso-vehicle__body {
		grid-column: 1;
	}
}

.autocorso-vehicle__aside > * + *,
.autocorso-vehicle__body > * + * {
	margin-top: calc(var(--autocorso-gap) * 1.5);
}

.autocorso-vehicle h2 {
	margin: 0 0 0.75rem;
	font-size: 1.5em;
	line-height: 1.25;
}

.autocorso-vehicle h3 {
	margin: 1.5rem 0 0.5rem;
	font-size: 1.1em;
	line-height: 1.3;
}

/* The gallery: a strip to swipe, one photo at a time. */
.autocorso-gallery__strip {
	display: flex;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	margin: 0;
	padding: 0;
	list-style: none;
	border-radius: var(--autocorso-radius);
	background: var(--autocorso-surface);
}

.autocorso-gallery__slide {
	flex: 0 0 100%;
	scroll-snap-align: start;
	aspect-ratio: 4 / 3;
	margin: 0;
	padding: 0;
}

.autocorso-gallery__photo {
	display: block;
	width: 100%;
	max-width: none;
	height: 100%;
	object-fit: contain;
}

.autocorso-gallery__thumbs {
	display: flex;
	gap: 0.5rem;
	overflow-x: auto;
	scrollbar-width: thin;
	margin: 0.5rem 0 0;
	padding: 0 0 0.25rem;
	list-style: none;
}

.autocorso-gallery__thumbs li {
	flex: 0 0 auto;
	margin: 0;
	padding: 0;
}

.autocorso-gallery__thumbs a {
	display: block;
	border-radius: var(--autocorso-radius);
	outline-offset: 2px;
}

.autocorso-gallery__thumbs img {
	display: block;
	width: 96px;
	max-width: none;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: var(--autocorso-radius);
}

.autocorso-gallery--empty {
	display: grid;
	place-items: center;
	aspect-ratio: 4 / 3;
	border-radius: var(--autocorso-radius);
	background: var(--autocorso-surface);
	color: var(--autocorso-muted);
}

.autocorso-gallery--empty p {
	margin: 0;
}

/* With the script: the controls, and full screen as the same strip with a class. */
.autocorso-gallery__controls {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 0.5rem;
}

.autocorso-gallery__controls[hidden] {
	display: none;
}

.autocorso-gallery__button {
	min-width: 2.75rem;
	min-height: 2.75rem;
	padding: 0 0.5rem;
	border: 1px solid var(--autocorso-line);
	border-radius: var(--autocorso-radius);
	background: var(--wp--preset--color--base, #fff);
	color: inherit;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
}

.autocorso-gallery__count {
	margin-right: auto;
	font-variant-numeric: tabular-nums;
}

.autocorso-full {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 1rem;
	background: #000;
	color: #fff;
}

.autocorso-full .autocorso-gallery__strip {
	flex: 1;
	background: none;
}

.autocorso-full .autocorso-gallery__slide {
	aspect-ratio: auto;
}

.autocorso-full .autocorso-gallery__button {
	background: #000;
}

/* The videos: a card of 16:9 that links to the service; after a click the player in the same box. */
.autocorso-videos {
	margin-top: var(--autocorso-gap);
}

.autocorso-videos__list {
	display: grid;
	gap: 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.autocorso-video__link,
.autocorso-video__player {
	box-sizing: border-box;
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	border: 0;
	border-radius: var(--autocorso-radius);
}

.autocorso-video__link {
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	gap: 0.25rem;
	padding: 1rem;
	background: #111;
	color: #fff;
	text-decoration: none;
}

.autocorso-video__link:hover .autocorso-video__play,
.autocorso-video__link:focus-visible .autocorso-video__play {
	text-decoration: underline;
}

.autocorso-video__title {
	font-weight: 600;
	overflow-wrap: break-word;
}

.autocorso-video__play::before {
	content: "\25B6\FE0E\00A0";
}

/* The summary. */
.autocorso-summary__title {
	margin: 0 0 0.75rem;
	font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
	line-height: 1.2;
	letter-spacing: normal;
	overflow-wrap: break-word;
	hyphens: auto;
}

/* An outline, no fill: the accent may be currentColor, which a fill with light text cannot follow. */
.autocorso-badge {
	display: inline-block;
	padding: 0.1em 0.6em;
	border: 1px solid;
	border-radius: var(--autocorso-radius);
	color: var(--autocorso-accent);
	font-size: 0.875em;
	font-weight: 600;
	line-height: 1.5;
}

.autocorso-badge--sold {
	color: inherit;
	border-color: transparent;
	background: var(--autocorso-line);
}

.autocorso-price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.25rem 0.75rem;
	margin: 1rem 0;
}

.autocorso-price__now {
	font-size: 1.75em;
	font-weight: 700;
	line-height: 1.2;
	color: var(--autocorso-accent);
}

.autocorso-price__was,
.autocorso-price__vat {
	color: var(--autocorso-muted);
}

/* Key facts and specifications: label and value per row. */
.autocorso-facts,
.autocorso-specs__list {
	margin: 0;
	padding: 0;
}

.autocorso-facts {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.75rem 1rem;
}

.autocorso-facts dt,
.autocorso-specs__list dt {
	margin: 0;
	padding: 0;
	color: var(--autocorso-muted);
	font-weight: 400;
}

.autocorso-facts dt {
	font-size: 0.875em;
}

.autocorso-facts dd,
.autocorso-specs__list dd {
	margin: 0;
	padding: 0;
	font-weight: 600;
}

.autocorso-specs__list > div {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 1rem;
	padding: 0.5rem 0;
	border-bottom: 1px solid var(--autocorso-line);
}

/* Accessories in columns. */
.autocorso-accessories__list {
	columns: 2 14rem;
	column-gap: var(--autocorso-gap);
	margin: 0;
	padding-left: 1.25em;
	list-style: disc;
}

.autocorso-accessories__list li {
	margin: 0 0 0.25em;
	break-inside: avoid;
}

/* The notice on a sold vehicle. */
.autocorso-sold {
	padding: 1rem;
	border: 1px solid var(--autocorso-line);
	border-radius: var(--autocorso-radius);
	background: var(--autocorso-surface);
}

.autocorso-sold p {
	margin: 0;
}

.autocorso-sold p + p {
	margin-top: 0.5rem;
}

.autocorso-sold a {
	color: var(--autocorso-accent);
	font-weight: 600;
}

/* The list: a grid that fills itself, cards of at least 260 px. */
.autocorso-list__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
	gap: var(--autocorso-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.autocorso-list__item {
	margin: 0;
	padding: 0;
}

.autocorso-list__empty {
	margin: 0;
	color: var(--autocorso-muted);
}

.autocorso-card {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	height: 100%;
}

.autocorso-card__link {
	color: inherit;
	text-decoration: none;
}

.autocorso-card__photo {
	display: block;
	width: 100%;
	max-width: none;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: var(--autocorso-radius);
	background: var(--autocorso-surface);
}

.autocorso-card__photo--empty {
	display: grid;
	place-items: center;
	color: var(--autocorso-muted);
}

.autocorso-card__title {
	margin: 0.75rem 0 0;
	font-size: 1.15em;
	line-height: 1.3;
}

.autocorso-card__link:hover .autocorso-card__title,
.autocorso-card__link:focus-visible .autocorso-card__title {
	text-decoration: underline;
}

.autocorso-card .autocorso-badge {
	align-self: flex-start;
}

.autocorso-card .autocorso-price {
	margin: 0;
}

.autocorso-card .autocorso-price__now {
	font-size: 1.25em;
}

.autocorso-card__facts {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1rem;
	margin: auto 0 0;
	padding: 0;
	list-style: none;
	color: var(--autocorso-muted);
	font-size: 0.875em;
}

.autocorso-pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: calc(var(--autocorso-gap) * 1.5);
}

.autocorso-pagination .page-numbers {
	padding: 0.25em 0.75em;
	border: 1px solid var(--autocorso-line);
	border-radius: var(--autocorso-radius);
}

.autocorso-pagination .current {
	background: var(--autocorso-accent);
	color: var(--wp--preset--color--base, #fff);
}

@media (prefers-reduced-motion: reduce) {
	.autocorso-gallery__strip {
		scroll-behavior: auto;
	}
}
