.map-block {
	height: 100svh;
	max-height: 800px;
	position: relative;
	padding: 0 var(--gap);
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	overflow: hidden;
}

.map-inner {
	position: relative;
	z-index: 1000;
	max-width: var(--wide-width);
	flex-grow: 1;
	height: 100%;
	display: flex;
	margin: auto;
	width: 100%;
	align-items: flex-end;
	flex-direction: column;
	transition: transform 0.4s ease;
	pointer-events: none;
}

.map-content .map-collapse-btn,
.map-content .wp-block-button__link {
	pointer-events: auto;
}

.map-inner-box {
	z-index: 2;
	display: flex;
	flex-direction: column;
	flex-grow: 1;
	justify-content: flex-end;
	align-items: flex-end;
	width: 100%;
}

.map-title {
	background-color: var(--nightblack);
	color: var(--white);
	padding: 10px 10px 10px 180px;
	max-width: calc(50% + 110px);
	order: 2;
	width: 100%;
	margin-right: 20px;
}

.map-block.map-organisations .map-title {
	padding: 10px 48px;
}

.map-title h2 {
	margin-bottom: 0;
}

.map-content {
	padding: 40px 110px 40px 180px;
	clip-path: polygon(110px 0%, 100% 0%, calc(100% - 110px) 100%, 0% 100%);
	max-width: calc(50% + 220px);
	margin-bottom: -1px;
	width: 100%;
	margin-right: calc(-90px);
}

.map-collapse-btn {
	position: absolute;
	left: -90px;
	bottom: -53px;
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	color: #85e8f0;
}

.map-collapse-btn:hover {
	color: #fff;
}

.map-block.is-collapsed .map-collapse-btn {
	display: none;
}

.map-block.is-collapsed .map-inner {
	transform: translateY(100%);
}

.map-text {
	position: relative;
	margin-bottom: 15px;
}

.map-bg {
	position: absolute;
	z-index: 1;
	inset: 0;
}

.map-bg--preview {
	background: #ccc;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	color: #666;
}

.map-block:fullscreen {
	max-height: none;
	height: 100dvh;
}

.map-block:fullscreen .map-bg {
	position: absolute;
	inset: 0;
}

.map-fullscreen-btn {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	color: #333;
}

.map-fullscreen-btn svg {
	width: 24px;
	height: 24px;
	display: block;
}

/* Leaflet popup sits above the map but below the content panel */
.map-bg .leaflet-popup {
	z-index: 800;
}

/* Suppress focus outlines on tiles and marker shadows */
.map-bg .leaflet-tile,
.map-bg .leaflet-marker-shadow {
	outline: none;
	border: none;
}

.map-bg .leaflet-marker-icon:not(:focus-visible) {
	outline: none;
	border: none;
}

.map-bg .leaflet-marker-icon.is-popup-open {
	filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.75));
}

.map-bg .leaflet-marker-icon:focus-visible {
	outline: 2px solid var(--nightblack);
	outline-offset: 3px;
	border-radius: 50%;
}

.map-bg .leaflet-popup-content img {
	outline: none;
	border: none;
	display: block;
}

/* Map popup card */

.map-popup-wrap {
	position: absolute;
	z-index: 900;
	width: 260px;
	pointer-events: auto;
	filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.25));
}

.map-popup-card {
	background: #fff;
	border-radius: 12px;
	overflow: hidden;
	position: relative;
	z-index: 1;
	font-size: 16px;
}

.map-popup-photo {
	display: block;
}

.map-popup-photo img {
	width: 100%;
	height: 150px;
	object-fit: cover;
	display: block;
	transition: opacity 0.2s;
}

.map-popup-photo:focus,
.map-popup-photo:focus-visible,
.map-popup-photo:focus img,
.map-popup-photo:focus-visible img {
	outline: none;
}

.map-popup-photo:focus img {
	opacity: 0.85;
}

.map-popup-close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.9);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1;
	color: #333;
	padding: 0;
	transition: background 0.2s;
}

.map-popup-close svg {
	width: 20px;
	height: 20px;
	display: block;
}

.map-popup-close:hover {
	background: #fff;
}

.map-popup-close:focus-visible {
	outline: 2px solid #fff;
	box-shadow: 0 0 0 2px var(--nightblack);
}

.map-popup-body {
	padding: 12px 14px 14px;
	font-size: 14px;
}

.map-popup-name {
	display: block;
	font-size: 16px;
	line-height: 1.1;
	margin-bottom: 2px;
}

.map-popup-subtitle {
	color: #767676;
	margin: 0 0 8px;
}

.map-popup-rows {
	margin-bottom: 0;
}

.map-popup-row {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	line-height: 1.5;
	font-weight: 600;
}

.map-popup-row-value {
	display: flex;
	align-items: center;
	gap: 5px;
}

.map-popup-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	flex-shrink: 0;
}

.map-popup-row--meta {
	font-weight: 400;
	color: #767676;
	font-size: 13px;
}

.map-popup-action {
	background: #efefef;
	border: none;
	border-radius: 6px;
	padding: 5px 12px;
	cursor: pointer;
	color: #333;
	font-size: 14px;
	font-weight: 500;
	margin-top: 12px;
}

.map-popup-action:hover {
	background: #e2e2e2;
}

.map-filters {
	position: absolute;
	width: 0;
	height: 0;
}

.map-bg.is-modal-open {
	pointer-events: none;
}

/* Sensor history link in popup */
.aq-history-link {
	display: inline-block;
	margin-top: 4px;
	font-size: 0.85em;
	color: #042b38;
}

/* History modal */
[x-cloak] {
	display: none !important;
}

.aq-modal-wrap {
	position: fixed;
	inset: 0;
	z-index: 9999;
	overflow-y: auto;
}

.aq-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
}

.aq-modal-positioner {
	position: relative;
	display: flex;
	min-height: 100vh;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
}

.aq-modal-panel {
	position: relative;
	background: #fff;
	border-radius: 12px;
	padding: 32px;
	width: 100%;
	max-width: 820px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
	overflow: hidden;
}

.aq-modal-close {
	position: absolute;
	top: 16px;
	right: 16px;
	background-color: white;
	border: none;
	cursor: pointer;
	padding: 3px;
	color: var(--nightblack);
	line-height: 1;
	transition: background-color 0.3s;
	border-radius: 50%;
}

.aq-modal-close:hover {
	background-color: var(--green);
}
.aq-modal-close svg {
	width: 32px;
	height: 32px;
	display: block;
}

.aq-modal-title {
	font-size: 1.5rem;
	font-weight: 600;
	margin: 0 32px 4px 0;
}

.aq-modal-header {
	display: flex;
	flex-direction: column;
	gap: 15px;
	margin: 0 0 20px;
}

.aq-period-filters {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

.aq-period-filters button {
	background: none;
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 2px 10px;
	font-size: 16px;
	font-weight: 400;
	cursor: pointer;
	color: #333;
	transition:
		border-color 0.3s,
		color 0.3s;
}

.aq-period-filters button:hover {
	border-color: #999;
	color: #222;
}

.aq-period-filters button.is-active {
	background: var(--nightblack);
	border-color: var(--nightblack);
	color: #fff;
	font-weight: 500;
}

.aq-modal-body {
	position: relative;
	margin: 0 -32px -32px;
	padding: 40px 30px 20px;
	background: var(--nightblack);
}

.aq-modal-overlay-msg {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.8);
	color: #666;
	font-size: 0.9em;
	z-index: 1;
}

.aq-modal-canvas {
	width: 100% !important;
	display: block;
}

/* Mobile */

@media (max-width: 1023px) {
	.map-block {
		padding: 0;
		height: auto;
		flex-direction: column-reverse;
	}
	.map-inner {
		position: static;
		flex-direction: column-reverse;
	}

	.map-title {
		position: absolute;
		top: 0;
		padding: 14px var(--gap);
		width: 100%;
		max-width: none;
		margin-right: 0;
	}

	.map-content {
		padding: 40px var(--gap);
		clip-path: none;
		max-width: none;
		margin-right: 0;
	}

	.map-collapse-btn {
		display: none;
	}

	.map-block.is-collapsed .map-content {
		display: block;
	}

	.map-bg {
		width: 100%;
		position: relative;
		aspect-ratio: 1 / 1;
	}
}
