/*
 * MapKit frontend styles: map container, pin markers, filter panel, popup.
 */

.mapkit {
	position: relative;
}

.mapkit [data-mapkit-map] {
	width: 100%;
	z-index: 0;
}

/* Re-pin Leaflet's UI font size — theme styles must not scale controls. */
.mapkit .leaflet-container {
	font-size: 0.75rem;
}

.mapkit .leaflet-control-attribution {
	font-size: 0.6875rem;
	line-height: 1.4;
}

.mapkit .leaflet-control-attribution a {
	font-size: inherit;
	line-height: inherit;
}

/* --- Zoom hint (shown on an unmodified wheel over the map) --- */

.mapkit-zoom-hint {
	position: absolute;
	inset: 0;
	/* Above Leaflet's panes (400) and controls (1000). */
	z-index: 1100;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	background: rgba( 0, 0, 0, 0.5 );
	color: #ffffff;
	font-size: 1rem;
	line-height: 1.4;
	text-align: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
	pointer-events: none;
}

.mapkit-zoom-hint.is-visible {
	opacity: 1;
	visibility: visible;
}

@media ( prefers-reduced-motion: reduce ) {
	.mapkit-zoom-hint {
		transition: none;
	}
}

/* --- Pin markers (colored teardrops) --- */

.mapkit-pin {
	background: none;
	border: none;
}

.mapkit-pin svg {
	display: block;
	filter: drop-shadow( 0 2px 3px rgba( 0, 0, 0, 0.3 ) );
}

/* --- Cluster bubbles ---
   Deliberately neutral: a bubble summarises points of several categories at
   once, so it cannot carry a category color. Shape and shadow follow the
   filter panel so both read as map UI rather than as data. */

.mapkit-cluster {
	background: none;
	border: none;
}

.mapkit-cluster span {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	background: #ffffff;
	/* Same neutral as MarkerFactory's fallback pin. */
	border: 3px solid #4a4a4a;
	color: #1a1a1a;
	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1;
	box-shadow: 0 2px 6px rgba( 0, 0, 0, 0.3 );
}

/* Leaflet makes markers keyboard-focusable — clusters are activated with
   Enter to zoom in, so the focus ring has to be visible. */
.mapkit-cluster:focus-visible {
	outline: 2px solid #1a1a1a;
	outline-offset: 3px;
	border-radius: 50%;
}

/* --- Filter panel (top right) --- */

.mapkit-filter__panel {
	background: #ffffff;
	border-radius: 12px;
	box-shadow: 0 6px 24px rgba( 0, 0, 0, 0.18 );
	padding: 1rem 1.25rem;
	min-width: 12.5rem;
}

.mapkit-filter__header {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.75rem;
	font-size: 1rem;
}

.mapkit-filter__icon {
	display: inline-flex;
	color: #555555;
}

.mapkit-filter__header strong {
	flex: 1;
	font-weight: 600;
}

.mapkit-filter__close {
	margin-left: auto;
}

.mapkit-filter__close,
.mapkit-filter__open {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: auto; /* theme sets button { width: 100% } */
	flex: none;
	background: none;
	border: none;
	padding: 0.25rem;
	cursor: pointer;
	color: #555555;
}

.mapkit-filter__close:hover,
.mapkit-filter__open:hover {
	color: #000000;
}

.mapkit-filter__row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	width: 100%;
	background: none;
	border: none;
	padding: 0.375rem 0;
	cursor: pointer;
	font-size: 0.9375rem;
	text-align: left;
	color: inherit;
}

.mapkit-filter__dot {
	width: 1rem;
	height: 1rem;
	border-radius: 50%;
	border: 2px solid rgba( 0, 0, 0, 0.15 );
	flex-shrink: 0;
	transition: opacity 0.15s ease;
}

.mapkit-filter__row[aria-pressed="false"] .mapkit-filter__dot {
	opacity: 0.2;
}

.mapkit-filter__row[aria-pressed="false"] .mapkit-filter__label {
	color: #999999;
}

/* Collapsed state: hide the panel, show the round funnel button. */

.mapkit-filter__open {
	display: none;
	background: #ffffff;
	border-radius: 50%;
	width: 2.5rem;
	height: 2.5rem;
	box-shadow: 0 3px 12px rgba( 0, 0, 0, 0.2 );
}

.mapkit-filter.is-closed .mapkit-filter__panel {
	display: none;
}

.mapkit-filter.is-closed .mapkit-filter__open {
	display: inline-flex;
}

/* --- Popup --- */

/* Explicit typography: theme styles must not scale popup content. */
.mapkit .leaflet-popup-content {
	font-size: 0.875rem;
	line-height: 1.5;
	margin: 0.875rem 1.25rem;
}

/* Bigger than Leaflet's 24px default — the button overlays the popup photo,
   so it needs size and contrast (red + black outline) to stay visible. */
.mapkit .leaflet-container a.leaflet-popup-close-button {
	width: 2.25rem;
	height: 2.25rem;
	font-size: 1.5rem;
	line-height: 2.25rem;
	color: #e02020;
	text-shadow: -1px -1px 0 #000000, 1px -1px 0 #000000, -1px 1px 0 #000000, 1px 1px 0 #000000;
}

.mapkit .leaflet-container a.leaflet-popup-close-button:hover {
	color: #ff4545;
}

.mapkit-popup__category {
	margin: 0 0 0.375rem;
	font-size: 1rem;
	line-height: 1.4;
	font-weight: 600;
}

/* Stacked rows — Leaflet measures popup width unreliably with CSS grid. */
.mapkit-popup {
	min-width: 12rem;
}

.mapkit-popup__fields {
	margin: 0;
}

.mapkit-popup__fields dt {
	font-weight: 600;
	margin: 0.375rem 0 0;
}

.mapkit-popup__fields dd {
	margin: 0;
}

/* Image sits flush against the popup edges — the content margin is undone
   here so the photo spans the full bubble width. The background fills the
   reserved box while the photo is still downloading. */
.mapkit-popup__figure {
	margin: -0.875rem -1.25rem 0.75rem;
	background: #eceff1;
	border-radius: 0.25rem 0.25rem 0 0;
}

/* A fixed height, deliberately not max-height with an intrinsic one: Leaflet
   measures the popup and auto-pans the map the instant it opens, while the
   photo is still loading. An auto height is 0 at that point, so the popup
   would grow past the top of the viewport afterwards and end up clipped.
   Reserving the box makes that first measurement the final one. */
.mapkit-popup__image {
	display: block;
	width: 100%;
	height: 11rem;
	object-fit: cover;
	border-radius: 0.25rem 0.25rem 0 0;
}

/* Photos need more room than a bare key/value list. */
.mapkit-popup--has-image {
	min-width: 16rem;
}
