/**
 * VWE inventory — surround only.
 *
 * Everything here styles OUR container. The vehicle listing itself is rendered
 * cross-origin by VWE and cannot be restyled from this document; no rule below
 * attempts to. The goal is that the seam between the custom design and the
 * embed reads as a deliberate panel rather than a broken one.
 */

.sd-inventory {
	--sd-inv-radius: 12px;
	position: relative;
}

/* ---------- Focus bar ---------- */

/* Shown once the visitor navigates inside the inventory, in place of the page's
   marketing intro. Sticks under the navigation strip so the way back is always
   one click away. */
/* A zero-height marker directly above the bar. When it scrolls out of view the
   bar has left its original position, which is how the stuck state is detected —
   `position: sticky` itself fires no event. */
.sd-inventory__sentinel {
	height: 1px;
	margin-bottom: -1px;
	pointer-events: none;
}

.sd-inventory__focusbar {
	position: sticky;
	top: var(--sd-nav-offset, 52px);
	z-index: 20;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 0.75rem 1.5rem;
	margin-bottom: 1.5rem;
	padding: 0.875rem 1rem;
	background: #fff;
	border: 1px solid var(--sd-line, #dde1e5);
	border-radius: var(--sd-inv-radius);
	box-shadow: 0 1px 2px rgba(23, 25, 28, 0.04);

	/* Entrance when focus mode engages. */
	animation: sd-focusbar-in 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;

	/* Lift/settle when it detaches from or returns to its starting position.
	   Every property here is cheap to animate. */
	transition:
		box-shadow 320ms cubic-bezier(0.2, 0.8, 0.2, 1),
		padding 320ms cubic-bezier(0.2, 0.8, 0.2, 1),
		border-color 320ms cubic-bezier(0.2, 0.8, 0.2, 1),
		background-color 320ms cubic-bezier(0.2, 0.8, 0.2, 1),
		transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Stuck: lifts off the page — tighter, elevated, slightly translucent. */
.sd-inventory__focusbar.is-stuck {
	padding-block: 0.5rem;
	transform: scale(0.995);
	background: rgba(255, 255, 255, 0.94);
	backdrop-filter: saturate(1.4) blur(8px);
	border-color: rgba(23, 25, 28, 0.09);
	box-shadow: 0 10px 28px rgba(23, 25, 28, 0.14);
}

@keyframes sd-focusbar-in {
	from { opacity: 0; transform: translateY(-8px); }
	to   { opacity: 1; transform: none; }
}

.sd-inventory__back {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	min-height: 44px;
	padding: 0 0.25rem;
	font-family: var(--sd-font-heading, "Manrope", sans-serif);
	font-size: 0.9375rem;
	font-weight: 700;
	color: var(--sd-ink, #17191c);
	text-decoration: none;
	transition: color 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sd-inventory__back:hover { color: var(--sd-red, #d71920); }
.sd-inventory__back .sd-icon {
	color: var(--sd-red, #d71920);
	transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sd-inventory__back:hover .sd-icon { transform: translateX(-3px); }

.sd-inventory__focusnote {
	margin: 0;
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--sd-muted, #8a929a);
	/* Label, not editable content — an I-beam cursor here reads as a mistake. */
	cursor: default;
	-webkit-user-select: none;
	user-select: none;
}

@media (max-width: 640px) {
	.sd-inventory__focusbar {
		margin-inline: calc(var(--sd-gutter, 1.125rem) * -1);
		border-radius: 0;
		border-left: 0;
		border-right: 0;
	}
	.sd-inventory__focusnote { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.sd-inventory__focusbar { animation: none; }
	.sd-inventory__focusbar.is-stuck { transform: none; }
	.sd-inventory__back:hover .sd-icon { transform: none; }
}

.sd-inventory__head {
	max-width: 46rem;
	margin: 0 auto 2rem;
	text-align: center;
}

.sd-inventory__title {
	margin: 0 0 0.75rem;
	font-family: var(--sd-font-heading, "Manrope", sans-serif);
	font-size: clamp(1.625rem, 3.2vw, 2.125rem);
	font-weight: 700;
	line-height: 1.18;
	color: var(--sd-ink, #17191c);
}

.sd-inventory__description {
	margin: 0;
	font-size: 1.0625rem;
	color: var(--sd-slate, #626a73);
}

/* The panel the embed sits in. A white surface with a soft border reads as an
   intentional frame, which keeps the vendor's own styling from looking like a
   rendering mistake. */
.sd-inventory__frame {
	position: relative;
	min-height: 420px;
	padding: clamp(0.5rem, 1.5vw, 1rem);
	background: #fff;
	border: 1px solid var(--sd-line, #dde1e5);
	border-radius: var(--sd-inv-radius);
	box-shadow: 0 2px 8px rgba(23, 25, 28, 0.06);
	/* Contains the embed on narrow screens instead of letting it scroll the page. */
	overflow-x: auto;
	overscroll-behavior-x: contain;
	-webkit-overflow-scrolling: touch;
}

.sd-inventory__mount {
	min-height: 0;
	border-radius: calc(var(--sd-inv-radius) - 4px);
	overflow: hidden;
}

/*
 * The listing iframe is rendered server-side and then resized by inventory.js
 * from the frame's own ResizeFrame message. That height is what keeps the
 * listing free of an inner scrollbar, so it is deliberately NOT overridden —
 * no min-height, no max-height, no !important.
 *
 * Only presentation that cannot fight the resize is applied.
 */
.sd-inventory__mount iframe {
	display: block;
	width: 100%;
	border: 0;
}

/* Until the first resize message arrives the server-rendered height applies.
   Should the message never come, the frame scrolls internally rather than
   clipping content. */
.sd-inventory__iframe {
	max-width: 100%;
}

/* ---------- Loading ---------- */

.sd-inventory__loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	/* Reserve the space the embed will occupy, so nothing jumps when it lands. */
	min-height: 400px;
	font-size: 0.9375rem;
	font-weight: 600;
	color: var(--sd-slate, #626a73);
}

.sd-inventory.is-loaded .sd-inventory__loading,
.sd-inventory.is-error .sd-inventory__loading {
	display: none;
}

.sd-inventory__spinner {
	width: 24px;
	height: 24px;
	border: 3px solid var(--sd-line, #dde1e5);
	border-top-color: var(--sd-red, #d71920);
	border-radius: 50%;
	animation: sd-inventory-spin 800ms linear infinite;
}

@keyframes sd-inventory-spin {
	to { transform: rotate(360deg); }
}

/* ---------- Error ---------- */

.sd-inventory__error {
	max-width: 34rem;
	margin: 0 auto;
	padding: clamp(1.5rem, 4vw, 3rem) 1rem;
	text-align: center;
}

.sd-inventory__error h2 {
	margin: 0 0 0.5rem;
	font-family: var(--sd-font-heading, "Manrope", sans-serif);
	font-size: 1.125rem;
	color: var(--sd-ink, #17191c);
}

.sd-inventory__error p {
	margin: 0 0 1.25rem;
	color: var(--sd-slate, #626a73);
	font-size: 0.9375rem;
}

.sd-inventory__error-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	justify-content: center;
	margin-bottom: 0;
}

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
	.sd-inventory__frame {
		min-height: 360px;
		padding: 0.5rem;
		/* Let the panel use the full viewport width — the embed is dense and
		   every pixel of horizontal space counts on a phone. */
		margin-inline: calc(var(--sd-gutter, 1.125rem) * -1);
		border-radius: 0;
		border-left: 0;
		border-right: 0;
	}
	.sd-inventory__loading { min-height: 320px; }
	.sd-inventory__mount iframe { min-height: 560px; }
	.sd-inventory__error-actions .sd-btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
	.sd-inventory__spinner {
		animation-duration: 1600ms;
	}
}
