/* theme/assets/css/_core_nav.css */

body > header,
#nav-bar {
	width: 100vw;
	height: 10vh;
}

body > header {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
}

body > header a {
  color: white;
  text-decoration: none;
}

#nav-bar {
	position: fixed;
	top: 0;
	left: 0;
	height: 10vh;
	width: 100vw;
	background-color: var(--mainColorTransparent);
	z-index: 2;
}

#logo-name {
	position: fixed;
	top: 28px;
	left: 50%;
	transform: translateX(-50%);
	color: white;
	z-index: 2;
	font-family: var(--font-brand);
	font-size: var(--font-size-logo);
	font-weight: var(--font-weight-bold);
	display: flex;
	gap: 1rem;
	min-width: 75vw;
	justify-content: center;
	align-items: center;
	cursor: pointer;
	transition: all 0.3s ease; /* Smooth transition for position changes */
}

#logo-name.logo-left.front-page {
	position: absolute !important;
}

#logo-name img {
	max-height: 5vh;
	width: auto;
}

#site-name,
#site-logo {
	align-self: center;
}

.user-nav,
#nav-bar.user-nav {
	margin-top: 32px;
}

body > nav {
	position: fixed;
	top: 0;
	left: 0;
	width: 40vw;
	height: 100vh;
	animation: 0.5s slideInFromLeft forwards;
	background-color: var(--navBgColor);
	color: white;
    z-index: 4;
}

body > nav.slide-out {
	animation: 0.5s slideOutFromLeft forwards;
}

body > nav .website-menu {
	max-height: 85vh;
	overflow-y: auto;
	padding: 2rem;
}

body > nav a {
	color: white;
	text-decoration: none;
}

body > nav a:hover {
	color: black;
	text-shadow: 1px 1px 5px hsla(0, 0%, 100%, 0.3);
}

.menu {
	margin-top: 3.5rem;
}

body > nav,
#close-nav-btn {
    display: none;
}

body > nav a {
	display: inline-block;
	width: 100%;
	font-family: var(--font-nav);
	font-size: var(--font-size-nav);
	font-weight: var(--font-weight-bold);
	color: white;
    text-align: right;
}

body > nav ul .menu-item {
	position: relative;
}

/* Position the link for top-level items */
body > nav .menu-item > a {
	display: block;
	padding-right: 2rem;
}

/* Position the link for nested items */
body > nav .sub-menu .menu-item > a {
	display: block;
	padding-right: 2rem;
}

/* Position expand icon for all menu levels */
body > nav .menu-item .expand-icon {
	position: absolute;
	left: 0;
	top: 0;
	pointer-events: none;
	color: white;
	font-weight: bold;
	z-index: 1;
}

body > nav .sub-menu {
	max-height: 0;
	transition: max-height 0.4s ease-out;
	overflow-y: hidden; /* Keep vertical clipping for animation */
	padding-left: 1rem;
}

body > nav .sub-menu a {
	font-size: 1rem;
}

body > nav ul {
	padding: 0;
}

body > nav ul > li {
	margin-top: .5rem;
}

body > nav li {
    list-style: none;
}

/* Menu items are now controlled via JavaScript based on authentication */

/* Generic Submenu Fixes - Handles Unlimited Nesting Levels */

/* Ensure nested submenus are properly displayed */
body > nav .website-menu .sub-menu {
    display: block !important;
    position: static !important;
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    width: 100% !important;
    min-width: auto !important;
    max-width: none !important;
    overflow: hidden !important;
    transition: max-height 0.4s ease-out;
}

/* Ensure all nested submenu items are visible when parent is expanded */
body > nav .website-menu .sub-menu li {
    display: list-item !important;
    position: relative !important;
    float: none !important;
    clear: both !important;
    width: 100% !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    overflow: visible !important;
    margin-top: 0.25rem !important;
}

/* Ensure all nested submenu links are visible */
body > nav .website-menu .sub-menu a {
    display: block !important;
    color: white !important;
    text-decoration: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    position: static !important;
    width: 100% !important;
    text-align: right;
}

/* Force visibility for any authentication-hidden submenu items */
body > nav .sub-menu li[style*="display: none"] {
    display: list-item !important;
}

body > nav .sub-menu li[style*="visibility: hidden"] {
    visibility: visible !important;
}

#hamburger, #close-nav-btn {
	max-width: 35px;
	height: auto;
	z-index: 5;
	position: fixed;
	top: 25px;
	left: 25px;
	cursor: pointer;
}

#backdrop {
	display: none;
	width: 100vw;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.9);
	position: fixed;
	z-index: 4;
	animation: 0.5s fadeIn forwards;
}

#backdrop.fade {
	animation: 0.5s fadeOut forwards;
}

@media (max-width: 800px) {
	body > nav {
		width: 70vw;
	}

	#logo-name img {
		max-height: 3.5vh;
	}

	#wpadminbar {
		position: fixed;
	}
	
	/* Critical: Re-enable ONLY hamburger menu at mobile breakpoint even with .element-disable */
	.element-disable #hamburger {
		display: block !important;
	}
	
	/* Ensure the parent container of hamburger element is shown */
	.element-disable:has(#hamburger) {
		display: block !important;
	}
	
	/* Close button should remain hidden initially (shown by JS when menu opens) */
	.element-disable #close-nav-btn {
		display: none !important;
	}
	
	/* Make sure nav functionality works normally at mobile */
	body > nav {
		display: none; /* Still hidden by default, shown by JS */
	}
	
	/* Ensure logo returns to center on mobile regardless of .logo-left class */
	#logo-name.logo-left {
		position: fixed;
		top: 28px;
		left: 50% !important;
		transform: translateX(-50%) !important;
		justify-content: center !important;
		min-width: 75vw !important;
	}
	
	/* Adjust font size for mobile navigation */
	body > nav a {
		font-size: var(--font-size-nav-mobile);
	}
}

/* Ensure overlay menu elements are properly hidden on desktop when not using overlay */
@media (min-width: 801px) {
	/* When overlay menu is not active, these should remain hidden */
	.element-disable:not(:has(#overlay-menu-container)):not(:has(#nav-overlay-container)) {
		display: none;
	}
}

/* Profile Dropdown Styles */
#profile-dropdown-container {
	position: fixed;
	top: 25px;
	right: 25px;
	z-index: 6;
	-webkit-tap-highlight-color: transparent;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

/* Hide profile dropdown behind backdrop when menu is open */
body.menu-open #profile-dropdown-container {
	z-index: 0;
}

/* Hide profile dropdown initially until auth state is determined */
#profile-dropdown-container {
	display: none;
}

/* Show profile dropdown only when auth state is determined */
body.auth-checked #profile-dropdown-container {
	display: block;
}

/* Hide main navigation initially until auth state is determined */
body > nav {
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.2s ease;
}

/* Hide all nav menu items initially */
body > nav ul li {
	display: none !important;
}

/* Show main navigation only when auth state is determined */
body.auth-checked > nav {
	visibility: visible;
	opacity: 1;
}

/* Allow nav items to be shown after auth check (override the !important) */
body.auth-checked > nav ul li {
	display: list-item !important;
}

/* Hide auth-specific items (login/signup when logged in, etc.) */
body.auth-checked > nav ul > li.auth-hide {
	display: none !important;
}

#profile-button {
	background: var(--mainColorTransparent, rgba(255, 255, 255, 0.1));
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all 0.3s ease;
	color: white;
	padding: 0;
	-webkit-tap-highlight-color: transparent;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	outline: none;
}

#profile-button:hover {
	background: var(--mainColor, rgba(255, 255, 255, 0.2));
	transform: scale(1.05);
}

#profile-button svg {
	width: 24px;
	height: 24px;
	color: currentColor;
}

.profile-dropdown-menu {
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	background: white;
	border-radius: 8px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
	min-width: 180px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-10px);
	transition: all 0.3s ease;
	overflow: hidden;
}

.profile-dropdown-menu[aria-hidden="false"] {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.profile-dropdown-item {
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	color: #333;
	text-decoration: none;
	font-family: system-ui, -apple-system, 'Segoe UI', 'Roboto', sans-serif;
	font-size: 14px;
	font-weight: 500;
	transition: background-color 0.2s ease;
	-webkit-tap-highlight-color: transparent;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	outline: none;
}

.profile-dropdown-item:hover {
	background-color: #f5f5f5;
	color: var(--mainColor, #333);
}

.profile-dropdown-item svg {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
}

.profile-dropdown-item:not(:last-child) {
	border-bottom: 1px solid #eee;
}

/* Adjust profile dropdown for user-nav state */
#profile-dropdown-container.user-nav {
	margin-top: 32px;
}

/* Mobile adjustments */
@media (max-width: 800px) {
	#profile-dropdown-container {
		top: 20px;
		right: 20px;
	}

	#profile-button {
		width: 35px;
		height: 35px;
	}

	#profile-button svg {
		width: 20px;
		height: 20px;
	}

	.profile-dropdown-menu {
		min-width: 160px;
	}

	.profile-dropdown-item {
		padding: 10px 14px;
		font-size: 13px;
	}
}