/*
 * Movimiento del sitio (solo en el sitio público, no en el editor).
 *
 * Lo que entra al scrollear arranca oculto y am-fx.js lo muestra. Si el script
 * no carga, una animación de seguridad lo muestra a los 2,5 s; con «reducir
 * movimiento» no se oculta nada. Todo usa transform, opacity y clip-path.
 */
:root {
	--am-out: cubic-bezier(0.16, 1, 0.3, 1);
	--am-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
	--am-struct: cubic-bezier(0.77, 0, 0.18, 1);
}

@keyframes am-in {

	from {
		opacity: 0;
		transform: translateY(28px);
		filter: blur(10px);
	}
}

@keyframes am-in-s {

	from {
		opacity: 0;
		transform: translateY(10px);
	}
}

@keyframes am-line {

	from { transform: translateY(108%); }
}

@keyframes am-veil {

	from { clip-path: inset(100% 0 0 0); }

	to { clip-path: inset(0 0 0 0); }
}

@keyframes am-wipe {

	from { clip-path: inset(0 100% 0 0); }

	to { clip-path: inset(0 0 0 0); }
}

@keyframes am-settle {

	from { transform: translateY(22%) scale(1.1); }
}

@keyframes am-r-fail {

	to { opacity: 1; }
}

/* Título que sube línea por línea detrás de una máscara */
.am-line {
	display: block;
	overflow: hidden;
	padding: 0 0.04em 0.1em;
	margin: 0 -0.04em -0.1em;
}

.am-line-in { display: block; }

/* Título que sube palabra por palabra (lo arma am-fx.js) */
.am-w {
	display: inline-block;
	overflow: hidden;
	vertical-align: top;
	padding: 0 0.04em 0.14em;
	margin: 0 -0.04em -0.14em;
}

.am-wi { display: inline-block; }

@media (prefers-reduced-motion: no-preference) {

	/* Entradas de la primera pantalla: CSS puro, arrancan con la página */
	[data-in] { animation: am-in 1.1s var(--am-out) var(--d, 0s) backwards; }

	[data-in="s"] {
		animation-name: am-in-s;
		animation-duration: 0.8s;
	}

	.am-line-in { animation: am-line 1.1s var(--am-out) var(--d, 0s) backwards; }

	[data-veil-in] { animation: am-veil 1.2s var(--am-struct) var(--d, 0s) backwards; }

	.am-logo--intro { animation: am-wipe 0.8s var(--am-struct) backwards; }

	/* Entradas al scrollear */
	[data-r]:not([data-r-on]) { opacity: 0; }

	html:not([data-fx]) [data-r]:not([data-r-on]) { animation: am-r-fail 0.01s linear 2.5s forwards; }
}

/* Cambio de página: fundido corto; la cabecera queda quieta */
@view-transition {
	navigation: auto;
}

@keyframes am-vt-out {

	to { opacity: 0; }
}

@keyframes am-vt-in {

	from { opacity: 0; }
}

::view-transition-old(root) { animation: am-vt-out 0.2s cubic-bezier(0.4, 0, 1, 1) both; }

::view-transition-new(root) { animation: am-vt-in 0.45s var(--am-ease) both; }

@media (prefers-reduced-motion: reduce) {

	::view-transition-group(*),
	::view-transition-old(*),
	::view-transition-new(*) { animation: none !important; }
}

/*
 * Pantalla de carga (includes/loader.php): el logo AM con las letras que
 * ruedan. Solo se ve si el script del <head> marca data-am-load en <html>; sin
 * JavaScript o con «reducir movimiento» no existe. Si se trabara, desaparece
 * sola a los 9 s.
 */
.am-loader { display: none; }

@keyframes am-loader-roll {

	0% { transform: translateY(0); }

	45%,
	100% { transform: translateY(-50%); }
}

@keyframes am-loader-pop {

	from {
		opacity: 0;
		transform: scale(0.86);
	}
}

@keyframes am-loader-fail {

	to {
		visibility: hidden;
		opacity: 0;
	}
}

@media (prefers-reduced-motion: no-preference) {

	html[data-am-load] .am-loader {
		position: fixed;
		inset: 0;
		z-index: 100000;
		display: grid;
		place-items: center;
		background: var(--wp--preset--color--surface-100, #0c0c0d);
		opacity: 1;
		transition: opacity 0.45s var(--am-ease);
		animation: am-loader-fail 0.01s linear 9s forwards;
	}

	html[data-am-load="out"] .am-loader {
		opacity: 0;
		pointer-events: none;
	}

	.am-loader__mark {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 72px;
		height: 72px;
		background: var(--wp--preset--color--accent, #ff5a1f);
		color: var(--wp--preset--color--on-accent, #0c0c0d);
		font-family: var(--wp--preset--font-family--jost, "Jost", system-ui, sans-serif);
		font-size: 36px;
		font-weight: 600;
		line-height: 1;
		letter-spacing: -0.015em;
		animation: am-loader-pop 0.5s var(--am-out) backwards;
	}

	.am-loader__l {
		display: block;
		height: 1em;
		overflow: hidden;
		line-height: 1;
	}

	.am-loader__li {
		display: flex;
		flex-direction: column;
		animation: am-loader-roll 1.5s var(--am-struct) var(--ld, 0s) infinite;
	}

	.am-loader__li::after {
		content: attr(data-l);
		display: block;
		height: 1em;
		line-height: 1;
	}

	/* Mientras se ve la pantalla de carga, lo de abajo espera para entrar. */
	html[data-am-load="first"] :is([data-in], .am-line-in, [data-veil-in], .am-logo--intro),
	html[data-am-load="slow"] :is([data-in], .am-line-in, [data-veil-in], .am-logo--intro) {
		animation-play-state: paused;
	}
}

@media (max-width: 640px) {

	.am-loader__mark {
		width: 56px;
		height: 56px;
		font-size: 28px;
	}
}

@media (prefers-reduced-motion: reduce) {

	.am-loader { display: none !important; }
}
