/* ==========================================================================
   Component: Footer reveal — pie fijo detrás del contenido (z más bajo); al final,
   scroll en flujo normal si el pie > viewport.
   ========================================================================== */

:root {
	--mwm-footer-reveal-offset: 0px;
}

/*
 * Capas: todo hijo directo de .wp-site-blocks menos header (.mwm-header) y footer
 * (.mwm-footer) va por encima del pie fijo. No usar :has(.mwm-header) — la clase está
 * en el propio template part, no en un descendiente.
 */

/* Pie detrás del contenido que hace scroll */
body.mwm-footer-reveal-active:not(.mwm-footer-reveal-flow) .mwm-footer {
	position: fixed;
	/* Misma franja útil que footer-reveal.js (innerHeight − barra) para evitar saltos al pasar a flow */
	top: var(--wp-admin--admin-bar--height, 0px);
	left: 0;
	right: 0;
	width: 100%;
	min-height: calc(100vh - var(--wp-admin--admin-bar--height, 0px));
	min-height: calc(100dvh - var(--wp-admin--admin-bar--height, 0px));
	z-index: -1;
	box-sizing: border-box;
}

/* Bloques de página (hero, grupos, main…) por encima del footer */
body.mwm-footer-reveal-active:not(.mwm-footer-reveal-flow) .wp-site-blocks > *:not(.mwm-footer):not(.mwm-header) {
	position: relative;
	z-index: 1;
}

/* Hueco de scroll en main cuando existe */
body.mwm-footer-reveal-active:not(.mwm-footer-reveal-flow) main {
	margin-bottom: var(--mwm-footer-reveal-offset, 100vh);
}

/* Plantillas sin <main>: margen en el contenedor raíz */
body.mwm-footer-reveal-active:not(.mwm-footer-reveal-flow) .wp-site-blocks:not(:has(main)) {
	margin-bottom: var(--mwm-footer-reveal-offset, 100vh);
}

/* Scroll al final: footer en documento */
body.mwm-footer-reveal-active.mwm-footer-reveal-flow .mwm-footer {
	position: static !important;
	top: auto !important;
	left: auto !important;
	right: auto !important;
	width: auto !important;
	min-height: calc(100vh - var(--wp-admin--admin-bar--height, 0px)) !important;
	min-height: calc(100dvh - var(--wp-admin--admin-bar--height, 0px)) !important;
	z-index: auto !important;
}

body.mwm-footer-reveal-active.mwm-footer-reveal-flow main,
body.mwm-footer-reveal-active.mwm-footer-reveal-flow .wp-site-blocks:not(:has(main)) {
	margin-bottom: 0 !important;
}

body.mwm-footer-reveal-active.mwm-footer-reveal-flow .wp-site-blocks > *:not(.mwm-footer):not(.mwm-header) {
	position: static;
	z-index: auto;
}

/* Móvil: sin reveal */
@media (max-width: 782px) {
	body.mwm-footer-reveal-active .mwm-footer {
		position: static !important;
		top: auto !important;
		left: auto !important;
		right: auto !important;
		width: auto !important;
		min-height: calc(100vh - var(--wp-admin--admin-bar--height, 0px)) !important;
		min-height: calc(100dvh - var(--wp-admin--admin-bar--height, 0px)) !important;
		z-index: auto !important;
	}

	body.mwm-footer-reveal-active main,
	body.mwm-footer-reveal-active .wp-site-blocks:not(:has(main)) {
		margin-bottom: 0 !important;
	}

	body.mwm-footer-reveal-active .wp-site-blocks > *:not(.mwm-footer):not(.mwm-header) {
		position: static;
		z-index: auto;
	}
}
