/* =====================================================
   Desktop Dropdown Overflow Fix (Divi Header)
   CSS Baseline - No-JS Fallback
   ===================================================== */

/* Breakpoint variable — JS reads this value automatically.
   NOTE: CSS media queries cannot use custom properties,
   so if you change this value you must also update the
   three @media rules below (981px / 980px) to match. */
:root {
	--divi-menu-breakpoint: 981px;
}

/* @media value must match --divi-menu-breakpoint */
@media (min-width: 981px) {
	/* Make L1 dropdowns scrollable when they exceed viewport.
       Add .divi-overflow-bypass to a top-level <li> to skip the fix for that item. */
	.et-l--header li.et-hover:not(.divi-overflow-bypass) > ul.sub-menu,
	.et-l--header li:hover:not(.divi-overflow-bypass) > ul.sub-menu,
	.et-l--header li.divi-l1-active:not(.divi-overflow-bypass) > ul.sub-menu {
		max-height: calc(100vh - 80px); /* CSS-only fallback; JS overrides with exact value */
		overflow-y: auto;
		overflow-x: hidden;
		overscroll-behavior: contain;
	}

	/* Keep L1 dropdown visible when our JS marks it active.
	   Divi's own mouseleave removes et-hover when the cursor moves to the overlay;
	   this class holds the dropdown open independently. */
	.et-l--header li.divi-l1-active:not(.divi-overflow-bypass) > ul.sub-menu {
		visibility: visible !important;
		opacity: 1 !important;
		transform: translateY(0) !important;
	}

	/* Smooth scrollbar styling */
	.et-l--header ul.sub-menu::-webkit-scrollbar {
		width: 6px;
	}

	.et-l--header ul.sub-menu::-webkit-scrollbar-track {
		background: #f1f1f1;
		border-radius: 3px;
	}

	.et-l--header ul.sub-menu::-webkit-scrollbar-thumb {
		background: #c1c1c1;
		border-radius: 3px;
	}

		.et-l--header ul.sub-menu::-webkit-scrollbar-thumb:hover {
			background: #a1a1a1;
		}

	/* When JS enhancement is active, hide nested submenus in L1 (bypassed items keep native behavior) */
	.et-l--header.divi-overflow-enhanced .et-menu > li:not(.divi-overflow-bypass) > ul.sub-menu ul.sub-menu {
		display: none !important;
	}

	/* L2 trigger item styling when overlay is active */
	.et-l--header li.divi-l2-active > a {
		background-color: #f8f8f8;
		font-weight: 600;
	}
}

/* =====================================================
   L2 Overlay Panel Styles
   ===================================================== */
.divi-submenu-overlay {
	position: fixed;
	background: #fff;
	min-width: 200px;
	box-shadow: 0px 3px 12px rgba(0, 0, 0, 0.18);
	border-radius: 15px;
	z-index: 10000;
	padding: 10px 0;
	opacity: 0;
	visibility: hidden;
	transform: translateX(10px);
	transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
	overflow-y: auto;
	overflow-x: hidden;
	overscroll-behavior: contain;
}

	.divi-submenu-overlay.divi-overlay-visible {
		opacity: 1;
		visibility: visible;
		transform: translateX(0);
	}

	.divi-submenu-overlay.divi-overlay-flip {
		transform: translateX(-10px);
	}

		.divi-submenu-overlay.divi-overlay-flip.divi-overlay-visible {
			transform: translateX(0);
		}

	/* Overlay scrollbar styling */
	.divi-submenu-overlay::-webkit-scrollbar {
		width: 6px;
	}

	.divi-submenu-overlay::-webkit-scrollbar-track {
		background: #f1f1f1;
		border-radius: 3px;
	}

	.divi-submenu-overlay::-webkit-scrollbar-thumb {
		background: #c1c1c1;
		border-radius: 3px;
	}

		.divi-submenu-overlay::-webkit-scrollbar-thumb:hover {
			background: #a1a1a1;
		}

	/* Overlay menu items */
	.divi-submenu-overlay ul {
		list-style: none;
		margin: 0;
		padding: 0;
	}

	.divi-submenu-overlay li {
		width: 100%;
	}

		.divi-submenu-overlay li a {
			display: block;
			padding: 12px 20px;
			color: #808080;
			text-decoration: none;
			white-space: nowrap;
			font-size: 14px;
			font-family: 'Montserrat', sans-serif;
			transition: all 0.15s ease;
		}

			.divi-submenu-overlay li a:hover {
				background-color: #f8f8f8;
				color: #333;
				font-weight: 600;
			}

	/* Nested sub-menus inside overlay: display in normal flow with indentation.
	   Overrides Divi's absolute positioning that would move them outside the overlay,
	   causing mouseleave events that close the menu prematurely. */
	.divi-submenu-overlay ul.sub-menu {
		position: static !important;
		display: block !important;
		visibility: visible !important;
		opacity: 1 !important;
		width: auto !important;
		padding: 0 0 0 12px !important;
		margin: 0 !important;
		box-shadow: none !important;
		background: transparent !important;
		border: none !important;
		transform: none !important;
		transition: none !important;
		z-index: auto !important;
		max-height: none !important;
		overflow: visible !important;
		pointer-events: auto !important;
	}

/* Hide overlay on mobile — @media value must match --divi-menu-breakpoint minus 1 */
@media (max-width: 980px) {
	.divi-submenu-overlay {
		display: none !important;
	}
}

/* =====================================================
   Accessibility Enhancements
   ===================================================== */

/* Focus indicators - visible focus ring for keyboard navigation */
/* @media value must match --divi-menu-breakpoint */
@media (min-width: 981px) {
	.et-l--header .et-menu a:focus,
	.et-l--header ul.sub-menu a:focus,
	.divi-submenu-overlay a:focus {
		outline: 2px solid #2ea3f2;
		outline-offset: -2px;
		background-color: #f0f7ff;
	}

		/* Focus-visible for modern browsers (only show on keyboard focus) */
		.et-l--header .et-menu a:focus:not(:focus-visible),
		.et-l--header ul.sub-menu a:focus:not(:focus-visible),
		.divi-submenu-overlay a:focus:not(:focus-visible) {
			outline: none;
			background-color: transparent;
		}

	.et-l--header .et-menu a:focus-visible,
	.et-l--header ul.sub-menu a:focus-visible,
	.divi-submenu-overlay a:focus-visible {
		outline: 2px solid #2ea3f2;
		outline-offset: -2px;
		background-color: #f0f7ff;
	}

	/* Keyboard-focused parent item indicator */
	.et-l--header li.menu-item-has-children.divi-keyboard-focus > a {
		outline: 2px solid #2ea3f2;
		outline-offset: -2px;
		background-color: #f0f7ff;
	}
}

/* Screen reader only - for live announcements */
.divi-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* =====================================================
   MOBILE MENU OVERFLOW FIX (removable)
   Delete this entire section to disable the mobile fix.
   ===================================================== */
/* @media value must match --divi-menu-breakpoint minus 1 */
@media (max-width: 980px) {
	/* The entire mobile menu scrolls as one unit */
	.et-l--header .et_mobile_menu {
		max-height: calc(100vh - 80px); /* CSS fallback; JS overrides with exact value */
		overflow-y: auto;
		overflow-x: hidden;
		overscroll-behavior: contain;
		-webkit-overflow-scrolling: touch;
	}

		/* Sub-menus inside mobile menu must NOT scroll individually —
       they expand naturally so the parent .et_mobile_menu scrolls */
		.et-l--header .et_mobile_menu ul.sub-menu {
			max-height: none !important;
			overflow: visible !important;
		}

		.et-l--header .et_mobile_menu::-webkit-scrollbar {
			width: 4px;
		}

		.et-l--header .et_mobile_menu::-webkit-scrollbar-track {
			background: transparent;
		}

		.et-l--header .et_mobile_menu::-webkit-scrollbar-thumb {
			background: #c1c1c1;
			border-radius: 2px;
		}
}
/* ===== END MOBILE MENU OVERFLOW FIX ================= */

/* =====================================================
   Reduced Motion Support (WCAG 2.3.3)
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
	.divi-submenu-overlay {
		transition: none;
		transform: none;
	}

		.divi-submenu-overlay.divi-overlay-flip {
			transform: none;
		}

	.et-l--header ul.sub-menu {
		transition: none !important;
		transform: none !important;
	}

		.et-l--header .et-menu a,
		.et-l--header ul.sub-menu a,
		.divi-submenu-overlay a {
			transition: none;
		}
}
