/* ===================================================================
   CMMRM Routes & Trails — isolated overrides
   Everything here is scoped to route pages via body classes.
   Delete this file + the `cmmrm_assets` hook in functions.php
   when the plugin is decommissioned.
   =================================================================== */

/* ---- Site wrapper: prevent CMMRM inline styles from constraining ---- */
body.cmmrm-route-page .wp-site-blocks {
	max-width: none !important;
	margin: 0 !important;
}

/* ---- Archive tile grid ---- */
.cmmrm-routes-archive-tiles {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 1.5rem;
}

body .cmmrm-routes-archive-tiles .cmmrm-shortcode-route-snippet {
	width: auto !important;
	margin-right: 0 !important;
	margin-bottom: 0 !important;
}

body .cmmrm-routes-archive-tiles .cmmrm-shortcode-route-snippet .cmmrm-route-featured-image-large {
	height: auto !important;
	aspect-ratio: 16 / 11;
}

/* ---- Nav alignment fix ---- */
/*
 * The plugin's block/index.php template calls wp_head() before
 * block_template_part('header'), so the per-container layout CSS
 * (justify-content: space-between, flex-wrap: nowrap, constrained
 * max-width) is never output for the header blocks. Provide the
 * missing styles here, scoped to route pages via existing body classes.
 *
 * See: cm-maps-routes-manager-pro/view/frontend/block/index.php
 */

/* Inner flex group — push site title left, nav right, prevent wrapping */
body.cmmrm-route-page .wp-block-group.is-content-justification-space-between.is-nowrap {
	justify-content: space-between !important;
	flex-wrap: nowrap !important;
}

/* Outer header — constrain the inner group to 1600px (matches theme.json wideSize) */
body.cmmrm-route-page header.wp-block-group.alignfull > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
	max-width: 1600px;
	margin-left: auto !important;
	margin-right: auto !important;
}

/*
 * The plugin's block/index.php calls wp_head() before
 * block_template_part('header'), so per-instance block styles
 * are normally lost. The pre-render in functions.php (priority 0
 * of wp_enqueue_scripts) fixes this by rendering the header early.
 * These fallbacks cover any edge cases the pre-render misses.
 */

body.cmmrm-route-page .has-base-background-color {
	background-color: var(--wp--preset--color--background, #dddbd2);
}

body.cmmrm-route-page .wp-block-navigation {
	font-size: var(--wp--preset--font-size--medium, 1rem);
}

/* ---- Map loading overlay ---- */
.cmmrm-loading-overlay {
	position: fixed;
	inset: 0;
	z-index: 10000;
	background: var(--wp--preset--color--base, #fff);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1.25rem;
	transition: opacity 0.5s ease;
}
.cmmrm-loading-overlay.is-hidden {
	opacity: 0;
	pointer-events: none;
}
.cmmrm-loading-spinner {
	width: 48px;
	height: 48px;
	border: 4px solid rgba(0,0,0,0.1);
	border-top-color: var(--wp--preset--color--primary, #134d80);
	border-radius: 50%;
	animation: cmmrm-spin 0.7s linear infinite;
}
.cmmrm-loading-text {
	font-size: 1.125rem;
	color: var(--wp--preset--color--contrast, #333);
	font-weight: 500;
}
@keyframes cmmrm-spin {
	to { transform: rotate(360deg); }
}
