/* Popup Home — frontend */
#phpu-popup {
	/* Margen mínimo alrededor del recuadro: horizontal (x) y vertical (y). */
	--phpu-gx: clamp(32px, 7vw, 120px);
	--phpu-gy: clamp(32px, 8vh, 110px);
	--phpu-vh: 100vh;
	--phpu-ease: cubic-bezier(.16, 1, .3, 1);
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100vw;
	height: var(--phpu-vh);
	overflow: hidden;
	overscroll-behavior: contain;
	touch-action: none;
	perspective: 1400px;
	perspective-origin: 50% 50%;
}
@supports (height: 100dvh) {
	#phpu-popup { --phpu-vh: 100dvh; }
}
#phpu-popup[hidden] { display: none !important; }

@media (max-width: 767px) {
	#phpu-popup {
		--phpu-gx: 20px;
		--phpu-gy: clamp(28px, 7vh, 64px);
	}
}

/* Fondo: oscurecido y difuminado suave, la web sigue intuyéndose detrás */
.phpu__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(12, 12, 16, .38);
	-webkit-backdrop-filter: blur(0px);
	backdrop-filter: blur(0px);
	opacity: 0;
	transition: opacity .6s ease, backdrop-filter .8s ease, -webkit-backdrop-filter .8s ease;
	cursor: pointer;
}
.phpu.is-open .phpu__backdrop {
	opacity: 1;
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
}

.phpu__stage {
	position: relative;
	transform-style: preserve-3d;
	pointer-events: none;
}

/* La imagen llega desde el fondo: profundidad + giro + desenfoque + fade */
.phpu__frame {
	position: relative;
	display: block;
	line-height: 0;
	border-radius: 14px;
	overflow: hidden;
	pointer-events: auto;
	opacity: 0;
	filter: blur(18px) brightness(.6);
	transform: translate3d(0, 40px, -900px) rotateX(14deg) scale(.7);
	box-shadow: 0 0 0 rgba(0, 0, 0, 0);
	transition:
		transform 1.1s var(--phpu-ease),
		opacity .8s ease,
		filter 1s var(--phpu-ease),
		box-shadow 1.2s ease;
	will-change: transform, opacity, filter;
}
.phpu.is-open .phpu__frame {
	opacity: 1;
	filter: blur(0) brightness(1);
	transform: translate3d(0, 0, 0) rotateX(0) scale(1);
	box-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 0 60px rgba(255, 255, 255, .08);
}
.phpu.is-closing .phpu__frame {
	opacity: 0;
	filter: blur(12px);
	transform: translate3d(0, 0, -500px) scale(.85);
	transition-duration: .5s, .4s, .5s, .4s;
	transition-timing-function: ease-in;
}
.phpu.is-closing .phpu__backdrop {
	opacity: 0;
	transition-duration: .45s;
}

/* Imagen: recuadro grande pero siempre con margen en los 4 lados */
.phpu__img {
	display: block;
	width: min(1400px, calc(100vw - var(--phpu-gx) * 2), calc((var(--phpu-vh) - var(--phpu-gy) * 2) * var(--phpu-r, 1)));
	height: auto;
	max-width: calc(100vw - var(--phpu-gx) * 2);
	max-height: calc(var(--phpu-vh) - var(--phpu-gy) * 2);
	aspect-ratio: var(--phpu-r, auto);
	object-fit: contain;
	margin: 0;
	border: 0;
	-webkit-user-drag: none;
	user-select: none;
}

/* Destello de luz que cruza la imagen al aparecer */
.phpu__shine {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .45) 50%, transparent 65%);
	transform: translateX(-120%);
	mix-blend-mode: soft-light;
}
.phpu.is-open .phpu__shine {
	animation: phpu-shine 1.4s .75s var(--phpu-ease) forwards;
}
@keyframes phpu-shine {
	to { transform: translateX(120%); }
}

/* Botón cerrar */
.phpu__close {
	position: absolute;
	top: 10px;
	right: 10px;
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	margin: 0;
	border: 1px solid rgba(255, 255, 255, .35);
	border-radius: 50%;
	background: rgba(0, 0, 0, .55);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	color: #fff;
	line-height: 1;
	cursor: pointer;
	opacity: 0;
	transform: scale(.6) rotate(-90deg);
	transition: opacity .4s ease .9s, transform .5s var(--phpu-ease) .9s, background .2s ease;
}
.phpu.is-open .phpu__close {
	opacity: 1;
	transform: scale(1) rotate(0);
}
.phpu__close:hover { background: rgba(0, 0, 0, .8); }
.phpu__close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Bloqueo de scroll mientras el popup está abierto */
html.phpu-lock,
html.phpu-lock body {
	overflow: hidden !important;
	overscroll-behavior: none;
}

/* Accesibilidad: movimiento reducido = fade simple */
@media (prefers-reduced-motion: reduce) {
	.phpu__frame,
	.phpu.is-open .phpu__frame,
	.phpu.is-closing .phpu__frame {
		transform: none;
		filter: none;
		transition: opacity .3s ease;
	}
	.phpu__shine { display: none; }
	.phpu__close { transition: opacity .3s ease; transform: none; }
}

/* Enlace de redirección sobre la imagen */
.phpu__link {
	display: block;
	line-height: 0;
	cursor: pointer;
}
.phpu__link:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }
