/**
 * Fixed site header behaviour.
 *
 * Default (top of page): position: fixed, transparent background, 80px tall.
 *   The header overlays the content underneath (e.g. the hero).
 * On scroll (.is-scrolled toggled via header.js): stays fixed, shrinks to
 *   60px, switches to the teal (#0E7490) background and turns text white.
 */

.flexa-site-header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 999;
	display: flex;
	align-items: center;
	min-height: 80px;
	/* Override the theme's opaque "base" background so it starts transparent. */
	background-color: transparent !important;
	border-bottom-color: transparent !important;
	/* White text in both states (transparent + teal). */
	color: #ffffff;
	transition:
		min-height 0.3s ease,
		padding 0.3s ease,
		background-color 0.3s ease,
		border-color 0.3s ease,
		box-shadow 0.3s ease;
}

/* Inner row: logo on the left, menu on the right, spread across the full width. */
.flexa-site-header > .wp-block-group {
	flex: 1;
	width: 100%;
	max-width: 1280px;
	margin-inline: auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 2rem;
}

/* Brand: logo next to the title. */
.flexa-site-header .flexa-site-brand {
	gap: 0.75rem;
}

.flexa-site-header .flexa-site-brand .wp-block-site-logo img {
	display: block;
	height: auto;
}

/* Space the menu items evenly. */
.flexa-site-header .flexa-primary-nav ul {
	gap: 2rem;
}

.flexa-site-header.is-scrolled {
	min-height: 60px;
	background-color: #0E7490 !important;
	border-bottom-color: #0E7490 !important;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* White text + links in both states (overrides the plugin's dark inline color). */
.flexa-site-header a,
.flexa-site-header .flexa-primary-nav a {
	color: #ffffff;
}

.flexa-site-header .flexa-primary-nav a:hover,
.flexa-site-header .flexa-primary-nav .current-menu-item > a {
	/* Cyan — stands out clearly on the blue hero + teal header
	   (!important to win the specificity war). */
	color: #22d3ee !important;
}

/* -------------------------------------------------------------------------
 * Hamburger toggle (hidden on desktop, shown on mobile).
 * ---------------------------------------------------------------------- */
/* Overlay is only used on mobile. */
.flexa-menu-overlay {
	display: none;
}

.flexa-menu-toggle {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	width: 44px;
	height: 44px;
	padding: 10px;
	margin: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
}

.flexa-menu-toggle__bar {
	display: block;
	width: 100%;
	height: 2px;
	border-radius: 2px;
	background: currentColor;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Animate into an "X" when the menu is open. */
.flexa-site-header.menu-open .flexa-menu-toggle__bar:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}
.flexa-site-header.menu-open .flexa-menu-toggle__bar:nth-child(2) {
	opacity: 0;
}
.flexa-site-header.menu-open .flexa-menu-toggle__bar:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

/* -------------------------------------------------------------------------
 * Mobile layout.
 * ---------------------------------------------------------------------- */
@media (max-width: 782px) {
	.flexa-menu-toggle {
		display: flex;
		color: #ffffff;
		/* Keep the toggle (X) clickable above the drawer + overlay. */
		position: relative;
		z-index: 4;
	}

	/* Keep the brand (logo + title) visible above the drawer,
	   so it sits at the top of the open drawer. */
	.flexa-site-header .flexa-site-brand {
		position: relative;
		z-index: 4;
	}

	/* Dim overlay behind the drawer, over the whole viewport. */
	.flexa-menu-overlay {
		display: block;
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, 0.5);
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.3s ease, visibility 0.3s ease;
		z-index: 2;
	}

	.flexa-site-header.menu-open .flexa-menu-overlay {
		opacity: 1;
		visibility: visible;
	}

	/* Menu becomes a full-height drawer sliding in from the LEFT, 80% wide,
	   overlaying the header (logo/title) and the page. */
	.flexa-site-header .flexa-primary-nav {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		width: 80%;
		height: 100vh;
		height: 100dvh;
		background: #0E7490;
		box-shadow: 8px 0 24px rgba(0, 0, 0, 0.25);
		/* Leave room for the fixed header bar at the top. */
		padding-top: 80px;
		overflow-y: auto;
		/* Hidden off-canvas until toggled open. */
		transform: translateX(-100%);
		transition: transform 0.3s ease;
		z-index: 3;
	}

	.flexa-site-header.menu-open .flexa-primary-nav {
		transform: translateX(0);
	}

	.flexa-site-header .flexa-primary-nav ul {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
		padding: 0.5rem 0;
	}

	.flexa-site-header .flexa-primary-nav li {
		width: 100%;
	}

	.flexa-site-header .flexa-primary-nav a {
		display: block;
		padding: 1rem var(--wp--preset--spacing--30, 24px);
	}
}
