/* ==========================================================================
   Matheson Header
   ========================================================================== */

/* ---- Visually hidden (screen-reader only) ---- */
.matheson-header .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;
}

/* ---- Layout ---- */
.matheson-header {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	z-index: 99999;
	background: #1c1f4e;
	font-family: 'Open Sans', sans-serif;
}

.admin-bar .matheson-header {
	top: 32px;
}

body.has-matheson-header {
	padding-top: 80px;
}

.admin-bar.has-matheson-header {
	padding-top: 80px;
}

.header-container {
	width: 80%;
	max-width: 1208px;
	margin: 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 80px;
}

/* ---- Logo ---- */
.header-logo {
	display: flex;
	align-items: center;
	flex-shrink: 0;
	text-decoration: none;
}

.header-logo img {
	max-height: 45px;
	width: auto;
	filter: brightness(0) invert(1);
	transition: opacity 0.2s ease;
}

.header-logo:hover img {
	opacity: 0.85;
}

/* ---- Nav ---- */
.header-nav {
	display: flex;
	align-items: center;
}

.header-menu {
	display: flex;
	list-style: none;
	margin: 0;
	padding: 0;
	gap: 10px;
}

/* ---- Menu Items ---- */
.menu-item {
	position: relative;
}

.menu-link,
.dropdown-toggle {
	display: flex;
	align-items: center;
	gap: 5px;
	background: none;
	border: none;
	color: #fff;
	font-family: 'Open Sans', sans-serif;
	font-size: 15px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.8px;
	padding: 10px 12px;
	cursor: pointer;
	white-space: nowrap;
	transition: color 0.2s ease;
	text-decoration: none;
	line-height: 1.4;
}

a.dropdown-toggle:visited {
	color: #fff;
}

.dropdown-toggle:hover,
.dropdown-toggle:focus-visible,
.menu-item.is-open > .dropdown-toggle {
	color: #B0C637;
}

a.dropdown-toggle:visited:hover,
a.dropdown-toggle:visited:focus-visible,
.menu-item.is-open > a.dropdown-toggle:visited {
	color: #B0C637;
}

.dropdown-toggle:focus-visible {
	outline: 2px solid #B0C637;
	outline-offset: -2px;
	border-radius: 3px;
}

/* Chevron */
.chevron {
	transition: transform 0.2s ease;
	flex-shrink: 0;
}

.menu-item.is-open > .dropdown-toggle .chevron {
	transform: rotate(180deg);
}

/* ---- Dropdown Menu ---- */
.dropdown-menu {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 230px;
	background: #1c1f4e;
	list-style: none;
	margin: 0;
	padding: 8px 0;
	border-top: 2px solid #B0C637;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-4px);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.menu-item.is-open > .dropdown-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.dropdown-menu a {
	display: block;
	padding: 9px 20px;
	color: rgba(255, 255, 255, 0.7);
	text-decoration: none;
	font-size: 13px;
	font-weight: 400;
	letter-spacing: 0.3px;
	transition: color 0.15s ease, background 0.15s ease;
}

.dropdown-menu a:hover,
.dropdown-menu a:focus-visible {
	color: #fff;
	background: rgba(255, 255, 255, 0.06);
}

.dropdown-menu a:focus-visible {
	outline: 2px solid #B0C637;
	outline-offset: -2px;
}

/* Divider inside dropdown */
.dropdown-divider {
	height: 1px;
	margin: 6px 20px;
	background: rgba(255, 255, 255, 0.1);
}

/* ---- Mega Menu ---- */
.mega-menu {
	position: absolute;
	top: 100%;
	right: 0;
	background: #1c1f4e;
	border-top: 2px solid #B0C637;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
	padding: 24px 28px;
	width: max-content;
}

.menu-item.is-open > .mega-menu {
	opacity: 1;
	visibility: visible;
}

.mega-menu-inner {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 28px;
}

.mega-col ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.mega-heading {
	color: #B0C637;
	font-family: 'Open Sans', sans-serif;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 1.5px;
	margin: 0 0 10px 0;
	padding: 0 0 6px 0;
	border-bottom: 1px solid rgba(176, 198, 55, 0.25);
	/* Reset button styles for desktop */
	background: none;
	border-top: none;
	border-left: none;
	border-right: none;
	cursor: default;
	text-align: left;
}

/* Hide chevron on desktop mega headings */
.mega-heading .chevron {
	display: none;
}

.mega-col .mega-heading + ul + .mega-heading,
.mega-col .mega-group + .mega-group {
	margin-top: 18px;
}

.mega-col a {
	display: block;
	padding: 5px 0;
	color: rgba(255, 255, 255, 0.7);
	text-decoration: none;
	font-size: 13px;
	font-weight: 400;
	letter-spacing: 0.3px;
	transition: color 0.15s ease;
}

.mega-col a:hover,
.mega-col a:focus-visible {
	color: #fff;
}

.mega-col a:focus-visible {
	outline: 2px solid #B0C637;
	outline-offset: 2px;
}

/* ---- Mobile-only dropdown items (hidden on desktop) ---- */
.mobile-only {
	display: none;
}

/* ---- Hamburger Toggle (hidden on desktop) ---- */
.header-menu-toggle {
	display: none;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 5px;
	background: none;
	border: none;
	cursor: pointer;
	padding: 8px;
	z-index: 10;
}

.hamburger-line {
	display: block;
	width: 24px;
	height: 2px;
	background: #fff;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

.header-menu-toggle:focus-visible {
	outline: 2px solid #B0C637;
	outline-offset: 2px;
	border-radius: 3px;
}

.header-menu-toggle.is-open .hamburger-line:nth-child(1) {
	transform: rotate(45deg) translate(5px, 5px);
}

.header-menu-toggle.is-open .hamburger-line:nth-child(2) {
	opacity: 0;
}

.header-menu-toggle.is-open .hamburger-line:nth-child(3) {
	transform: rotate(-45deg) translate(5px, -5px);
}

/* ---- Overlay ---- */
.header-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.5);
	z-index: -1;
}

body.header-menu-open .header-overlay {
	display: block;
}

/* ---- Scroll shadow (subtle bottom border on scroll) ---- */
.matheson-header.is-scrolled {
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   Mobile / Responsive
   ========================================================================== */

@media (max-width: 980px) {
	.header-container {
		width: 90%;
		height: 65px;
	}

	body.has-matheson-header {
		padding-top: 65px;
	}

	.admin-bar.has-matheson-header {
		padding-top: 65px;
	}

	.header-logo img {
		max-height: 38px;
	}

	/* Show hamburger */
	.header-menu-toggle {
		display: flex;
	}

	/* Slide-out nav panel */
	.header-nav {
		position: fixed;
		top: 65px;
		right: -100%;
		width: 85%;
		max-width: 380px;
		height: calc(100vh - 65px);
		background: #1c1f4e;
		overflow-y: auto;
		transition: right 0.3s ease;
		display: block;
		padding: 16px 0;
		box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
		-webkit-overflow-scrolling: touch;
	}

	.admin-bar .header-nav {
		top: 97px;
		height: calc(100vh - 97px);
	}

	.header-nav.is-open {
		right: 0;
	}

	.header-menu {
		flex-direction: column;
		gap: 0;
	}

	/* Dropdown toggle fills width */
	.dropdown-toggle {
		width: 100%;
		justify-content: space-between;
		padding: 14px 24px;
		font-size: 14px;
	}

	/* Dropdown accordion style */
	.dropdown-menu {
		position: static;
		min-width: 0;
		border-top: none;
		box-shadow: none;
		background: rgba(0, 0, 0, 0.15);
		max-height: 0;
		overflow: hidden;
		opacity: 1;
		visibility: visible;
		transform: none;
		transition: max-height 0.3s ease;
		padding: 0;
	}

	.menu-item.is-open > .dropdown-menu {
		/* max-height set by JS for smooth transitions */
		padding: 0;
	}

	.dropdown-menu a {
		padding: 10px 24px 10px 36px;
		font-size: 13px;
	}

	.dropdown-divider {
		margin: 4px 36px;
	}

	/* Mega menu mobile */
	.mega-menu {
		position: static;
		min-width: 0;
		width: auto;
		border-top: none;
		box-shadow: none;
		background: rgba(0, 0, 0, 0.15);
		max-height: 0;
		overflow: hidden;
		opacity: 1;
		visibility: visible;
		transform: none;
		transition: max-height 0.3s ease;
		padding: 0;
	}

	.menu-item.is-open > .mega-menu {
		/* max-height set by JS for smooth transitions */
		padding: 0;
		transform: none;
	}

	.mega-menu-inner {
		grid-template-columns: 1fr;
		gap: 0;
		padding: 0;
	}

	.mega-heading {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		padding: 12px 24px;
		margin: 0;
		background: none;
		border: none;
		border-bottom: none;
		cursor: pointer;
		color: #B0C637;
		font-family: 'Open Sans', sans-serif;
		font-size: 11px;
		font-weight: 700;
		text-transform: uppercase;
		letter-spacing: 1.5px;
		text-align: left;
	}

	.mega-heading .chevron {
		display: block;
		transition: transform 0.2s ease;
		flex-shrink: 0;
	}

	.mega-col.is-open > .mega-heading .chevron,
	.mega-group.is-open > .mega-heading .chevron {
		transform: rotate(180deg);
	}

	/* Collapse sub-category links by default on mobile */
	.mega-col > ul,
	.mega-group > ul {
		max-height: 0;
		overflow: hidden;
		transition: max-height 0.3s ease;
	}

	.mega-col.is-open > ul,
	.mega-group.is-open > ul {
		/* max-height set by JS to actual scrollHeight for smooth transitions */
	}

	.mega-heading:focus-visible {
		outline: 2px solid #fff;
		outline-offset: -2px;
		border-radius: 2px;
	}

	.mega-col .mega-group + .mega-group {
		margin-top: 4px;
	}

	.mega-col a {
		padding: 8px 24px 8px 36px;
	}

	/* Show mobile-only items */
	.mobile-only {
		display: list-item;
	}

	.mobile-only a {
		font-weight: 600;
		color: #B0C637 !important;
	}

	/* Lock body scroll when menu is open */
	body.header-menu-open {
		overflow: hidden;
	}
}

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

	.admin-bar .header-nav {
		top: 111px;
		height: calc(100vh - 111px);
	}

	.admin-bar.has-matheson-header {
		padding-top: 65px;
	}
}

@media (max-width: 480px) {
	.header-container {
		width: 92%;
	}

	.header-nav {
		width: 100%;
		max-width: none;
	}
}
