/* ==========================================================================
   LUNA LABS - Navigation
   Neo-Brutalist Dropdown Navbar with theme toggle
   ========================================================================== */

/* -----------------------------------------------------------------------------
   Navbar Container
   - Fixed positioning for sticky behavior while scrolling
   - Aligns with max-width container on wide screens
   ----------------------------------------------------------------------------- */
.nav-dropdown {
	position: fixed;
	top: 2rem;
	/* Align with 1400px max-width container: half of overflow + padding */
	right: max(2rem, calc((100vw - 1400px) / 2 + 2rem));
	z-index: 1000;
	opacity: 0;
	/* Initial state for GSAP animation */
}

/* -----------------------------------------------------------------------------
   Toggle Button
   - Borderless to match landing's floating aesthetic
   - Displays − (minus) when expanded, + (plus) when collapsed
   - Hover effect preserved with subtle background
   ----------------------------------------------------------------------------- */
.nav-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	background: transparent;
	border: none;
	cursor: pointer;
	transition: background 0.2s ease;
}

.nav-toggle:hover {
	background: var(--text);
}

.nav-toggle:hover .nav-toggle-icon {
	color: var(--background);
}

.nav-toggle-icon {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 5px;
	width: 20px;
	height: 20px;
}

.hamburger-line {
	display: block;
	width: 100%;
	height: 2px;
	background: var(--text);
	transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-toggle:hover .hamburger-line {
	background: var(--background);
}

/* Hamburger to X animation when expanded */
.nav-dropdown.expanded .hamburger-line:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}

.nav-dropdown.expanded .hamburger-line:nth-child(2) {
	opacity: 0;
}

.nav-dropdown.expanded .hamburger-line:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

.nav-toggle:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* -----------------------------------------------------------------------------
   Dropdown Menu
   - Borderless, floating appearance to match landing
   - Uses spacing instead of borders for separation
   - Smooth fade + slide animation preserved
   ----------------------------------------------------------------------------- */
.nav-menu {
	position: absolute;
	top: calc(100% + 0.5rem);
	right: 0;
	min-width: 140px;
	background: var(--background);
	border: none;
	overflow: visible;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-8px);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

/* Expanded state - menu visible */
.nav-dropdown.expanded .nav-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* -----------------------------------------------------------------------------
   Navigation Links List
   ----------------------------------------------------------------------------- */
.nav-links {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

/* -----------------------------------------------------------------------------
   Navigation Items & Links
   - Borderless, uses vertical spacing for separation
   - High-contrast hover/active states preserved
   - Typography matches landing (weight 400, airy spacing)
   ----------------------------------------------------------------------------- */
.nav-item {
	border: none;
}

.nav-item a {
	display: block;
	padding: 0.5rem 0.75rem;
	font-size: 0.875rem;
	font-weight: 400;
	letter-spacing: 0.02em;
	color: var(--text-muted);
	text-decoration: none;
	text-align: right;
	transition: background 0.2s ease, color 0.2s ease;
}

.nav-item a:hover {
	background: var(--text);
	color: var(--background);
}

.nav-item a:active {
	background: var(--accent);
	color: var(--background);
}

.nav-item a:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
	background: transparent;
}

/* Nav Contact with email tooltip */
.nav-contact {
	position: relative;
	text-shadow: none !important; /* Disable Doppler effect */
}

.nav-contact::after {
	content: attr(data-email);
	position: absolute;
	right: 100%;
	top: 50%;
	transform: translateY(-50%) translateX(-0.5rem);
	padding: 0.25rem 0.5rem;
	font-family: monospace;
	font-size: 0.625rem;
	font-weight: 400;
	letter-spacing: 0.02em;
	color: var(--text-muted);
	background: var(--background);
	border: 1px solid var(--text-muted);
	white-space: nowrap;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.nav-contact:hover::after {
	opacity: 1;
	visibility: visible;
	transform: translateY(-50%) translateX(-0.75rem);
}

/* -----------------------------------------------------------------------------
   Theme Toggle Container
   - Borderless, minimal appearance
   - Sun/Moon icons instead of text labels
   ----------------------------------------------------------------------------- */
.theme-toggle-container {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.625rem;
	padding: 0.75rem 0.75rem;
	margin-top: 0.5rem;
	background: transparent;
}

/* Theme Icons (Sun & Moon) */
.theme-icon {
	color: var(--text-muted);
	transition: color 0.2s ease, opacity 0.2s ease;
	opacity: 0.5;
}

/* Highlight active theme icon */
[data-theme="light"] .theme-icon-sun,
:root:not([data-theme="dark"]) .theme-icon-sun {
	color: var(--text);
	opacity: 1;
}

[data-theme="dark"] .theme-icon-moon {
	color: var(--text);
	opacity: 1;
}

/* -----------------------------------------------------------------------------
   Theme Switch (Slider Toggle)
   - Minimal borderless design
   - Knob-only visual, track is subtle
   ----------------------------------------------------------------------------- */
.theme-switch {
	position: relative;
	display: inline-block;
	width: 32px;
	height: 18px;
}

.theme-switch input {
	opacity: 0;
	width: 0;
	height: 0;
}

.theme-slider {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: transparent;
	border: 1px solid var(--text-muted);
	transition: border-color 0.2s ease, background 0.2s ease;
}

/* Slider knob */
.theme-slider::before {
	position: absolute;
	content: "";
	height: 10px;
	width: 10px;
	left: 3px;
	bottom: 3px;
	background: var(--text-muted);
	transition: transform 0.2s ease, background 0.2s ease;
}

/* Checked state - knob moves right (dark mode) */
.theme-switch input:checked+.theme-slider::before {
	transform: translateX(14px);
}

/* Hover state */
.theme-slider:hover {
	background: var(--text);
	border-color: var(--text);
}

.theme-slider:hover::before {
	background: var(--background);
}

/* Focus state for accessibility */
.theme-switch input:focus-visible+.theme-slider {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* ==========================================================================
   RESPONSIVE - Navigation
   ========================================================================== */

/* Tablet (max-width: 768px) */
@media (max-width: 768px) {
	.nav-dropdown {
		top: 1.5rem;
		right: 1.5rem;
	}

	.nav-toggle {
		width: 36px;
		height: 36px;
	}

	.nav-toggle-icon {
		width: 18px;
		height: 18px;
		gap: 4px;
	}

	.hamburger-line {
		height: 2px;
	}

	/* Adjust animation offset for smaller size */
	.nav-dropdown.expanded .hamburger-line:nth-child(1) {
		transform: translateY(6px) rotate(45deg);
	}

	.nav-dropdown.expanded .hamburger-line:nth-child(3) {
		transform: translateY(-6px) rotate(-45deg);
	}

	.nav-item a {
		font-size: 0.8rem;
	}

	.theme-icon {
		width: 14px;
		height: 14px;
	}
}

/* Mobile (max-width: 480px) */
@media (max-width: 480px) {
	.nav-dropdown {
		top: 1rem;
		right: 1.25rem;
	}

	/* Increased touch targets for mobile (44px minimum recommended) */
	.nav-toggle {
		width: 44px;
		height: 44px;
	}

	.nav-toggle-icon {
		width: 18px;
		height: 18px;
		gap: 4px;
	}

	.hamburger-line {
		height: 2px;
	}

	.nav-item a {
		font-size: 0.75rem;
		padding: 0.4rem 0.625rem;
	}

	.theme-icon {
		width: 14px;
		height: 14px;
	}

	/* Larger touch target for theme switch on mobile */
	.theme-switch {
		width: 44px;
		height: 24px;
	}

	.theme-slider::before {
		height: 16px;
		width: 16px;
		left: 3px;
		bottom: 3px;
	}

	.theme-switch input:checked+.theme-slider::before {
		transform: translateX(20px);
	}

	/* Show email directly on mobile instead of hover */
	.nav-contact[data-email]::after {
		position: static;
		display: block;
		transform: none !important;
		opacity: 0.7 !important;
		visibility: visible !important;
		margin-top: 0.25rem;
		padding: 0;
		border: none;
		background: none;
		font-size: 0.7rem;
	}

	.nav-contact[data-email]:hover::after {
		transform: none !important;
		opacity: 0.7 !important;
	}
}

/* Small Mobile (max-width: 360px) */
@media (max-width: 360px) {
	.nav-dropdown {
		top: 0.75rem;
		right: 1rem;
	}

	/* Keep 44px touch target even on small screens */
	.nav-toggle {
		width: 44px;
		height: 44px;
	}

	.nav-toggle-icon {
		width: 20px;
		height: 20px;
		gap: 5px;
	}

	.hamburger-line {
		height: 2px;
	}

	.nav-item a {
		font-size: 0.8rem;
		padding: 0.5rem 0.75rem;
		/* Minimum 44px touch height */
		min-height: 44px;
		display: flex;
		flex-direction: column;
		align-items: flex-end;
		justify-content: center;
	}

	.theme-icon {
		width: 14px;
		height: 14px;
	}

	/* Keep accessible switch size */
	.theme-switch {
		width: 44px;
		height: 24px;
	}

	.theme-slider::before {
		height: 16px;
		width: 16px;
		left: 3px;
		bottom: 3px;
	}

	.theme-switch input:checked+.theme-slider::before {
		transform: translateX(20px);
	}
}

/* ==========================================================================
   TOUCH DEVICE SUPPORT
   Show email tooltip on all touch devices (not just mobile widths)
   ========================================================================== */
@media (hover: none) {
	.nav-contact[data-email]::after {
		position: static;
		display: block;
		transform: none !important;
		opacity: 0.7 !important;
		visibility: visible !important;
		margin-top: 0.25rem;
		padding: 0;
		border: none;
		background: none;
		font-size: 0.7rem;
		text-align: right;
	}

	.nav-contact[data-email]:hover::after {
		transform: none !important;
		opacity: 0.7 !important;
	}
}
