/*
 * Header modes (engine 2.1.0, E10). Loads where a block carries the class
 * "revsults-header" (inc/navigation.php). The bar's own look (blur, border,
 * z-index) stays in base.css; this file holds the sticky shell, the burger
 * and the phone menu button. Tokens only.
 *
 *   settings.custom.revsults.header.sticky: "always" | "desktop" | "never"
 *     → body.revsults-header-sticky-<mode>
 *   settings.custom.revsults.header.phoneMenuButton: true
 *     → body.revsults-header-fab; revsults.js clones the header's
 *       .revsults-burger[aria-controls] into .revsults-fab-menu
 */

/* ---------- admin-bar offset ---------- */

/* WordPress sets --wp-admin--admin-bar--position-offset only inside
   .is-position-sticky (its block "sticky" setting); the header part and the
   phone menu button are sticky/fixed by theme CSS, so they read the bar's own
   --wp-admin--admin-bar--height, which exists only while the bar shows. Up to
   600 px the bar scrolls away with the page, so the offset is 0 there. */
:root {
	--revsults-admin-bar-offset: var(--wp-admin--admin-bar--height, 0px);
}

@media screen and (max-width: 600px) {
	:root {
		--revsults-admin-bar-offset: 0px;
	}
}

/* ---------- sticky shell ---------- */

/* The template part <header> sticks inside .wp-site-blocks: the bar is its only
   child in flow and exactly as tall, so a sticky bar alone had no room to stick
   and scrolled away. A pattern that still carries core's sticky position on its
   outer group keeps working: both stick at the same edge. */
.revsults-header-sticky-always .wp-site-blocks > header.wp-block-template-part:has(> .revsults-header) {
	position: sticky;
	top: var(--revsults-admin-bar-offset, 0px);
	z-index: 50;
}

@media (min-width: 768px) {
	.revsults-header-sticky-desktop .wp-site-blocks > header.wp-block-template-part:has(> .revsults-header) {
		position: sticky;
		top: var(--revsults-admin-bar-offset, 0px);
		z-index: 50;
	}
}

/* ---------- burger (revsults_burger_html()) ---------- */

/* The theme toggle's proportions, so both sit side by side in the bar. */
.revsults-burger {
	display: inline-grid;
	place-items: center;
	box-sizing: border-box;
	width: 2.5rem;
	height: 2.5rem;
	margin: 0;
	padding: 0;
	border: var(--wp--custom--border--width, 1px) solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--pill, 999px);
	background: var(--wp--preset--color--base-2);
	color: var(--wp--preset--color--contrast-2);
	cursor: pointer;
	transition: color var(--wp--custom--transition--fast, 0.15s ease), border-color var(--wp--custom--transition--fast, 0.15s ease);
}

.revsults-burger:hover,
.revsults-burger:focus-visible {
	color: var(--wp--preset--color--secondary, var(--wp--preset--color--primary));
	border-color: var(--wp--preset--color--border-strong, var(--wp--preset--color--border));
}

.revsults-burger svg {
	width: 1.25rem;
	height: 1.25rem;
}

/* ---------- phone menu button ---------- */

/* A copy of the header's burger (same icon, label and aria-controls) shown top
   right while the header is out of view at ≤ 767 px (modes "never"/"desktop"
   scroll the header away on phones). In the header's look (base-2 88 % + blur,
   border, soft shadow); z 55: above the content (header 50), below the sticky
   CTA (60), the consent layer and the top-layer dialogs. Inert while hidden. */
.revsults-fab-menu.revsults-fab-menu {
	display: none;
}

@media (max-width: 767px) {
	.revsults-fab-menu.revsults-fab-menu {
		position: fixed;
		top: calc(var(--revsults-admin-bar-offset, 0px) + 12px);
		right: var(--wp--style--root--padding-right, var(--wp--custom--layout--gutter, 1.5rem));
		z-index: 55;
		display: inline-grid;
		margin: 0;
		background: color-mix(in srgb, var(--wp--preset--color--base-2) 88%, transparent);
		-webkit-backdrop-filter: blur(10px);
		backdrop-filter: blur(10px);
		box-shadow: var(--wp--preset--shadow--soft);
		opacity: 0;
		visibility: hidden;
	}

	.revsults-fab-menu.is-shown {
		opacity: 1;
		visibility: visible;
	}
}

@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
	.revsults-fab-menu.revsults-fab-menu {
		transition: opacity var(--wp--custom--transition--base, 0.2s ease), visibility 0s linear 0.2s;
	}

	.revsults-fab-menu.is-shown {
		transition: opacity var(--wp--custom--transition--base, 0.2s ease), visibility 0s;
	}
}
