/* ============================================================================
 * ORCRIST STICKY NAVIGATION
 * Apple iMac-Inspired Navigation System
 * ============================================================================
 *
 * Features:
 * - Backdrop blur with glass morphism effect
 * - Scroll-triggered appearance (hidden on page load)
 * - Animated section indicator that moves between menu items
 * - Animated hamburger menu icon
 * - Smooth scroll with offset
 * - Responsive design
 *
 * Research inspired by:
 * - Apple.com iMac page navigation
 * - Modern scroll-spy implementations
 * - Premium web design patterns (2025-2026)
 * ============================================================================ */

/* ========== NAVIGATION CONTAINER ========== */
.sticky-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;

    /* Hidden by default - appears on scroll */
    opacity: 0;
    transform: translateY(-100%);

    /* Smooth transitions */
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                background-color 0.3s ease,
                backdrop-filter 0.3s ease;

    /* Glass morphism effect */
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);

    /* Subtle shadow for depth */
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06),
                0 4px 16px rgba(0, 0, 0, 0.04);

    /* Ensure backdrop-filter works correctly */
    isolation: isolate;

    /* Prevent horizontal overflow */
    overflow-x: hidden;
    width: 100%;
}

/* Navigation visible state - triggered by JavaScript */
.sticky-nav.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Dark variant for dark sections */
.sticky-nav.dark-mode {
    background: rgba(45, 55, 72, 0.85);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08),
                0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ========== NAVIGATION INNER CONTAINER ========== */
.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(20px, 5vw, 48px);
    height: 60px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    position: relative;
    /* Proper z-index context */
    z-index: 1;

    /* Prevent overflow */
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* ========== HAMBURGER MENU ICON ========== */
.hamburger-menu {
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;

    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;

    transition: background-color 0.2s ease;
    position: relative;
    z-index: 10;
}

.hamburger-menu:hover {
    background: rgba(255, 107, 53, 0.1);
}

.hamburger-menu:active {
    transform: scale(0.95);
}

/* Hamburger lines */
.hamburger-line {
    width: 24px;
    height: 2px;
    background: var(--orcrist-navy, #2C4A62);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: center;
}

.dark-mode .hamburger-line {
    background: rgba(255, 255, 255, 0.9);
}

/* Animated hamburger states */
.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

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

/* ========== NAV LOGO ========== */
.nav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.nav-logo-icon {
    width: 32px;
    height: 32px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Targeting circles - mini version */
.nav-target-circle {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--orcrist-navy, #2C4A62);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.3s ease;
}

.dark-mode .nav-target-circle {
    border-color: rgba(255, 255, 255, 0.7);
}

.nav-target-circle:nth-child(1) {
    width: 6px;
    height: 6px;
    background: var(--orcrist-orange, #FF6B35);
    border-width: 1.5px;
}
.nav-target-circle:nth-child(2) { width: 12px; height: 12px; border-width: 1.5px; }
.nav-target-circle:nth-child(3) { width: 20px; height: 20px; border-width: 2px; }
.nav-target-circle:nth-child(4) { width: 28px; height: 28px; border-width: 2px; }

/* Frame corners - mini version */
.nav-frame-corner {
    position: absolute;
    width: 8px;
    height: 8px;
    border: 2px solid var(--orcrist-orange, #FF6B35);
    transition: transform 0.3s ease;
}

.nav-frame-corner.tl { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.nav-frame-corner.tr { top: -2px; right: -2px; border-left: none; border-bottom: none; }
.nav-frame-corner.bl { bottom: -2px; left: -2px; border-right: none; border-top: none; }
.nav-frame-corner.br { bottom: -2px; right: -2px; border-left: none; border-top: none; }

/* Logo hover animation */
.nav-logo:hover .nav-target-circle {
    transform: translate(-50%, -50%) scale(1.08);
}

.nav-logo:hover .nav-frame-corner {
    transform: scale(1.15);
}

/* Logo auto-animation - subtle pulse every 2 seconds (0.5s animation + 1.5s pause) */
@keyframes logoCirclePulse {
    0%, 75% {
        transform: translate(-50%, -50%) scale(1);
    }
    87.5% {
        transform: translate(-50%, -50%) scale(1.08);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes logoCornerPulse {
    0%, 75% {
        transform: scale(1);
    }
    87.5% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

.nav-logo-icon .nav-target-circle {
    animation: logoCirclePulse 2s ease-in-out infinite;
}

.nav-logo-icon .nav-frame-corner {
    animation: logoCornerPulse 2s ease-in-out infinite 0.05s;
}

/* Nav wordmark */
.nav-wordmark {
    font-family: 'Dune Rise', sans-serif;
    font-size: 20px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--orcrist-orange, #FF6B35);
    font-weight: 800;
}

.dark-mode .nav-wordmark {
    color: var(--orcrist-orange, #FF6B35);
}

/* ========== MOBILE SECTION TITLE ========== */

.nav-section-title-container {
    display: none;
    position: relative;
    overflow: hidden;
    height: 24px;
    min-width: 120px;
    max-width: 200px;
}

.nav-section-title {
    font-family: 'Dune Rise', sans-serif;
    font-size: 16px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--orcrist-orange, #FF6B35);
    font-weight: normal;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 300ms cubic-bezier(0.4, 0.0, 0.2, 1),
                transform 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
    will-change: transform, opacity;
}

.nav-section-title.animating-out {
    opacity: 0;
    transform: translateY(-20px);
}

.nav-section-title.animating-in {
    opacity: 0;
    transform: translateY(20px);
}

.nav-section-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.dark-mode .nav-section-title {
    color: var(--orcrist-orange, #FF6B35);
}

.nav-section-title.animation-complete {
    will-change: auto;
}

@media (min-width: 769px) {
    .nav-logo-desktop {
        display: flex;
    }
    .nav-section-title-container {
        display: none;
    }
}

@media (max-width: 768px) {
    .nav-logo-desktop {
        display: none;
    }
    .nav-section-title-container {
        /* Absolute positioning for perfect screen centering */
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        /* Prevent pointer events from blocking hamburger button */
        pointer-events: none;
        /* Ensure it stays within nav bounds */
        max-width: calc(100% - 120px); /* Leave space for hamburger on left and margin on right */
        /* Proper z-index to stay within nav layer */
        z-index: 1;
    }
    .nav-logo {
        /* Remove flex: 1 to prevent logo from expanding */
        justify-content: flex-start;
    }
    .nav-container {
        /* Ensure proper flex layout for mobile */
        justify-content: space-between;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-section-title {
        transition: opacity 150ms ease;
        transform: none !important;
    }
    .nav-section-title.animating-out,
    .nav-section-title.animating-in {
        transform: translateY(0) !important;
    }
}

@media (prefers-contrast: high) {
    .nav-section-title {
        text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
        font-weight: 600;
    }
}

/* ========== NAV LINKS ========== */
.nav-links {
    display: flex;
    align-items: center;
    gap: clamp(16px, 3vw, 40px);
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    justify-content: center;
    position: relative;
}

.nav-links li {
    margin: 0;
}

.nav-links a {
    display: block;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--orcrist-navy, #2C4A62);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    transition: color 0.2s ease,
                background-color 0.2s ease,
                transform 0.2s ease;
    position: relative;
    z-index: 2;
}

.dark-mode .nav-links a {
    color: rgba(255, 255, 255, 0.85);
}

.nav-links a:hover {
    color: var(--orcrist-orange, #FF6B35);
    background: rgba(255, 107, 53, 0.08);
    transform: translateY(-1px);
}

.dark-mode .nav-links a:hover {
    color: var(--orcrist-orange, #FF6B35);
    background: rgba(255, 107, 53, 0.15);
}

.nav-links a.active {
    color: var(--orcrist-orange, #FF6B35);
    font-weight: 600;
}

/* ========== ANIMATED SECTION INDICATOR ========== */
.nav-indicator {
    position: absolute;
    bottom: -10px;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg,
        var(--orcrist-orange, #FF6B35) 0%,
        #FF8554 100%);
    border-radius: 3px 3px 0 0;

    /* Initial hidden state */
    width: 0;
    opacity: 0;

    /* Smooth animated transitions */
    transition: left 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                width 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.3s ease;

    /* Subtle glow effect */
    box-shadow: 0 0 8px rgba(255, 107, 53, 0.4);

    /* Ensure it's always visible */
    z-index: 1;
    pointer-events: none;
}

.nav-indicator.visible {
    opacity: 1;
}

/* ========== RESPONSIVE DESIGN ========== */

/* Tablet and below */
@media (max-width: 1024px) {
    .nav-container {
        height: 56px;
        padding: 0 clamp(16px, 4vw, 32px);
    }

    .nav-links {
        gap: clamp(12px, 2.5vw, 24px);
    }

    .nav-links a {
        font-size: 13px;
        padding: 6px 10px;
    }

    .nav-wordmark {
        font-size: 18px;
    }
}

/* Mobile - nav-links hidden on mobile */
@media (max-width: 768px) {
    .nav-container {
        height: 52px;
    }

    /* nav-links hidden on mobile */
    .nav-links {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;

        /* Remove from layout */
        position: absolute !important;
        top: -9999px !important;
        left: -9999px !important;
    }

    .nav-indicator {
        display: none;
    }

    .hamburger-menu {
        /* Hamburger is always visible on mobile */
        display: flex;
        z-index: 9999;
    }

    .nav-logo {
        flex: 1;
        justify-content: center;
    }

    .nav-wordmark {
        font-size: 16px;
    }

    /* REMOVED: Dark mode mobile menu styles - nav-links doesn't open on mobile */
}

/* Small mobile phones (320px - 375px) */
@media (max-width: 375px) {
    .nav-container {
        height: 48px;
        padding: 0 16px;
    }

    .nav-wordmark {
        font-size: 14px;
    }

    .nav-logo-icon {
        width: 28px;
        height: 28px;
    }

    .hamburger-menu {
        width: 40px;
        height: 40px;
    }

    .hamburger-line {
        width: 20px;
    }

    .nav-links {
        top: 48px;
        padding: 1.5rem 0;
    }

    .nav-links a {
        padding: 1rem 1.5rem;
        font-size: 16px;
    }
}

/* Desktop - show hamburger for menu options */
@media (min-width: 769px) {
    .hamburger-menu {
        /* Show hamburger as placeholder for future mobile menu */
        display: flex;
    }

    /* Ensure desktop nav links are visible */
    .nav-links {
        display: flex;
        position: relative;
        opacity: 1;
        visibility: visible;
        transform: none;
    }
}

/* ========== ACCESSIBILITY ========== */

/* Focus states for keyboard navigation */
.hamburger-menu:focus-visible,
.nav-links a:focus-visible {
    outline: 2px solid var(--orcrist-orange, #FF6B35);
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .sticky-nav,
    .nav-links a,
    .hamburger-line,
    .nav-indicator,
    .nav-target-circle,
    .nav-frame-corner {
        transition: none;
    }

    .sticky-nav {
        transition: opacity 0.1s ease;
    }

    /* Disable auto-animation for reduced motion */
    .nav-logo-icon .nav-target-circle,
    .nav-logo-icon .nav-frame-corner {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .sticky-nav {
        background: rgba(255, 255, 255, 0.95);
        border-bottom: 2px solid currentColor;
    }

    .nav-links a {
        border: 1px solid transparent;
    }

    .nav-links a:hover,
    .nav-links a.active {
        border-color: currentColor;
    }
}

/* ========== PRINT STYLES ========== */
@media print {
    .sticky-nav {
        display: none;
    }
}

/* ========== PERFORMANCE OPTIMIZATIONS ========== */

/* GPU acceleration for smooth animations */
.sticky-nav,
.nav-indicator,
.hamburger-line {
    will-change: transform;
    transform: translateZ(0);
}

/* Remove will-change after animation completes */
.sticky-nav.animation-complete {
    will-change: auto;
}

/* ========== BROWSER COMPATIBILITY FALLBACKS ========== */

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(20px)) {
    .sticky-nav {
        background: rgba(255, 255, 255, 0.95);
    }

    .sticky-nav.dark-mode {
        background: rgba(45, 55, 72, 0.95);
    }
}

/* Safari-specific fixes */
@supports (-webkit-backdrop-filter: blur(20px)) {
    .sticky-nav {
        -webkit-backdrop-filter: saturate(180%) blur(20px);
    }
}

/* ========== UTILITY CLASSES ========== */

/* Force show nav (for testing/debugging) */
.sticky-nav.force-visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* Disable backdrop blur (performance mode) */
.sticky-nav.no-blur {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255, 255, 255, 0.95);
}

.sticky-nav.dark-mode.no-blur {
    background: rgba(45, 55, 72, 0.95);
}
