/* Visor de imagenes de producto (order.php y abrir_devolucion.php).
   abrir_devolucion.php se usa sobre todo desde el movil: los gestos y los
   tamanos de los botones estan pensados para dedo, no para raton. */

/* --- Miniatura que abre el visor --------------------------------------- */

.pgal-trigger {
	padding: 0;
	border: 0;
	background: none;
	line-height: 0;
	cursor: zoom-in;
	position: relative;
	display: inline-block;
	border-radius: .375rem;
}

.pgal-trigger:focus-visible {
	outline: 2px solid #0d6efd;
	outline-offset: 2px;
}

.pgal-trigger img {
	transition: transform .15s ease;
}

.pgal-trigger:hover img {
	transform: scale(1.04);
}

/* Contador de imagenes adicionales sobre la miniatura. */
.pgal-trigger-badge {
	position: absolute;
	right: -.35rem;
	bottom: -.35rem;
	min-width: 1.35rem;
	height: 1.35rem;
	padding: 0 .3rem;
	border-radius: .7rem;
	background: rgba(33, 37, 41, .85);
	color: #fff;
	font-size: .7rem;
	line-height: 1.35rem;
	text-align: center;
	pointer-events: none;
}

/* --- Visor -------------------------------------------------------------- */

.pgal {
	position: fixed;
	inset: 0;
	z-index: 20000;
	display: none;
	/* Opaco a proposito: con el fondo del panel entrevisto, sus textos de colores
	   se cuelan por detras del titulo y de la ayuda y no hay quien los lea. */
	background: #000;
	color: #fff;
	/* dvh evita que la barra del navegador movil recorte el visor. */
	height: 100vh;
	height: 100dvh;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
}

.pgal.pgal-abierto {
	display: flex;
	flex-direction: column;
}

body.pgal-bloqueado {
	overflow: hidden;
}

.pgal-barra {
	display: flex;
	align-items: center;
	gap: .75rem;
	padding: .5rem .75rem;
	padding-top: calc(.5rem + env(safe-area-inset-top));
	flex: 0 0 auto;
}

.pgal-titulo {
	flex: 1 1 auto;
	min-width: 0;
	font-size: .9rem;
	line-height: 1.2;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	opacity: .9;
}

.pgal-contador {
	flex: 0 0 auto;
	font-size: .85rem;
	opacity: .75;
	font-variant-numeric: tabular-nums;
}

.pgal-btn {
	border: 0;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	border-radius: 50%;
	width: 2.75rem;
	height: 2.75rem;
	font-size: 1.4rem;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex: 0 0 auto;
}

.pgal-btn:hover,
.pgal-btn:focus-visible {
	background: rgba(255, 255, 255, .25);
}

.pgal-visor {
	flex: 1 1 auto;
	overflow: hidden;
	position: relative;
	min-height: 0;
	cursor: grab;
}

.pgal-visor.pgal-arrastrando {
	cursor: grabbing;
}

.pgal-track {
	display: flex;
	height: 100%;
	will-change: transform;
}

.pgal-track.pgal-animado {
	transition: transform .25s ease-out;
}

.pgal-slide {
	flex: 0 0 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: .5rem;
}

.pgal-slide img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	pointer-events: none;
	-webkit-user-drag: none;
}

.pgal-slide.pgal-zoom img {
	will-change: transform;
}

/* Flechas: en movil molestan sobre la imagen, se ocultan y se navega
   deslizando (las miniaturas de abajo siguen sirviendo para saltar). */
.pgal-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 3rem;
	height: 3rem;
	font-size: 1.25rem;
	background: rgba(0, 0, 0, .45);
}

.pgal-prev { left: .5rem; }
.pgal-next { right: .5rem; }

.pgal-strip {
	flex: 0 0 auto;
	display: flex;
	gap: .5rem;
	padding: .5rem .75rem;
	padding-bottom: calc(.5rem + env(safe-area-inset-bottom));
	overflow-x: auto;
	overflow-y: hidden;
	touch-action: pan-x;
	scrollbar-width: thin;
}

.pgal-strip img {
	width: 3.5rem;
	height: 3.5rem;
	object-fit: contain;
	background: rgba(255, 255, 255, .08);
	border-radius: .35rem;
	padding: .15rem;
	cursor: pointer;
	opacity: .55;
	flex: 0 0 auto;
}

.pgal-strip img.pgal-activa {
	opacity: 1;
	box-shadow: 0 0 0 2px #fff inset;
}

.pgal-ayuda {
	flex: 0 0 auto;
	text-align: center;
	font-size: .75rem;
	opacity: .55;
	padding-bottom: .4rem;
}

@media (max-width: 767.98px) {
	.pgal-nav {
		display: none;
	}
	.pgal-strip img {
		width: 3rem;
		height: 3rem;
	}
}

@media (hover: none) {
	.pgal-trigger:hover img {
		transform: none;
	}
}
