/* Impreza - Image Hotspots */
.hsi-wrap {
	--hsi-color: var(--color-content-primary, #2e9e3e);
	--hsi-size: 24px;
	--hsi-shift: 0px;
	position: relative;
	display: block;
	width: 100%;
	line-height: 1.4;
}
.hsi-stage { position: relative; }
.hsi-wrap .hsi-image {
	display: block;
	width: 100%;
	height: auto;
}

/* Punto */
.hsi-spot {
	position: absolute;
	width: 0;
	height: 0;
	z-index: 2;
}
.hsi-spot.is-open { z-index: 20; }

.hsi-marker {
	position: absolute;
	left: 0;
	top: 0;
	width: var(--hsi-size);
	height: var(--hsi-size);
	margin: 0;
	padding: 0;
	transform: translate(-50%, -50%);
	border: 3px solid #fff;
	border-radius: 50%;
	background: var(--hsi-color);
	box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
	cursor: pointer;
	transition: transform .2s;
}
.hsi-marker::after { /* icona "+" */
	content: "";
	position: absolute;
	inset: 0;
	background:
		linear-gradient(#fff, #fff) center / 50% 2px no-repeat,
		linear-gradient(#fff, #fff) center / 2px 50% no-repeat;
	transition: transform .2s;
}
.hsi-spot.is-open .hsi-marker::after { transform: rotate(45deg); }
.hsi-marker:hover,
.hsi-spot.is-open .hsi-marker { transform: translate(-50%, -50%) scale(1.15); }
.hsi-marker:focus { outline: none; }
.hsi-marker:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.hsi-pulse .hsi-marker::before {
	content: "";
	position: absolute;
	inset: -3px;
	border-radius: 50%;
	background: var(--hsi-color);
	animation: hsi-pulse 2s ease-out infinite;
	z-index: -1;
}
@keyframes hsi-pulse {
	0%   { transform: scale(1);   opacity: .6; }
	100% { transform: scale(2.4); opacity: 0; }
}

/* Tooltip */
.hsi-tip {
	position: absolute;
	width: max-content;
	max-width: 260px;
	padding: 10px 14px;
	background: #1f2a2e;
	color: #fff;
	font-size: 14px;
	text-align: left;
	border-radius: 6px;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity .2s, visibility .2s, margin .2s;
}
.hsi-spot.is-open .hsi-tip {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}
.hsi-tip-title { display: block; font-weight: 700; }
.hsi-tip-title + .hsi-tip-text { display: block; margin-top: 4px; }

/* Freccia */
.hsi-tip::after {
	content: "";
	position: absolute;
	border: 7px solid transparent;
}

/* Sopra */
.hsi-pos-top .hsi-tip {
	bottom: calc(var(--hsi-size) / 2 + 12px);
	left: 0;
	transform: translateX(calc(-50% + var(--hsi-shift)));
}
.hsi-pos-top .hsi-tip::after {
	top: 100%;
	left: calc(50% - var(--hsi-shift));
	margin-left: -7px;
	border-top-color: #1f2a2e;
}
/* Sotto */
.hsi-pos-bottom .hsi-tip {
	top: calc(var(--hsi-size) / 2 + 12px);
	left: 0;
	transform: translateX(calc(-50% + var(--hsi-shift)));
}
.hsi-pos-bottom .hsi-tip::after {
	bottom: 100%;
	left: calc(50% - var(--hsi-shift));
	margin-left: -7px;
	border-bottom-color: #1f2a2e;
}
/* Sinistra */
.hsi-pos-left .hsi-tip {
	right: calc(var(--hsi-size) / 2 + 12px);
	top: 0;
	transform: translateY(-50%);
}
.hsi-pos-left .hsi-tip::after {
	left: 100%;
	top: 50%;
	margin-top: -7px;
	border-left-color: #1f2a2e;
}
/* Destra */
.hsi-pos-right .hsi-tip {
	left: calc(var(--hsi-size) / 2 + 12px);
	top: 0;
	transform: translateY(-50%);
}
.hsi-pos-right .hsi-tip::after {
	right: 100%;
	top: 50%;
	margin-top: -7px;
	border-right-color: #1f2a2e;
}

/* Mobile: punti più piccoli, tooltip sempre sopra/sotto e tenuti dentro lo schermo via JS */
@media (max-width: 767px) {
	.hsi-wrap { --hsi-size: 18px; }
	.hsi-marker { border-width: 2px; }
	.hsi-tip { max-width: min(260px, calc(100vw - 24px)); font-size: 13px; }

	.hsi-pos-left .hsi-tip,
	.hsi-pos-right .hsi-tip {
		top: auto;
		right: auto;
		bottom: calc(var(--hsi-size) / 2 + 12px);
		left: 0;
		transform: translateX(calc(-50% + var(--hsi-shift)));
	}
	.hsi-pos-left .hsi-tip::after,
	.hsi-pos-right .hsi-tip::after {
		top: 100%;
		right: auto;
		left: calc(50% - var(--hsi-shift));
		margin: 0 0 0 -7px;
		border-color: transparent;
		border-top-color: #1f2a2e;
	}
}

/* ---- Numeri sui punti + legenda ---- */
.hsi-marker .hsi-num {
	display: none;
	position: absolute;
	inset: 0;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
}
.hsi-legend { display: none; }

.hsi-legend-always .hsi-marker .hsi-num { display: flex; }
.hsi-legend-always .hsi-marker::after { display: none; }
.hsi-legend-always .hsi-legend { display: grid; }

@media (max-width: 767px) {
	.hsi-legend-mobile .hsi-marker .hsi-num { display: flex; }
	.hsi-legend-mobile .hsi-marker::after { display: none; }
	.hsi-legend-mobile .hsi-legend { display: grid; }
	/* Con la legenda visibile il tooltip è superfluo: il tocco evidenzia la voce */
	.hsi-legend-mobile .hsi-tip,
	.hsi-legend-always .hsi-tip { display: none; }
	.hsi-spot.is-open .hsi-marker { box-shadow: 0 0 0 4px rgba(255, 255, 255, .9), 0 2px 8px rgba(0, 0, 0, .4); }
	.hsi-wrap.hsi-legend-mobile,
	.hsi-wrap.hsi-legend-always { --hsi-size: 20px; }
}

.hsi-legend {
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 8px 24px;
	margin: 16px 0 0;
	padding: 0;
	list-style: none;
}
.hsi-legend li { margin: 0; padding: 0; }
.hsi-legend-item {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	width: 100%;
	margin: 0;
	padding: 6px 8px;
	background: none;
	border: 0;
	border-radius: 6px;
	color: inherit;
	font: inherit;
	font-size: 14px;
	line-height: 1.4;
	text-align: left;
	cursor: pointer;
	transition: background .2s;
}
.hsi-legend-item:hover,
.hsi-legend-item.is-active { background: rgba(0, 0, 0, .05); }
.hsi-legend-item .hsi-num {
	flex: 0 0 22px;
	height: 22px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--hsi-color);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
}
.hsi-legend-body .hsi-tip-title { display: block; font-weight: 700; }
.hsi-legend-body .hsi-tip-text { display: block; opacity: .8; }

@media (prefers-reduced-motion: reduce) {
	.hsi-pulse .hsi-marker::before { animation: none; }
}
