/*
 * Custom Mega Menu — front-end stylesheet.
 *
 * Breakpoint below (900px) must match:
 *   - cmmSettings.breakpoint in custom-mega-menu.php
 *   - CMM breakpoint constant referenced in mega-menu.js
 *
 * All structural/layout rules are !important AND scoped under
 * .custom-mega-menu-nav for extra specificity. This is intentional:
 * this menu is injected into a theme's existing primary-menu
 * location, which usually ships its own submenu CSS (often
 * float/inline-block based, sometimes itself using !important on
 * generic "ul ul li" selectors). Both !important and the extra class
 * scope are needed to reliably win that specificity fight regardless
 * of theme or page builder (Astra, Elementor, ElementsKit, etc.).
 * Colors/typography are kept !important-free where practical so a
 * child theme can still restyle them.
 *
 * Font: override --cmm-font-family below (or via a child theme /
 * custom CSS snippet) to match your brand typography. Defaults to
 * Poppins with a safe system-font fallback stack.
 */

.custom-mega-menu-nav {
	--cmm-font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	--cmm-accent-color: #0057ff;
	--cmm-text-color: inherit;

	position: relative !important;
	display: flex !important;
	align-items: center !important;
	justify-content: flex-end !important;
	width: 100% !important;
	height: 100% !important;
	font-family: var(--cmm-font-family);
	color: var(--cmm-text-color);
	box-sizing: border-box;
}

.custom-mega-menu-nav *,
.custom-mega-menu-nav *::before,
.custom-mega-menu-nav *::after {
	box-sizing: border-box;
}

.custom-mega-menu-nav button {
	font-family: inherit;
	color: inherit;
}

.custom-mega-menu-nav ul {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
}

.custom-mega-menu-nav .custom-mega-menu {
	display: flex !important;
	flex-wrap: wrap !important;
	align-items: center !important;
	float: none !important;
	position: relative !important;
	height: 100%;
	width: auto;
}

.custom-mega-menu-nav .custom-mega-menu > .menu-item {
	position: relative !important;
	display: flex !important;
	align-items: center !important;
	float: none !important;
	width: auto;
}

.custom-mega-menu-nav .menu-link {
	display: flex !important;
	align-items: center !important;
	gap: 6px;
	padding: 14px 14px;
	color: inherit;
	text-decoration: none;
	font-size: 16px;
	font-weight: 500 !important;
	line-height: 33px;
	white-space: nowrap;
	float: none !important;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.custom-mega-menu-nav .menu-link:hover,
.custom-mega-menu-nav .menu-link:focus-visible {
	background-color: rgba(0, 0, 0, 0.05);
}

.custom-mega-menu-nav .menu-item.is-current > .menu-link {
	font-weight: 600;
	color: var(--cmm-accent-color);
}

.mega-menu-caret {
	width: 8px;
	height: 8px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	margin-top: -4px;
	transition: transform 0.2s ease;
	flex: 0 0 auto;
}

.custom-mega-menu-nav .menu-item.has-mega-menu.is-open > .menu-link .mega-menu-caret {
	transform: rotate(-135deg);
	margin-top: 2px;
}

/* Per-item mobile accordion toggle (the small +/x next to an item that
   has children — separate from the main hamburger below). */
.custom-mega-menu-nav .mega-menu-mobile-toggle {
	display: none;
	position: absolute !important;
	top: 0;
	right: 0;
	width: 48px;
	height: 48px;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 0;
	cursor: pointer;
	padding: 0;
}

.mega-menu-mobile-toggle-icon {
	position: relative;
	display: block;
	width: 14px;
	height: 14px;
	transition: transform 0.2s ease;
}

.mega-menu-mobile-toggle-icon::before,
.mega-menu-mobile-toggle-icon::after {
	content: "";
	position: absolute;
	background-color: currentColor;
}

.mega-menu-mobile-toggle-icon::before {
	top: 50%;
	left: 0;
	width: 100%;
	height: 2px;
	transform: translateY(-50%);
}

.mega-menu-mobile-toggle-icon::after {
	top: 0;
	left: 50%;
	width: 2px;
	height: 100%;
	transform: translateX(-50%);
}

.custom-mega-menu-nav .mega-menu-mobile-toggle[aria-expanded="true"] .mega-menu-mobile-toggle-icon {
	transform: rotate(45deg);
}

.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	width: 1px;
	overflow: hidden;
	position: absolute !important;
	word-wrap: normal !important;
}

/* -------------------------------------------------------------------- */
/* Mega panel — true full viewport width, positioned via JS             */
/* -------------------------------------------------------------------- */
/* position:fixed makes the viewport (not the <li>, not any Elementor  */
/* container) the containing block, so left/right: 0 always spans the  */
/* full browser width. "top" is set inline by mega-menu.js to sit      */
/* exactly under the header, since header height varies by theme.      */

.custom-mega-menu-nav .mega-menu-panel {
	position: fixed !important;
	left: 0 !important;
	right: 0 !important;
	width: 100% !important;
	float: none !important;
	background: #ffffff;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
	border-top: 3px solid var(--cmm-accent-color);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
	z-index: 99999 !important;
}

.custom-mega-menu-nav .menu-item.has-mega-menu.is-open > .mega-menu-panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.mega-menu-panel-inner {
	max-width: 1280px;
	margin: 0 auto;
	padding: 28px 40px;
}

.custom-mega-menu-nav .mega-menu-columns {
	display: grid !important;
	grid-template-columns: repeat(5, 1fr) !important;
	float: none !important;
	gap: 32px;
	width: 100%;
}

.custom-mega-menu-nav .mega-menu-column {
	display: flex !important;
	flex-direction: column !important;
	float: none !important;
	width: 100% !important;
	align-items: stretch !important;
}

.custom-mega-menu-nav .mega-menu-column > .mega-menu-link {
	display: block !important;
	float: none !important;
	width: 100%;
	padding: 4px 0 10px;
	font-weight: 700;
	font-size: 14px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: inherit;
	text-decoration: none;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	margin-bottom: 8px;
}

.custom-mega-menu-nav .mega-menu-sub {
	display: flex !important;
	flex-direction: column !important;
	float: none !important;
	width: 100%;
	gap: 2px;
}

.custom-mega-menu-nav .mega-menu-item {
	display: block !important;
	float: none !important;
	width: 100%;
}

.custom-mega-menu-nav .mega-menu-item > .mega-menu-link {
	display: block !important;
	float: none !important;
	width: 100%;
	padding: 6px 0;
	color: inherit;
	text-decoration: none;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.5;
	border-radius: 4px;
	transition: color 0.15s ease, padding-left 0.15s ease;
}

.custom-mega-menu-nav .mega-menu-item > .mega-menu-link:hover,
.custom-mega-menu-nav .mega-menu-item > .mega-menu-link:focus-visible {
	padding-left: 6px;
	color: var(--cmm-accent-color);
}

.mega-menu-link:focus-visible,
.menu-link:focus-visible {
	outline: 2px solid var(--cmm-accent-color);
	outline-offset: -2px;
}

/* -------------------------------------------------------------------- */
/* Best-effort cleanup of Astra's own native mobile-header icons        */
/* -------------------------------------------------------------------- */
/* Astra (and similar themes) often render their own search/account/    */
/* menu-trigger icons independently of the "primary" menu location we   */
/* hook into, which can visually clash with our hamburger. These are    */
/* Astra's common class names — safe to delete this block, or add your  */
/* theme's actual class (inspect the stray icon in DevTools to confirm) */
/* if your site uses different markup.                                  */
@media (max-width: 900px) {
	.ast-mobile-menu-buttons,
	.ast-mobile-menu-trigger-minimal,
	.ast-mobile-menu-trigger-fill,
	.ast-mobile-menu-trigger-outline,
	.ast-header-search,
	.astra-search-icon,
	.ast-search-menu-icon,
	.ast-header-account,
	.ast-mobile-header-account {
		display: none !important;
	}
}

/* -------------------------------------------------------------------- */
/* Hamburger toggle (tablet + mobile)                                    */
/* -------------------------------------------------------------------- */

.cmm-hamburger {
	display: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	flex: 0 0 auto;
	position: relative;
	z-index: 999999;
}

.cmm-hamburger-box {
	position: relative;
	width: 22px;
	height: 16px;
}

.cmm-hamburger-box span {
	position: absolute;
	left: 0;
	width: 100%;
	height: 2px;
	background-color: currentColor;
	border-radius: 1px;
	transition: transform 0.25s ease, opacity 0.2s ease, top 0.25s ease;
}

.cmm-hamburger-box span:nth-child(1) {
	top: 0;
}

.cmm-hamburger-box span:nth-child(2) {
	top: 7px;
}

.cmm-hamburger-box span:nth-child(3) {
	top: 14px;
}

.cmm-hamburger[aria-expanded="true"] .cmm-hamburger-box span:nth-child(1) {
	top: 7px;
	transform: rotate(45deg);
}

.cmm-hamburger[aria-expanded="true"] .cmm-hamburger-box span:nth-child(2) {
	opacity: 0;
}

.cmm-hamburger[aria-expanded="true"] .cmm-hamburger-box span:nth-child(3) {
	top: 7px;
	transform: rotate(-45deg);
}

/* Body scroll lock while the drawer is open (no dark overlay used —
   the single hamburger button, which morphs into an "X", is the only
   open/close control). */
body.cmm-nav-open {
	overflow: hidden !important;
}

/* -------------------------------------------------------------------- */
/* Tablet + mobile: hamburger-triggered slide-in drawer (left → right)   */
/* Single column, full accordion, edge-to-edge drawer.                  */
/* -------------------------------------------------------------------- */

@media (max-width: 900px) {
	.cmm-hamburger {
		display: inline-flex !important;
		position: fixed !important;
		top: 14px !important;
		right: 14px !important;
		background: #ffffff !important;
		border-radius: 50% !important;
		box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18) !important;
		z-index: 999999 !important;
	}

	.custom-mega-menu-nav {
		justify-content: flex-end !important;
	}

	.custom-mega-menu-nav .custom-mega-menu {
		position: fixed !important;
		top: 0 !important;
		left: 0 !important;
		transform: translateX(-100%);
		width: min(320px, 85vw) !important;
		height: auto !important;
		max-height: 100vh !important;
		max-height: 100dvh !important;
		flex-direction: column !important;
		/* FIX: desktop sets flex-wrap:wrap. In a column drawer with a
		   max-height that makes items wrap into extra columns off-screen
		   as soon as a submenu opens. Must be nowrap on mobile. */
		flex-wrap: nowrap !important;
		justify-content: flex-start !important;
		align-items: stretch !important;
		background: #ffffff;
		box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18);
		overflow-x: hidden !important;
		overflow-y: auto !important;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
		/* Top padding leaves room for the fixed hamburger/close button. */
		padding: 68px 0 24px;
		transition: transform 0.3s ease;
		z-index: 999998 !important;
	}

	.custom-mega-menu-nav.cmm-menu-open .custom-mega-menu {
		transform: translateX(0);
	}

	.custom-mega-menu-nav .custom-mega-menu > .menu-item {
		width: 100% !important;
		display: block !important;
		flex: 0 0 auto !important;
		min-width: 0;
		border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	}

	.custom-mega-menu-nav .menu-link {
		width: 100% !important;
		padding: 14px 48px 14px 20px;
		white-space: normal;
	}

	/* Only one toggle indicator on mobile: the dedicated button. The
	   decorative caret inside the link itself is redundant here. */
	.custom-mega-menu-nav .menu-link .mega-menu-caret {
		display: none !important;
	}

	.custom-mega-menu-nav .mega-menu-mobile-toggle {
		display: flex !important;
		height: 61px; /* matches menu-link row height (14 + 33 + 14) */
		background: rgba(0, 0, 0, 0.03);
	}

	.custom-mega-menu-nav .mega-menu-mobile-toggle:hover,
	.custom-mega-menu-nav .mega-menu-mobile-toggle:focus-visible {
		background: rgba(0, 0, 0, 0.07);
	}

	.custom-mega-menu-nav .mega-menu-panel {
		position: static !important;
		width: 100% !important;
		min-width: 0;
		box-shadow: none;
		border-top: none;
		background: rgba(0, 0, 0, 0.02);
		opacity: 1;
		visibility: visible;
		transform: none;
		/* Closed = display:none, so collapsed links can't be tabbed to. */
		display: none !important;
		height: auto;
		max-width: 100%;
		overflow: hidden;
	}

	.custom-mega-menu-nav .menu-item.has-mega-menu.is-open > .mega-menu-panel {
		display: block !important;
	}

	.custom-mega-menu-nav .mega-menu-panel-inner {
		max-width: 100%;
		margin: 0;
		padding: 8px 20px 18px;
	}

	.custom-mega-menu-nav .mega-menu-columns {
		grid-template-columns: minmax(0, 1fr) !important;
		gap: 14px;
	}

	.custom-mega-menu-nav .mega-menu-column {
		min-width: 0;
	}

	.custom-mega-menu-nav .mega-menu-column > .mega-menu-link {
		padding: 8px 8px 8px 0;
		margin-bottom: 4px;
		font-size: 13px;
		white-space: normal;
		overflow-wrap: anywhere;
	}

	.custom-mega-menu-nav .mega-menu-item > .mega-menu-link {
		padding: 9px 8px 9px 0;
		white-space: normal;
		overflow-wrap: anywhere;
	}

	/* No hover-nudge on touch screens. */
	.custom-mega-menu-nav .mega-menu-item > .mega-menu-link:hover,
	.custom-mega-menu-nav .mega-menu-item > .mega-menu-link:focus-visible {
		padding-left: 0;
	}
}

/* Small phones: drawer takes full width for easier tapping */
@media (max-width: 420px) {
	.custom-mega-menu-nav .custom-mega-menu {
		width: 90vw !important;
	}
}
