/* ============================================================
   cedares — Componente · Modal de pieza (visor ampliado)
   Figma: 21:557 · card interna_pieza 61:6034 (1070×600) · móvil 136:1026.
   Valores destilados del Figma (tamaño, padding, borde, color, tipografía).
   Móvil: hoja a pantalla completa (imagen arriba + info debajo, scroll).
   Desktop (>=1024px): tarjeta centrada de 2 columnas con proporción FIJA
   1070/600 — no cambia de alto con el contenido.
   ============================================================ */

.modal-pieza {
	position: fixed;
	inset: 0;
	z-index: 130;
}

.modal-pieza[hidden] {
	display: none;
}

.modal-pieza__dialog:focus {
	outline: none;
}

/* Bloquea el scroll del fondo mientras el modal está abierto. */
.modal-pieza-open {
	overflow: hidden;
}

.modal-pieza__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(6, 10, 26, 0.92);
	border: 0;
}

@supports (backdrop-filter: blur(2px)) {
	.modal-pieza__backdrop {
		background: rgba(6, 10, 26, 0.82);
		backdrop-filter: blur(6px);
	}
}

/* --- Diálogo: móvil = hoja a pantalla completa con scroll --- */
.modal-pieza__dialog {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: var(--ced-bg); /* #121e42 (ambas columnas) */
}

/* --- Columna imagen (media): foto nítida centrada sobre fondo desenfocado --- */
.modal-pieza__media {
	position: relative;
	flex: 0 0 auto;
	margin: 0;
	overflow: hidden;
	background: var(--ced-bg);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	aspect-ratio: 576 / 626; /* móvil: proporción del área de imagen (Figma) */
}

/* Fondo: misma imagen a sangre, desenfocada y oscurecida (Figma image 26). */
.modal-pieza__media-bg {
	position: absolute;
	inset: 0;
	background-position: center;
	background-size: cover;
	filter: blur(10px);
	transform: scale(1.15);
}

.modal-pieza__media-bg::after {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.75);
}

/* Foto nítida contenida (letterbox). Móvil: 373/626 = 59.6% (Figma image 27). */
.modal-pieza__img {
	position: relative;
	z-index: 1;
	display: block;
	width: 100%;
	height: 59.6%;
	object-fit: cover;
}

/* Piezas VERTICALES (afiches, programas): se muestran COMPLETAS sobre el fondo
   oscuro desenfocado, en lugar de recortarse. La clase la pone el JS al cargar
   la imagen según su proporción real. Aplica en móvil y desktop (2 clases →
   gana en especificidad a la banda con `cover`). */
.modal-pieza--portrait .modal-pieza__img {
	height: 100%;
	object-fit: contain;
}

/* Insignia «imagen protegida» (Figma 61:6039). */
.modal-pieza__shield {
	position: absolute;
	z-index: 2;
	top: 20px;
	left: 20px;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	max-width: calc(100% - 76px); /* móvil: deja libre el botón cerrar */
	padding: 10px 16px;
	border-radius: 40px;
	background: rgba(17, 17, 50, 0.5);
	border: 0.5px solid rgba(255, 255, 255, 0.3);
	color: rgba(255, 255, 255, 0.85);
}

.modal-pieza__shield-ico {
	flex: 0 0 auto;
	color: var(--ced-amarillo);
}

.modal-pieza__shield-txt {
	font-family: var(--ced-font-base);
	font-weight: 500;
	font-size: 10px;
	line-height: 1.25;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	overflow-wrap: anywhere; /* móvil: envuelve en vez de colisionar con la X */
}

/* Contador «Colección: 01/04» (Figma 61:6037). Solo desktop (en móvil va el zoom). */
.modal-pieza__count {
	display: none;
	position: absolute;
	z-index: 2;
	left: 20px;
	bottom: 44px;
	margin: 0;
	font-family: var(--ced-font-base);
	font-weight: 300;
	font-size: 16px;
	line-height: 1;
	letter-spacing: 0.15em;
	text-transform: uppercase;
	color: #fff;
	text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.modal-pieza__count-cur {
	font-weight: 600;
	color: var(--ced-amarillo);
}

/* --- Columna info (panel) ---
   Móvil (Figma 136:1823): el cuerpo azul SUBE sobre la imagen y sus esquinas
   superiores van redondeadas (rounded-t 50px + margen negativo). */
.modal-pieza__info {
	position: relative;
	z-index: 1;
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	gap: 24px;
	margin-top: -26px;
	padding: 40px 24px;
	background: var(--ced-bg);
	color: #fff;
	border-top-left-radius: 32px;
	border-top-right-radius: 32px;
}

.modal-pieza__head {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 12px;
}

.modal-pieza__eyebrow {
	margin: 0;
	font-family: var(--ced-font-base);
	font-weight: 300;
	font-size: 13px;
	line-height: 1;
	letter-spacing: 0.15em;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.85);
}

.modal-pieza__eyebrow span {
	font-weight: 600;
}

.modal-pieza__title {
	margin: 0;
	font-family: var(--ced-font-base);
	font-weight: 900;
	font-size: clamp(1.5rem, 5.6vw, 1.625rem); /* ~24 → 26px */
	line-height: 1.1;
	color: #fff;
	overflow-wrap: anywhere;
}

/* Pill lavanda: «Sala 02 · Teatro / Colección 02 · TUC» (Figma 61:6049). */
.modal-pieza__badge {
	align-self: flex-start;
	margin: 0;
	padding: 5px 10px;
	border-radius: 30px;
	background: #e3b9f4;
	color: var(--ced-morado); /* #733d89 */
	font-family: var(--ced-font-base);
	font-weight: 700;
	font-size: 13px;
	line-height: 1;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	overflow-wrap: anywhere;
}

.modal-pieza__badge[hidden] {
	display: none;
}

.modal-pieza__rule {
	height: 0;
	margin: 0;
	border: 0;
	border-top: 1px solid rgba(255, 255, 255, 0.16);
	width: 100%;
}

/* Rejilla de metadatos: 2 columnas (col1 fija 154px + col2 auto). */
.modal-pieza__meta {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); /* móvil: 2 columnas fluidas */
	gap: 16px 24px;
	margin: 0;
	width: 100%;
}

/* Pantallas muy angostas: una sola columna (evita apretar los valores). */
@media (max-width: 320px) {
	.modal-pieza__meta {
		grid-template-columns: minmax(0, 1fr);
	}
}

.modal-pieza__meta-item {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.modal-pieza__meta-item[hidden] {
	display: none;
}

.modal-pieza__meta-item--wide {
	grid-column: 1 / -1;
}

.modal-pieza__meta-label {
	margin: 0;
	font-family: var(--ced-font-base);
	font-weight: 500;
	font-size: 12px;
	line-height: 1.4;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--ced-amarillo);
}

.modal-pieza__meta-value {
	margin: 0;
	font-family: var(--ced-font-base);
	font-weight: 400;
	font-size: 13px;
	line-height: 1.45;
	letter-spacing: 0.01em;
	color: rgba(255, 255, 255, 0.85);
	overflow-wrap: anywhere;
}

/* Descripción (Figma 61:6066). */
.modal-pieza__desc[hidden] {
	display: none;
}

.modal-pieza__desc-label {
	margin: 0 0 6px;
	font-family: var(--ced-font-base);
	font-weight: 500;
	font-size: 12px;
	line-height: 1.4;
	letter-spacing: 0.1em;
	color: var(--ced-amarillo);
}

.modal-pieza__desc-text {
	margin: 0;
	font-family: var(--ced-font-base);
	font-size: 14px;
	line-height: 1.6;
	letter-spacing: 0.01em;
	text-align: left; /* móvil: sin justificado (evita «ríos» en columna angosta) */
	color: rgba(255, 255, 255, 0.85);
	overflow-wrap: break-word;
}

/* Acciones — móvil (Figma 136:1848): botones apilados a todo el ancho. */
.modal-pieza__actions {
	display: flex;
	flex-direction: column;
	gap: 14px;
	width: 100%;
}

.modal-pieza__btn {
	flex: 0 0 auto;
	width: 100%;
	min-width: 0;
	min-height: 52px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 12px 22px;
	border-radius: 50px;
	font-family: var(--ced-font-base);
	font-weight: 600;
	font-size: 15px;
	line-height: 1.3;
	letter-spacing: 0.005em;
	cursor: pointer;
	transition: background-color 0.18s ease, border-color 0.18s ease;
}

.modal-pieza__btn svg {
	flex: 0 0 auto;
}

.modal-pieza__btn--cite {
	background: var(--ced-magenta);
	border: 1px solid var(--ced-magenta);
	color: #fff;
	box-shadow: 0 2px 0 rgba(5, 145, 255, 0.1);
}

.modal-pieza__btn--cite:hover {
	background: #c50d5b;
	border-color: #c50d5b;
}

.modal-pieza__btn--share {
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.35);
	color: #fff;
}

.modal-pieza__btn--share:hover {
	border-color: rgba(255, 255, 255, 0.7);
	background: rgba(255, 255, 255, 0.06);
}

/* --- Botón cerrar (móvil: fijo arriba-derecha) --- */
.modal-pieza__close {
	position: fixed;
	top: 12px;
	right: 12px;
	z-index: 3;
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(17, 17, 50, 0.6);
	border: 1px solid rgba(255, 255, 255, 0.3);
	color: #fff;
	cursor: pointer;
	transition: background-color 0.18s ease;
}

.modal-pieza__close:hover {
	background: #1b1b4a;
}

/* --- Flechas prev/next (solo desktop; en móvil se usa el zoom) --- */
.modal-pieza__arrow {
	display: none;
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	width: 44px;
	height: 44px;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(8, 12, 26, 0.55);
	border: 1px solid rgba(255, 255, 255, 0.2);
	color: #fff;
	cursor: pointer;
	transition: background-color 0.18s ease, color 0.18s ease;
}

.modal-pieza__arrow:hover {
	background: rgba(8, 12, 26, 0.85);
}

.modal-pieza__arrow[hidden] {
	display: none;
}

.modal-pieza__arrow:disabled {
	opacity: 0.35;
	cursor: default;
}

.modal-pieza__arrow svg {
	width: 24px;
	height: 24px;
}

/* El chevron de Figma apunta hacia arriba; se gira a izquierda/derecha. */
.modal-pieza__arrow--prev .modal-pieza__arrow-ico {
	transform: rotate(-90deg);
}

.modal-pieza__arrow--next .modal-pieza__arrow-ico {
	transform: rotate(90deg);
}

.modal-pieza__arrow--prev {
	left: 12px;
}

.modal-pieza__arrow--next {
	right: 12px;
}

/* --- Botón zoom (móvil · UNA sola pieza, Figma 136:1820) --- */
.modal-pieza__zoom-btn {
	display: none;
	position: absolute;
	z-index: 2;
	right: 16px;
	bottom: 46px; /* en la banda inferior, por encima del panel que sube */
	width: 52px;
	height: 46px;
	align-items: center;
	justify-content: center;
	border-radius: 40px;
	background: rgba(17, 17, 50, 0.5);
	border: 0.5px solid rgba(255, 255, 255, 0.75);
	color: #fff;
	cursor: pointer;
	transition: background-color 0.18s ease;
}

/* Solo cuando hay una única pieza (sin navegación). */
.modal-pieza--single .modal-pieza__zoom-btn {
	display: inline-flex;
}

.modal-pieza__zoom-btn:hover {
	background: rgba(17, 17, 50, 0.85);
}

/* --- Barra de navegación (móvil · VARIAS piezas, Figma 139:1955/1969) ---
   «← Colección: 01/04 →»: flechas amarillas (atenuadas en extremos). */
.modal-pieza__navbar {
	display: none;
	align-items: center;
	justify-content: space-between;
	gap: clamp(6px, 3vw, 16px);
	width: 100%;
}

/* Solo cuando hay varias piezas. */
.modal-pieza--multi .modal-pieza__navbar {
	display: flex;
}

/* Variante sobre la imagen: absoluta en la banda inferior. */
.modal-pieza__navbar--media {
	position: absolute;
	z-index: 2;
	left: 0;
	right: 0;
	bottom: 40px;
	width: auto;
	padding: 0 20px;
}

/* Variante al final del panel info: en el flujo, tras los botones. */
.modal-pieza__navbar--info {
	margin-top: 4px;
}

.modal-pieza__navbar-arrow {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: clamp(28px, 8vw, 34px);
	height: clamp(28px, 8vw, 34px);
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--ced-amarillo);
	cursor: pointer;
	transition: opacity 0.18s ease;
}

.modal-pieza__navbar-arrow:disabled {
	color: rgba(255, 255, 255, 0.4);
	cursor: default;
}

.modal-pieza__navbar-count {
	margin: 0;
	min-width: 0;
	font-family: var(--ced-font-base);
	font-weight: 300;
	font-size: clamp(0.8125rem, 4.2vw, 1rem); /* 13 → 16px */
	line-height: 1;
	letter-spacing: clamp(0.06em, 0.6vw, 0.15em);
	text-transform: uppercase;
	color: #fff;
	text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
	white-space: nowrap;
}

.modal-pieza__navbar-count .modal-pieza__count-cur {
	font-weight: 600;
	color: var(--ced-amarillo);
}

/* --- Capa de zoom: imagen ampliada sobre fondo oscuro --- */
.modal-pieza__zoom {
	position: fixed;
	inset: 0;
	z-index: 140;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(4, 7, 18, 0.94);
}

.modal-pieza__zoom[hidden] {
	display: none;
}

.modal-pieza__zoom-img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 8px;
}

.modal-pieza__zoom-close {
	position: fixed;
	top: 12px;
	right: 12px;
	z-index: 1;
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(17, 17, 50, 0.6);
	border: 1px solid rgba(255, 255, 255, 0.3);
	color: #fff;
	cursor: pointer;
}

/* ============================================================
   Desktop (>=1024px) — Figma 61:6034: tarjeta de proporción fija 1070/600.
   ============================================================ */
@media (min-width: 1024px) {
	.modal-pieza {
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 44px 60px;
		/* Ancho del card (proporción fija 1070/600); reusado por las flechas. */
		--modal-w: min(1070px, calc(100vw - 120px), calc((100vh - 100px) * 1.78333));
	}

	.modal-pieza__dialog {
		position: relative; /* ancla del modal de cita, que cubre la columna info */
		flex-direction: row;
		/* Proporción FIJA 1070/600, acotada por ancho y alto del viewport. */
		width: var(--modal-w);
		height: auto;
		aspect-ratio: 1070 / 600;
		border: 1px solid rgba(255, 255, 255, 0.2);
		border-radius: 26px;
		overflow: hidden;
		box-shadow: 0 15px 34px rgba(0, 0, 0, 0.5);
	}

	/* Imagen: 660/1070 = 61.682% del ancho de la tarjeta. */
	.modal-pieza__media {
		flex: 0 0 61.682%;
		height: 100%;
		aspect-ratio: auto;
	}

	/* Foto nítida contenida a 427/600 = 71.17% de alto (letterbox). */
	.modal-pieza__img {
		width: 100%;
		height: 71.17%;
	}

	.modal-pieza__count {
		display: block;
		left: 32px;
		bottom: 40px;
	}

	/* En desktop no hay zoom ni barra móvil (el Figma usa flechas laterales). */
	.modal-pieza__zoom-btn,
	.modal-pieza--single .modal-pieza__zoom-btn,
	.modal-pieza__navbar,
	.modal-pieza--multi .modal-pieza__navbar {
		display: none;
	}

	/* Panel info: ~410px, contenido centrado; scroll propio si excede.
	   En desktop no sube ni redondea (el card ya tiene su radio). */
	.modal-pieza__info {
		flex: 1 1 auto;
		height: 100%;
		gap: 20px;
		margin-top: 0;
		padding: 24px 25px;
		border-radius: 0;
		justify-content: safe center;
		overflow-y: auto;
	}

	/* Botones lado a lado, iguales (Figma 61:6079). */
	.modal-pieza__actions {
		flex-direction: row;
		gap: 10px;
	}

	.modal-pieza__btn {
		flex: 1 1 0;
		width: auto;
		min-height: 44px;
		gap: 6px;
		padding: 10px 20px;
		font-size: 14px;
	}

	.modal-pieza__title {
		font-size: 26px;
	}

	/* El escudo cabe en una línea dentro de la tarjeta (Figma). */
	.modal-pieza__shield {
		max-width: calc(100% - 40px);
	}

	.modal-pieza__shield-txt {
		white-space: nowrap;
		line-height: 1.03;
	}

	/* Rejilla de metadatos: col1 fija 154px + col2 auto (Figma 61:6052). */
	.modal-pieza__meta {
		grid-template-columns: 154px auto;
		gap: 16px 30px;
	}

	/* Descripción justificada en columna ancha (Figma 61:6068). */
	.modal-pieza__desc-text {
		text-align: justify;
	}

	/* Cerrar: fuera de la tarjeta, arriba-derecha (Figma 21:615). */
	.modal-pieza__close {
		position: absolute;
		top: 34px;
		right: 46px;
		width: 46px;
		height: 46px;
		background: rgba(17, 17, 50, 0.55);
	}

	/* Flechas: line-icons blancos, fuera de la tarjeta, centrados (Figma 61:6086). */
	.modal-pieza__arrow {
		display: inline-flex;
		top: 50%;
		width: 40px;
		height: 40px;
		background: transparent;
		border: 0;
		color: rgba(255, 255, 255, 0.9);
	}

	.modal-pieza__arrow:hover {
		background: transparent;
		color: #fff;
	}

	.modal-pieza__arrow svg {
		width: 34px;
		height: 34px;
	}

	/* Justo fuera del card (~46px), no pegadas al borde de pantalla; se
	   acercan al extremo solo si el viewport es angosto (max()). */
	.modal-pieza__arrow--prev {
		left: max(16px, calc(50% - var(--modal-w) / 2 - 86px));
		right: auto;
	}

	.modal-pieza__arrow--next {
		right: max(16px, calc(50% - var(--modal-w) / 2 - 86px));
		left: auto;
	}
}
