/* Menú Interactivo con Hotspots – frontend */

.imh {
	--imh-accent: #2f80d1;
	--imh-card-bg: #eef4fb;
	--imh-card-active: #d6e6f7;
	--imh-text: #1f2937;
	--imh-icon: #1f2937;
	--imh-menu-w: 320px;
	--imh-fs: 17px;
	--imh-size: 8;
	--imh-radius: 6px;
	display: grid;
	gap: 24px;
	align-items: start;
	width: 100%;
	color: var(--imh-text);
	box-sizing: border-box;
}
.imh *,
.imh *::before,
.imh *::after { box-sizing: border-box; }

.imh--montserrat,
.imh-modal.imh--montserrat { font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif; }

/* ---------- Disposición ---------- */
.imh--left  { grid-template-columns: var(--imh-menu-w) minmax(0, 1fr); }
.imh--right { grid-template-columns: minmax(0, 1fr) var(--imh-menu-w); }
.imh--right .imh-menu { order: 2; }
.imh--top   { grid-template-columns: minmax(0, 1fr); }

/* ---------- Menú ---------- */
.imh-menu {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.imh--top .imh-menu {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.imh .imh-tab {
	-webkit-appearance: none;
	appearance: none;
	display: flex;
	align-items: center;
	gap: 16px;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	height: auto;
	min-height: 64px;
	margin: 0;
	padding: 12px 20px;
	overflow: hidden;
	white-space: normal;
	word-break: normal;
	overflow-wrap: break-word;
	-webkit-hyphens: auto;
	hyphens: auto;
	background: var(--imh-card-bg);
	color: var(--imh-text);
	border: 0;
	border-left: 4px solid transparent;
	border-radius: var(--imh-radius);
	box-shadow: none;
	font: inherit;
	font-size: var(--imh-fs);
	font-weight: 500;
	line-height: 1.25;
	letter-spacing: normal;
	text-align: left;
	text-transform: none;
	text-decoration: none;
	cursor: pointer;
	transition: background-color .2s ease, border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.imh .imh-tab:hover,
.imh .imh-tab:focus {
	background: var(--imh-card-active);
	color: var(--imh-text);
	transform: translateX(3px);
}
.imh--right .imh-tab:hover,
.imh--right .imh-tab:focus,
.imh--top .imh-tab:hover,
.imh--top .imh-tab:focus { transform: translateY(-2px); }
.imh .imh-tab:focus { outline: none; }
.imh .imh-tab:focus-visible { outline: 2px solid var(--imh-accent); outline-offset: 2px; }
.imh .imh-tab.is-active {
	background: var(--imh-card-active);
	border-left-color: var(--imh-accent);
	box-shadow: 0 6px 18px -10px rgba(15, 23, 42, .35);
}

.imh-tab-icon {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	color: var(--imh-icon);
	transition: color .2s ease;
}
.imh-tab.is-active .imh-tab-icon { color: var(--imh-accent); }
.imh-tab-icon svg,
.imh .imh-tab-icon img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	margin: 0;
}
.imh .imh-tab-label {
	flex: 1 1 auto;
	min-width: 0;
	max-width: 100%;
	white-space: normal;
	overflow-wrap: break-word;
}

/* ---------- Paneles ---------- */
.imh-panels { position: relative; min-width: 0; }
.imh-panel[hidden] { display: none !important; }
.imh-panel.is-active { animation: imh-fade .45s ease both; }

@keyframes imh-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.imh-stage {
	position: relative;
	line-height: 0;
	border-radius: var(--imh-radius);
}
.imh .imh-bg {
	display: block;
	width: 100%;
	max-width: none;
	height: auto;
	margin: 0;
	border-radius: var(--imh-radius);
	user-select: none;
}

/* ---------- Video ---------- */
.imh-video {
	position: relative;
	overflow: hidden;
	width: 100%;
	border-radius: var(--imh-radius);
	background: #000;
	line-height: 0;
}
.imh-video--embed { aspect-ratio: 16 / 9; }
.imh-video iframe,
.imh .imh-video video {
	display: block;
	width: 100%;
	max-width: 100%;
	margin: 0;
	border: 0;
}
.imh-video iframe { position: absolute; inset: 0; height: 100%; }
.imh .imh-video video { height: auto; max-height: 85vh; }

/* ---------- Descripción bajo la imagen / video ---------- */
.imh-desc {
	margin-top: 20px;
	color: var(--imh-text);
	font-size: 16px;
	line-height: 1.65;
	overflow-wrap: break-word;
}
.imh-desc > :first-child { margin-top: 0; }
.imh-desc > :last-child { margin-bottom: 0; }
.imh-desc--text h2,
.imh-desc--text h3,
.imh-desc--text h4 { margin: 1.2em 0 .5em; line-height: 1.3; color: inherit; }
.imh-desc--text p { margin: 0 0 1em; }
.imh-desc--text ul,
.imh-desc--text ol { margin: 0 0 1em 1.3em; padding: 0; }
.imh-desc--text a { color: var(--imh-accent); }
.imh-desc img,
.imh-desc video,
.imh-desc iframe { max-width: 100%; }
.imh-desc img { height: auto; }

.imh-empty {
	display: grid;
	place-items: center;
	min-height: 260px;
	padding: 24px;
	border-radius: var(--imh-radius);
	background: var(--imh-card-bg);
	font-size: var(--imh-fs);
	line-height: 1.4;
}

.imh-caption {
	position: absolute;
	left: 50%;
	bottom: 14px;
	transform: translateX(-50%);
	max-width: 90%;
	color: #fff;
	font-size: clamp(14px, 1.5vw, 22px);
	line-height: 1.3;
	letter-spacing: .02em;
	text-align: center;
	text-shadow: 0 2px 10px rgba(0, 0, 0, .65);
	pointer-events: none;
	z-index: 1;
}

/* ---------- Hotspots ---------- */
.imh-spot {
	position: absolute;
	z-index: 2;
	width: calc(var(--imh-s, var(--imh-size)) * 1%);
	min-width: 34px;
	aspect-ratio: 1 / 1;
	transform: translate(-50%, -50%);
	line-height: 1.5;
}
.imh-spot.is-open { z-index: 30; }

.imh .imh-dot {
	-webkit-appearance: none;
	appearance: none;
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 3px;
	border: 3px solid var(--imh-accent);
	border-radius: 50%;
	background: #fff;
	color: var(--imh-accent);
	box-shadow: 0 8px 22px -6px rgba(0, 0, 0, .55);
	cursor: pointer;
	transition: transform .25s ease, box-shadow .25s ease;
}
.imh .imh-dot:hover,
.imh .imh-dot:focus,
.imh-spot.is-open .imh-dot {
	background: #fff;
	transform: scale(1.08);
	box-shadow: 0 0 0 4px rgba(255, 255, 255, .45), 0 12px 28px -6px rgba(0, 0, 0, .6);
}
.imh .imh-dot:focus { outline: none; }
.imh .imh-dot:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.imh .imh-dot img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: 50%;
	object-fit: cover;
}
.imh .imh-dot--plain {
	display: grid;
	place-items: center;
	background: var(--imh-accent);
	border-color: #fff;
	color: #fff;
	font-size: 22px;
	font-weight: 600;
	line-height: 1;
}
.imh .imh-dot--plain:hover,
.imh .imh-dot--plain:focus,
.imh-spot.is-open .imh-dot--plain { background: var(--imh-accent); }
.imh-spot.is-open .imh-dot--plain span { transform: rotate(45deg); }
.imh-dot--plain span { transition: transform .25s ease; }

/* Solo borde: círculo transparente */
.imh .imh-dot--outline,
.imh .imh-dot--outline:hover,
.imh .imh-dot--outline:focus,
.imh-spot.is-open .imh-dot--outline {
	padding: 0;
	background: var(--imh-fill, transparent);
	border: var(--imh-outline-w, 3px) solid var(--imh-outline, #fff);
	box-shadow: none;
}
.imh .imh-dot--outline:hover,
.imh .imh-dot--outline:focus,
.imh-spot.is-open .imh-dot--outline {
	box-shadow: 0 0 18px 2px var(--imh-outline, #fff);
}
.imh--pulse .imh-dot--outline::after { border-color: var(--imh-outline, #fff); }

.imh--pulse .imh-dot::after {
	content: "";
	position: absolute;
	inset: -6px;
	border: 2px solid var(--imh-accent);
	border-radius: 50%;
	pointer-events: none;
	animation: imh-pulse 2.4s ease-out infinite;
}
.imh--pulse .imh-spot.is-open .imh-dot::after { animation: none; opacity: 0; }

@keyframes imh-pulse {
	0%   { transform: scale(1);    opacity: .85; }
	70%  { transform: scale(1.35); opacity: 0; }
	100% { transform: scale(1.35); opacity: 0; }
}

/* ---------- Tarjeta (tooltip) ---------- */
.imh-pop {
	--imh-tx: -8px;
	--imh-ty: -50%;
	position: absolute;
	top: 50%;
	left: calc(100% + 18px);
	z-index: 5;
	width: 310px;
	max-width: 70vw;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translate(var(--imh-tx), var(--imh-ty));
	transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
	filter: drop-shadow(0 22px 40px rgba(15, 23, 42, .35));
}
/* Puente invisible para no perder el hover entre el punto y la tarjeta */
.imh-pop::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	right: 100%;
	width: 22px;
}
.imh-spot.is-left .imh-pop {
	--imh-tx: 8px;
	left: auto;
	right: calc(100% + 18px);
}
.imh-spot.is-left .imh-pop::before { right: auto; left: 100%; }
.imh-spot.is-down .imh-pop { --imh-ty: 0%; top: 0; }
.imh-spot.is-up .imh-pop   { --imh-ty: 0%; top: auto; bottom: 0; }

.imh-spot.is-open:not(.is-modal) .imh-pop {
	--imh-tx: 0px;
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transition-delay: 0s;
}

/* Contenido compartido por tarjeta y modal */
.imh-pop-inner {
	overflow: hidden;
	background: #fff;
	color: #1f2937;
	border-top: 4px solid var(--imh-accent);
	border-radius: 14px;
	font-size: 15px;
	line-height: 1.55;
	text-align: left;
	white-space: normal;
	letter-spacing: normal;
	text-transform: none;
	overflow-wrap: break-word;
}
.imh-pop-inner,
.imh-pop-inner * { box-sizing: border-box; }
.imh-pop-inner p,
.imh-pop-inner li { font-size: inherit; line-height: inherit; color: inherit; }
.imh-pop-media {
	display: flex;
	justify-content: center;
	padding: 16px;
	background: #f3f6fa;
}
.imh-pop-inner .imh-pop-media img {
	display: block;
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: 170px;
	margin: 0;
	object-fit: contain;
}
.imh-pop-body { padding: 16px 18px 18px; }
.imh-pop-inner .imh-pop-title {
	margin: 0 0 6px;
	padding: 0;
	color: #0f172a;
	font-family: inherit;
	font-size: 18px;
	font-weight: 600;
	line-height: 1.3;
	text-transform: none;
}
.imh-pop-content p { margin: 0 0 .6em; }
.imh-pop-content p:last-child { margin-bottom: 0; }
.imh-pop-content ul,
.imh-pop-content ol { margin: 0 0 .6em 1.2em; padding: 0; }
.imh-pop-content a { color: var(--imh-accent); }

.imh-pop-inner .imh-pop-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 14px;
	padding: 9px 18px;
	border-radius: 999px;
	background: var(--imh-accent);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	transition: filter .2s ease, transform .2s ease;
}
.imh-pop-inner .imh-pop-btn::after { content: "→"; }
.imh-pop-inner .imh-pop-btn:hover,
.imh-pop-inner .imh-pop-btn:focus {
	color: #fff;
	filter: brightness(1.1);
	transform: translateX(2px);
	text-decoration: none;
}

/* ---------- Modal ---------- */
.imh-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: grid;
	place-items: center;
	padding: 20px;
}
.imh-modal[hidden] { display: none; }
.imh-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, .6);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
	animation: imh-fade .2s ease both;
}
.imh-modal-box {
	position: relative;
	width: min(460px, 100%);
	max-height: calc(100vh - 40px);
	overflow: auto;
	border-radius: 14px;
	box-shadow: 0 30px 70px -15px rgba(0, 0, 0, .5);
	animation: imh-zoom .25s ease both;
}
.imh-modal .imh-pop-media img { max-height: 240px; }
.imh-modal .imh-pop-inner > .imh-pop-body:first-child { padding-right: 56px; }
.imh-modal .imh-modal-close {
	-webkit-appearance: none;
	appearance: none;
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 2;
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .92);
	color: #0f172a;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}
.imh-modal .imh-modal-close:hover { background: #fff; color: var(--imh-accent); }

@keyframes imh-zoom {
	from { opacity: 0; transform: scale(.94) translateY(8px); }
	to   { opacity: 1; transform: none; }
}

html.imh-lock { overflow: hidden; }

/* ---------- Responsive ---------- */

/* Escritorio pequeño: el menú se encoge antes que la imagen */
@media (max-width: 1200px) {
	.imh--left  { grid-template-columns: minmax(200px, min(var(--imh-menu-w), 30%)) minmax(0, 1fr); }
	.imh--right { grid-template-columns: minmax(0, 1fr) minmax(200px, min(var(--imh-menu-w), 30%)); }
	.imh .imh-tab { gap: 12px; padding: 12px 14px; font-size: min(var(--imh-fs), 16px); }
	.imh-tab-icon { width: 32px; height: 32px; }
}

/* Tablet: menú arriba en cuadrícula, imagen debajo */
@media (max-width: 900px) {
	.imh { gap: 16px; }
	.imh--left,
	.imh--right { grid-template-columns: minmax(0, 1fr); }
	.imh--right .imh-menu { order: 0; }
	.imh-menu,
	.imh--top .imh-menu {
		display: grid;
		grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
		gap: 10px;
	}
	.imh .imh-tab {
		min-height: 56px;
		gap: 10px;
		padding: 10px 12px;
		font-size: max(13px, min(var(--imh-fs), 15px));
	}
	.imh .imh-tab:hover,
	.imh .imh-tab:focus { transform: none; }
	.imh-tab-icon { width: 28px; height: 28px; }
	.imh-panels { scroll-margin-top: 80px; }
}

/* Móvil: icono arriba y texto centrado debajo, para aprovechar todo el ancho */
@media (max-width: 600px) {
	.imh-menu,
	.imh--top .imh-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
	.imh--m1 .imh-menu { grid-template-columns: minmax(0, 1fr); }

	.imh:not(.imh--m1) .imh-tab {
		flex-direction: column;
		justify-content: center;
		gap: 6px;
		min-height: 84px;
		padding: 10px 8px;
		border-left: 0;
		border-bottom: 3px solid transparent;
		font-size: 13px;
		line-height: 1.2;
		text-align: center;
	}
	.imh:not(.imh--m1) .imh-tab.is-active { border-bottom-color: var(--imh-accent); }
	.imh:not(.imh--m1) .imh-tab-label { flex: 0 0 auto; width: 100%; }
	.imh--m1 .imh-tab { min-height: 52px; font-size: 14px; }

	.imh-tab-icon { width: 26px; height: 26px; }
	.imh-spot { min-width: 28px; }
	.imh .imh-dot--plain { font-size: 16px; }
	.imh-caption { bottom: 6px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
	.imh *,
	.imh-modal * { animation: none !important; transition: none !important; }
}
