/*
 * Business directory: filters, list and map.
 *
 * Loaded where the block renders - see car_renders_directory(). Kept apart from
 * style.css because it is a self-contained block with a lot of rules; it draws
 * its colours and spacing from the tokens there.
 *
 * Light mode only. The rest of the site has no dark mode, and a single dark
 * block next to a light page reads as a bug rather than a feature.
 */

/* Colours, type and spacing come from the :root tokens in style.css. They used
   to be redeclared here, back when this block lived on a page drawn by the
   legacy header and style.css was not loaded at all. */
.car-directory {
	max-width: var(--car-width);
	margin: 0 auto;
	padding: 24px 16px 48px;
}

.car-directory-heading {
	margin: 0 0 12px;
	font-size: 22px;
	line-height: 1.2;
}

/* Filters -------------------------------------------------------------- */

.car-directory-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 12px;
}

.car-filter {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 7px 13px;
	border: 1px solid var(--car-line);
	border-radius: 999px;
	background: var(--car-surface);
	font: inherit;
	font-size: 14px;
	color: var(--car-ink-2);
	cursor: pointer;
}

.car-filter:hover {
	border-color: var(--car-muted);
	color: var(--car-ink);
}

.car-filter:focus-visible {
	outline: 2px solid var(--car-brand);
	outline-offset: 2px;
}

/* The active state is a filled pill, not a colour swap - the pressed filter has
   to stay obvious to anyone who cannot see the hue shift. */
.car-filter.is-active {
	border-color: var(--car-ink);
	background: var(--car-ink);
	color: #fff;
}

.car-filter-count {
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	opacity: 0.7;
}

.car-directory-status {
	margin: 0 0 16px;
	font-size: 13px;
	color: var(--car-muted);
}

/* Layout --------------------------------------------------------------- */

.car-directory-layout {
	display: grid;
	grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
	gap: 20px;
	align-items: start;
}

/* List ----------------------------------------------------------------- */

.car-directory-list {
	max-height: 74vh;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	list-style: none;
	/* Deliberately not scroll-behavior: smooth. Measured here, smooth turns a
	   programmatic scroll of this element into a no-op - scrollTop is assigned
	   and stays where it was, so clicking a marker selected a card that never
	   came into view. The jump is instant instead, which at least happens. */
}

.car-shop-card {
	position: relative;
	padding: 14px 14px 14px 12px;
	border: 1px solid var(--car-line);
	border-radius: 8px;
	background: var(--car-surface);
	margin-bottom: 8px;
	cursor: pointer;
}

.car-shop-card:hover {
	border-color: var(--car-muted);
}

.car-shop-card.is-hidden {
	display: none;
}

.car-shop-card.is-selected {
	border-color: var(--car-ink);
	box-shadow: 0 0 0 1px var(--car-ink);
}

/* Full bleed inside the card: a photo inset by the card's own padding reads as
   a mistake, and there is little enough of it as it is. */
.car-shop-card-photo {
	display: block;
	margin: -14px -14px 10px -12px;
}

.car-shop-card-photo img {
	display: block;
	width: 100%;
	height: 160px;
	object-fit: cover;
	border-radius: 8px 8px 0 0;
}

.car-shop-name {
	margin: 0 0 6px;
	font-size: 16px;
	line-height: 1.3;
}

/* The card's top right corner, photo or not. The shadow is not decoration: over
   a photograph a pale pill on a pale sky would vanish. */
.car-shop-badge {
	position: absolute;
	top: 8px;
	right: 8px;
	/* A paragraph's default top margin is added to the offset, not ignored by it:
	   without this the badge sits 21px down instead of 8. */
	margin: 0;
	padding: 1px 8px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 600;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

/* With no photo the badge lands beside the name, so the name stops short of it.
   Only where there is a badge to avoid - every other card keeps the full width. */
.car-shop-card.has-badge:not(.has-photo) .car-shop-name {
	padding-right: 78px;
}

.car-shop-badge.is-open {
	background: #edfaef;
	color: #0a6b2d;
}

.car-shop-badge.is-shut {
	background: #f1f0ec;
	color: var(--car-ink-2);
}

/* A row of targets rather than a column of lines: a card is scanned, not read,
   and the label each one carries lives in its tooltip now. */
.car-contacts--card {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 8px 0 0;
}

.car-contacts--card .car-contact {
	margin: 0;
}

.car-contacts--card .car-contact-icon {
	/* The drawing is 24; the box is what it needs to sit in without touching its
	   own border. */
	width: 34px;
	height: 34px;
	border: 1px solid var(--car-line);
	border-radius: 6px;
	background: #fff;
}

.car-contacts--card .car-contact-icon:hover {
	border-color: var(--car-brand);
}

.car-contacts--card .car-contact-icon svg {
	width: 24px;
	height: 24px;
}

/* Simple Icons fill their 24x24 field where Maki leave air around the shape;
   matched exactly, the brand marks come out the heavier of the two. */
.car-contacts--card .car-contact--social .car-contact-icon svg {
	width: 21px;
	height: 21px;
}

.car-shop-name a {
	color: var(--car-ink);
	text-decoration: none;
}

.car-shop-name a:hover {
	text-decoration: underline;
}

.car-shop-cats {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 12px;
	margin: 0 0 6px;
}

.car-shop-cat {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: var(--car-ink-2);
}

.car-shop-address,
.car-shop-hours,
.car-shop-links {
	margin: 0 0 4px;
	font-size: 13px;
	color: var(--car-ink-2);
}

.car-shop-hours {
	white-space: pre-line;
}

.car-shop-links a {
	margin-right: 12px;
	color: var(--car-brand);
}

/* Quieter than the unverified warning below: being off the Row is a fact about
   where the place stands, not a caution about the record. */
.car-shop-offrow {
	margin: 0 0 4px;
	font-size: 12px;
	color: var(--car-muted);
}

.car-shop-unchecked {
	margin: 8px 0 0;
	padding-top: 8px;
	border-top: 1px dashed var(--car-line);
	font-size: 12px;
	color: #8a1f2b;
}

/* Map ------------------------------------------------------------------ */

.car-directory-map-panel {
	position: sticky;
	top: 16px;
}

.car-directory-map {
	height: 74vh;
	min-height: 420px;
	border: 1px solid var(--car-line);
	border-radius: 8px;
}

.car-popup-name {
	display: block;
	font-size: 14px;
	font-weight: 600;
	margin-bottom: 2px;
}

.car-popup-cat,
.car-popup-address {
	display: block;
	font-size: 12px;
	color: var(--car-ink-2);
}

.car-directory-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 16px;
	margin: 10px 0 0;
	padding: 0;
	list-style: none;
	font-size: 12px;
	color: var(--car-ink-2);
}

.car-directory-legend li {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

/* The legend and the filters wear whatever the markers wear - otherwise they
   explain a map that does not look like them. Same markup from
   car_category_marker(), only the sizes differ. */
.car-legend-marker,
.car-filter-marker {
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--car-dot);
	flex: none;
}

.car-legend-marker svg,
.car-filter-marker svg {
	display: block;
	fill: var(--car-ink-on, #fff);
}

.car-legend-marker {
	width: 20px;
	height: 20px;
}

.car-legend-marker svg {
	width: 14px;
	height: 14px;
}

.car-filter-marker {
	width: 18px;
	height: 18px;
}

.car-filter-marker svg {
	width: 12px;
	height: 12px;
}

/* Narrow screens ------------------------------------------------------- */

@media (max-width: 900px) {
	.car-directory-layout {
		grid-template-columns: minmax(0, 1fr);
	}

	/* Map first: on a phone it is the thing worth seeing without scrolling.
	 *
	 * relative, not static: static would cancel the sticky positioning above,
	 * which is all that is wanted here - but it would also stop the panel being
	 * a containing block, and the "Expand map" button inside it is positioned
	 * absolutely. With static the button escapes the map entirely and lands in
	 * the top corner of the page, over the masthead. */
	.car-directory-map-panel {
		position: relative;
		order: -1;
	}

	.car-directory-map {
		height: 52vh;
		min-height: 300px;
	}

	.car-directory-list {
		max-height: none;
		overflow-y: visible;
	}
}
