/* ==========================================================================
   Meridian West - Custom Header Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
	--mw-header-height: 92px;
	--mw-header-bg: #ffffff;
	--mw-header-text: #0D0C33;
	--mw-header-link: #0D0C33;
	--mw-header-link-hover: #2F31FC;
	--mw-header-font: "Meridian West", sans-serif;
	--mw-header-padding-x: 20px;
	--mw-transition-speed: 0.3s;
	--mw-mobile-menu-bg: #ffffff;
	--mw-top-bar-height: 0px;
	--mw-admin-bar-height: 0px;
}

/* On desktop the top bar is always 40px — set immediately so layout
   is correct before deferred JS runs, preventing CLS on the header. */
@media (min-width: 769px) {
	:root {
		--mw-top-bar-height: 40px;
	}
}

body.admin-bar {
	--mw-admin-bar-height: 32px;
}

@media (max-width: 782px) {
	body.admin-bar {
		--mw-admin-bar-height: 46px;
	}
}

/* --------------------------------------------------------------------------
   Anchor Scroll Offset (accounts for fixed header)
   -------------------------------------------------------------------------- */
html {
	scroll-padding-top: var(--mw-header-height);
}

/* --------------------------------------------------------------------------
   Pre-Header Top Bar
   -------------------------------------------------------------------------- */
.mw-top-bar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 10001;
	background-color: #f7f7f9;
	color: #0D0C33;
	will-change: transform;
}

/* Only animate after page has loaded (prevents instant-hide on scroll-restored pages) */
body.mw-top-bar-ready .mw-top-bar {
	transition: transform 0.2s ease;
}

/* Extend header background upward to cover any gap during transition */
body.has-top-bar .mw-header::before {
	content: '';
	position: absolute;
	top: calc(-1 * var(--mw-top-bar-height, 0px));
	left: 0;
	right: 0;
	height: var(--mw-top-bar-height, 0px);
	background-color: var(--mw-header-bg);
}

.mw-top-bar.is-hidden {
	transform: translateY(-100%);
}

.mw-top-bar__inner {
	max-width: var(--container-max-width, 1320px);
	margin: 0 auto;
	padding: 3px var(--mw-header-padding-x);
	text-align: center;
}

.mw-top-bar__link,
.mw-top-bar__text {
	font-family: var(--mw-header-font);
	font-size: 15px;
	font-weight: 400;
	color: #0D0C33;
	text-decoration: none;
	line-height: 1.2;
}

.mw-top-bar__link {
	display: block;
	padding: 8px 0;
}

.mw-top-bar__link:hover,
.mw-top-bar__link:focus {
	text-decoration: underline;
	color: var(--mw-header-link-hover);
}

/* Body offset when top bar is present */
body.has-top-bar {
	padding-top: calc(var(--mw-header-height) + var(--mw-top-bar-height, 0px));
}

/* Header shifts down when top bar is visible */
body.has-top-bar .mw-header {
	top: var(--mw-top-bar-height, 0px);
}

/* Only animate top after page has loaded (JS adds this class) */
body.has-top-bar.mw-top-bar-ready .mw-header {
	transition: box-shadow var(--mw-transition-speed) ease,
				background-color var(--mw-transition-speed) ease,
				top var(--mw-transition-speed) ease;
}

/* When scrolled: top bar hidden, header slides to top */
body.has-top-bar.mw-top-bar-hidden .mw-header {
	top: 0;
}

body.has-top-bar.mw-top-bar-hidden {
	padding-top: var(--mw-header-height);
}

/* Admin bar + top bar offsets */
body.admin-bar.has-top-bar .mw-top-bar {
	top: 32px;
}

body.admin-bar.has-top-bar .mw-header {
	top: calc(32px + var(--mw-top-bar-height, 0px));
}

body.admin-bar.has-top-bar.mw-top-bar-hidden .mw-header {
	top: 32px;
}

@media (max-width: 782px) {
	body.admin-bar.has-top-bar .mw-top-bar {
		top: 46px;
	}

	body.admin-bar.has-top-bar .mw-header {
		top: calc(46px + var(--mw-top-bar-height, 0px));
	}

	body.admin-bar.has-top-bar.mw-top-bar-hidden .mw-header {
		top: 46px;
	}
}

/* --------------------------------------------------------------------------
   Header Base
   -------------------------------------------------------------------------- */
.mw-header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 9999;
	background-color: var(--mw-header-bg);
	height: var(--mw-header-height);
	transition: box-shadow var(--mw-transition-speed) ease,
				background-color var(--mw-transition-speed) ease;
}

.mw-header--scrolled {
	box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}

/* Push page content below fixed header */
body {
	padding-top: var(--mw-header-height);
}

/* WP Admin Bar offset (32px desktop, 46px mobile < 783px) */
body.admin-bar .mw-header {
	top: 32px;
}

@media (max-width: 782px) {
	body.admin-bar .mw-header {
		top: 46px;
	}
}

/* Elementor editor: don't fix header */
.elementor-editor-active .mw-header {
	position: relative;
	top: 0;
}
.elementor-editor-active body {
	padding-top: 0;
}

.mw-header__inner {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	max-width: var(--container-max-width, 1320px);
	margin: 0 auto;
	padding: 0 var(--mw-header-padding-x);
	height: 100%;
	padding-bottom: 16px;
}

/* --------------------------------------------------------------------------
   Logo
   -------------------------------------------------------------------------- */
.mw-header__logo a {
	display: flex;
	align-items: flex-end;
	text-decoration: none;
}

.mw-header__logo-img {
	max-width: 180px;
	height: auto;
	width: auto;
	display: block;
	padding-bottom: 8px;
}

.mw-header__logo-text {
	font-family: var(--mw-header-font);
	font-size: 28px;
	font-weight: 400;
	color: var(--mw-header-text);
	letter-spacing: -0.02em;
	line-height: 1;
}

/* --------------------------------------------------------------------------
   Desktop Navigation
   -------------------------------------------------------------------------- */
.mw-header__nav {
	display: flex;
	align-items: flex-end;
}

.mw-header__menu {
	display: flex;
	align-items: flex-end;
	list-style: none;
	margin: 0;
	padding: 0;
	gap: 0;
}

/* Top-level menu items */
.mw-header__menu > li {
	position: relative;
}

.mw-header__menu > li > a {
	display: flex;
	align-items: center;
	padding: 8px 14px 8px;
	font-family: var(--mw-header-font);
	font-size: 17px;
	font-weight: 400;
	color: var(--mw-header-link);
	text-decoration: none;
	white-space: nowrap;
	transition: color var(--mw-transition-speed) ease;
	position: relative;
	line-height: 1;
}

/* Underline effect */
.mw-header__menu > li > a::after {
	content: '';
	position: absolute;
	bottom: 6px;
	left: 14px;
	right: 14px;
	height: 1px;
	background-color: currentColor;
	transform: scaleX(0);
	transform-origin: right center;
	transition: transform var(--mw-transition-speed) ease;
}

/* Hover state: blue text + blue underline */
.mw-header__menu > li > a:hover,
.mw-header__menu > li > a:focus {
	color: var(--mw-header-link-hover);
}

.mw-header__menu > li > a:hover::after,
.mw-header__menu > li > a:focus::after {
	transform: scaleX(1);
	transform-origin: left center;
}

/* Parent item stays highlighted while dropdown is open */
.mw-header__menu > li.menu-item-has-children:hover > a {
	color: var(--mw-header-link-hover);
}

.mw-header__menu > li.menu-item-has-children:hover > a::after {
	transform: scaleX(1);
	transform-origin: left center;
}

/* Current page / parent page: black text + black underline (always visible) */
.mw-header__menu > li.current-menu-item > a,
.mw-header__menu > li.current-menu-ancestor > a {
	color: var(--mw-header-link);
}

.mw-header__menu > li.current-menu-item > a::after,
.mw-header__menu > li.current-menu-ancestor > a::after {
	transform: scaleX(1);
	transform-origin: left center;
}

/* --------------------------------------------------------------------------
   Desktop Dropdown Submenus
   -------------------------------------------------------------------------- */
.mw-header__menu li > .sub-menu {
	display: block;
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 240px;
	background-color: #ffffff;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
	list-style: none;
	margin: 0;
	padding: 8px 0;
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity var(--mw-transition-speed) ease,
				visibility var(--mw-transition-speed) ease,
				transform var(--mw-transition-speed) ease;
	z-index: 100;
}

.mw-header__menu li:hover > .sub-menu,
.mw-header__menu li:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* Right-align submenu when it would overflow the viewport */
.mw-header__menu li > .sub-menu.sub-menu--right-align {
	left: auto;
	right: 0;
}

/* Nested dropdowns (level 3+) */
.mw-header__menu li > .sub-menu .sub-menu {
	top: 0;
	left: 100%;
}

/* Submenu items */
.mw-header__menu .sub-menu li {
	position: relative;
}

.mw-header__menu .sub-menu li a {
	display: block;
	padding: 10px 24px;
	font-family: var(--mw-header-font);
	font-size: 15px;
	font-weight: 400;
	color: var(--mw-header-link);
	text-decoration: none;
	transition: color var(--mw-transition-speed) ease,
				background-color var(--mw-transition-speed) ease;
	line-height: 1.4;
}

.mw-header__menu .sub-menu li a:hover,
.mw-header__menu .sub-menu li a:focus {
	color: var(--mw-header-link-hover);
	background-color: #f8f8f8;
}

.mw-header__menu .sub-menu li.current-menu-item > a {
	color: var(--mw-header-link-hover);
}

/* --------------------------------------------------------------------------
   Mobile Toggle Button
   -------------------------------------------------------------------------- */
.mw-header__toggle {
	display: none;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 5px;
	width: 44px;
	height: 44px;
	background: transparent !important;
	border: none;
	cursor: pointer;
	padding: 10px;
	-webkit-tap-highlight-color: transparent;
}

.mw-header__toggle:hover {
	background: #f1f1f1 !important;
}

.mw-header__toggle:visited,
.mw-header__toggle:focus {
	background: transparent !important;
}

.mw-header__toggle-bar {
	display: block;
	width: 22px;
	height: 2px;
	background-color: var(--mw-header-text);
	transition: transform var(--mw-transition-speed) ease,
				opacity var(--mw-transition-speed) ease;
}

/* Hamburger to X animation */
.mw-header__toggle[aria-expanded="true"] .mw-header__toggle-bar:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}

.mw-header__toggle[aria-expanded="true"] .mw-header__toggle-bar:nth-child(2) {
	opacity: 0;
}

.mw-header__toggle[aria-expanded="true"] .mw-header__toggle-bar:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

/* --------------------------------------------------------------------------
   Mobile Menu Panel
   -------------------------------------------------------------------------- */
.mw-mobile-menu {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	max-width: 420px;
	background-color: var(--mw-mobile-menu-bg);
	z-index: 10000;
	transform: translateX(100%);
	transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.mw-mobile-menu.is-open {
	transform: translateX(0);
}

.mw-mobile-menu__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 var(--mw-header-padding-x);
	height: var(--mw-header-height);
	flex-shrink: 0;
	border-bottom: 1px solid #f0f0f0;
}

/* Hide logo in off-canvas on tablet, only show on mobile */
.mw-mobile-menu__header .mw-header__logo {
	display: none;
}

.mw-mobile-menu__header .mw-mobile-menu__close {
	margin-left: auto;
}

.mw-mobile-menu__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	background: transparent !important;
	border: none;
	cursor: pointer;
	color: var(--mw-header-text);
	padding: 0;
	-webkit-tap-highlight-color: transparent;
}

.mw-mobile-menu__close:hover {
	background: #f1f1f1 !important;
	color: var(--mw-header-text);
}

.mw-mobile-menu__close:visited,
.mw-mobile-menu__close:focus {
	background: transparent !important;
	color: var(--mw-header-text);
}

/* Mobile Navigation */
.mw-mobile-menu__nav {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	position: relative;
}

.mw-mobile-menu__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* Mobile menu items */
.mw-mobile-menu__item {
	border-bottom: 1px solid #f0f0f0;
}

.mw-mobile-menu__item > .mw-mobile-menu__link-wrap {
	display: flex;
	align-items: center;
}

.mw-mobile-menu__item > .mw-mobile-menu__link-wrap > a {
	display: block;
	flex: 1;
	padding: 18px 24px;
	font-family: var(--mw-header-font);
	font-size: 18px;
	font-weight: 400;
	color: var(--mw-header-text);
	text-decoration: none;
	transition: color var(--mw-transition-speed) ease;
}

.mw-mobile-menu__item > .mw-mobile-menu__link-wrap > a:hover,
.mw-mobile-menu__item > .mw-mobile-menu__link-wrap > a:focus {
	color: var(--mw-header-link-hover);
}

.mw-mobile-menu__item.current-menu-item > .mw-mobile-menu__link-wrap > a,
.mw-mobile-menu__item.current-menu-ancestor > .mw-mobile-menu__link-wrap > a {
	color: var(--mw-header-link-hover);
}

/* Mobile submenu expand button */
.mw-mobile-menu__expand {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: auto;
	align-self: stretch;
	background: none;
	border: none;
	border-left: 1px solid #f0f0f0;
	cursor: pointer;
	color: #000000;
	padding: 0;
	-webkit-tap-highlight-color: transparent;
	transition: background-color var(--mw-transition-speed) ease;
}

.mw-mobile-menu__expand:hover,
.mw-mobile-menu__expand:focus {
	background-color: #f8f8f8;
	color: #000000;
}

.mw-mobile-menu__expand svg {
	transition: transform var(--mw-transition-speed) ease;
}

.mw-mobile-menu__expand[aria-expanded="true"] svg {
	transform: rotate(180deg);
}

/* Mobile sub-menu */
.mw-mobile-menu__sub-menu {
	list-style: none;
	margin: 0;
	padding: 0;
	background-color: #f8f8f8;
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mw-mobile-menu__sub-menu.is-open {
	max-height: 1000px;
}

.mw-mobile-menu__sub-menu li {
	border-top: 1px solid #eeeeee;
}

.mw-mobile-menu__sub-menu li a {
	display: block;
	padding: 14px 24px 14px 40px;
	font-family: var(--mw-header-font);
	font-size: 16px;
	font-weight: 400;
	color: var(--mw-header-text);
	text-decoration: none;
	transition: color var(--mw-transition-speed) ease;
}

.mw-mobile-menu__sub-menu li a:hover,
.mw-mobile-menu__sub-menu li a:focus {
	color: var(--mw-header-link-hover);
}

/* Level 3 submenu items */
.mw-mobile-menu__sub-menu .mw-mobile-menu__sub-menu li a {
	padding-left: 56px;
}

/* --------------------------------------------------------------------------
   Mobile Menu Overlay
   -------------------------------------------------------------------------- */
.mw-mobile-menu__overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(13, 12, 51, 0.5);
	z-index: 9998;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

.mw-mobile-menu__overlay.is-visible {
	opacity: 1;
	visibility: visible;
}

/* --------------------------------------------------------------------------
   Body lock when mobile menu is open
   -------------------------------------------------------------------------- */
body.mw-menu-open {
	overflow: hidden;
}

/* Hide top bar behind mobile menu when open */
body.mw-menu-open .mw-top-bar {
	z-index: 1;
}

/* --------------------------------------------------------------------------
   Keyboard Focus Styles
   -------------------------------------------------------------------------- */
.mw-header__menu a:focus-visible,
.mw-mobile-menu__item a:focus-visible,
.mw-mobile-menu__expand:focus-visible,
.mw-header__toggle:focus-visible,
.mw-mobile-menu__close:focus-visible {
	outline: 2px solid var(--mw-header-link-hover);
	outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Responsive - Between 1200px and 1320px: tighten nav to delay hamburger
   -------------------------------------------------------------------------- */
@media (max-width: 1320px) and (min-width: 1201px) {
	.mw-header__menu > li > a {
		padding: 8px 10px 8px;
		font-size: 17px;
	}

	.mw-header__logo-img {
		height: 36px;
	}
}

/* --------------------------------------------------------------------------
   Responsive - Tablet & Mobile (< 1200px)
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
	.mw-header__nav {
		display: none;
	}

	.mw-header__inner {
		align-items: center;
		padding-top: 16px;
		padding-bottom: 16px;
	}

	.mw-header__logo-img {
		padding-bottom: 0;
	}

	.mw-header__toggle {
		display: flex;
	}

	body:not(.has-reduced-header) .mw-header__toggle {
		margin-right: -6px;
	}
}

/* --------------------------------------------------------------------------
   Responsive - Mobile (< 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
	:root {
		--mw-header-height: 72px;
	}

	.mw-header__logo-img {
		height: 32px;
	}

	.mw-header__logo-text {
		font-size: 22px;
	}

	.mw-mobile-menu {
		max-width: 100%;
		transform: none;
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.2s ease, visibility 0.2s ease;
	}

	.mw-mobile-menu.is-open {
		transform: none;
		opacity: 1;
		visibility: visible;
	}

	.mw-mobile-menu__item > .mw-mobile-menu__link-wrap > a {
		font-size: 16px;
		padding: 16px 20px;
	}

	/* Show logo in off-canvas on mobile */
	.mw-mobile-menu__header .mw-header__logo {
		display: block;
	}

	/* Remove hover state on burger/close buttons on mobile */
	.mw-header__toggle:hover {
		background: transparent !important;
	}

	.mw-mobile-menu__close:hover {
		background: transparent !important;
	}

	/* Top bar mobile adjustments */
	.mw-top-bar__link,
	.mw-top-bar__text {
		font-size: 14px;
	}

	.mw-top-bar__inner {
		padding: 4px var(--mw-header-padding-x);
	}
}

/* --------------------------------------------------------------------------
   Reduced Header (logo + CTA + burger, no top bar, no desktop nav)
   -------------------------------------------------------------------------- */
.has-reduced-header {
	--mw-top-bar-height: 0px;
}

/* Full-width header (no max-width constraint) */
.has-reduced-header .mw-header__inner {
	max-width: none;
	align-items: center;
	padding-top: 12px;
	padding-bottom: 12px;
}

/* Smaller logo in reduced mode */
.has-reduced-header .mw-header__logo-img {
	max-width: 150px;
	padding-bottom: 0;
}

.has-reduced-header {
	--mw-header-height: 68px;
}

.has-reduced-header .mw-header {
	height: 68px;
}

.mw-header__reduced-actions {
	display: flex;
	align-items: center;
	margin-left: auto;
	margin-right: 16px;
}

.mw-header__reduced-cta {
	display: none;
	align-items: center;
	padding: 8px 14px 8px 18px;
	font-family: "Meridian West", sans-serif;
	font-size: 15px;
	font-weight: 400;
	color: #ffffff;
	background-color: var(--e-global-color-90f9ad7, #2F31FC);
	border-radius: 20px;
	text-decoration: none;
	white-space: nowrap;
	transition: opacity var(--mw-transition-speed) ease;
}

.mw-header__reduced-cta:hover {
	opacity: 0.9;
	color: #ffffff;
}

/* Only show the CTA button on the Knowledge Hub template */
.knowledge-hub-page .mw-header__reduced-cta {
	display: inline-flex;
}

/* In reduced mode, always show the burger toggle (even on desktop) */
.has-reduced-header .mw-header__toggle {
	display: flex;
}

/* Reduced header on Knowledge Hub page: border-bottom instead of shadow */
.knowledge-hub-page .mw-header {
	border-bottom: 1px solid #eeeeee;
}

.knowledge-hub-page .mw-header--scrolled {
	box-shadow: none;
}

/* Reduced header on other pages: keep the normal scroll shadow */
.has-reduced-header .mw-header--scrolled {
	box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}

@media (max-width: 1024px) {
	.mw-header__reduced-cta {
		font-size: 14px;
		padding: 7px 14px;
	}

	.has-reduced-header .mw-header__logo-img {
		max-width: 120px;
	}

	.has-reduced-header .mw-header__reduced-actions {
		margin-right: 4px;
	}

	.has-reduced-header .mw-header__inner {
		padding-right: 8px;
	}

	.mw-mobile-menu__header {
		padding-right: 10px;
	}
}

/* --------------------------------------------------------------------------
   Hide parent theme's default header when our custom one is active
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
	.has-reduced-header .mw-header__logo-img {
		max-width: 100px;
	}
}

.site-header {
	display: none !important;
}
