/**
 * Car archive pages (Current Stock, Sold Out): toolbar, search, grids,
 * pagination and empty states. Grid layouts are defined here per variant;
 * the shared card (components/car-card.css) is not modified by them.
 */

.nscb-archive {
	padding-block: var(--nscb-space-6) var(--nscb-space-section);
}

.nscb-archive__intro {
	max-width: 62ch;
	margin-bottom: var(--nscb-space-6);
	color: var(--nscb-color-text-secondary);
	font-size: var(--nscb-text-lg);
}

.nscb-archive__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--nscb-space-4) var(--nscb-space-6);
	margin-bottom: var(--nscb-space-6);
}

/* Results count: a quiet chip beside the search. */
.nscb-archive__summary {
	display: inline-flex;
	align-items: center;
	gap: var(--nscb-space-2);
	min-height: 2.5rem;
	padding: 0.4rem 1rem 0.4rem 0.75rem;
	border: 1px solid var(--nscb-edge);
	border-radius: var(--nscb-radius-pill);
	background-color: var(--nscb-surface-raised);
	color: var(--nscb-color-text);
	font-family: var(--nscb-font-body);
	font-size: var(--nscb-text-sm);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.01em;
}

.nscb-archive__summary::before {
	content: "";
	flex: none;
	width: 0.45rem;
	height: 0.45rem;
	border-radius: 50%;
	background-color: var(--nscb-color-highlight);
	box-shadow: 0 0 0 3px var(--nscb-highlight-soft);
}

/* Sold Out: a silver dot, as on the sold status pill. */
.nscb-archive--sold .nscb-archive__summary::before {
	background-color: var(--nscb-color-text-secondary);
	box-shadow: none;
}

/* ---------- Search: one app-style bar (field with the action set inside) ---------- */

/* The field spans the whole row and the submit button sits over its right
   end, so they read as a single control; the clear link drops below. */
.nscb-search {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	width: 100%;
	max-width: 38rem;
}

.nscb-search__field {
	position: relative;
	grid-column: 1 / -1;
	grid-row: 1;
	min-width: 0;
}

.nscb-search__icon {
	position: absolute;
	top: 50%;
	left: var(--nscb-space-5);
	width: 1.125rem;
	height: 1.125rem;
	color: var(--nscb-color-text-secondary);
	transform: translateY(-50%);
	pointer-events: none;
}

.nscb-search__input {
	width: 100%;
	min-height: 3.75rem;
	padding: var(--nscb-space-3) 7.5rem var(--nscb-space-3) 3.25rem;
	border: 1px solid var(--nscb-edge-strong);
	border-radius: var(--nscb-radius-pill);
	background: var(--nscb-surface-card);
	box-shadow: var(--nscb-edge-light), var(--nscb-shadow-card);
	color: var(--nscb-color-text);
	font-size: max(1rem, var(--nscb-text-sm)); /* ≥16px avoids iOS zoom on focus. */
	transition: border-color var(--nscb-duration-fast) var(--nscb-ease-standard), box-shadow var(--nscb-duration-fast) var(--nscb-ease-standard);
	-webkit-appearance: none;
	appearance: none;
}

.nscb-search__input::placeholder {
	color: var(--nscb-color-text-secondary);
	opacity: 0.8;
}

.nscb-search__input::-webkit-search-cancel-button {
	display: none;
}

.nscb-search__input:hover {
	border-color: color-mix(in srgb, var(--nscb-color-text) 26%, transparent);
}

.nscb-search__input:focus {
	border-color: var(--nscb-color-highlight);
	box-shadow: 0 0 0 4px var(--nscb-highlight-soft), var(--nscb-shadow-card);
}

/* The field shows its own highlight ring; no second outline. */
.nscb-search__input:focus-visible {
	outline: none;
}

.nscb-search__field:focus-within .nscb-search__icon {
	color: var(--nscb-color-highlight);
}

/* The key action of the page, in the highlight color, inside the bar. */
.nscb-search__submit {
	grid-column: 2;
	grid-row: 1;
	z-index: 1;
	min-height: 2.875rem;
	margin-inline-end: 0.4375rem;
	padding-inline: var(--nscb-space-5);
}

.nscb-search__clear {
	display: inline-flex;
	grid-column: 1 / -1;
	align-items: center;
	justify-self: start;
	gap: var(--nscb-space-2);
	min-height: 2.75rem;
	margin-top: var(--nscb-space-2);
	padding-inline: var(--nscb-space-2);
	color: var(--nscb-color-text-secondary);
	font-size: var(--nscb-text-sm);
	text-decoration: none;
}

.nscb-search__clear .nscb-icon {
	width: 1rem;
	height: 1rem;
}

.nscb-search__clear:hover {
	color: var(--nscb-color-text);
}

/* ---------- Grids (layout only; cards are shared) ---------- */

.nscb-car-grid {
	display: grid;
	gap: var(--nscb-space-5);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Gentle staggered entrance for the first cards; CSS only, no hidden state without it. */
.nscb-car-grid__item {
	animation: nscb-card-in 0.6s var(--nscb-ease-out) both;
}

.nscb-car-grid__item:nth-child(2) { animation-delay: 60ms; }
.nscb-car-grid__item:nth-child(3) { animation-delay: 120ms; }
.nscb-car-grid__item:nth-child(4) { animation-delay: 180ms; }
.nscb-car-grid__item:nth-child(n + 5) { animation-delay: 240ms; }

@keyframes nscb-card-in {
	from {
		opacity: 0;
		transform: translateY(1rem);
	}
}

/* Current Stock: one generous card per row on phones (square photo crop keeps
   the car large without a very tall card), then 2 → 3 → 4 columns. */
.nscb-car-grid--stock {
	--nscb-card-ratio: 1 / 1;
	--nscb-card-title-min: 0; /* One card per row: no neighbour to align with. */
	grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 36rem) {
	.nscb-car-grid--stock {
		--nscb-card-ratio: 4 / 5;
		--nscb-card-title-min: calc(2em * var(--nscb-leading-snug));
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 64rem) {
	.nscb-car-grid--stock {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: var(--nscb-space-6) var(--nscb-space-5);
	}
}

@media (min-width: 80rem) {
	.nscb-car-grid--stock {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* Sold Out: a compact horizontal list on phones (thumbnail + details),
   becoming a quieter multi-column gallery on larger screens. */
.nscb-car-grid--sold {
	gap: var(--nscb-space-3);
	grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 47.99rem) {
	.nscb-car-grid--sold .nscb-car-card {
		flex-direction: row;
		align-items: stretch;
	}

	.nscb-car-grid--sold .nscb-car-card {
		--nscb-card-radius: 1.5rem;
		--nscb-card-inset: 0.375rem;
	}

	.nscb-car-grid--sold .nscb-car-card__media {
		flex: 0 0 36%;
		aspect-ratio: 4 / 5;
	}

	.nscb-car-grid--sold .nscb-car-card__body {
		flex: 1 1 auto;
		align-content: center;
		padding: var(--nscb-space-3) var(--nscb-space-2) var(--nscb-space-3) var(--nscb-space-4);
	}

	.nscb-car-grid--sold .nscb-price {
		font-size: var(--nscb-text-lg);
	}

	.nscb-car-grid--sold .nscb-car-card__go {
		width: 2.5rem;
		height: 2.5rem;
	}

	.nscb-car-grid--sold .nscb-car-card__photos {
		display: none;
	}

	.nscb-car-grid--sold .nscb-status {
		top: var(--nscb-space-2);
		left: var(--nscb-space-2);
		padding: 0.3rem 0.55rem;
		font-size: 0.6875rem;
	}

	.nscb-car-grid--sold .nscb-car-card__title {
		min-height: 0;
	}
}

/* Square crops make the sold gallery read differently from the 4:5 stock grid. */
@media (min-width: 48rem) {
	.nscb-car-grid--sold {
		--nscb-card-ratio: 1 / 1;
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: var(--nscb-space-5);
	}
}

@media (min-width: 80rem) {
	.nscb-car-grid--sold {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* ---------- Pagination: assets/css/components/pagination.css ---------- */

/* Sold Out: the current page uses the neutral colour. */
.nscb-archive--sold .nscb-pagination .page-numbers.current {
	background-color: var(--nscb-color-text);
	box-shadow: none;
	color: var(--nscb-color-bg);
}

/* ---------- No-reload browsing: assets/css/components/browse.css ---------- */

.nscb-archive.is-loading .nscb-search__submit {
	opacity: 0.7;
}

/* Empty state: assets/css/components/empty-state.css. */

@media (prefers-reduced-motion: reduce) {
	.nscb-car-grid__item {
		animation: none;
	}
}
