/* ==========================================================================
   Map Functionality — responsive Sicily map
   Layers (bottom → top): sea background (CSS) → land image → markers + labels.
   All coordinates are percentages of the map, all sizes are "reference pixels"
   multiplied by --so-unit (= current map width / 1600), so everything scales
   together and stays pixel-aligned at any width.
   ========================================================================== */

.so-map-scroll {
	width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.so-responsive-map {
	position: relative;
	width: 100%;
	max-width: 1800px;
	margin: 0 auto;
	overflow: visible;
	line-height: 1;
	container-type: inline-size;
	/* Fallback scale; JS sets the exact value, container queries do it in CSS. */
	--so-unit: 0.6px;

	/* SEA — separate background layer. Swap the image or use a plain colour here. */
	background-color: #b6d2ea;
	background-repeat: no-repeat;
	background-position: 0 0;
	background-size: 100% 100%;
}

@supports (container-type: inline-size) {
	.so-responsive-map {
		--so-unit: calc(100cqw / 1600);
	}
}

/* LAND layer */
.so-responsive-map__land,
.so-responsive-map__image {
	display: block;
	width: 100%;
	height: auto;
	margin: 0;
	padding: 0;
	pointer-events: none;
	user-select: none;
	-webkit-user-drag: none;
}

/* ---------- Hotspot (marker + label) ---------- */

.so-responsive-map .so-point {
	position: absolute;
	left: var(--so-x);
	top: var(--so-y);
	width: calc(var(--so-size) * var(--so-unit));
	height: calc(var(--so-size) * var(--so-unit));
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0;
	background: transparent !important;
	box-shadow: none !important;
	transform: translate(-50%, -50%);
	min-width: 0 !important;
	min-height: 0 !important;
	line-height: 1 !important;
	overflow: visible;
	cursor: pointer;
	z-index: 3;
	-webkit-appearance: none;
	appearance: none;
	outline: none;
}

.so-responsive-map .so-point:hover,
.so-responsive-map .so-point:focus,
.so-responsive-map .so-point:active {
	background: transparent !important;
	box-shadow: none !important;
	border: 0 !important;
	transform: translate(-50%, -50%);
}

/* Bigger invisible tap area (does not move the marker). */
.so-responsive-map .so-point::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: max(100%, 22px);
	height: max(100%, 22px);
	transform: translate(-50%, -50%);
	border-radius: 50%;
}

/* ---------- Markers ---------- */

.so-marker {
	position: absolute;
	inset: 0;
	display: block;
	box-sizing: border-box;
	border-radius: 50%;
	border-style: solid;
	border-color: #000;
	border-width: calc(1.6 * var(--so-unit));
	background: #fff;
	pointer-events: none;
}

/* Province capitals — red circle, black outline. */
.so-marker--province {
	background: #ed1f24;
}

/* Major non-capital cities — larger white circle, black outline. */
.so-marker--city {
	background: #fff;
}

/* Other towns — white circle, black outline. */
.so-marker--town {
	background: #fff;
	border-width: calc(1.3 * var(--so-unit));
}

/* Palermo — red star, black outline. */
.so-marker--capital {
	border: 0;
	border-radius: 0;
	background: transparent;
}

.so-marker--capital svg {
	display: block;
	width: 100%;
	height: 100%;
	overflow: visible;
}

.so-marker--capital polygon {
	fill: #ed1f24;
	stroke: #000;
	stroke-width: 1.8;
	stroke-linejoin: round;
}

.so-point:hover .so-marker,
.so-point:focus-visible .so-marker {
	filter: drop-shadow(0 0 calc(3 * var(--so-unit)) rgba(255, 255, 255, 0.95));
}

.so-point:focus-visible .so-marker {
	outline: calc(2 * var(--so-unit)) solid #d4a84f;
	outline-offset: calc(2 * var(--so-unit));
}

/* ---------- Labels ---------- */

.so-map-label {
	position: absolute;
	left: calc(50% + var(--so-lx) * var(--so-unit));
	top: calc(50% + var(--so-ly) * var(--so-unit));
	transform: translate(-50%, -50%);
	margin: 0;
	padding: 0;
	white-space: nowrap;
	text-align: center;
	font-family: Verdana, "DejaVu Sans", "Bitstream Vera Sans", Geneva, Tahoma, Arial, sans-serif !important;
	font-size: calc(var(--so-font) * var(--so-unit)) !important;
	font-weight: 700 !important;
	font-style: normal !important;
	line-height: 1.2 !important;
	letter-spacing: 0 !important;
	text-transform: none !important;
	color: #111 !important;
	text-shadow:
		0 0 calc(2 * var(--so-unit)) #fff,
		0 0 calc(2 * var(--so-unit)) #fff,
		0 0 calc(3 * var(--so-unit)) #fff;
	pointer-events: auto;
}

.so-point:hover .so-map-label,
.so-point:focus-visible .so-map-label {
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

/* ---------- Zoom / pan viewport ----------
   .so-map-viewport is the fixed window; .so-map-stage is moved/scaled with a CSS
   transform (translate + scale), so markers and labels zoom with the map and stay
   exactly on their positions. --so-zoom holds the current scale. */

.so-map-wrap {
	width: 100%;
	--so-zoom: 1;
}

.so-map-viewport {
	position: relative;
	width: 100%;
	max-width: 1800px;
	margin: 0 auto;
	aspect-ratio: 1600 / 1216;
	overflow: hidden;
	background: #b6d2ea;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	cursor: grab;
	outline: none;
}

.so-map-viewport.is-dragging {
	cursor: grabbing;
}

.so-map-viewport:focus-visible {
	box-shadow: 0 0 0 3px #d4a84f;
}

.so-map-stage {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	transform-origin: 0 0;
	will-change: transform;
}

.so-map-stage .so-responsive-map {
	max-width: none;
}

/* Zoom buttons */
.so-map-controls {
	position: absolute;
	right: 12px;
	bottom: 12px;
	z-index: 10;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.so-map-controls .so-map-ctl {
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0 !important;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid rgba(0, 0, 0, 0.25) !important;
	border-radius: 6px;
	background: #fff !important;
	color: #222 !important;
	font-size: 22px !important;
	font-weight: 500;
	line-height: 1 !important;
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25) !important;
	min-width: 0 !important;
	min-height: 0 !important;
}

.so-map-controls .so-map-ctl:hover,
.so-map-controls .so-map-ctl:focus-visible {
	background: #f2f2f2 !important;
}

.so-map-controls .so-map-ctl[disabled] {
	opacity: 0.4;
	cursor: default;
}

.so-map-hint {
	margin: 8px 0 0;
	font-size: 12px;
	line-height: 1.4;
	color: #666;
}

/* ---------- Readability on small screens ----------
   JS adds .is-zoomed to .so-map-wrap once a label would render at >= 7px on screen.
   Below that (phones at 1x) labels are hidden and markers get a minimum tap size;
   the minimum is divided by the zoom so it does not balloon while zooming in. */

.so-map-wrap:not(.is-zoomed) .so-map-label {
	display: none;
}

.so-map-wrap:not(.is-zoomed) .so-point {
	width: max(calc(var(--so-size) * var(--so-unit)), calc(10px / var(--so-zoom)));
	height: max(calc(var(--so-size) * var(--so-unit)), calc(10px / var(--so-zoom)));
}

.so-map-wrap:not(.is-zoomed) .so-point--province {
	width: max(calc(var(--so-size) * var(--so-unit)), calc(12px / var(--so-zoom)));
	height: max(calc(var(--so-size) * var(--so-unit)), calc(12px / var(--so-zoom)));
}

.so-map-wrap:not(.is-zoomed) .so-point--capital {
	width: max(calc(var(--so-size) * var(--so-unit)), calc(16px / var(--so-zoom)));
	height: max(calc(var(--so-size) * var(--so-unit)), calc(16px / var(--so-zoom)));
}

.so-map-wrap:not(.is-zoomed) .so-marker {
	border-width: max(calc(1.6 * var(--so-unit)), calc(1.5px / var(--so-zoom)));
}

.so-map-wrap:not(.is-zoomed) .so-point::before {
	width: max(100%, calc(24px / var(--so-zoom)));
	height: max(100%, calc(24px / var(--so-zoom)));
}

@media (max-width: 767px) {
	.so-map-controls {
		right: 8px;
		bottom: 8px;
	}

	.so-map-controls .so-map-ctl {
		width: 40px;
		height: 40px;
	}
}

/* ---------- Members tooltip ---------- */

#so-province-tooltip {
	position: fixed;
	display: none;
	z-index: 999999;
	width: 310px;
	max-width: calc(100vw - 30px);
	max-height: 360px;
	overflow-y: auto;
	padding: 16px;
	background: #fff;
	color: #222;
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 12px;
	box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
	font-family: inherit;
}

#so-province-tooltip.is-visible {
	display: block;
}

#so-province-tooltip .so-tooltip-title {
	margin: 0 0 12px;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
}

#so-province-tooltip .so-user {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 0;
	border-top: 1px solid #eee;
}

#so-province-tooltip .so-user-profile {
	display: flex;
	flex: 0 0 48px;
	text-decoration: none;
}

#so-province-tooltip .so-user img {
	width: 48px;
	height: 48px;
	flex: 0 0 48px;
	border-radius: 50%;
	object-fit: cover;
}

#so-province-tooltip .so-user-name {
	display: block;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.35;
	color: #222;
	text-decoration: none;
}

#so-province-tooltip .so-user-name:hover {
	text-decoration: underline;
}

#so-province-tooltip .so-user-details {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

#so-province-tooltip .so-user-stories {
	display: block;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.35;
	color: #777;
	text-decoration: none;
}

#so-province-tooltip .so-user-stories:hover {
	color: #8a6d1f;
	text-decoration: underline;
}

#so-province-tooltip .so-status {
	margin: 0;
	font-size: 14px;
	color: #666;
}

@media (max-width: 767px) {
	#so-province-tooltip {
		left: 15px !important;
		right: 15px;
		bottom: 15px;
		top: auto !important;
		width: auto;
		max-width: none;
	}
}

/* Province chooser (shown when several markers overlap under one tap). */
#so-province-tooltip .so-chooser {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

#so-province-tooltip .so-chooser-item {
	margin: 0;
	padding: 8px 12px !important;
	border: 1px solid #222 !important;
	border-radius: 999px;
	background: #fff !important;
	color: #222 !important;
	font-size: 13px !important;
	font-weight: 600;
	line-height: 1.2 !important;
	cursor: pointer;
	box-shadow: none !important;
}

#so-province-tooltip .so-chooser-item:hover,
#so-province-tooltip .so-chooser-item:focus {
	background: #222 !important;
	color: #fff !important;
}
