/*
 * Galería de la ficha de una actividad pasada.
 *
 * Copia adaptada de «El club por dentro» del área de socios (medidas del
 * Figma, nodo 297:33): escenario 1344×728, flechas de 70px a 24px del borde,
 * nueve miniaturas de 140×76 a 24px del escenario y puntos de 8px a 20px de
 * las miniaturas.
 *
 * Todo cuelga de `.act-gallery`, porque Bridge pisa los estilos globales de
 * botones e imágenes. El reset va dentro de `:where()` para no ganar en
 * especificidad a los componentes. El lightbox es un <dialog> colgado de
 * <body> y lleva sus propios estilos y tokens al final.
 */

.act-gallery,
.act-lightbox {
	--act-gallery-stage: #111;
	--act-gallery-dot: #b3b3b3;
	--act-gallery-dot-active: #20442f;
	--act-gallery-focus: #a08962;
}

/* Colocación en la ficha: la misma que en la 1.4.4. */
.act-gallery {
	width: 100%;
	margin-top: clamp(44px, 6vw, 72px);
	padding-top: clamp(26px, 4vw, 40px);
	border-top: 1px solid var(--act-accent, #a08962);
}

/* Cuando la galería sustituye a la imagen destacada en la ficha. */
.act-gallery--featured {
	margin-top: 0;
	margin-bottom: 42px;
	padding-top: 0;
	border-top: 0;
}

/* Reset acotado. */
.act-gallery,
.act-gallery *,
.act-gallery *::before,
.act-gallery *::after {
	box-sizing: border-box;
}

.act-gallery :where(figure) {
	margin: 0;
	padding: 0;
	border: 0;
}

.act-gallery :where(button) {
	min-width: 0;
	min-height: 0;
	margin: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	font: inherit;
	color: inherit;
	cursor: pointer;
	/* Bridge fuerza mayúsculas y tracking en todos los botones del sitio. */
	text-transform: none;
	letter-spacing: normal;
}

.act-gallery [hidden] {
	display: none !important;
}

.act-gallery :focus-visible {
	outline: 2px solid var(--act-gallery-focus);
	outline-offset: 3px;
	border-radius: 4px;
}

/* Encabezado opcional: la ficha la pinta sin él. */
.act-gallery .act-gallery__heading {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 18px;
	margin-bottom: 18px;
}

.act-gallery .act-gallery__heading h2 {
	margin: 0 !important;
	font-family: var(--act-font-heading) !important;
	font-size: clamp(28px, 3.8vw, 40px) !important;
	font-weight: 700 !important;
	line-height: 1.1 !important;
	letter-spacing: -0.7px !important;
	text-transform: none !important;
	color: var(--act-text) !important;
}

.act-gallery .act-gallery__heading > span {
	font-family: var(--act-font-body);
	font-size: 14px;
	color: var(--act-muted);
	white-space: nowrap;
}

/* Escenario */
.act-gallery .act-gallery__stage {
	position: relative;
}

.act-gallery .act-gallery__track {
	/* Posicionado para que el `offsetLeft` de cada diapositiva se mida desde
	   aquí y no desde la página. */
	position: relative;
	display: flex;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	background: var(--act-gallery-stage);
	cursor: grab;
	scrollbar-width: none;
}

.act-gallery .act-gallery__track::-webkit-scrollbar,
.act-gallery .act-gallery__thumbs::-webkit-scrollbar {
	display: none;
}

/* Mientras se arrastra con el ratón (`drag-scroll.js`): sin ajuste por
   diapositiva, que tiraría de la franja hacia atrás, y sin seleccionar. */
.act-gallery .act-gallery__track.is-dragging,
.act-gallery .act-gallery__thumbs.is-dragging {
	cursor: grabbing;
	scroll-snap-type: none;
	user-select: none;
}

.act-gallery .act-gallery__track.is-dragging *,
.act-gallery .act-gallery__thumbs.is-dragging * {
	pointer-events: none;
}

.act-gallery .act-gallery__slide {
	position: relative;
	flex: 0 0 100%;
	aspect-ratio: 1344 / 728;
	overflow: hidden;
	scroll-snap-align: start;
	background: var(--act-gallery-stage);
}

.act-gallery .act-gallery__zoom {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	cursor: zoom-in;
}

.act-gallery .act-gallery__media {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: contain;
}

/* Solo lo que ya es casi igual de apaisado llena el escenario
   (`Actividades_Gallery::fit()`); lo demás se ve entero. */
.act-gallery .act-gallery__slide--cover .act-gallery__media {
	object-fit: cover;
}

/* La misma imagen, ampliada y difuminada, rellena los lados de una vertical o
   una cuadrada en vez de dejar dos franjas negras. */
.act-gallery .act-gallery__backdrop {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	filter: blur(28px) brightness(0.55);
	transform: scale(1.15);
	pointer-events: none;
}

.act-gallery .act-gallery__expand {
	position: absolute;
	top: 20px;
	right: 24px;
	z-index: 1;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	color: #fff;
	filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}

.act-gallery .act-gallery__expand svg {
	width: 26px;
	height: 26px;
}

.act-gallery .act-gallery__nav {
	position: absolute;
	top: 50%;
	z-index: 1;
	display: grid;
	place-items: center;
	width: 70px;
	height: 70px;
	padding: 0;
	color: #fff;
	transform: translateY(-50%);
	/* Sin sombra la flecha blanca desaparece sobre una foto clara. */
	filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}

.act-gallery .act-gallery__nav svg {
	width: 100%;
	height: 100%;
}

.act-gallery .act-gallery__nav--prev {
	left: 24px;
}

.act-gallery .act-gallery__nav--prev svg {
	transform: scaleX(-1);
}

.act-gallery .act-gallery__nav--next {
	right: 24px;
}

/* Miniaturas y puntos */
.act-gallery .act-gallery__thumbs {
	--act-thumb-gap: 10.5px;

	display: grid;
	grid-auto-columns: calc((100% - 8 * var(--act-thumb-gap)) / 9);
	grid-auto-flow: column;
	gap: var(--act-thumb-gap);
	margin-top: 24px;
	overflow-x: auto;
	cursor: grab;
	scrollbar-width: none;
}

.act-gallery .act-gallery__thumb {
	position: relative;
	aspect-ratio: 140 / 76;
	padding: 0;
	overflow: hidden;
	background: var(--act-gallery-stage);
	opacity: 0.55;
	transition: opacity 0.2s ease;
}

.act-gallery .act-gallery__thumb:hover,
.act-gallery .act-gallery__thumb.is-active {
	opacity: 1;
}

.act-gallery .act-gallery__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

/* Triángulo de «reproducir» sobre la miniatura de un vídeo. */
.act-gallery .act-gallery__play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 9px 0 9px 15px;
	border-color: transparent transparent transparent #fff;
	transform: translate(-40%, -50%);
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.act-gallery .act-gallery__dots {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin-top: 20px;
}

.act-gallery .act-gallery__dot {
	width: 8px;
	height: 8px;
	padding: 0;
	border-radius: 50%;
	background: var(--act-gallery-dot);
}

.act-gallery .act-gallery__dot.is-active {
	background: var(--act-gallery-dot-active);
}

@media (prefers-reduced-motion: reduce) {
	.act-gallery .act-gallery__thumb {
		transition: none;
	}
}

/* 782px es el umbral que usa WordPress (y el área de socios) para «móvil». */
@media (max-width: 782px) {
	/* Un poco más alto: una vertical se queda menos pequeña. */
	.act-gallery .act-gallery__slide {
		aspect-ratio: 4 / 3;
	}

	.act-gallery .act-gallery__expand {
		top: 6px;
		right: 6px;
	}

	.act-gallery .act-gallery__nav {
		width: 44px;
		height: 44px;
	}

	.act-gallery .act-gallery__nav--prev {
		left: 4px;
	}

	.act-gallery .act-gallery__nav--next {
		right: 4px;
	}

	.act-gallery .act-gallery__thumbs {
		--act-thumb-gap: 8px;

		grid-auto-columns: 96px;
		margin-top: 16px;
	}

	/* Las galerías de actividades llegan a 40-60 archivos: en móvil los
	   puntos ocupan varias filas y ya se navega con las miniaturas. */
	.act-gallery .act-gallery__dots {
		display: none;
	}
}

/* Márgenes de la ficha en móvil: los mismos que en la 1.4.4. */
@media (max-width: 640px) {
	.act-gallery--featured {
		margin-bottom: 28px;
	}

	.act-gallery .act-gallery__heading {
		align-items: flex-start;
		flex-direction: column;
		gap: 6px;
	}
}

/*
 * Lightbox
 *
 * No cuelga de `.act-gallery`: el <dialog> vive en <body> y no hereda sus
 * variables ni la tipografía. Los botones se escriben con dos clases para
 * que los estilos globales de botón de Bridge no les ganen.
 */

/* Mientras está abierto, la página de detrás no se desplaza. */
.act-lightbox-open {
	overflow: hidden;
}

.act-lightbox {
	position: fixed;
	inset: 0;
	width: 100vw;
	height: 100vh;
	height: 100dvh;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	background: rgba(10, 10, 10, 0.94);
	color: #fff;
}

.act-lightbox,
.act-lightbox *,
.act-lightbox *::before,
.act-lightbox *::after {
	box-sizing: border-box;
}

.act-lightbox [hidden] {
	display: none !important;
}

.act-lightbox::backdrop {
	background: transparent;
}

.act-lightbox .act-lightbox__stage {
	/* Márgenes que dejan sitio a la cruz, las flechas y el contador. */
	--act-lb-top: 72px;
	--act-lb-side: 104px;
	--act-lb-bottom: 72px;

	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	padding: var(--act-lb-top) var(--act-lb-side) var(--act-lb-bottom);
	overflow: hidden;
	/* El deslizamiento horizontal lo gestiona el lightbox. */
	touch-action: pan-y;
}

/* Los límites se miden contra la ventana y no con `max-height: 100%`: dentro
   de una rejilla ese porcentaje no tiene altura fija a la que referirse, el
   navegador lo ignora y una foto vertical se salía por abajo. */
.act-lightbox .act-lightbox__stage img,
.act-lightbox .act-lightbox__stage video {
	display: block;
	width: auto;
	height: auto;
	max-width: calc(100vw - 2 * var(--act-lb-side));
	max-height: calc(100vh - var(--act-lb-top) - var(--act-lb-bottom));
	max-height: calc(100dvh - var(--act-lb-top) - var(--act-lb-bottom));
	margin: 0;
	object-fit: contain;
	user-select: none;
}

/* Un vídeo sin dimensiones aún (cargando sus metadatos) se quedaría en 0. */
.act-lightbox .act-lightbox__stage video {
	min-width: min(320px, 100%);
}

.act-lightbox .act-lightbox__close,
.act-lightbox .act-lightbox__nav {
	position: absolute;
	display: grid;
	place-items: center;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: #fff;
	line-height: 1;
	cursor: pointer;
	opacity: 0.85;
}

.act-lightbox .act-lightbox__close:hover,
.act-lightbox .act-lightbox__nav:hover {
	opacity: 1;
}

.act-lightbox .act-lightbox__close:focus-visible,
.act-lightbox .act-lightbox__nav:focus-visible {
	outline: 2px solid var(--act-gallery-focus);
	outline-offset: 2px;
}

.act-lightbox .act-lightbox__close svg,
.act-lightbox .act-lightbox__nav svg {
	width: 100%;
	height: 100%;
}

.act-lightbox .act-lightbox__close {
	top: 16px;
	right: 16px;
	width: 44px;
	height: 44px;
	padding: 8px;
}

.act-lightbox .act-lightbox__nav {
	top: 50%;
	width: 70px;
	height: 70px;
	transform: translateY(-50%);
}

.act-lightbox .act-lightbox__nav--prev {
	left: 20px;
}

.act-lightbox .act-lightbox__nav--prev svg {
	transform: scaleX(-1);
}

.act-lightbox .act-lightbox__nav--next {
	right: 20px;
}

.act-lightbox .act-lightbox__count {
	position: absolute;
	bottom: 28px;
	left: 50%;
	margin: 0;
	font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 12px;
	letter-spacing: 0.12em;
	color: #fff;
	opacity: 0.75;
	transform: translateX(-50%);
}

@media (prefers-reduced-motion: no-preference) {
	.act-lightbox[open] {
		animation: act-lightbox-in 0.2s ease;
	}
}

@keyframes act-lightbox-in {
	from {
		opacity: 0;
	}
}

@media (max-width: 782px) {
	.act-lightbox .act-lightbox__stage {
		--act-lb-top: 64px;
		--act-lb-side: 12px;
		--act-lb-bottom: 96px;
	}

	/* Abajo y al alcance del pulgar, sin tapar la imagen. */
	.act-lightbox .act-lightbox__nav {
		top: auto;
		bottom: 20px;
		width: 52px;
		height: 52px;
		transform: none;
	}

	.act-lightbox .act-lightbox__nav--prev {
		left: 12px;
	}

	.act-lightbox .act-lightbox__nav--next {
		right: 12px;
	}

	.act-lightbox .act-lightbox__count {
		bottom: 36px;
	}
}
