/* ViralMente motion — transiciones del sitio.
   Solo se animan transform, opacity y clip-path. Todo lo que se mueve
   vive dentro de prefers-reduced-motion: no-preference; con movimiento
   reducido queda el estado final (y fundidos cortos). */

:root {
	--vm-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
	--vm-ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);
	--vm-ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
	--vm-t-press: 140ms;
	--vm-t-hover: 180ms;
	--vm-t-ui: 240ms;
	--vm-t-reveal: 700ms;
}

/* ---------------------------------------------------------------
   1. Transiciones entre paginas (View Transitions, mismo origen)
   --------------------------------------------------------------- */

@view-transition {
	navigation: auto;
}

/* La cabecera se queda quieta mientras cambia el contenido */
.site-header {
	view-transition-name: vm-header;
}

::view-transition-group(vm-header) {
	animation: none;
}

/* En el articulo, la imagen destacada es el destino de la miniatura.
   El script en linea de 17-motion.php nombra la miniatura del enlace. */
.single .featured-image img {
	view-transition-name: vm-hero;
}

/* La imagen que viaja (miniatura <-> destacada) se recorta, no se deforma */
::view-transition-old(vm-hero),
::view-transition-new(vm-hero) {
	height: 100%;
	object-fit: cover;
	overflow: clip;
}

@media (prefers-reduced-motion: no-preference) {
	::view-transition-old(root) {
		animation: vm-page-out 160ms var(--vm-ease-out) both;
	}
	::view-transition-new(root) {
		animation: vm-page-in 380ms var(--vm-ease-out) 60ms both;
	}
	::view-transition-group(vm-hero) {
		animation-duration: 460ms;
		animation-timing-function: var(--vm-ease-in-out);
	}
}

@media (prefers-reduced-motion: reduce) {
	::view-transition-group(*) {
		animation: none;
	}
	::view-transition-old(root) {
		animation: vm-page-out 120ms ease both;
	}
	::view-transition-new(root) {
		animation: vm-fade-in 160ms ease both;
	}
}

@keyframes vm-page-out {
	to { opacity: 0; }
}

@keyframes vm-page-in {
	from { opacity: 0; transform: translateY(14px); }
}

@keyframes vm-fade-in {
	from { opacity: 0; }
}

/* ---------------------------------------------------------------
   2. Entradas al hacer scroll
   vm-motion.js marca con data-vm-reveal solo lo que esta fuera de la
   pantalla al cargar; sin JS no se oculta nada.
   --------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
	/* Partes de un articulo del listado: titulo, resumen y meta suben */
	html [data-vm-reveal="rise"] {
		opacity: 0;
		transform: translateY(22px);
		transition:
			opacity 600ms var(--vm-ease-out),
			transform var(--vm-t-reveal) var(--vm-ease-out);
		transition-delay: calc(var(--vm-i, 0) * 80ms);
	}

	/* La imagen del listado se abre desde abajo y se asienta.
	   El recorte va en el enlace interior: IntersectionObserver no ve
	   un elemento recortado por su propio clip-path. */
	html [data-vm-reveal="shutter"] > a {
		display: block;
		clip-path: inset(0 0 100% 0);
		transition: clip-path 900ms var(--vm-ease-in-out);
	}
	html [data-vm-reveal="shutter"] img {
		transform: scale(1.08);
		transition: transform 1300ms var(--vm-ease-soft);
	}

	/* Filas de listas (relacionados, populares, categorias): llegan una a una */
	html [data-vm-reveal="row"] {
		opacity: 0;
		transform: translateY(12px);
		transition:
			opacity 450ms var(--vm-ease-out),
			transform 550ms var(--vm-ease-out);
		transition-delay: calc(var(--vm-i, 0) * 60ms);
	}

	html [data-vm-reveal].is-in {
		opacity: 1;
		transform: none;
	}
	html [data-vm-reveal="shutter"].is-in > a {
		clip-path: inset(0);
	}
	html [data-vm-reveal="shutter"].is-in img {
		transform: none;
	}
}

/* ---------------------------------------------------------------
   3. Barra de progreso de lectura (solo articulos)
   --------------------------------------------------------------- */

.vm-progress {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 1000;
	height: 3px;
	background: var(--vm-accent, var(--accent, #1e73be));
	transform-origin: 0 50%;
	transform: scaleX(0);
	pointer-events: none;
}

.admin-bar .vm-progress {
	top: 32px;
}

@media (max-width: 782px) {
	.admin-bar .vm-progress {
		top: 46px;
	}
}

/* Sin scroll-timeline la barra la mueve vm-motion.js (via --vm-progress) */
.vm-progress.is-js {
	transform: scaleX(var(--vm-progress, 0));
}

@supports (animation-timeline: scroll()) {
	.vm-progress,
	.vm-progress.is-js {
		transform: scaleX(0);
		animation: vm-progress linear both;
		animation-timeline: scroll(root block);
	}
}

@keyframes vm-progress {
	to { transform: scaleX(1); }
}

/* ---------------------------------------------------------------
   4. Respuesta al pulsar y al pasar el raton
   --------------------------------------------------------------- */

.read-more,
.vm-home-cats-cta,
.vm-menu-toggle,
.vm-menu-close,
.site-main button,
.site-main input[type="submit"],
.wp-block-button__link {
	transition:
		transform var(--vm-t-press) var(--vm-ease-out),
		color var(--vm-t-hover) ease,
		background-color var(--vm-t-hover) ease;
}

.read-more:active,
.vm-home-cats-cta:active,
.vm-menu-toggle:active,
.vm-menu-close:active,
.site-main button:active,
.site-main input[type="submit"]:active,
.wp-block-button__link:active {
	transform: scale(0.96);
}

/* El toggle ya usa translateY(-50%) para centrarse */
.vm-menu-toggle:active {
	transform: translateY(-50%) scale(0.92);
}

.entry-title a,
.vm-related-title,
.vm-popular-item a,
.vm-cat-related-link,
.vm-block-link,
.vm-footer a {
	transition: color var(--vm-t-hover) ease;
}

/* Miniaturas del listado: un unico zoom suave dentro del marco */
.post-image,
.vm-related-thumb {
	overflow: hidden;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
	.post-image img,
	.vm-related-thumb img {
		transition: transform 600ms var(--vm-ease-soft);
	}
	.post-image a:hover img,
	.vm-related-item:hover .vm-related-thumb img {
		transform: scale(1.03);
	}
}
