/**
 * Miles & Moon - Luxurious Mobile Navigation
 * Mystical, elegant navigation that embodies our sophisticated aesthetic
 */

/* Mobile navigation only shows on mobile */
.mobile-nav-trigger,
.mobile-nav-overlay {
    display: none;
}

/* Ensure mobile nav never shows on desktop */
@media (min-width: 769px) {
    .mobile-nav-trigger,
    .mobile-nav-overlay {
        display: none !important;
        visibility: hidden !important;
    }
}

@media (max-width: 768px) {
    
    /* Show mobile navigation elements */
    .mobile-nav-trigger {
        display: flex !important;
    }
    
    .mobile-nav-overlay {
        display: flex !important;
    }
    
    /* Hide desktop navigation on mobile */
    .site-nav {
        display: none;
    }
    
    .account-link {
        display: none;
    }
    
    /* Reduce body padding for mobile - header is much smaller */
    body {
        padding-top: 160px !important;
    }
    
    /* Give homepage hero extra top spacing to match other pages */
    .hero {
        margin-top: 20px !important;
    }
    
    /* Hide desktop navigation on mobile */
    .site-nav {
        display: none;
    }
    
    /* Keep original main content heights */
    
    /* Clean floating action button */
    .mobile-nav-trigger {
        display: flex !important;
        position: fixed !important;
        bottom: 75px !important;
        right: 20px !important;
        z-index: 9999 !important;
        width: 58px;
        height: 58px;
        border-radius: 50%;
        background: var(--color-light-cream);
        border: 1px solid var(--color-gold);
        cursor: pointer;
        align-items: center;
        justify-content: center;
        transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.3),
            0 0 0 1px rgba(154, 121, 41, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
        font-size: 20px;
        color: var(--color-charcoal);
        overflow: hidden;
        backdrop-filter: blur(10px);
    }
    
    .mobile-nav-trigger::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: radial-gradient(circle at 30% 30%, 
            rgba(154, 121, 41, 0.15) 0%, 
            transparent 50%);
        border-radius: 50%;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .mobile-nav-trigger:hover {
        transform: translateY(-4px);
        box-shadow: 
            0 12px 40px rgba(0, 0, 0, 0.4),
            0 0 0 1px var(--color-gold),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
        border-color: rgba(154, 121, 41, 0.8);
    }
    
    .mobile-nav-trigger:hover::before {
        opacity: 1;
    }
    
    .mobile-nav-trigger.active {
        background: transparent;
        background-image: url('/mobile-nav-button.svg');
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        color: var(--color-charcoal);
        transform: translateY(-4px) rotate(90deg);
        box-shadow: 
            0 12px 40px rgba(154, 121, 41, 0.5),
            0 0 0 1px rgba(154, 121, 41, 0.8),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
    
    /* Luxurious overlay with ethereal backdrop - mobile viewport aware */
    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        background: linear-gradient(135deg, 
            rgba(254, 253, 251, 0.97) 0%, 
            rgba(250, 249, 246, 0.98) 50%,
            rgba(254, 253, 251, 0.99) 100%);
        backdrop-filter: blur(20px) saturate(120%);
        -webkit-backdrop-filter: blur(20px) saturate(120%);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: safe center; /* Safe centering to avoid overflow */
        padding: 2rem 2rem 4rem 2rem; /* Extra bottom padding for mobile bars */
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    /* Mystical starfield background */
    .mobile-nav-overlay::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: 
            radial-gradient(1px 1px at 20% 30%, var(--color-gold), transparent),
            radial-gradient(1px 1px at 40% 70%, rgba(154, 121, 41, 0.6), transparent),
            radial-gradient(1px 1px at 90% 40%, rgba(154, 121, 41, 0.4), transparent),
            radial-gradient(1px 1px at 60% 10%, rgba(154, 121, 41, 0.3), transparent);
        background-size: 300px 300px, 200px 200px, 250px 250px, 180px 180px;
        animation: starsTwinkle 8s ease-in-out infinite;
        opacity: 0.3;
    }
    
    @keyframes starsTwinkle {
        0%, 100% { opacity: 0.3; transform: translateY(0); }
        50% { opacity: 0.6; transform: translateY(-10px); }
    }
    
    .mobile-nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Hide the redundant close button - trigger button handles this */
    .mobile-nav-close {
        display: none !important;
    }
    
    .mobile-nav-close:hover {
        background: rgba(154, 121, 41, 0.2);
        border-color: var(--color-gold);
        transform: rotate(90deg) scale(1.1);
        box-shadow: 0 4px 20px rgba(154, 121, 41, 0.3);
    }
    
    /* Mystical logo presentation */
    .mobile-nav-logo {
        width: 80px;
        height: auto;
        margin-bottom: 3rem;
        filter: 
            drop-shadow(0 4px 12px rgba(154, 121, 41, 0.4))
            drop-shadow(0 0 20px rgba(154, 121, 41, 0.2));
        animation: logoGlow 4s ease-in-out infinite alternate;
    }
    
    @keyframes logoGlow {
        0% { 
            filter: 
                drop-shadow(0 4px 12px rgba(154, 121, 41, 0.4))
                drop-shadow(0 0 20px rgba(154, 121, 41, 0.2));
        }
        100% { 
            filter: 
                drop-shadow(0 6px 16px rgba(154, 121, 41, 0.6))
                drop-shadow(0 0 30px rgba(154, 121, 41, 0.4));
        }
    }
    
    /* Navigation stars flanking Miles & Moon */
    .nav-star {
        width: 16px;
        height: auto;
        vertical-align: middle;
        filter: 
            drop-shadow(0 2px 6px rgba(154, 121, 41, 0.3))
            drop-shadow(0 0 10px rgba(154, 121, 41, 0.2));
        animation: starTwinkle 3s ease-in-out infinite alternate;
    }
    
    .nav-star-left {
        margin-right: 1rem;
    }
    
    .nav-star-right {
        margin-left: 1rem;
    }
    
    @keyframes starTwinkle {
        0% { 
            opacity: 0.7;
            filter: 
                drop-shadow(0 2px 6px rgba(154, 121, 41, 0.3))
                drop-shadow(0 0 10px rgba(154, 121, 41, 0.2));
        }
        100% { 
            opacity: 1;
            filter: 
                drop-shadow(0 3px 8px rgba(154, 121, 41, 0.5))
                drop-shadow(0 0 15px rgba(154, 121, 41, 0.4));
        }
    }

    /* Luxurious navigation structure */
    .mobile-nav-menu {
        width: 100%;
        max-width: 320px;
        text-align: center;
    }
    
    .nav-section {
        margin-bottom: 2.5rem;
    }
    
    .nav-divider {
        height: 1px;
        background: linear-gradient(90deg, 
            transparent 0%, 
            rgba(154, 121, 41, 0.3) 20%, 
            var(--color-gold) 45%, 
            transparent 45%, 
            transparent 55%, 
            var(--color-gold) 55%, 
            rgba(154, 121, 41, 0.3) 80%, 
            transparent 100%);
        margin: 2.5rem 0;
        opacity: 0.8;
        position: relative;
    }
    
    .nav-divider::before {
        content: '';
        position: absolute;
        top: -10px;
        left: 50%;
        transform: translateX(-50%);
        width: 20px;
        height: 20px;
        background-image: url('/star-gold.svg');
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        animation: starTwinkle 3s ease-in-out infinite alternate;
    }
    
    /* Sophisticated link styling */
    .mobile-nav-link {
        display: block;
        text-align: center;
        text-decoration: none;
        color: var(--color-charcoal);
        font-family: var(--font-sans);
        font-size: 0.9rem;
        font-weight: 300;
        letter-spacing: 0.15em;
        text-transform: uppercase;
        padding: 1.5rem 2.5rem;
        margin-bottom: 1rem;
        border-radius: 0;
        transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
        background: transparent;
        border: 1px solid transparent;
        position: relative;
        overflow: hidden;
    }
    
    .mobile-nav-link::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, 
            transparent, 
            rgba(154, 121, 41, 0.2), 
            transparent);
        transition: left 0.6s ease;
    }
    
    .mobile-nav-link:hover {
        color: var(--color-gold);
        background: rgba(154, 121, 41, 0.05);
        transform: none;
    }
    
    .mobile-nav-link:hover::before {
        left: 100%;
    }
    
    .mobile-nav-link.primary {
        background: var(--color-gold);
        color: var(--color-white);
        border: 1px solid var(--color-gold);
        font-weight: 400;
        font-family: var(--font-sans);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-nav-link.primary:hover {
        background: var(--color-charcoal);
        color: var(--color-white);
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }
    
    .mobile-nav-link.current {
        color: var(--color-gold);
        border-top: 1px solid rgba(154, 121, 41, 0.5);
        border-bottom: 1px solid rgba(154, 121, 41, 0.5);
        background: linear-gradient(90deg,
            transparent 0%,
            rgba(154, 121, 41, 0.1) 50%,
            transparent 100%);
        font-weight: 500;
        position: relative;
    }
    
    .mobile-nav-link.current::after {
        display: none;
    }
    
    @keyframes currentPageGlow {
        0% { opacity: 0.6; }
        100% { opacity: 1; }
    }
    
    .nav-label {
        font-size: 1rem;
        letter-spacing: 0.05em;
    }
    
    /* Mystical entrance animations */
    .mobile-nav-overlay.active .nav-section {
        animation: mysticalRise 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;
        opacity: 0;
        transform: translateY(40px);
    }
    
    .mobile-nav-overlay.active .primary-nav {
        animation-delay: 0.2s;
    }
    
    .mobile-nav-overlay.active .nav-divider {
        animation: dividerAppear 0.6s ease 0.5s forwards;
        opacity: 0;
        transform: scaleX(0);
    }
    
    .mobile-nav-overlay.active .secondary-nav {
        animation-delay: 0.7s;
    }
    
    @keyframes mysticalRise {
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    @keyframes dividerAppear {
        to {
            opacity: 0.8;
            transform: scaleX(1);
        }
    }
    
    /* Mystical footer signature */
    .mobile-nav-footer {
        position: absolute;
        bottom: 3rem;
        left: 50%;
        transform: translateX(-50%);
        text-align: center;
        color: rgba(154, 121, 41, 0.7);
        font-size: 0.8rem;
        font-style: italic;
        letter-spacing: 0.1em;
        font-family: var(--font-heading);
        z-index: 10;
    }
}

/* Small screens optimization */
@media (max-width: 480px) {
    .mobile-nav-trigger {
        bottom: 70px !important;
        right: 16px !important;
        width: 54px;
        height: 54px;
        font-size: 18px;
    }
    
    .mobile-nav-overlay {
        padding: 1.5rem;
    }
    
    .mobile-nav-logo {
        width: 70px;
        margin-bottom: 2.5rem;
    }
    
    .mobile-nav-link {
        font-size: 1.1rem;
        padding: 1.2rem 2rem;
    }
    
    .mobile-nav-menu {
        max-width: 280px;
    }
}

/* High contrast mode support - maintaining mystical aesthetic */
.high-contrast .mobile-nav-trigger {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
}

.high-contrast .mobile-nav-trigger.active {
    background: #000000 !important;
    color: #ffffff !important;
}

.high-contrast .mobile-nav-overlay {
    background: #ffffff !important;
    backdrop-filter: none !important;
}

.high-contrast .mobile-nav-overlay::before {
    display: none !important;
}

.high-contrast .mobile-nav-link {
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #000000 !important;
}

.high-contrast .mobile-nav-link:hover,
.high-contrast .mobile-nav-link.primary {
    background: #000000 !important;
    color: #ffffff !important;
    transform: none !important;
}

.high-contrast .mobile-nav-close {
    color: #000000 !important;
    background: #ffffff !important;
    border: 2px solid #000000 !important;
}

.high-contrast .nav-divider {
    background: #000000 !important;
}

.high-contrast .nav-divider::before {
    color: #000000 !important;
    background: #ffffff !important;
}