/**
 * WP Smith — navigation.css
 * Sticky header · Mega menu · Off-canvas mobile menu · Skip link
 */

/* ── CSS Custom Properties ───────────────────────────────────────────────── */
:root {
	--wpsmith-header-height: 72px;
	--wpsmith-header-bg: var(--wp--preset--color--surface);
	--wpsmith-header-border: var(--wp--preset--color--border);
	--wpsmith-header-shadow-scrolled: 0 2px 16px rgba(0, 0, 0, 0.08);
	--wpsmith-mega-cols: 4;
	--wpsmith-mega-max-width: 960px;
	--wpsmith-mobile-menu-width: 320px;
	--wpsmith-z-header: 100;
	--wpsmith-z-mega: 200;
	--wpsmith-z-overlay: 300;
	--wpsmith-z-offcanvas: 400;
}

/* ── Skip to Content ─────────────────────────────────────────────────────── */
.wp-smith-skip-link {
	position: absolute;
	top: -100%;
	left: 1rem;
	z-index: 9999;
	padding: 0.5rem 1rem;
	background: var(--wp--preset--color--accent);
	color: #fff;
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 700;
	border-radius: 0 0 6px 6px;
	text-decoration: none;
	transition: top 0.15s;
}
.wp-smith-skip-link:focus {
	top: 0;
	outline: 3px solid #fff;
	outline-offset: 2px;
}

/* ── Site Header ─────────────────────────────────────────────────────────── */
.site-header {
	position: sticky;
	top: 0;
	z-index: var(--wpsmith-z-header);
	height: var(--wpsmith-header-height);
	padding-inline: var(--wp--preset--spacing--6);
	background: var(--wpsmith-header-bg);
	border-bottom: 1px solid var(--wpsmith-header-border);
	transition: height 0.25s ease, box-shadow 0.25s ease;
	will-change: height, box-shadow;
}

/* Shrink on scroll — class toggled by JS */
.site-header.is-scrolled {
	--wpsmith-header-height: 56px;
	box-shadow: var(--wpsmith-header-shadow-scrolled);
}

.site-header .wp-block-site-logo img {
	max-height: calc(var(--wpsmith-header-height) - 24px);
	width: auto;
	transition: max-height 0.25s ease;
}

/* ── Primary Navigation ──────────────────────────────────────────────────── */
.site-header .wp-block-navigation {
	--navigation-layout-justification-setting: flex-end;
}

/* Top-level nav items */
.site-header .wp-block-navigation-item__content {
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	letter-spacing: 0.01em;
	padding: 0.5rem 0.75rem;
	transition: color 0.15s;
}

.site-header .wp-block-navigation-item__content:hover {
	color: var(--wp--preset--color--accent);
}

/* ── Mega Menu ───────────────────────────────────────────────────────────── */
/*
 * Trigger: add CSS class "has-mega-menu" to a top-level nav item in the
 * WordPress editor (Navigation block → item → Advanced → Additional CSS class).
 * The submenu of that item renders as a full-width mega panel.
 */

.site-header .wp-block-navigation-item.has-mega-menu {
	position: static; /* Let mega panel break out of the nav */
}

.site-header .wp-block-navigation-item.has-mega-menu > .wp-block-navigation__submenu-container {
	position: fixed;
	top: var(--wpsmith-header-height);
	left: 0;
	right: 0;
	width: 100%;
	max-height: 0;
	overflow: hidden;
	display: grid;
	grid-template-columns: repeat(var(--wpsmith-mega-cols), 1fr);
	gap: var(--wp--preset--spacing--8);
	padding: 0 var(--wp--preset--spacing--6);
	background: var(--wp--preset--color--surface);
	border-bottom: 1px solid var(--wpsmith-header-border);
	box-shadow: var(--wpsmith-header-shadow-scrolled);
	transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
	opacity: 0;
	z-index: var(--wpsmith-z-mega);
}

.site-header .wp-block-navigation-item.has-mega-menu:hover > .wp-block-navigation__submenu-container,
.site-header .wp-block-navigation-item.has-mega-menu:focus-within > .wp-block-navigation__submenu-container {
	max-height: 480px;
	padding-top: var(--wp--preset--spacing--8);
	padding-bottom: var(--wp--preset--spacing--8);
	opacity: 1;
}

/* Mega menu items */
.site-header .wp-block-navigation-item.has-mega-menu .wp-block-navigation-item {
	display: block;
}

.site-header .wp-block-navigation-item.has-mega-menu .wp-block-navigation-item__content {
	display: block;
	padding: 0.25rem 0;
	font-weight: 400;
	font-size: var(--wp--preset--font-size--sm);
}

/* Mega menu section heading (first item in a column acts as label) */
.site-header .wp-block-navigation-item.has-mega-menu .wp-block-navigation__submenu-container > li:first-child > a {
	font-weight: 700;
	font-size: var(--wp--preset--font-size--sm);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--wp--preset--color--text-muted);
	cursor: default;
	pointer-events: none;
	margin-bottom: var(--wp--preset--spacing--3);
}

/* ── Standard Dropdown (non-mega) ────────────────────────────────────────── */
.site-header .wp-block-navigation__submenu-container {
	min-width: 220px;
	border-radius: 8px;
	border: 1px solid var(--wpsmith-header-border);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
	padding: var(--wp--preset--spacing--2) 0;
}

.site-header .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
	padding: 0.5rem 1.25rem;
	font-weight: 400;
	white-space: nowrap;
}

/* ── Off-Canvas Mobile Menu ──────────────────────────────────────────────── */
.wp-smith-offcanvas-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: var(--wpsmith-z-overlay);
	opacity: 0;
	transition: opacity 0.3s;
}

.wp-smith-offcanvas-overlay.is-open {
	display: block;
	opacity: 1;
}

.wp-smith-offcanvas {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: var(--wpsmith-mobile-menu-width);
	max-width: 90vw;
	background: var(--wp--preset--color--surface);
	z-index: var(--wpsmith-z-offcanvas);
	overflow-y: auto;
	overscroll-behavior: contain;
	transform: translateX(100%);
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	padding: var(--wp--preset--spacing--6);
	box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
}

.wp-smith-offcanvas.is-open {
	transform: translateX(0);
}

.wp-smith-offcanvas__close {
	display: flex;
	justify-content: flex-end;
	margin-bottom: var(--wp--preset--spacing--6);
}

.wp-smith-offcanvas__close button {
	background: none;
	border: none;
	cursor: pointer;
	font-size: 1.5rem;
	line-height: 1;
	padding: 0.25rem;
	color: var(--wp--preset--color--text-primary);
}

/* Mobile nav inside off-canvas */
.wp-smith-offcanvas .wp-block-navigation {
	flex-direction: column;
	align-items: flex-start;
}

.wp-smith-offcanvas .wp-block-navigation-item__content {
	font-size: var(--wp--preset--font-size--md);
	font-weight: 600;
	padding: 0.75rem 0;
	border-bottom: 1px solid var(--wp--preset--color--border);
	display: block;
	width: 100%;
}

/* ── Hamburger Button (visible only on mobile) ───────────────────────────── */
.wp-smith-hamburger {
	display: none;
	background: none;
	border: none;
	cursor: pointer;
	padding: 0.5rem;
	flex-direction: column;
	gap: 5px;
}

.wp-smith-hamburger span {
	display: block;
	width: 24px;
	height: 2px;
	background: var(--wp--preset--color--text-primary);
	border-radius: 2px;
	transition: transform 0.2s, opacity 0.2s;
}

@media (max-width: 781px) {
	.wp-smith-hamburger {
		display: flex;
	}

	/* Hide the WP Navigation block's built-in mobile overlay (we use off-canvas) */
	.site-header .wp-block-navigation__responsive-container:not(.is-menu-open) {
		display: none;
	}
}

/* ── Smooth scroll (native CSS) ──────────────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}
