/**
 * Maxt Offroad Theme — garage.css
 *
 * Styles for the maxtdesign-ymm garage UI (md_ymm_render_garage()) and
 * the sitewide garage modal (md_ymm_render_garage_modal()). The plugin
 * ships zero CSS by design; its md-ymm-garage__* / md-ymm-garage-modal__*
 * classes are the styling contract and this file is the theme-side
 * implementation, translated from the V0 my-garage reference into mxo
 * tokens (overlay + centered ~480px card, mobile bottom sheet).
 *
 * Loaded sitewide when the plugin is active: the modal mounts in
 * footer.php on every page (see inc/enqueue.php).
 *
 * @package maxtoffroad
 */

.md-ymm-garage {
	display: grid;
	gap: 1.5rem;
	max-width: 640px;
}

/* garage.js toggles sections with the hidden attribute; the display
   rules below would otherwise override it (author styles beat the UA's
   [hidden] { display: none }). */
.md-ymm-garage [hidden] {
	display: none !important;
}

.md-ymm-garage__noscript {
	padding: 0.875rem 1.25rem;
	border: 1px solid var(--destructive);
	border-radius: var(--radius-md);
	color: var(--destructive);
	font-size: 0.9375rem;
}

/* ── Active vehicle line ─────────────────────────────────────────── */
.md-ymm-garage__current {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	font-size: 0.9375rem;
}

.md-ymm-garage__current-title {
	font-family: var(--font-display);
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--muted-foreground);
}

.md-ymm-garage__current .md-ymm-garage-label {
	font-weight: 600;
	color: var(--muted-foreground);
}

.md-ymm-garage.md-ymm-has-vehicle .md-ymm-garage-label {
	color: var(--primary);
}

/* ── Status messages ─────────────────────────────────────────────── */
.md-ymm-garage__status {
	padding: 0.75rem 1rem;
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	font-size: 0.875rem;
}

.md-ymm-garage__status--success {
	border-color: oklch(0.55 0.15 145);
	background: oklch(0.95 0.04 145);
	color: oklch(0.35 0.12 145);
}

.md-ymm-garage__status--error {
	border-color: var(--destructive);
	background: oklch(0.96 0.03 25);
	color: var(--destructive);
}

/* ── Section headings ────────────────────────────────────────────── */
.md-ymm-garage__heading {
	margin: 0 0 0.75rem;
	font-family: var(--font-display);
	font-size: 0.8125rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--muted-foreground);
}

/* ── Saved vehicles list ─────────────────────────────────────────── */
.md-ymm-garage__empty {
	display: block;
	padding: 2rem 1.5rem;
	border: 1px dashed var(--border);
	border-radius: var(--radius-md);
	background: var(--card);
	text-align: center;
	font-size: 0.875rem;
	color: var(--muted-foreground);
}

.md-ymm-garage__vehicles {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.75rem;
}

.md-ymm-garage__vehicle {
	display: flex;
	align-items: stretch;
	gap: 0.5rem;
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	background: var(--card);
	padding: 0.875rem 1rem;
	transition: border-color 150ms ease, box-shadow 150ms ease;
}

.md-ymm-garage__vehicle:hover {
	border-color: var(--primary);
	box-shadow: var(--shadow-sm, 0 1px 2px rgb(0 0 0 / 0.08));
}

.md-ymm-garage__vehicle--primary {
	border-color: var(--primary);
}

.md-ymm-garage__vehicle-select {
	display: flex;
	flex: 1;
	align-items: center;
	gap: 0.75rem;
	min-width: 0;
	background: none;
	border: 0;
	padding: 0;
	text-align: left;
	font: inherit;
	color: var(--foreground);
	cursor: pointer;
}

.md-ymm-garage__vehicle-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	flex-shrink: 0;
	border-radius: 999px;
	background: var(--muted);
	color: var(--primary);
}

.md-ymm-garage__vehicle-info {
	display: grid;
	gap: 0.125rem;
	min-width: 0;
}

.md-ymm-garage__vehicle-label {
	font-weight: 600;
	font-size: 0.9375rem;
	line-height: 1.3;
}

.md-ymm-garage__vehicle-trim {
	font-size: 0.8125rem;
	color: var(--muted-foreground);
}

.md-ymm-garage__primary-badge {
	margin-left: auto;
	flex-shrink: 0;
	padding: 0.125rem 0.625rem;
	border-radius: 999px;
	background: var(--primary);
	color: var(--primary-foreground);
	font-family: var(--font-display);
	font-size: 0.6875rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.md-ymm-garage__vehicle-remove {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	flex-shrink: 0;
	background: none;
	border: 0;
	padding: 0;
	color: var(--muted-foreground);
	cursor: pointer;
	border-radius: var(--radius);
	transition: color 150ms ease, background 150ms ease;
}

.md-ymm-garage__vehicle-remove:hover {
	color: var(--destructive);
	background: oklch(0.96 0.03 25);
}

/* ── Picker form ─────────────────────────────────────────────────── */
.md-ymm-garage__picker {
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	background: var(--card);
	padding: 1.25rem;
	display: grid;
	gap: 1rem;
}

.md-ymm-garage__fields {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.875rem;
}

@media (min-width: 560px) {
	.md-ymm-garage__fields {
		grid-template-columns: repeat(2, 1fr);
	}
}

.md-ymm-garage__field {
	display: grid;
	gap: 0.375rem;
}

.md-ymm-garage__field-label {
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--muted-foreground);
}

.md-ymm-garage__field select {
	width: 100%;
	padding: 0.625rem 0.875rem;
	font: inherit;
	font-size: 0.9375rem;
	color: var(--foreground);
	background: var(--background);
	border: 1px solid var(--input);
	border-radius: var(--radius);
	cursor: pointer;
}

.md-ymm-garage__field select:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.md-ymm-garage__field select:focus {
	outline: 2px solid var(--ring);
	outline-offset: 1px;
	border-color: var(--ring);
}

.md-ymm-garage__form-actions {
	display: flex;
	gap: 0.75rem;
	justify-content: flex-end;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.md-ymm-garage__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.375rem;
	padding: 0.625rem 1.25rem;
	border-radius: var(--radius);
	font-family: var(--font-display);
	font-size: 0.8125rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	cursor: pointer;
	transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.md-ymm-garage__btn--primary {
	background: var(--primary);
	color: var(--primary-foreground);
	border: 2px solid var(--primary);
}

.md-ymm-garage__btn--primary:hover {
	background: var(--accent);
	border-color: var(--accent);
}

.md-ymm-garage__btn--primary:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.md-ymm-garage__btn--ghost {
	background: transparent;
	color: var(--foreground);
	border: 2px solid var(--border);
}

.md-ymm-garage__btn--ghost:hover {
	border-color: var(--foreground);
}

/* ── Add / cap ───────────────────────────────────────────────────── */
.md-ymm-garage__add-actions {
	display: grid;
	gap: 0.5rem;
}

.md-ymm-garage__cap-note {
	margin: 0;
	font-size: 0.8125rem;
	color: var(--muted-foreground);
}

/* ── Loading state ───────────────────────────────────────────────── */
.md-ymm-garage--loading .md-ymm-garage__picker,
.md-ymm-garage--loading .md-ymm-garage__vehicles {
	opacity: 0.6;
}

/* ── Account tab shell ───────────────────────────────────────────── */
.mxo-account-garage__intro {
	max-width: 60ch;
	margin: 0 0 1.5rem;
	font-size: 0.9375rem;
	color: var(--muted-foreground);
	line-height: 1.6;
}

/* ── Sitewide garage modal (md_ymm_render_garage_modal()) ────────── */
/* garage.js locks page scroll while the dialog is open. */
body.md-ymm-modal-open {
	overflow: hidden;
}

.md-ymm-garage-modal {
	position: fixed;
	inset: 0;
	z-index: 1200;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.5rem;
}

/* garage.js toggles the modal with the hidden attribute; the flex rule
   above would otherwise override the UA's [hidden] { display: none }. */
.md-ymm-garage-modal[hidden] {
	display: none !important;
}

.md-ymm-garage-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgb(0 0 0 / 0.6);
}

.md-ymm-garage-modal__dialog {
	position: relative;
	width: 100%;
	max-width: 480px;
	max-height: min(90vh, 100%);
	overflow-y: auto;
	background: var(--background);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-lg, 0 20px 50px rgb(0 0 0 / 0.3));
	padding: 1.25rem 1.5rem 1.5rem;
}

/* Focus lands on the dialog itself on open (tabindex="-1"); the visible
   ring belongs on the interactive children, not the container. */
.md-ymm-garage-modal__dialog:focus {
	outline: none;
}

.md-ymm-garage-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1.25rem;
}

.md-ymm-garage-modal__title {
	display: flex;
	align-items: center;
	gap: 0.625rem;
	margin: 0;
	font-family: var(--font-display);
	font-size: 1.25rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	color: var(--foreground);
}

.md-ymm-garage-modal__title-icon {
	display: flex;
	color: var(--primary);
}

.md-ymm-garage-modal__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	flex-shrink: 0;
	background: none;
	border: 0;
	padding: 0;
	color: var(--muted-foreground);
	cursor: pointer;
	border-radius: var(--radius);
	transition: color 150ms ease, background 150ms ease;
}

.md-ymm-garage-modal__close:hover {
	color: var(--foreground);
	background: var(--muted);
}

.md-ymm-garage-modal__close:focus-visible {
	outline: 2px solid var(--ring);
	outline-offset: 1px;
}

/* The garage app fills the card; the inline 640px cap is the page-flow
   sizing, not the modal's. */
.md-ymm-garage-modal__body .md-ymm-garage {
	max-width: none;
}

/* Mobile: full-width bottom sheet. */
@media (max-width: 559px) {
	.md-ymm-garage-modal {
		padding: 0;
		align-items: flex-end;
	}

	.md-ymm-garage-modal__dialog {
		max-width: none;
		max-height: 92vh;
		border-left: 0;
		border-right: 0;
		border-bottom: 0;
		border-radius: var(--radius-md) var(--radius-md) 0 0;
	}
}

/* ── /vehicles/ quick-picker section ─────────────────────────────── */
.mxo-vhub-garage {
	padding: 2.5rem 0;
	border-bottom: 1px solid var(--border);
}

.mxo-vhub-garage__title {
	font-family: var(--font-display);
	font-size: clamp(1.25rem, 3vw, 1.75rem);
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	margin: 0 0 0.375rem;
}

.mxo-vhub-garage__desc {
	margin: 0 0 1.5rem;
	font-size: 0.9375rem;
	color: var(--muted-foreground);
}
