/*
 * Park finder + browse blocks.
 * Desktop: intro and list on the left, map on the right.
 * Phone (container under 760px): intro, map, list as a bottom sheet over the map.
 */

.bps-finder {
	--bps-line: var(--theme-palette-color-5);
	--bps-surface: var(--theme-palette-color-8);
	--bps-ground: var(--theme-palette-color-7);
	--bps-ink: var(--theme-palette-color-4);
	--bps-text: var(--theme-palette-color-3);
	--bps-accent: var(--theme-palette-color-1);
	container-type: inline-size;
	margin-block: 0 !important;
	border-bottom: 1px solid var(--bps-line);
	background: var(--bps-ground);
}

.bps-finder__grid {
	display: grid;
	grid-template-columns: 380px minmax(0, 1fr);
	grid-template-rows: auto minmax(0, 1fr);
	height: min(700px, calc(100vh - 80px));
	min-height: 560px;
}

/* Intro: inner blocks + search */
.bps-finder__intro {
	grid-column: 1;
	grid-row: 1;
	padding: 26px 22px 16px;
	background: var(--bps-surface);
	border-right: 1px solid var(--bps-line);
}

.bps-finder__intro > :is(h1, h2) {
	font-size: 34px;
	margin: 0;
}

.bps-finder__intro :is(h1, h2) em {
	font-style: normal;
	color: var(--bps-accent);
}

.bps-finder__intro > p {
	margin: 10px 0 16px;
	color: var(--bps-muted);
	font-size: 15px;
}

.bps-search {
	display: flex;
	gap: 8px;
}

.bps-search__field {
	position: relative;
	flex: 1;
	min-width: 0;
	margin: 0;
}

.bps-search__field svg {
	position: absolute;
	left: 12px;
	top: 50%;
	translate: 0 -50%;
	width: 16px;
	height: 16px;
	color: var(--bps-muted);
	pointer-events: none;
}

.bps-search input[type="search"] {
	width: 100%;
	height: 44px;
	padding: 0 12px 0 36px;
	border: 1px solid var(--bps-line);
	border-radius: var(--bps-radius);
	background: var(--bps-ground);
	color: var(--bps-ink);
	font-size: 16px; /* 16px stops iPhone from zooming in */
}

.bps-near {
	flex: none;
	height: 44px;
	padding: 0 14px;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	border: 1px solid var(--bps-scan);
	border-radius: var(--bps-radius);
	color: var(--bps-scan);
	background: color-mix(in srgb, var(--bps-scan) 12%, transparent);
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
}

.bps-near svg {
	width: 16px;
	height: 16px;
}

.bps-near[aria-pressed="true"] {
	background: var(--bps-scan);
	color: var(--bps-surface);
}

.bps-status {
	margin: 8px 0 0;
	font-size: 13px;
	color: var(--bps-muted);
}

.bps-quick {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 12px;
}

.bps-finder .bps-chip,
.bps-browse .bps-chip {
	border: 1px solid transparent;
	cursor: pointer;
	text-decoration: none;
	font: inherit;
	font-size: 13px;
}

.bps-chip .bps-data {
	font-size: 11.5px;
	color: var(--bps-muted);
}

.bps-chip[aria-pressed="true"] {
	border-color: var(--theme-palette-color-1);
	color: var(--theme-palette-color-1);
	background: transparent;
}

/* List */
.bps-finder__list {
	grid-column: 1;
	grid-row: 2;
	display: flex;
	flex-direction: column;
	min-height: 0;
	background: var(--bps-surface);
	border-right: 1px solid var(--bps-line);
}

.bps-sheet-grip {
	display: none;
}

.bps-list-head {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	padding: 10px 22px;
	border-top: 1px solid var(--bps-line);
	border-bottom: 1px solid var(--bps-line);
	font-size: 13px;
	color: var(--bps-muted);
}

.bps-list-head b {
	color: var(--bps-ink);
}

.bps-results {
	list-style: none;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	flex: 1;
	min-height: 0;
}

.bps-result a {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 2px 12px;
	padding: 12px 22px;
	border-bottom: 1px solid var(--bps-line);
	color: inherit;
	text-decoration: none;
}

.bps-result a:hover,
.bps-result.is-active a {
	background: var(--bps-ground);
}

.bps-result__name {
	font-family: var(--bps-font-display);
	font-weight: 700;
	font-size: 15.5px;
	color: var(--bps-ink);
	letter-spacing: -0.01em;
}

.bps-result__dist {
	grid-row: 1;
	grid-column: 2;
	font-size: 12.5px;
	color: var(--bps-scan);
}

.bps-result__where {
	grid-column: 1 / -1;
	font-size: 13px;
	color: var(--bps-muted);
}

.bps-result__teams {
	grid-column: 1 / -1;
	font-size: 13px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bps-empty {
	padding: 28px 22px;
	color: var(--bps-muted);
	font-size: 14px;
}

/* Map */
.bps-finder__map {
	grid-column: 2;
	grid-row: 1 / span 2;
	position: relative;
	min-height: 0;
}

/* Doubled class: WordPress's editor stylesheet (loaded on the front end for
   logged-in admins) sets [role=region]{position:relative}, which would
   otherwise collapse the map to zero height. */
.bps-map.bps-map {
	position: absolute;
	inset: 0;
	background: var(--bps-ground);
}

.bps-map .leaflet-container,
.bps-map.leaflet-container {
	font-family: var(--bps-font-body);
	background: var(--bps-ground);
}

/* Muted street map that matches the brand, and a dark version */
.bps-tiles {
	filter: grayscale(1) contrast(0.92) brightness(1.04) opacity(0.8);
}

:root[data-bps-mode="dark"] .bps-tiles {
	filter: grayscale(1) invert(1) contrast(0.85) brightness(0.8) opacity(0.85);
}

@media (prefers-color-scheme: dark) {
	:root:not([data-bps-mode="light"]) .bps-tiles {
		filter: grayscale(1) invert(1) contrast(0.85) brightness(0.8) opacity(0.85);
	}
}

.bps-map .leaflet-bar {
	border: 1px solid var(--bps-line);
	border-radius: var(--bps-radius);
	overflow: hidden;
	box-shadow: none;
}

.bps-map .leaflet-bar a {
	background: var(--bps-surface);
	color: var(--bps-ink);
	border-color: var(--bps-line);
}

.bps-map .leaflet-control-attribution {
	background: color-mix(in srgb, var(--bps-surface) 85%, transparent);
	color: var(--bps-muted);
	font-size: 11px;
}

.bps-map .leaflet-control-attribution a {
	color: var(--bps-muted);
}

.bps-pin-wrap,
.bps-cluster-wrap {
	background: none;
	border: 0;
}

.bps-pin,
.bps-dot {
	border-radius: 50%;
	background: var(--bps-pin);
	border: 3px solid var(--bps-surface);
	box-shadow: 0 0 0 1px var(--bps-pin);
}

.bps-pin {
	width: 18px;
	height: 18px;
}

.bps-pin.is-approx,
.bps-dot.is-approx {
	background: var(--bps-surface);
	border-color: var(--bps-pin);
	box-shadow: none;
}

.bps-pin.is-active {
	background: var(--bps-ink);
	box-shadow: 0 0 0 4px var(--bps-pin);
}

.bps-pin.is-me {
	background: var(--bps-scan);
	box-shadow: 0 0 0 6px color-mix(in srgb, var(--bps-scan) 25%, transparent);
}

.bps-cluster {
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: var(--bps-ink);
	color: var(--bps-surface);
	font: 600 12.5px var(--bps-font-data);
	border: 3px solid var(--bps-surface);
	box-shadow: 0 0 0 1px var(--bps-ink);
}

.bps-legend {
	position: absolute;
	left: 12px;
	bottom: 24px;
	z-index: 500;
	display: flex;
	gap: 12px;
	padding: 6px 10px;
	border-radius: 8px;
	background: var(--bps-surface);
	border: 1px solid var(--bps-line);
	font-size: 12px;
	color: var(--bps-muted);
}

.bps-legend span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.bps-dot {
	display: inline-block;
	width: 10px;
	height: 10px;
	border-width: 2px;
}

/* Park card */
.bps-card {
	position: absolute;
	z-index: 600;
	top: 14px;
	right: 14px;
	width: 330px;
	max-width: calc(100% - 28px);
	padding: 16px;
	background: var(--bps-surface);
	border: 1px solid var(--bps-line);
	border-radius: var(--bps-radius);
}

.bps-card[hidden] {
	display: none;
}

.bps-card__top {
	display: flex;
	justify-content: space-between;
	gap: 10px;
}

.bps-card .bps-card__name {
	font-size: 21px;
	margin: 0;
}

.bps-card__where {
	color: var(--bps-muted);
	font-size: 13.5px;
	margin-top: 3px;
}

.bps-card dl {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: 6px 14px;
	margin: 14px 0;
	font-size: 13.5px;
}

.bps-card dt {
	color: var(--bps-muted);
	font-weight: 400;
}

.bps-card dd {
	margin: 0;
	color: var(--bps-ink);
}

.bps-fences {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.bps-fences span {
	padding: 2px 7px;
	border-radius: 6px;
	background: var(--bps-chip);
	font-size: 12px;
}

.bps-card__note {
	font-size: 12.5px;
	color: var(--bps-muted);
	border-left: 2px solid var(--bps-pin);
	padding-left: 8px;
	margin: -4px 0 12px;
}

.bps-card__actions {
	display: flex;
	gap: 8px;
}

.bps-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 40px;
	padding: 0 16px;
	border-radius: var(--bps-radius);
	border: 1px solid transparent;
	font-weight: 600;
	font-size: 14px;
	text-decoration: none;
}

.bps-btn--primary {
	background: var(--theme-palette-color-1);
	color: #FFFFFF;
}

.bps-btn--primary:hover {
	background: var(--theme-palette-color-2);
	color: #FFFFFF;
}

.bps-btn--line {
	border-color: var(--bps-line);
	color: var(--bps-ink);
}

.bps-btn--line:hover {
	border-color: var(--bps-text);
	color: var(--bps-ink);
}

.bps-card__close {
	flex: none;
	width: 30px;
	height: 30px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: var(--bps-chip);
	color: var(--bps-ink);
	cursor: pointer;
}

.bps-card__close svg {
	width: 14px;
	height: 14px;
}

/* Browse block */
.bps-browse {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 28px;
}

.bps-browse .bps-browse__label {
	font-family: var(--bps-font-body);
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0;
	color: var(--bps-muted);
	margin: 0 0 10px;
}

.bps-chip-cloud {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.bps-browse .bps-chip {
	background: var(--theme-palette-color-8);
	border-color: var(--theme-palette-color-5);
	color: var(--theme-palette-color-4);
}

.bps-browse .bps-chip:hover {
	border-color: var(--theme-palette-color-1);
}

@media (max-width: 689.98px) {
	.bps-browse {
		grid-template-columns: 1fr;
	}

	.bps-browse .bps-chip:nth-child(n+9) {
		display: none;
	}
}

/* Phone layout */
@container (max-width: 760px) {
	.bps-finder__grid {
		display: block;
		height: auto;
		min-height: 0;
		position: relative;
	}

	.bps-finder__intro {
		border-right: 0;
		padding: 18px 16px 14px;
	}

	.bps-finder__intro > :is(h1, h2) {
		font-size: 27px;
	}

	.bps-finder__intro > p {
		font-size: 14px;
		margin: 6px 0 12px;
	}

	.bps-near__label {
		display: none;
	}

	.bps-near {
		padding: 0 12px;
	}

	.bps-near::after {
		content: "";
	}

	.bps-quick {
		flex-wrap: nowrap;
		overflow-x: auto;
		scrollbar-width: none;
		margin-inline: -16px;
		padding-inline: 16px;
	}

	.bps-quick .bps-chip {
		flex: none;
	}

	.bps-finder__map {
		height: 500px;
	}

	.bps-legend {
		bottom: 66px;
	}

	/* Keep the map credit above the closed park list */
	.bps-map .leaflet-bottom {
		bottom: 56px;
	}

	.bps-finder__list {
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 700;
		border-right: 0;
		border-top: 1px solid var(--bps-line);
		border-radius: 16px 16px 0 0;
		max-height: 56px;
		overflow: hidden;
		transition: max-height 0.25s ease;
	}

	.bps-finder__list.is-open {
		max-height: 300px;
	}

	.bps-sheet-grip {
		display: block;
		width: 38px;
		height: 4px;
		margin: 8px auto 0;
		padding: 0;
		border: 0;
		border-radius: 4px;
		background: var(--bps-line);
		cursor: pointer;
	}

	.bps-list-head {
		border-top: 0;
		padding: 8px 16px 10px;
		cursor: pointer;
	}

	.bps-result a {
		padding: 12px 16px;
	}

	.bps-card {
		top: auto;
		bottom: 0;
		left: 0;
		right: 0;
		width: auto;
		max-width: none;
		z-index: 800;
		border-radius: 16px 16px 0 0;
		padding: 16px 16px 18px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bps-finder__list {
		transition: none;
	}
}

/* ---------- Scorebook look ----------
   Intro on ruled paper, the park list as a lineup card (numbered rows,
   park names in pencil), paper-toned map tiles, clusters drawn like
   circled tallies. */
.bps-finder__intro {
	background-color: var(--bps-ground);
	background-image: linear-gradient(var(--bps-rule) 1px, transparent 1px);
	background-size: 100% 28px;
	border-right: 3px double var(--bps-ink-line);
}

.bps-finder__intro > :is(h1, h2) {
	font-size: 36px;
	line-height: 1.02;
}

/* An emphasized word becomes a pencil note instead of a colored word */
.bps-finder__intro :is(h1, h2) em {
	font-family: var(--bps-font-hand);
	font-weight: 700;
	font-size: 1.12em;
	letter-spacing: 0;
}

.bps-finder__intro > p {
	color: var(--bps-text);
}

.bps-finder .bps-chip {
	border: 1.5px solid var(--bps-ink-line);
}

.bps-chip[aria-pressed="true"],
.bps-finder .bps-chip[aria-pressed="true"] {
	border-color: var(--bps-ink-line);
	background: var(--bps-ink-line);
	color: var(--bps-ground);
}

.bps-chip[aria-pressed="true"] .bps-data {
	color: inherit;
}

.bps-search input[type="search"] {
	border: 1.5px solid var(--bps-ink-line);
	background: var(--bps-surface);
}

.bps-near {
	border-width: 1.5px;
}

.bps-finder__list {
	border-right: 3px double var(--bps-ink-line);
}

.bps-list-head {
	background: var(--theme-palette-color-6);
	border-top: 1.5px solid var(--bps-ink-line);
	border-bottom: 1.5px solid var(--bps-ink-line);
	font-family: var(--bps-font-display);
	font-size: 14px;
	font-weight: 700;
	color: var(--bps-ink);
}

.bps-results {
	counter-reset: bps-lineup;
}

.bps-result {
	counter-increment: bps-lineup;
}

.bps-result a {
	grid-template-columns: 30px minmax(0, 1fr) auto;
	padding-left: 8px;
}

.bps-result a::before {
	content: counter(bps-lineup);
	grid-row: 1 / span 3;
	grid-column: 1;
	padding-top: 6px;
	text-align: center;
	font: 700 13px var(--bps-font-display);
	font-variant-numeric: tabular-nums;
	color: var(--bps-muted);
}

.bps-result__name {
	grid-column: 2;
	font-family: var(--bps-font-hand);
	font-size: 23px;
	font-weight: 700;
	line-height: 1.05;
	letter-spacing: 0;
}

.bps-result__dist {
	grid-column: 3;
	align-self: center;
	font-size: 14px;
	font-weight: 700;
}

.bps-result__where,
.bps-result__teams {
	grid-column: 2 / -1;
}

.bps-result a:hover,
.bps-result.is-active a {
	background: var(--theme-palette-color-6);
}

/* Paper-toned street map */
.bps-tiles {
	filter: grayscale(1) sepia(0.3) contrast(0.88) brightness(1.06) opacity(0.82);
}

.bps-map .leaflet-bar {
	border: 1.5px solid var(--bps-ink-line);
}

.bps-cluster {
	background: var(--bps-surface);
	color: var(--bps-ink);
	font: 700 19px/1 var(--bps-font-hand);
	border: 1.5px dashed var(--bps-ink-line);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--bps-surface) 70%, transparent);
}

.bps-pin.is-active {
	background: var(--bps-ink-line);
}

.bps-legend,
.bps-card {
	border: 1.5px solid var(--bps-ink-line);
	border-radius: var(--bps-radius-sm);
}

.bps-card .bps-card__name {
	font-size: 24px;
}

.bps-fences span {
	border-radius: var(--bps-radius-sm);
	border: 1px solid var(--bps-line);
	background: var(--bps-ground);
	font: 700 13px var(--bps-font-display);
}

.bps-btn {
	font-family: var(--bps-font-display);
	font-size: 16px;
	font-weight: 700;
	border-width: 1.5px;
}

.bps-btn--line {
	border-color: var(--bps-ink-line);
}

.bps-card__close {
	border-radius: var(--bps-radius-sm);
}

@container (max-width: 760px) {
	.bps-finder__intro {
		border-right: 0;
		border-bottom: 3px double var(--bps-ink-line);
	}

	.bps-finder__intro > :is(h1, h2) {
		font-size: 30px;
	}

	.bps-finder__list {
		border-right: 0;
		border-top: 1.5px solid var(--bps-ink-line);
		border-radius: 6px 6px 0 0;
	}

	.bps-card {
		border-radius: 6px 6px 0 0;
	}
}

/* Block editor preview */
.bps-finder-editor {
	border: 1px dashed var(--theme-palette-color-5, #DBE2E6);
	border-radius: 10px;
	padding: 16px;
}

.bps-finder-editor__intro {
	margin-bottom: 12px;
}
