/**
 * Urrá Core — Galería Elementor widget.
 *
 * Desktop: grid, masonry o carrusel Swiper.
 * Mobile: siempre carrusel inline con scroll-snap + bullets pill.
 * Lightbox: overlay y botón cerrar coherentes con el buscador modal.
 */

/* ─── Variables ──────────────────────────────────────────────── */

.urra-gallery {
	--uc-gallery-cols: 3;
	--uc-gallery-gap: 12px;
	--uc-gallery-radius: 12px;
	--uc-gallery-ratio: 4/3;
	--uc-gallery-mobile-slide: 85%;
	--uc-gallery-mobile-inset: 0px;
	--uc-gallery-bullet-color: rgba(51, 153, 204, 0.35);
	--uc-gallery-bullet-color-active: #0a6bb8;
	--uc-gallery-bullet-size: 10px;
	--uc-gallery-bullet-size-active: 28px;
	--uc-gallery-bullet-gap: 6px;
	--uc-gallery-bullet-offset: 14px;
	--uc-gallery-arrow-size: 44px;
	--uc-gallery-arrow-bg: rgba(255, 255, 255, 0.92);
	--uc-gallery-arrow-color: #0b1220;
	--uc-gallery-lb-overlay: rgba(15, 23, 42, 0.55);

	position: relative;
	width: 100%;
}

/* ─── Viewport / track base ──────────────────────────────────── */

.urra-gallery__viewport {
	position: relative;
}

.urra-gallery__track {
	margin: 0;
	padding: 0;
	list-style: none;
}

.urra-gallery__item {
	min-width: 0;
}

.urra-gallery__figure {
	margin: 0;
	overflow: hidden;
	border-radius: var(--uc-gallery-radius);
	line-height: 0;
}

/* Reset agresivo: themes/Elementor pintan todos los <button> con
   background primario y padding, dejando la imagen flotando dentro
   de una caja azul. Mismo patrón que .uc-search-modal__close. */
.urra-gallery__trigger,
.urra-gallery__trigger:hover,
.urra-gallery__trigger:focus,
.urra-gallery__trigger:active {
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	appearance: none !important;

	display: block !important;
	width: 100% !important;
	height: 100% !important;
	margin: 0 !important;
	padding: 0 !important;

	border: 0 !important;
	border-radius: inherit !important;
	outline: none;
	box-shadow: none !important;
	text-shadow: none !important;

	background: transparent !important;
	background-image: none !important;
	background-color: transparent !important;

	font: inherit !important;
	font-size: 0 !important;
	line-height: 0 !important;
	color: inherit !important;
	text-transform: none !important;
	letter-spacing: 0 !important;
	white-space: nowrap !important;

	cursor: zoom-in !important;
	text-align: inherit !important;
	transform: none !important;
	-webkit-tap-highlight-color: transparent;
}

.urra-gallery__trigger:focus-visible {
	outline: 2px solid var(--uc-gallery-bullet-color-active) !important;
	outline-offset: 3px !important;
	box-shadow: none !important;
}

.urra-gallery__img {
	display: block;
	width: 100%;
	height: auto;
	object-fit: cover;
	border-radius: var(--uc-gallery-radius);
}

/* ─── Desktop: Grid ──────────────────────────────────────────── */

@media (min-width: 768px) {
	.urra-gallery--layout-grid .urra-gallery__track {
		display: grid;
		grid-template-columns: repeat(var(--uc-gallery-cols), minmax(0, 1fr));
		gap: var(--uc-gallery-gap);
	}

	.urra-gallery--layout-grid .urra-gallery__figure {
		aspect-ratio: var(--uc-gallery-ratio);
		display: block;
	}

	.urra-gallery--layout-grid .urra-gallery__trigger {
		min-height: 100%;
	}

	.urra-gallery--layout-grid .urra-gallery__img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
}

/* ─── Desktop: Masonry ───────────────────────────────────────── */

@media (min-width: 768px) {
	.urra-gallery--layout-masonry .urra-gallery__track {
		columns: var(--uc-gallery-cols);
		column-gap: var(--uc-gallery-gap);
	}

	.urra-gallery--layout-masonry .urra-gallery__item {
		break-inside: avoid;
		margin-bottom: var(--uc-gallery-gap);
	}

	.urra-gallery--layout-masonry .urra-gallery__img {
		width: 100%;
		height: auto;
	}
}

/* ─── Desktop: Carousel (Swiper) ─────────────────────────────── */

@media (min-width: 768px) {
	.urra-gallery--layout-carousel .urra-gallery__swiper {
		overflow: hidden;
	}

	.urra-gallery--layout-carousel .urra-gallery__figure {
		aspect-ratio: var(--uc-gallery-ratio);
		width: 100%;
	}

	.urra-gallery--layout-carousel .urra-gallery__img {
		width: 100%;
		height: 100%;
	}

	.urra-gallery__arrow,
	.urra-gallery__arrow:hover,
	.urra-gallery__arrow:focus,
	.urra-gallery__arrow:active {
		-webkit-appearance: none !important;
		-moz-appearance: none !important;
		appearance: none !important;

		position: absolute;
		top: 50%;
		z-index: 3;
		display: inline-flex !important;
		align-items: center;
		justify-content: center;
		width: var(--uc-gallery-arrow-size) !important;
		height: var(--uc-gallery-arrow-size) !important;
		margin: 0 !important;
		padding: 0 !important;
		border: 0 !important;
		border-radius: 50% !important;
		background: rgba(255, 255, 255, 0.92) !important;
		background-image: none !important;
		color: var(--uc-gallery-arrow-color) !important;
		box-shadow: 0 8px 24px -10px rgba(15, 23, 42, 0.35) !important;
		font-size: 0 !important;
		line-height: 0 !important;
		cursor: pointer;
		transform: translateY(-50%);
		transition: background-color 150ms ease, transform 150ms ease;
		-webkit-tap-highlight-color: transparent;
	}

	.urra-gallery__arrow:hover {
		transform: translateY(-50%) scale(1.06);
	}

	.urra-gallery__arrow:active {
		transform: translateY(-50%) scale(0.96);
	}

	.urra-gallery__arrow:focus-visible {
		outline: none;
		box-shadow:
			0 0 0 2px #ffffff,
			0 0 0 4px var(--uc-gallery-bullet-color-active);
	}

	.urra-gallery__arrow--prev {
		left: 12px;
	}

	.urra-gallery__arrow--next {
		right: 12px;
	}

	.urra-gallery__arrow svg,
	.urra-gallery__arrow .urra-gallery__arrow-icon {
		display: block !important;
		width: 20px !important;
		height: 20px !important;
		min-width: 20px !important;
		min-height: 20px !important;
		flex-shrink: 0 !important;
		overflow: visible !important;
		pointer-events: none;
	}

	.urra-gallery__arrow svg path,
	.urra-gallery__arrow .urra-gallery__arrow-icon path {
		stroke: currentColor !important;
		fill: none !important;
		stroke-width: 2 !important;
		vector-effect: non-scaling-stroke;
	}

	.urra-gallery__arrow::before,
	.urra-gallery__arrow::after {
		content: none !important;
		display: none !important;
	}

	/* Ocultar flechas en mobile: el carrusel es touch-first. */
	.urra-gallery--layout-carousel .urra-gallery__arrow {
		display: inline-flex;
	}
}

/* ─── Bullets (pill pattern hero-slider / servicios-grid) ─────── */

.urra-gallery__bullets {
	display: none;
	width: 100%;
	margin-top: var(--uc-gallery-bullet-offset);
	align-items: center;
	justify-content: center;
	gap: var(--uc-gallery-bullet-gap);
}

.uc-gallery__bullet,
.urra-gallery__bullets .swiper-pagination-bullet {
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	appearance: none !important;

	display: inline-block !important;
	box-sizing: border-box !important;
	width: var(--uc-gallery-bullet-size) !important;
	height: var(--uc-gallery-bullet-size) !important;
	min-width: 0 !important;
	min-height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;

	border: 0 !important;
	border-radius: 999px !important;
	outline: none;

	background: var(--uc-gallery-bullet-color) !important;
	background-image: none !important;
	box-shadow: none !important;
	opacity: 1 !important;

	font: inherit !important;
	color: inherit !important;
	line-height: 1 !important;

	cursor: pointer !important;
	transition: width 0.25s ease, background-color 0.2s ease !important;
	transform: none !important;
}

.uc-gallery__bullet:focus-visible,
.urra-gallery__bullets .swiper-pagination-bullet:focus-visible {
	outline: 2px solid var(--uc-gallery-bullet-color-active) !important;
	outline-offset: 3px !important;
}

.uc-gallery__bullet--active,
.urra-gallery__bullets .swiper-pagination-bullet-active {
	width: var(--uc-gallery-bullet-size-active) !important;
	background: var(--uc-gallery-bullet-color-active) !important;
}

/* Desktop carousel: Swiper rellena el contenedor de bullets. */
@media (min-width: 768px) {
	.urra-gallery--layout-carousel .urra-gallery__bullets {
		display: flex;
		position: relative;
		z-index: 2;
	}
}

/* ─── Mobile: siempre carrusel inline ─────────────────────────── */

@media (max-width: 767.98px) {
	.urra-gallery .urra-gallery__viewport {
		overflow: visible;
	}

	.urra-gallery .urra-gallery__track,
	.urra-gallery .urra-gallery__swiper .swiper-wrapper {
		display: flex !important;
		flex-wrap: nowrap !important;
		grid-template-columns: unset !important;
		columns: unset !important;

		overflow-x: auto;
		overflow-y: visible;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: var(--uc-gallery-mobile-inset);
		overscroll-behavior-x: contain;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		touch-action: pan-x pan-y;

		gap: var(--uc-gallery-gap);
		padding-inline: var(--uc-gallery-mobile-inset);
		padding-block: 4px;
	}

	.urra-gallery .urra-gallery__track::-webkit-scrollbar,
	.urra-gallery .urra-gallery__swiper .swiper-wrapper::-webkit-scrollbar {
		display: none;
	}

	.urra-gallery .urra-gallery__item,
	.urra-gallery .urra-gallery__swiper .swiper-slide {
		flex: 0 0 var(--uc-gallery-mobile-slide);
		align-self: stretch;
		scroll-snap-align: start;
		width: auto !important;
	}

	.urra-gallery .urra-gallery__figure {
		aspect-ratio: var(--uc-gallery-ratio, 4/3);
		display: block;
	}

	.urra-gallery .urra-gallery__trigger {
		min-height: 100%;
	}

	.urra-gallery .urra-gallery__img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}

	.urra-gallery .urra-gallery__arrow {
		display: none !important;
	}

	.urra-gallery .urra-gallery__bullets {
		display: flex;
		padding-inline: var(--uc-gallery-mobile-inset);
	}

	/* Neutralizar Swiper en mobile: el track es scroll nativo. */
	.urra-gallery--layout-carousel .urra-gallery__swiper {
		overflow: visible;
	}
}

/* ─── Lightbox ───────────────────────────────────────────────── */

body.uc-gallery-lb-open {
	overflow: hidden;
}

.uc-gallery-lb {
	position: fixed;
	inset: 0;
	z-index: 99998;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	box-sizing: border-box;
	font-family: inherit;
}

.uc-gallery-lb[hidden] {
	display: none;
}

.uc-gallery-lb__overlay {
	position: absolute;
	inset: 0;
	z-index: 1;
	background: var(--uc-gallery-lb-overlay);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	animation: cfGalleryOverlayIn 180ms ease-out;
}

.uc-gallery-lb__panel {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: min(1100px, 96vw);
	max-height: 90vh;
	padding: 0;
}

.uc-gallery-lb__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	max-width: 100%;
}

.uc-gallery-lb__img-wrap {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	max-width: 100%;
	max-height: 90vh;
	line-height: 0;
	overflow: hidden;
	border-radius: var(--uc-gallery-radius);
	flex: 0 1 auto;
	min-width: 0;
}

.uc-gallery-lb__img {
	display: block;
	max-width: min(1100px, 96vw);
	max-height: 90vh;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: var(--uc-gallery-radius);
}

/* Botón cerrar — esquina superior derecha de la imagen */
.uc-gallery-lb__close,
.uc-gallery-lb__close:hover,
.uc-gallery-lb__close:focus,
.uc-gallery-lb__close:active {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;

	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0 !important;

	-webkit-appearance: none;
	appearance: none;
	background: rgba(255, 255, 255, 0.94) !important;
	border: 0 !important;
	border-radius: 50% !important;
	box-shadow: 0 2px 12px rgba(15, 23, 42, 0.22) !important;
	text-shadow: none;

	color: var(--e-global-color-brand-600, #0a6bb8) !important;

	font: inherit;
	font-size: 0;
	line-height: 0;
	letter-spacing: 0;
	text-transform: none;
	white-space: nowrap;

	cursor: pointer;
	transition: background-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
	-webkit-tap-highlight-color: transparent;
}

.uc-gallery-lb__close:hover {
	background: #ffffff !important;
	transform: scale(1.06);
	box-shadow: 0 4px 16px rgba(15, 23, 42, 0.28) !important;
}

.uc-gallery-lb__close:active {
	background: rgba(255, 255, 255, 0.88) !important;
	transform: scale(0.96);
}

.uc-gallery-lb__close:focus-visible {
	outline: none;
	background: #ffffff !important;
	box-shadow:
		0 0 0 2px rgba(255, 255, 255, 0.95),
		0 0 0 4px var(--e-global-color-brand-600, #0a6bb8) !important;
}

.uc-gallery-lb__close-icon {
	display: block !important;
	width: 18px !important;
	height: 18px !important;
	min-width: 18px !important;
	min-height: 18px !important;
	flex-shrink: 0 !important;
	pointer-events: none;
	color: inherit;
	overflow: visible;
}

.uc-gallery-lb__close-icon path {
	stroke: currentColor !important;
	fill: none !important;
}

/* Flechas del lightbox — a los lados de la imagen, sobre el overlay */
.uc-gallery-lb__nav,
.uc-gallery-lb__nav:hover,
.uc-gallery-lb__nav:focus,
.uc-gallery-lb__nav:active {
	position: relative;
	z-index: 3;
	flex-shrink: 0;

	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 44px !important;
	height: 44px !important;
	margin: 0 !important;
	padding: 0 !important;

	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	appearance: none !important;

	border: 0 !important;
	border-radius: 50% !important;
	background: rgba(255, 255, 255, 0.94) !important;
	background-image: none !important;
	box-shadow: 0 2px 12px rgba(15, 23, 42, 0.22) !important;
	text-shadow: none !important;

	color: var(--e-global-color-brand-600, #0a6bb8) !important;

	font: inherit !important;
	font-size: 0 !important;
	line-height: 0 !important;
	text-transform: none !important;

	cursor: pointer;
	transform: none;
	transition: background-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
	-webkit-tap-highlight-color: transparent;
}

.uc-gallery-lb__nav:hover {
	background: #ffffff !important;
	transform: scale(1.06);
	box-shadow: 0 4px 16px rgba(15, 23, 42, 0.28) !important;
}

.uc-gallery-lb__nav:active {
	background: rgba(255, 255, 255, 0.88) !important;
	transform: scale(0.96);
}

.uc-gallery-lb__nav:focus-visible {
	outline: none;
	background: #ffffff !important;
	box-shadow:
		0 0 0 2px rgba(255, 255, 255, 0.95),
		0 0 0 4px var(--e-global-color-brand-600, #0a6bb8) !important;
}

.uc-gallery-lb__nav svg,
.uc-gallery-lb__nav .urra-gallery__arrow-icon {
	display: block !important;
	width: 20px !important;
	height: 20px !important;
	min-width: 20px !important;
	min-height: 20px !important;
	flex-shrink: 0 !important;
	overflow: visible !important;
	pointer-events: none;
	color: inherit;
}

.uc-gallery-lb__nav svg path,
.uc-gallery-lb__nav .urra-gallery__arrow-icon path {
	stroke: currentColor !important;
	fill: none !important;
	stroke-width: 2 !important;
	vector-effect: non-scaling-stroke;
}

.uc-gallery-lb__nav::before,
.uc-gallery-lb__nav::after {
	content: none !important;
	display: none !important;
}

.uc-gallery-lb__counter {
	position: absolute;
	bottom: -36px;
	left: 50%;
	margin: 0;
	transform: translateX(-50%);
	font-size: 13px;
	font-weight: 600;
	color: #ffffff;
	text-shadow: 0 1px 8px rgba(15, 23, 42, 0.45);
}

/* ─── Animaciones ────────────────────────────────────────────── */

@keyframes cfGalleryOverlayIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@keyframes cfGalleryOverlayOut {
	from {
		opacity: 1;
	}
	to {
		opacity: 0;
	}
}

@keyframes cfGalleryFadeOut {
	from {
		opacity: 1;
	}
	to {
		opacity: 0;
	}
}

/* Cierre: fade de todo el lightbox a la vez (overlay + imagen + controles). */
.uc-gallery-lb--closing {
	animation: cfGalleryFadeOut 220ms ease forwards;
	pointer-events: none;
}

.uc-gallery-lb--closing .uc-gallery-lb__overlay {
	animation: none;
	opacity: 1;
}

/* ─── Mobile lightbox ────────────────────────────────────────── */

@media (max-width: 767.98px) {
	.uc-gallery-lb {
		padding: 0 8px;
		align-items: center;
	}

	.uc-gallery-lb__panel {
		width: 100%;
		max-height: 88vh;
		padding: 0;
		box-sizing: border-box;
	}

	.uc-gallery-lb__stage {
		gap: 8px;
	}

	.uc-gallery-lb__close,
	.uc-gallery-lb__close:hover,
	.uc-gallery-lb__close:focus,
	.uc-gallery-lb__close:active {
		top: 8px;
		right: 8px;
		width: 40px;
		height: 40px;
	}

	.uc-gallery-lb__nav,
	.uc-gallery-lb__nav:hover,
	.uc-gallery-lb__nav:focus,
	.uc-gallery-lb__nav:active {
		width: 40px !important;
		height: 40px !important;
	}

	.uc-gallery-lb__counter {
		position: relative;
		bottom: auto;
		margin-top: 12px;
		left: auto;
		transform: none;
		color: #ffffff;
	}
}

/* ─── Reduced motion ─────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
	.urra-gallery__arrow,
	.uc-gallery__bullet,
	.urra-gallery__bullets .swiper-pagination-bullet,
	.uc-gallery-lb__close,
	.uc-gallery-lb__nav,
	.uc-gallery-lb__overlay,
	.uc-gallery-lb--closing {
		transition: none;
		animation: none;
	}
}
