/* SVG Map Markers — front end (also loaded in the block editor preview). */

.smm-map {
	--smm-color: #d63638;
	--smm-size: 28px;
	--smm-popup-width: 280px;
	--smm-gap: 8px;
	position: relative;
}

.smm-map__viewport {
	position: relative;
}

.smm-map__canvas {
	position: relative;
	line-height: 0;
}

/* Zoom: the canvas is widened (not CSS-scaled) so markers and popups keep their size. */
.smm-map--zoomable .smm-map__viewport {
	overflow: hidden;
	/* The page can still scroll over the map, but pinch and double-tap zoom the map, not the page. */
	touch-action: pan-x pan-y;
}

.smm-map--zoomable .smm-map__canvas {
	width: calc(var(--smm-zoom, 1) * 100%);
	transform: translate(var(--smm-pan-x, 0px), var(--smm-pan-y, 0px));
	transform-origin: 0 0;
}

.smm-map--zoomed .smm-map__viewport {
	cursor: grab;
	touch-action: none;
}

.smm-map--panning .smm-map__viewport {
	cursor: grabbing;
	user-select: none;
}

.smm-map--animate .smm-map__canvas {
	transition: width 0.2s ease, transform 0.2s ease;
}

.smm-zoom {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 20;
	display: flex;
	flex-direction: column;
	border-radius: 6px;
	background: #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
	overflow: hidden;
}

.smm-map .smm-zoom__button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: #fff;
	box-shadow: none;
	color: #1e1e1e;
	cursor: pointer;
}

.smm-map .smm-zoom__button + .smm-zoom__button {
	border-top: 1px solid #e0e0e0;
}

.smm-map .smm-zoom__button:hover,
.smm-map .smm-zoom__button:focus {
	background: #f0f0f0;
	color: #1e1e1e;
}

.smm-map .smm-zoom__button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -3px;
}

.smm-map .smm-zoom__button:disabled {
	background: #fff;
	color: #b0b0b0;
	cursor: default;
}

.smm-zoom__button svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.smm-map__image {
	display: block;
	width: 100%;
	max-width: none;
	height: auto;
}

/* Markers — reset theme button styles first. */
.smm-map .smm-marker {
	position: absolute;
	z-index: 2;
	display: block;
	width: var(--smm-size);
	height: var(--smm-size);
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transform: translate(-50%, -50%);
	transition: transform 0.15s ease;
}

.smm-map .smm-marker:hover,
.smm-map .smm-marker:focus {
	background: none;
	box-shadow: none;
}

.smm-map .smm-marker:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.smm-marker__icon {
	position: absolute;
	inset: 0;
	background: var(--smm-marker-color, var(--smm-color));
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

.smm-map .smm-marker--static {
	cursor: default;
}

/* Dot: centered on the point. */
.smm-map--dot .smm-marker__icon {
	border: 3px solid #fff;
	border-radius: 50%;
}

.smm-map--dot .smm-marker:hover,
.smm-map--dot .smm-marker[aria-expanded="true"] {
	transform: translate(-50%, -50%) scale(1.15);
	z-index: 3;
}

/* Pin: the tip of the pin sits on the point. */
.smm-map--pin .smm-marker {
	transform: translate(-50%, calc(-50% - var(--smm-size) * 0.72));
}

.smm-map--pin .smm-marker:hover,
.smm-map--pin .smm-marker[aria-expanded="true"] {
	transform: translate(-50%, calc(-50% - var(--smm-size) * 0.72 - 3px));
	z-index: 3;
}

.smm-map--pin .smm-marker__icon {
	border-radius: 50% 50% 50% 0;
	transform: rotate(-45deg);
}

.smm-map--pin .smm-marker__icon::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36%;
	height: 36%;
	border-radius: 50%;
	background: #fff;
	transform: translate(-50%, -50%);
}

/* Hover label. Scoped under .smm-map so theme rules (e.g. uppercase or bold buttons) don't leak in. */
.smm-map .smm-marker__label {
	position: absolute;
	bottom: calc(100% + 6px);
	left: 50%;
	padding: 4px 8px;
	border-radius: 3px;
	background: rgba(0, 0, 0, 0.85);
	color: #fff;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.3;
	text-transform: none;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transform: translateX(-50%);
	transition: opacity 0.15s ease;
}

.smm-marker:hover .smm-marker__label,
.smm-marker:focus-visible .smm-marker__label {
	opacity: 1;
}

.smm-marker[aria-expanded="true"] .smm-marker__label {
	opacity: 0;
}

/* Visually hidden, still read by screen readers. */
.smm-map .smm-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Popup. */
.smm-map {
	--smm-offset-above: calc(var(--smm-size) / 2 + var(--smm-gap));
	--smm-offset-below: calc(var(--smm-size) / 2 + var(--smm-gap));
}

.smm-map--pin {
	--smm-offset-above: calc(var(--smm-size) * 1.45 + var(--smm-gap));
	--smm-offset-below: var(--smm-gap);
}

.smm-popup {
	--smm-tx: -50%;
	--smm-ty: calc(-100% - var(--smm-offset-above));
	position: absolute;
	z-index: 10;
	box-sizing: border-box;
	width: var(--smm-popup-width);
	max-width: calc(100vw - 16px);
	padding: 16px 36px 16px 16px;
	border-radius: 6px;
	background: #fff;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
	color: #1e1e1e;
	font-size: 15px;
	line-height: 1.5;
	transform: translate(var(--smm-tx), var(--smm-ty));
}

.smm-popup[hidden] {
	display: none;
}

.smm-popup--below {
	--smm-ty: var(--smm-offset-below);
}

.smm-popup--start {
	--smm-tx: -24px;
}

.smm-popup--end {
	--smm-tx: calc(-100% + 24px);
}

.smm-popup__title {
	margin: 0 0 6px;
	font-size: 1.05em;
	font-weight: 700;
	line-height: 1.3;
}

.smm-popup__content > :first-child {
	margin-top: 0;
}

.smm-popup__content > :last-child {
	margin-bottom: 0;
}

.smm-popup__link {
	display: inline-block;
	margin-top: 8px;
	font-weight: 600;
}

.smm-map .smm-popup__close {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 28px;
	height: 28px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	box-shadow: none;
	color: #555;
	font-size: 22px;
	line-height: 28px;
	text-align: center;
	cursor: pointer;
}

.smm-map .smm-popup__close:hover,
.smm-map .smm-popup__close:focus {
	background: #f0f0f0;
	color: #1e1e1e;
}

/* Touch: bigger buttons, in a row below the map so they never cover markers. */
@media (pointer: coarse) {
	.smm-zoom {
		position: static;
		flex-direction: row;
		width: max-content;
		margin: 8px 0 0 auto;
	}

	.smm-map .smm-zoom__button {
		width: 44px;
		height: 44px;
	}

	.smm-map .smm-zoom__button + .smm-zoom__button {
		border-top: 0;
		border-left: 1px solid #e0e0e0;
	}

	.smm-zoom__button svg {
		width: 18px;
		height: 18px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.smm-map .smm-marker,
	.smm-map .smm-marker__label,
	.smm-map--animate .smm-map__canvas {
		transition: none;
	}
}
