/**
 * Header and Navigation Styling Module
 *
 * @package Tech_Chartered
 * @since 1.0.0
 */

/* Sticky Header Glassmorphism effect */
.tech-chartered-header-wrap {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	z-index: 999;
	transition: transform 0.3s ease;
}

.tech-chartered-sticky-header {
	background-color: rgba(255, 255, 255, 0.95);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	box-shadow: var(--box-shadow-sm);
	padding: 15px 0;
	transition: padding 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.tech-chartered-header-wrap.is-scrolled .tech-chartered-sticky-header {
	padding: 10px 0;
	background-color: #071A35;
	border-bottom: 1px solid rgba(255, 255, 255, 0.05);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

/* Scrolled link colors override: ONLY apply on desktop and only to top-level menu items */
@media (min-width: 993px) {
	.tech-chartered-header-wrap.is-scrolled .tech-chartered-nav-menu>li>a {
		color: var(--color-white) !important;
	}
}

.tech-chartered-header-wrap.is-scrolled .tech-chartered-sticky-header .site-title a {
	color: var(--color-white) !important;
}

/* Custom Navigation Menu styles */
.tech-chartered-nav-menu {
	display: flex;
	list-style: none;
	margin: 0;
	padding: 0;
	gap: 2rem;
}

.tech-chartered-nav-menu a {
	font-family: var(--font-body);
	font-weight: 500;
	font-size: 0.95rem;
	color: var(--color-primary);
	position: relative;
	padding: 8px 0;
	display: block;
}

.tech-chartered-nav-menu a::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 0;
	width: 0;
	height: 2px;
	background-color: var(--color-accent);
	transition: var(--transition-fast);
}

.tech-chartered-nav-menu a:hover::after,
.tech-chartered-nav-menu .current-menu-item>a::after {
	width: 100%;
}

/* Dropdown Menu styling */
.tech-chartered-nav-menu li {
	position: relative;
}

.tech-chartered-nav-menu .sub-menu {
	position: absolute;
	top: 100%;
	left: 0;
	background-color: var(--color-white);
	box-shadow: var(--box-shadow-md);
	border-radius: var(--border-radius-md);
	min-width: 220px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(10px);
	transition: var(--transition-smooth);
	z-index: 100;
	padding: 10px 0;
	list-style: none;
}

.tech-chartered-nav-menu li:hover>.sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.tech-chartered-nav-menu .sub-menu a {
	padding: 8px 20px;
	font-size: 0.875rem;
	font-weight: 400;
	color: var(--color-secondary);
}

.tech-chartered-nav-menu .sub-menu a::after {
	display: none;
}

.tech-chartered-nav-menu .sub-menu a:hover {
	background-color: var(--color-bg-light);
	color: var(--color-accent);
}

/* Mobile Toggle Hamburger button */
.tech-chartered-menu-toggle {
	display: none;
	background: none;
	border: none;
	cursor: pointer;
	padding: 10px;
	z-index: 1001;
}

.tech-chartered-menu-toggle span {
	display: block;
	width: 25px;
	height: 3px;
	background-color: var(--color-primary);
	margin: 5px 0;
	transition: var(--transition-smooth);
}

/* Open states for toggle */
.tech-chartered-menu-toggle.is-active span:nth-child(1) {
	transform: translateY(8px) rotate(45deg);
}

.tech-chartered-menu-toggle.is-active span:nth-child(2) {
	opacity: 0;
}

.tech-chartered-menu-toggle.is-active span:nth-child(3) {
	transform: translateY(-8px) rotate(-45deg);
}

@media (max-width: 992px) {
	.tech-chartered-menu-toggle {
		display: block;
	}

	.tech-chartered-nav-menu {
		position: fixed;
		top: 0;
		right: -100%;
		height: 100vh;
		width: 300px;
		background-color: var(--color-white);
		box-shadow: var(--box-shadow-lg);
		flex-direction: column;
		padding: 80px 40px;
		gap: 1.5rem;
		transition: var(--transition-smooth);
		z-index: 1000;
	}

	.tech-chartered-nav-menu.is-open {
		right: 0;
	}

	.tech-chartered-nav-menu .sub-menu {
		position: static;
		max-height: 0;
		overflow: hidden;
		opacity: 0;
		transform: none;
		box-shadow: none;
		padding-left: 20px;
		background-color: transparent;
		transition: max-height 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s ease;
	}

	.tech-chartered-nav-menu .menu-item-has-children.is-active>.sub-menu,
	.tech-chartered-nav-menu .tech-dropdown-parent.is-active>.sub-menu {
		max-height: 500px;
		opacity: 1;
		padding-top: 5px;
		padding-bottom: 5px;
	}
}

/* --- Professional Mega Menu Styling --- */

/* Desktop Mega Menu Hover & Alignment */
@media (min-width: 993px) {
	.tech-chartered-nav {
		position: relative;
	}

	.tech-mega-menu-parent {
		position: static !important;
		/* Allow the content block to anchor to the parent nav layout width */
	}

	.tech-mega-menu-content {
		position: absolute;
		top: 100%;
		left: 50%;
		transform: translate(-50%, 10px);
		background-color: var(--color-white);
		box-shadow: 0 15px 35px rgba(15, 76, 129, 0.12);
		border-radius: var(--border-radius-md);
		border: 1px solid #e2e8f0;
		width: 860px;
		max-width: 90vw;
		padding: 28px 32px;
		opacity: 0;
		visibility: hidden;
		transition: var(--transition-smooth);
		z-index: 9999;
	}

	.tech-chartered-nav-menu .tech-mega-menu-parent:hover>.tech-mega-menu-content {
		opacity: 1 !important;
		visibility: visible !important;
		transform: translate(-50%, 0) !important;
	}

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

	.mega-menu-col h5 {
		font-family: var(--font-display);
		font-size: 0.85rem;
		font-weight: 700;
		color: var(--color-secondary);
		margin: 0 0 16px 0;
		padding-bottom: 8px;
		border-bottom: 2px solid var(--color-accent);
		text-transform: uppercase;
		letter-spacing: 0.08em;
	}

	.mega-menu-col ul {
		list-style: none;
		margin: 0;
		padding: 0;
		display: flex;
		flex-direction: column;
		gap: 12px;
	}

	.mega-menu-col ul li a {
		padding: 0 !important;
		font-size: 0.875rem !important;
		font-weight: 500 !important;
		color: #4b5563 !important;
		transition: transform 0.2s ease, color 0.2s ease !important;
		display: inline-block !important;
	}

	.mega-menu-col ul li a:hover {
		color: var(--color-accent) !important;
		transform: translateX(4px);
	}

	.mega-menu-col ul li a::after {
		display: none !important;
	}
}

/* Mobile responsive accordion fallback for Mega Menu */
@media (max-width: 992px) {
	.tech-mega-menu-content {
		max-height: 0;
		overflow: hidden;
		opacity: 0;
		transition: max-height 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s ease;
		padding-left: 15px;
	}

	.tech-mega-menu-parent.is-active .tech-mega-menu-content {
		max-height: 1000px;
		opacity: 1;
		padding-top: 10px;
		padding-bottom: 10px;
	}

	.mega-menu-grid {
		display: flex;
		flex-direction: column;
		gap: 20px;
	}

	.mega-menu-col h5 {
		font-family: var(--font-display);
		font-size: 0.8rem;
		font-weight: 700;
		color: var(--color-secondary);
		margin: 0 0 10px 0;
		text-transform: uppercase;
		letter-spacing: 0.05em;
		border-left: 2px solid var(--color-accent);
		padding-left: 8px;
	}

	.mega-menu-col ul {
		list-style: none;
		margin: 0;
		padding: 0 0 0 10px;
		display: flex;
		flex-direction: column;
		gap: 10px;
	}

	.mega-menu-col ul li a {
		padding: 4px 0 !important;
		font-size: 0.85rem !important;
		color: #64748b !important;
	}

	.mega-menu-col ul li a::after {
		display: none !important;
	}
}

/* --- Sticky Header Desktop Offset & Homepage Overlays --- */
@media (min-width: 993px) {

	/* Homepage Transparent Header Overlay */
	.home .tech-chartered-sticky-header {
		background-color: transparent !important;
		backdrop-filter: none !important;
		-webkit-backdrop-filter: none !important;
		box-shadow: none !important;
		border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
		padding: 6px 0;
	}

	.home .tech-chartered-sticky-header a {
		color: rgba(255, 255, 255, 0.9) !important;
	}

	.home .tech-chartered-sticky-header .site-logo .logo-link {
		color: var(--color-white) !important;
	}

	.home .tech-chartered-sticky-header .logo-accent {
		color: var(--color-accent) !important;
	}

	.home .tech-chartered-sticky-header .tech-chartered-btn-primary {
		background-color: var(--color-accent) !important;
		color: #061225 !important;
		border-color: var(--color-accent) !important;
	}

	.home .tech-chartered-sticky-header .tech-chartered-btn-primary:hover {
		background-color: var(--color-white) !important;
		color: #061225 !important;
		border-color: var(--color-white) !important;
	}

	/* Homepage Scrolled Header Overlay */
	.home .tech-chartered-header-wrap.is-scrolled .tech-chartered-sticky-header {
		background-color: #071A35 !important;
		backdrop-filter: blur(15px) !important;
		-webkit-backdrop-filter: blur(15px) !important;
		box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25) !important;
		border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
		padding: 10px 0;
	}

	.home .tech-chartered-header-wrap.is-scrolled .tech-chartered-sticky-header a {
		color: rgba(255, 255, 255, 0.9) !important;
	}

	.home .tech-chartered-header-wrap.is-scrolled .tech-chartered-sticky-header .tech-chartered-btn-primary {
		background-color: var(--color-accent) !important;
		color: #061225 !important;
		border-color: var(--color-accent) !important;
	}
}

/* Ensure mobile header displays properly on homepage */
@media (max-width: 992px) {
	.home .tech-chartered-sticky-header {
		background-color: transparent !important;
		border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
		box-shadow: none !important;
	}

	.home .tech-chartered-header-wrap.is-scrolled .tech-chartered-sticky-header {
		background-color: #071A35 !important;
		border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
		box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25) !important;
	}

	.home .tech-chartered-sticky-header a {
		color: var(--color-white) !important;
	}

	.home .tech-chartered-sticky-header .site-logo .logo-link {
		color: var(--color-white) !important;
	}

	.home .tech-chartered-sticky-header .tech-chartered-menu-toggle span,
	.tech-chartered-header-wrap.is-scrolled .tech-chartered-menu-toggle span {
		background-color: var(--color-white) !important;
	}
}

/* Specificity fix for logo and dropdown contrast on scrolled state */
.tech-chartered-sticky-header.is-scrolled .site-logo .logo-link {
	color: var(--color-white) !important;
}

/* Homepage Mega Menu & Submenu color contrast fix (avoid white text on white bg) */
.home .tech-chartered-sticky-header .tech-mega-menu-content a,
.home .tech-chartered-sticky-header .sub-menu a {
	color: var(--color-secondary) !important;
}

.home .tech-chartered-sticky-header .tech-mega-menu-content a:hover,
.home .tech-chartered-sticky-header .sub-menu a:hover {
	color: var(--color-accent) !important;
}

/* Header CTA Button styling overrides */
.header-cta .tech-chartered-btn {
	padding: 8px 18px !important;
	font-size: 0.85rem !important;
	font-weight: 700 !important;
	border-radius: 6px !important;
	letter-spacing: 0.02em !important;
	text-transform: uppercase !important;
	box-shadow: 0 4px 12px rgba(244, 180, 0, 0.15) !important;
	transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

.header-cta .tech-chartered-btn:hover {
	transform: translateY(-2px) !important;
	box-shadow: 0 6px 18px rgba(244, 180, 0, 0.3) !important;
}

/* Header space offset for internal pages */
body:not(.home) {
	padding-top: 118px;
	/* Pushes content down below the sticky header + topbar */
}

@media (max-width: 992px) {
	body:not(.home) {
		padding-top: 70px;
		/* Offset for mobile header height */
	}

	body.home {
		padding-top: 0;
	}
}

/* --- Global Layout and Typography for Header & Topbar --- */
.tech-chartered-topbar {
	background-color: var(--color-secondary);
	color: rgba(255, 255, 255, 0.85);
	font-size: 0.825rem;
	padding: 10px 0;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	transition: margin-top 0.3s ease, opacity 0.3s ease;
}

.tech-chartered-header-wrap.is-scrolled .tech-chartered-topbar {
	margin-top: -43px;
	/* Slide up topbar */
	opacity: 0;
	pointer-events: none;
}

.tech-chartered-topbar-flex {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.tech-chartered-topbar-info {
	display: flex;
	gap: 24px;
}

.topbar-item {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.topbar-item a {
	color: rgba(255, 255, 255, 0.85);
	text-decoration: none;
	transition: var(--transition-fast);
}

.topbar-item a:hover {
	color: var(--color-accent);
}

.tech-chartered-topbar-hours {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

@media (max-width: 768px) {
	.tech-chartered-topbar-hours {
		display: none;
	}

	.tech-chartered-topbar-flex {
		justify-content: center;
	}

	.tech-chartered-topbar-info {
		gap: 16px;
	}
}

.header-nav-flex {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

/* --- Brand Logo Container and Responsive Transitions --- */
.site-logo .logo-link {
	display: flex;
	align-items: center;
	text-decoration: none;
	position: relative;
	height: 60px;
	width: 263px;
	/* Precise width of logo-horizontal.png at 60px height to prevent layout shift */
	transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1), width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.tech-chartered-header-wrap.is-scrolled .site-logo .logo-link {
	height: 48px;
	width: 164px;
	/* Precise width of logo-white.png at 48px height to prevent layout shift */
}

.brand-logo {
	max-height: 100%;
	object-fit: contain;
	display: block;
}

.logo-desktop {
	height: 60px;
	width: auto;
	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), height 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
}

.logo-desktop.logo-default {
	opacity: 1;
	visibility: visible;
}

.logo-desktop.logo-scrolled {
	opacity: 0;
	visibility: hidden;
}

/* Scrolled logo state adjustments */
.tech-chartered-header-wrap.is-scrolled .logo-desktop.logo-default {
	opacity: 0;
	visibility: hidden;
}

.tech-chartered-header-wrap.is-scrolled .logo-desktop.logo-scrolled {
	opacity: 1;
	visibility: visible;
	height: 48px;
}

.logo-mobile {
	display: none;
	height: 40px;
}

@media (max-width: 992px) {
	.site-logo .logo-link {
		width: auto !important;
		height: 40px !important;
	}

	.logo-desktop {
		display: none !important;
	}

	.logo-mobile {
		display: block !important;
		position: static !important;
		height: 40px !important;
	}
}

/* Ensure mobile menu cta items behave correctly */
.nav-cta-mobile {
	display: none !important;
}

@media (max-width: 992px) {
	.nav-cta-mobile {
		display: block !important;
		margin-top: 15px;
		background-color: var(--color-accent) !important;
		color: #061225 !important;
		text-align: center;
		padding: 10px 20px !important;
		border-radius: 6px;
		font-weight: 700;
	}
}

/* --- Professional Dropdown and Mega Menu Contrast Rules --- */

/* 1. Desktop - When NOT scrolled (Default light header) */
@media (min-width: 993px) {
	.tech-chartered-sticky-header:not(.is-scrolled) .sub-menu {
		background-color: var(--color-white);
		border: 1px solid #e2e8f0;
	}

	.tech-chartered-sticky-header:not(.is-scrolled) .sub-menu a {
		color: var(--color-secondary) !important;
	}

	.tech-chartered-sticky-header:not(.is-scrolled) .sub-menu a:hover {
		background-color: var(--color-bg-light) !important;
		color: var(--color-accent) !important;
	}
}

/* 2. Desktop - When Scrolled (Dark blue header) or on Home Page (Transparent with dark hero background) */
@media (min-width: 993px) {

	.tech-chartered-header-wrap.is-scrolled .sub-menu,
	.home .tech-chartered-sticky-header .sub-menu {
		background-color: #0c2548 !important;
		border: 1px solid rgba(255, 255, 255, 0.1) !important;
		box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
	}

	.tech-chartered-header-wrap.is-scrolled .sub-menu a,
	.home .tech-chartered-sticky-header .sub-menu a {
		color: rgba(255, 255, 255, 0.9) !important;
		background-color: transparent !important;
	}

	.tech-chartered-header-wrap.is-scrolled .sub-menu a:hover,
	.home .tech-chartered-sticky-header .sub-menu a:hover {
		background-color: rgba(255, 255, 255, 0.05) !important;
		color: var(--color-accent) !important;
	}

	/* Mega Menu Scrolled & Homepage Dark Theme */
	.tech-chartered-header-wrap.is-scrolled .tech-mega-menu-content,
	.home .tech-chartered-sticky-header .tech-mega-menu-content {
		background-color: #0c2548 !important;
		border: 1px solid rgba(255, 255, 255, 0.1) !important;
		box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4) !important;
	}

	.tech-chartered-header-wrap.is-scrolled .tech-mega-menu-content h5,
	.home .tech-chartered-sticky-header .tech-mega-menu-content h5 {
		color: var(--color-white) !important;
		border-bottom: 2px solid var(--color-accent) !important;
	}

	.tech-chartered-header-wrap.is-scrolled .tech-mega-menu-content .mega-menu-col ul li a,
	.home .tech-chartered-sticky-header .tech-mega-menu-content .mega-menu-col ul li a {
		color: rgba(255, 255, 255, 0.8) !important;
	}

	.tech-chartered-header-wrap.is-scrolled .tech-mega-menu-content .mega-menu-col ul li a:hover,
	.home .tech-chartered-sticky-header .tech-mega-menu-content .mega-menu-col ul li a:hover {
		color: var(--color-accent) !important;
		transform: translateX(4px);
	}
}

/* 3. Mobile Navigation Drawer Style & Contrast Fixes */
@media (max-width: 992px) {
	.tech-chartered-nav-menu {
		background-color: var(--color-white) !important;
		box-shadow: var(--box-shadow-lg) !important;
	}

	/* Force all mobile menu drawer links to be clearly visible dark color */
	.tech-chartered-nav-menu a {
		color: var(--color-secondary) !important;
	}

	.tech-chartered-nav-menu a:hover,
	.tech-chartered-nav-menu a:focus {
		color: var(--color-accent) !important;
	}

	.tech-chartered-nav-menu .sub-menu a {
		color: #64748b !important;
	}

	.tech-chartered-nav-menu .sub-menu a:hover {
		color: var(--color-accent) !important;
	}

	/* Ensure toggle button closing state is visible against white drawer background */
	.tech-chartered-menu-toggle.is-active span {
		background-color: var(--color-primary) !important;
	}
}

/* Default Astra Header/Footer global suppression */
.site-header,
#masthead,
.site-footer,
#colophon {
	display: none !important;
}