/*!
 * Naru Glass Preloader — hoja principal
 *
 * Toda la línea de tiempo se expresa como porcentajes de una única duración
 * (--gp-dur). Cambiar esa variable reescala la secuencia completa sin tocar
 * ningún keyframe. Las curvas se aplican por keyframe, no globalmente, para
 * que las fases de espera no se deformen.
 *
 * Fases (fracción de --gp-dur):
 *   0 – 26 %   entrada del logo
 *   8 – 56 %   barra de progreso + barrido de luz sobre el cristal
 *  56 – 76 %   salida del logo
 *  56 – 94 %   apertura de las puertas
 *  94 – 100 %  retirada del overlay
 */

#naru-gp {
	--gp-blur-scale: 1;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	height: 100%;
	min-height: 100vh;
	margin: 0;
	padding: 0;
	overflow: hidden;
	isolation: isolate;
	animation: gp-overlay var(--gp-dur, 3000ms) linear forwards;
	-webkit-tap-highlight-color: transparent;
}

@supports (height: 100dvh) {
	#naru-gp {
		min-height: 100dvh;
	}
}

#naru-gp.is-preview {
	position: absolute;
	height: 100%;
	min-height: 0;
}

/* ------------------------------------------------------------------ *
 * Cristal
 * ------------------------------------------------------------------ */

#naru-gp .naru-gp__glass {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
}

#naru-gp .naru-gp__pane {
	position: absolute;
	top: 0;
	bottom: 0;
	width: calc(50% + 1px);
	overflow: hidden;
	background:
		linear-gradient(
			160deg,
			rgba(var(--gp-bg), calc(var(--gp-tint) * 0.88)) 0%,
			rgba(var(--gp-bg), var(--gp-tint)) 45%,
			rgba(var(--gp-bg), calc(var(--gp-tint) * 0.94)) 100%
		);
	-webkit-backdrop-filter: blur(calc(var(--gp-blur) * var(--gp-blur-scale))) saturate(135%);
	backdrop-filter: blur(calc(var(--gp-blur) * var(--gp-blur-scale))) saturate(135%);
	box-shadow:
		inset 0 0 160px rgba(255, 255, 255, 0.045),
		0 0 60px rgba(0, 0, 0, 0.35);
	transform: translate3d(0, 0, 0);
	backface-visibility: hidden;
	will-change: transform;
}

#naru-gp.is-solid .naru-gp__pane {
	-webkit-backdrop-filter: none;
	backdrop-filter: none;
	background: rgb(var(--gp-bg));
}

/* Navegadores sin backdrop-filter: se compensa opacando el tinte. */
@supports not ((-webkit-backdrop-filter: blur(2px)) or (backdrop-filter: blur(2px))) {
	#naru-gp .naru-gp__pane {
		background: rgba(var(--gp-bg), min(1, calc(var(--gp-tint) + 0.22)));
	}
}

#naru-gp .naru-gp__pane--a {
	left: 0;
	animation: gp-pane-a var(--gp-dur, 3000ms) linear both;
}

#naru-gp .naru-gp__pane--b {
	right: 0;
	animation: gp-pane-b var(--gp-dur, 3000ms) linear both;
}

/* Canto interior: la junta luminosa entre las dos hojas. */
#naru-gp .naru-gp__edge {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 2px;
	opacity: 0.75;
	background: linear-gradient(
		to bottom,
		transparent 0%,
		rgba(255, 255, 255, 0.5) 18%,
		var(--gp-accent) 50%,
		rgba(255, 255, 255, 0.5) 82%,
		transparent 100%
	);
	filter: drop-shadow(0 0 12px var(--gp-accent));
}

#naru-gp .naru-gp__pane--a .naru-gp__edge {
	right: 0;
}

#naru-gp .naru-gp__pane--b .naru-gp__edge {
	left: 0;
}

/* Barrido de luz sobre el cristal. */
#naru-gp .naru-gp__sheen {
	position: absolute;
	top: -25%;
	left: -25%;
	right: -25%;
	bottom: -25%;
	background: linear-gradient(
		112deg,
		transparent 38%,
		rgba(255, 255, 255, 0.1) 45%,
		rgba(255, 255, 255, 0.26) 50%,
		rgba(255, 255, 255, 0.1) 55%,
		transparent 62%
	);
	mix-blend-mode: screen;
	transform: translate3d(-75%, 0, 0);
	animation: gp-sheen var(--gp-dur, 3000ms) linear both;
	will-change: transform;
}

/* ------------------------------------------------------------------ *
 * Escenario (logo, texto, barra)
 * ------------------------------------------------------------------ */

#naru-gp .naru-gp__stage {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: clamp(14px, 2.4vw, 26px);
	padding: clamp(18px, 5vw, 48px);
	text-align: center;
	pointer-events: none;
}

#naru-gp .naru-gp__logo {
	animation: gp-logo var(--gp-dur, 3000ms) linear both;
	will-change: transform, opacity, filter;
}

#naru-gp .naru-gp__logo img {
	display: block;
	width: min(var(--gp-logo, 260px), 68vw);
	height: auto;
	max-height: 46vh;
	object-fit: contain;
	user-select: none;
}

#naru-gp .naru-gp__logo--text span {
	display: block;
	font-family: inherit;
	font-size: clamp(1.6rem, 6vw, 2.6rem);
	font-weight: 600;
	letter-spacing: 0.01em;
	line-height: 1.15;
	color: var(--gp-label, #e8eef6);
	text-wrap: balance;
}

#naru-gp .naru-gp__label {
	margin: 0;
	max-width: 32ch;
	font-size: clamp(0.85rem, 2.6vw, 1rem);
	line-height: 1.5;
	color: var(--gp-label, #e8eef6);
	opacity: 0.72;
	animation: gp-label var(--gp-dur, 3000ms) linear both;
}

#naru-gp .naru-gp__bar {
	position: relative;
	width: min(220px, 46vw);
	height: 2px;
	overflow: hidden;
	border-radius: 2px;
	background: rgba(255, 255, 255, 0.14);
	animation: gp-label var(--gp-dur, 3000ms) linear both;
}

#naru-gp .naru-gp__bar i {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	width: 100%;
	transform: scaleX(0);
	transform-origin: left center;
	background: linear-gradient(90deg, rgba(var(--gp-bg), 0), var(--gp-accent));
	animation: gp-bar var(--gp-dur, 3000ms) linear both;
}

/* Modo "esperar a la carga": la barra pasa a indeterminada. */
#naru-gp.is-gated .naru-gp__bar i {
	width: 38%;
	transform: none;
	transform-origin: center;
	animation: gp-bar-loop 1200ms cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

/* ------------------------------------------------------------------ *
 * Compuerta: pausa la apertura hasta que el runtime dé paso
 * ------------------------------------------------------------------ */

#naru-gp.is-gated,
#naru-gp.is-gated .naru-gp__pane,
#naru-gp.is-gated .naru-gp__sheen,
#naru-gp.is-gated .naru-gp__logo,
#naru-gp.is-gated .naru-gp__label,
#naru-gp.is-gated .naru-gp__bar {
	animation-play-state: paused;
}

/* ------------------------------------------------------------------ *
 * Variante vertical
 * ------------------------------------------------------------------ */

#naru-gp.is-vertical .naru-gp__pane {
	width: 100%;
	height: calc(50% + 1px);
	left: 0;
	right: 0;
	top: auto;
	bottom: auto;
}

#naru-gp.is-vertical .naru-gp__pane--a {
	top: 0;
	animation-name: gp-pane-a-v;
}

#naru-gp.is-vertical .naru-gp__pane--b {
	bottom: 0;
	animation-name: gp-pane-b-v;
}

#naru-gp.is-vertical .naru-gp__edge {
	top: auto;
	bottom: auto;
	left: 0;
	right: 0;
	width: auto;
	height: 2px;
	background: linear-gradient(
		to right,
		transparent 0%,
		rgba(255, 255, 255, 0.5) 18%,
		var(--gp-accent) 50%,
		rgba(255, 255, 255, 0.5) 82%,
		transparent 100%
	);
}

#naru-gp.is-vertical .naru-gp__pane--a .naru-gp__edge {
	bottom: 0;
}

#naru-gp.is-vertical .naru-gp__pane--b .naru-gp__edge {
	top: 0;
}

/* ------------------------------------------------------------------ *
 * Keyframes
 * ------------------------------------------------------------------ */

@keyframes gp-overlay {
	0%,
	55.9% {
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
	}

	56%,
	99.9% {
		opacity: 1;
		visibility: visible;
		pointer-events: none;
	}

	100% {
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
	}
}

@keyframes gp-pane-a {
	0%,
	56% {
		transform: translate3d(0, 0, 0);
		animation-timing-function: var(--gp-ease, cubic-bezier(0.76, 0, 0.16, 1));
	}

	94%,
	100% {
		transform: translate3d(-100.5%, 0, 0);
	}
}

@keyframes gp-pane-b {
	0%,
	56% {
		transform: translate3d(0, 0, 0);
		animation-timing-function: var(--gp-ease, cubic-bezier(0.76, 0, 0.16, 1));
	}

	94%,
	100% {
		transform: translate3d(100.5%, 0, 0);
	}
}

@keyframes gp-pane-a-v {
	0%,
	56% {
		transform: translate3d(0, 0, 0);
		animation-timing-function: var(--gp-ease, cubic-bezier(0.76, 0, 0.16, 1));
	}

	94%,
	100% {
		transform: translate3d(0, -100.5%, 0);
	}
}

@keyframes gp-pane-b-v {
	0%,
	56% {
		transform: translate3d(0, 0, 0);
		animation-timing-function: var(--gp-ease, cubic-bezier(0.76, 0, 0.16, 1));
	}

	94%,
	100% {
		transform: translate3d(0, 100.5%, 0);
	}
}

@keyframes gp-logo {
	0% {
		opacity: 0;
		filter: blur(12px);
		transform: translate3d(0, 16px, 0) scale(0.9);
		animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
	}

	26%,
	56% {
		opacity: 1;
		filter: blur(0);
		transform: translate3d(0, 0, 0) scale(1);
		animation-timing-function: cubic-bezier(0.55, 0, 0.35, 1);
	}

	76%,
	100% {
		opacity: 0;
		filter: blur(6px);
		transform: translate3d(0, -8px, 0) scale(1.06);
	}
}

@keyframes gp-label {
	0%,
	12% {
		opacity: 0;
		transform: translate3d(0, 8px, 0);
		animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
	}

	32%,
	56% {
		opacity: 0.72;
		transform: translate3d(0, 0, 0);
	}

	70%,
	100% {
		opacity: 0;
		transform: translate3d(0, -6px, 0);
	}
}

@keyframes gp-bar {
	0%,
	8% {
		transform: scaleX(0);
		animation-timing-function: cubic-bezier(0.32, 0.72, 0.28, 1);
	}

	56%,
	100% {
		transform: scaleX(1);
	}
}

@keyframes gp-bar-loop {
	0% {
		transform: translate3d(-140%, 0, 0);
	}

	100% {
		transform: translate3d(400%, 0, 0);
	}
}

@keyframes gp-sheen {
	0%,
	10% {
		transform: translate3d(-75%, 0, 0);
		opacity: 0;
		animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
	}

	18% {
		opacity: 1;
	}

	50% {
		transform: translate3d(75%, 0, 0);
		opacity: 1;
	}

	62%,
	100% {
		transform: translate3d(75%, 0, 0);
		opacity: 0;
	}
}

@keyframes gp-reduced {
	0%,
	55% {
		opacity: 1;
		visibility: visible;
	}

	100% {
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
	}
}

/* ------------------------------------------------------------------ *
 * Adaptaciones
 * ------------------------------------------------------------------ */

@media (max-width: 640px) {
	#naru-gp {
		/* El desenfoque de fondo es el coste dominante en GPU móvil. */
		--gp-blur-scale: 0.66;
	}

	#naru-gp .naru-gp__pane {
		box-shadow: inset 0 0 90px rgba(255, 255, 255, 0.04);
	}
}

@media (prefers-reduced-motion: reduce) {
	#naru-gp .naru-gp__pane,
	#naru-gp .naru-gp__sheen,
	#naru-gp .naru-gp__logo,
	#naru-gp .naru-gp__label,
	#naru-gp .naru-gp__bar,
	#naru-gp .naru-gp__bar i {
		animation: none !important;
	}

	#naru-gp .naru-gp__logo,
	#naru-gp .naru-gp__label,
	#naru-gp .naru-gp__bar {
		opacity: 1;
		filter: none;
		transform: none;
	}

	#naru-gp .naru-gp__bar i {
		transform: scaleX(1);
	}

	#naru-gp {
		animation: gp-reduced 900ms linear forwards !important;
	}
}

/* Modo alto contraste: el cristal translúcido deja de ser legible. */
@media (forced-colors: active) {
	#naru-gp .naru-gp__pane {
		background: Canvas;
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
	}
}
