/**
 * sfx-custom-maps.css — map, consent panel, category chips, marker and popup.
 *
 * Every colour and measure runs through a --sfx-map-* custom property with a
 * built-in default, so the plugin looks right on a bare install and a theme can
 * retint the whole map by redefining a handful of properties on .sfx-map-section
 * (or on :root).
 */

.sfx-map-section {
	--sfx-map-primary: #002d53;
	--sfx-map-on-primary: #fff;
	--sfx-map-accent: #5d9aa4;
	--sfx-map-tint: #dbe9eb;
	--sfx-map-surface: #fff;
	--sfx-map-surface-2: #f2f5f8;
	--sfx-map-border: #dee6ed;
	--sfx-map-text: #1b2b3a;
	--sfx-map-muted: #4a6378;
	--sfx-map-radius: 0;
	--sfx-map-height: clamp(18rem, 45vw, 32rem);

	scroll-margin-top: 2rem;
}

/* Full-bleed by default; [sfx_map bleed="0"] keeps the map inside its column. */
.sfx-map-section__bleed {
	width: 100vw;
	margin-inline: calc(50% - 50vw);
}

.sfx-map {
	position: relative;
	width: 100%;
	min-height: var(--sfx-map-height);
	overflow: hidden;
	background: var(--sfx-map-surface-2);
	border-block: 1px solid var(--sfx-map-border);
}

.sfx-map__canvas {
	position: absolute;
	inset: 0;
}

/* Consent: a tinted panel rather than a preview image — nothing to maintain,
   and no request goes to OpenStreetMap before the click. */
.sfx-map__consent {
	display: grid;
	place-content: center;
	justify-items: center;
	gap: 0.5rem;
	min-height: inherit;
	padding: 2rem;
	text-align: center;
	background: var(--sfx-map-tint);
}

.sfx-map__consent-icon {
	display: inline-flex;
	font-size: 2.5rem;
	color: var(--sfx-map-primary);
}

.sfx-map__consent-title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 400;
	color: var(--sfx-map-primary);
}

.sfx-map__consent-note {
	margin: 0;
	max-width: 32rem;
	font-size: 0.875rem;
	line-height: 1.6;
	color: var(--sfx-map-muted);
}

.sfx-map__consent-btn {
	margin-top: 0.75rem;
	padding: 0.75em 1.5em;
	font: inherit;
	line-height: 1;
	color: var(--sfx-map-on-primary);
	background: var(--sfx-map-primary);
	border: 1px solid var(--sfx-map-primary);
	border-radius: var(--sfx-map-radius);
	cursor: pointer;
}

.sfx-map__consent-btn:hover {
	background: color-mix(in srgb, var(--sfx-map-primary) 88%, #fff);
}

.sfx-map__consent-btn:focus-visible {
	outline: 2px solid var(--sfx-map-primary);
	outline-offset: 2px;
}

/* An uploaded icon of any colour, painted in the current text colour. */
.sfx-map-icon {
	display: inline-block;
	width: 1em;
	height: 1em;
	flex: none;
	background-color: currentColor;
	-webkit-mask-image: var(--sfx-map-icon);
	mask-image: var(--sfx-map-icon);
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-position: center;
	mask-position: center;
	-webkit-mask-size: contain;
	mask-size: contain;
}

/* Category chips: multi-select, none pressed = all markers visible. */
.sfx-map-filter {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem;
	margin-bottom: 1.5rem;
}

.sfx-map-filter__chip {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	padding: 0.5em 1em;
	font: inherit;
	font-size: 1rem;
	font-weight: 400;
	line-height: 1.2;
	color: var(--sfx-map-text);
	background: var(--sfx-map-surface);
	border: 1px solid var(--sfx-map-border);
	border-radius: var(--sfx-map-radius);
	white-space: nowrap;
	cursor: pointer;
	transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.sfx-map-filter__chip:hover {
	border-color: var(--sfx-map-accent);
}

.sfx-map-filter__chip[aria-pressed="true"] {
	color: var(--sfx-map-on-primary);
	background: var(--sfx-map-primary);
	border-color: var(--sfx-map-primary);
}

.sfx-map-filter__chip:focus-visible {
	outline: 2px solid var(--sfx-map-primary);
	outline-offset: 2px;
}

.sfx-map-filter__chip .sfx-map-icon {
	font-size: 1.125rem;
}

/* Marker: navy circle with a white category icon and a small tip (divIcon). */
.sfx-map-marker__pin {
	position: relative;
	display: grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	font-size: 1.25rem;
	color: var(--sfx-map-on-primary, #fff);
	background: var(--sfx-map-primary, #002d53);
	border: 2px solid var(--sfx-map-on-primary, #fff);
	border-radius: 50%;
	box-shadow: 0 4px 12px rgba(0, 17, 34, 0.28);
}

.sfx-map-marker__pin::after {
	content: "";
	position: absolute;
	left: 50%;
	top: calc(100% - 2px);
	translate: -50%;
	border: 6px solid transparent;
	border-top: 8px solid var(--sfx-map-primary, #002d53);
}

/* Leaflet chrome, tied back to the map's own properties. */
.sfx-map .leaflet-container {
	font: inherit;
	font-size: 0.75rem;
}

.sfx-map .leaflet-bar {
	border: 1px solid var(--sfx-map-border);
	border-radius: var(--sfx-map-radius);
	box-shadow: 0 4px 16px rgba(0, 17, 34, 0.1);
	overflow: hidden;
}

.sfx-map .leaflet-touch .leaflet-bar a,
.sfx-map .leaflet-bar a {
	width: 2.25rem;
	height: 2.25rem;
	line-height: 2.25rem;
	color: var(--sfx-map-primary);
	border-bottom-color: var(--sfx-map-border);
}

.sfx-map .leaflet-bar a:hover {
	background: var(--sfx-map-surface-2);
}

.sfx-map .leaflet-control-attribution {
	font-size: 0.75rem;
	color: var(--sfx-map-muted);
	background: color-mix(in srgb, var(--sfx-map-surface) 88%, transparent);
}

.sfx-map .leaflet-control-attribution a {
	color: var(--sfx-map-primary);
}

/* Fixed popup layout: image, title, text, address, link. */
.sfx-map__popup .leaflet-popup-content-wrapper {
	padding: 0;
	color: var(--sfx-map-text);
	background: var(--sfx-map-surface);
	border: 1px solid var(--sfx-map-border);
	border-radius: var(--sfx-map-radius);
	box-shadow: 0 8px 24px rgba(0, 17, 34, 0.14);
	overflow: hidden;
}

.sfx-map__popup .leaflet-popup-content {
	margin: 0;
	font: inherit;
	font-size: 0.9375rem;
	line-height: 1.55;
}

.sfx-map .leaflet-container a.leaflet-popup-close-button {
	top: 0.25rem;
	right: 0.25rem;
	width: 1.5rem;
	height: 1.5rem;
	font-size: 1.1rem;
	line-height: 1.5rem;
	color: var(--sfx-map-primary);
	background: color-mix(in srgb, var(--sfx-map-surface) 82%, transparent);
	border-radius: 50%;
}

.sfx-map-popup__media {
	display: block;
	width: 100%;
	aspect-ratio: 21 / 9;
	object-fit: cover;
}

.sfx-map-popup__body {
	display: grid;
	justify-items: start;
	gap: 0.25rem;
	padding: 0.75rem 1rem 1rem;
}

.sfx-map-popup__title {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
	color: var(--sfx-map-primary);
}

/* Leaflet ships `.leaflet-popup-content p { margin: 17px 0 }`, which outranks a
   single class. Reset it here or the popup falls apart into loose blocks. */
.sfx-map__popup .leaflet-popup-content p {
	margin: 0;
}

.sfx-map-popup__address {
	font-size: 0.8125rem;
	color: var(--sfx-map-muted);
}

.sfx-map-popup__link {
	font-weight: 600;
	color: var(--sfx-map-primary);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.sfx-map-hint {
	padding: 0.75rem 1rem;
	color: #664d03;
	background: #fff3cd;
}
