/* =========================================================
   Transiciones entre páginas
   - Chrome / Edge / Safari 18.2+: View Transitions nativas entre documentos.
     La página que se va se desvanece subiendo un pelín; la nueva entra
     y la cabecera se queda quieta (no parpadea).
   - Resto (Firefox): el JS hace el fundido de salida (body.hv-leaving).
   - En todos: los bloques del contenido entran escalonados.
   Con "reducir movimiento" activado no se anima nada.
   ========================================================= */

:root {
	--hv-pt-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--hv-pt-out: 0.28s;
	--hv-pt-in: 0.55s;
}

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

	/* ---------- View Transitions nativas ---------- */

	@view-transition {
		navigation: auto;
	}

	/* La cabecera es un elemento con nombre propio: no se funde con el resto */
	.wp-site-blocks > header.wp-block-template-part {
		view-transition-name: hv-header;
		/* view-transition-name crea un contexto de apilamiento: sin esto,
		   el desplegable del menú quedaría por detrás del contenido. */
		position: relative;
		z-index: 100;
	}
	::view-transition-group(hv-header) {
		animation-duration: 0.45s;
		animation-timing-function: var(--hv-pt-ease);
	}

	::view-transition-old(root) {
		animation: hv-pt-out var(--hv-pt-out) cubic-bezier(0.4, 0, 1, 1) both;
	}
	::view-transition-new(root) {
		animation: hv-pt-in var(--hv-pt-in) 0.12s var(--hv-pt-ease) both;
	}

	/* ---------- Respaldo sin View Transitions (lo activa el JS) ---------- */

	body.hv-leaving .wp-site-blocks > :not(header) {
		animation: hv-pt-out var(--hv-pt-out) cubic-bezier(0.4, 0, 1, 1) forwards;
	}

	/* ---------- Entrada escalonada del contenido ----------
	   Se anima "translate" (no "transform") para no pisar los efectos
	   de hover de los listados, que usan transform. */

	/* Bloques principales de cada página (en la portada, el bloque
	   de presentación ya tiene su propia animación: se respeta). */
	body:not(.home) .wp-site-blocks > main > *,
	body.home .wp-block-post-content > :not(:first-child),
	.wp-site-blocks > footer {
		animation: hv-rise-in 0.8s var(--hv-pt-ease) backwards;
		animation-delay: calc(0.1s + var(--hv-i, 0) * 0.08s);
	}
	.wp-site-blocks > main > :nth-child(2),
	.wp-block-post-content > :nth-child(2) { --hv-i: 1; }
	.wp-site-blocks > main > :nth-child(3),
	.wp-block-post-content > :nth-child(3) { --hv-i: 2; }
	.wp-site-blocks > main > :nth-child(4),
	.wp-block-post-content > :nth-child(4) { --hv-i: 3; }
	.wp-site-blocks > main > :nth-child(n+5),
	.wp-block-post-content > :nth-child(n+5) { --hv-i: 4; }
	.wp-site-blocks > footer { --hv-i: 5; }

	/* Elementos de los listados (trabajos y entradas): uno detrás de otro */
	.wp-block-post-template > li {
		animation: hv-rise-in 0.7s var(--hv-pt-ease) backwards;
		animation-delay: calc(0.2s + var(--hv-j, 0) * 0.06s);
	}
	.wp-block-post-template > li:nth-child(2) { --hv-j: 1; }
	.wp-block-post-template > li:nth-child(3) { --hv-j: 2; }
	.wp-block-post-template > li:nth-child(4) { --hv-j: 3; }
	.wp-block-post-template > li:nth-child(5) { --hv-j: 4; }
	.wp-block-post-template > li:nth-child(6) { --hv-j: 5; }
	.wp-block-post-template > li:nth-child(7) { --hv-j: 6; }
	.wp-block-post-template > li:nth-child(8) { --hv-j: 7; }
	.wp-block-post-template > li:nth-child(9) { --hv-j: 8; }
	.wp-block-post-template > li:nth-child(n+10) { --hv-j: 9; }
}

@keyframes hv-pt-out {
	to {
		opacity: 0;
		translate: 0 -10px;
		filter: blur(2px);
	}
}

@keyframes hv-pt-in {
	from {
		opacity: 0;
		translate: 0 14px;
	}
}

@keyframes hv-rise-in {
	from {
		opacity: 0;
		translate: 0 22px;
	}
}
