/**
 * Mobile Navigation Optimizations - Issue #55
 * VR-Infotainment Ticketshop
 * 
 * Features:
 * - Animated hamburger icon (→ X transformation)
 * - Full-screen overlay menu
 * - 48px minimum touch targets
 * - Premium "Tickets sichern" button
 * - Enhanced active state highlighting
 * - Smooth animations
 */

/* ========================================
   HAMBURGER ICON - ANIMATED (→ X)
   ======================================== */

#mobile-menu-button {
    /* Minimum 44x44px touch target (WCAG recommendation) */
    min-width: 48px;
    min-height: 48px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    z-index: 9999;
    -webkit-tap-highlight-color: transparent;
}

#mobile-menu-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

#mobile-menu-button:active {
    transform: scale(0.95);
}

/* Icon inside button */
#mobile-menu-button svg,
#mobile-menu-button [data-lucide] {
    width: 26px;
    height: 26px;
    transition: transform 0.3s ease;
}

/* Icon rotation when menu is open */
#mobile-menu-button[aria-expanded="true"] svg {
    transform: rotate(90deg);
}

/* ========================================
   FULL-SCREEN OVERLAY MOBILE MENU
   ======================================== */

@media (max-width: 768px) {
    #mobile-menu {
        /* Full-screen overlay positioning */
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        z-index: 9500;
        
        /* Background with blur */
        background: linear-gradient(
            180deg,
            rgba(4, 6, 15, 0.98) 0%,
            rgba(12, 17, 35, 0.98) 50%,
            rgba(8, 12, 28, 0.98) 100%
        );
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        
        /* Flexbox for centered content */
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 6rem 2rem 4rem;
        gap: 0.75rem;
        
        /* Hidden state */
        opacity: 0;
        visibility: hidden;
        transform: translateY(-100%);
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        
        /* Ensure full coverage */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Open state */
    #mobile-menu.is-open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    /* Menu close button (X) - positioned in top right */
    #mobile-menu::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 100px;
        background: linear-gradient(
            to bottom,
            rgba(4, 6, 15, 1) 0%,
            rgba(4, 6, 15, 0) 100%
        );
        pointer-events: none;
        z-index: 1;
    }

    /* ========================================
       MENU ITEMS - LARGE TOUCH TARGETS
       ======================================== */

    #mobile-menu > a,
    #mobile-menu > .nav-accordion,
    #mobile-menu > details {
        width: 100%;
        max-width: 320px;
    }

    /* Regular menu links */
    #mobile-menu > a:not([class*="bg-"]) {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 56px;
        padding: 16px 24px;
        font-size: 1.2rem;
        font-weight: 600;
        color: #e2e8f0;
        text-decoration: none;
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.06);
        transition: all 0.25s ease;
        position: relative;
        overflow: hidden;
    }

    #mobile-menu > a:not([class*="bg-"]):hover,
    #mobile-menu > a:not([class*="bg-"]):focus {
        background: rgba(59, 130, 246, 0.15);
        border-color: rgba(59, 130, 246, 0.3);
        color: #fff;
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
    }

    #mobile-menu > a:not([class*="bg-"]):active {
        transform: scale(0.98) translateY(0);
    }

    /* Active state highlighting */
    #mobile-menu > a.nav-link-active,
    #mobile-menu > a[aria-current] {
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(6, 182, 212, 0.15));
        border-color: rgba(59, 130, 246, 0.4);
        color: #fff;
    }

    #mobile-menu > a.nav-link-active::before,
    #mobile-menu > a[aria-current]::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 4px;
        background: linear-gradient(to bottom, #3b82f6, #06b6d4);
        border-radius: 4px 0 0 4px;
    }

    /* ========================================
       ACCORDION/DROPDOWN FOR SUBMENU
       ======================================== */

    #mobile-menu .nav-accordion,
    #mobile-menu details {
        width: 100%;
        max-width: 320px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 16px;
        overflow: hidden;
        transition: all 0.25s ease;
    }

    #mobile-menu .nav-accordion:hover,
    #mobile-menu details:hover {
        background: rgba(255, 255, 255, 0.05);
    }

    #mobile-menu .nav-accordion summary,
    #mobile-menu details summary {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        min-height: 56px;
        padding: 16px 24px;
        font-size: 1.2rem;
        font-weight: 600;
        color: #e2e8f0;
        cursor: pointer;
        list-style: none;
        transition: all 0.2s ease;
    }

    #mobile-menu .nav-accordion summary::-webkit-details-marker,
    #mobile-menu details summary::-webkit-details-marker {
        display: none;
    }

    #mobile-menu .nav-accordion summary:hover,
    #mobile-menu details summary:hover {
        color: #fff;
    }

    /* Chevron icon */
    #mobile-menu .nav-accordion summary i,
    #mobile-menu .nav-accordion summary svg,
    #mobile-menu details summary i,
    #mobile-menu details summary svg {
        transition: transform 0.3s ease;
    }

    #mobile-menu .nav-accordion[open] summary i,
    #mobile-menu .nav-accordion[open] summary svg,
    #mobile-menu details[open] summary i,
    #mobile-menu details[open] summary svg {
        transform: rotate(180deg);
    }

    /* Submenu items */
    #mobile-menu .nav-accordion > div,
    #mobile-menu details > div {
        padding: 0 16px 16px;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    #mobile-menu .nav-accordion > div a,
    #mobile-menu details > div a {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 48px;
        padding: 12px 20px;
        font-size: 1.05rem;
        color: #cbd5e1;
        text-decoration: none;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.03);
        transition: all 0.2s ease;
    }

    #mobile-menu .nav-accordion > div a:hover,
    #mobile-menu details > div a:hover {
        background: rgba(59, 130, 246, 0.15);
        color: #fff;
    }

    /* ========================================
       PREMIUM "TICKETS SICHERN" BUTTON
       ======================================== */

    #mobile-menu > a[href*="tickets"]:last-of-type,
    #mobile-menu > a.mobile-cta-button {
        min-height: 64px;
        padding: 18px 32px;
        margin-top: 1.5rem;
        font-size: 1.3rem;
        font-weight: 700;
        text-transform: none;
        letter-spacing: 0.02em;
        
        /* Premium gradient background */
        background: linear-gradient(
            135deg,
            #2563eb 0%,
            #3b82f6 40%,
            #0ea5e9 100%
        ) !important;
        border: none !important;
        border-radius: 20px !important;
        color: #fff !important;
        
        /* Glow effect */
        box-shadow: 
            0 0 0 0 rgba(59, 130, 246, 0.5),
            0 8px 32px rgba(59, 130, 246, 0.4),
            0 16px 48px rgba(37, 99, 235, 0.25),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
        
        /* Animation */
        animation: ctaGlow 3s ease-in-out infinite;
        position: relative;
        overflow: hidden;
    }

    /* Shine effect */
    #mobile-menu > a[href*="tickets"]:last-of-type::after,
    #mobile-menu > a.mobile-cta-button::after {
        content: '';
        position: absolute;
        top: -50%;
        left: -100%;
        width: 50%;
        height: 200%;
        background: linear-gradient(
            90deg,
            transparent,
            rgba(255, 255, 255, 0.2),
            transparent
        );
        transform: rotate(25deg);
        animation: ctaShine 4s ease-in-out infinite;
    }

    #mobile-menu > a[href*="tickets"]:last-of-type:hover,
    #mobile-menu > a.mobile-cta-button:hover {
        transform: translateY(-4px) scale(1.02) !important;
        box-shadow: 
            0 0 0 4px rgba(59, 130, 246, 0.3),
            0 12px 40px rgba(59, 130, 246, 0.5),
            0 20px 60px rgba(37, 99, 235, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
    }

    #mobile-menu > a[href*="tickets"]:last-of-type:active,
    #mobile-menu > a.mobile-cta-button:active {
        transform: translateY(-2px) scale(0.98) !important;
    }

    /* CTA glow animation */
    @keyframes ctaGlow {
        0%, 100% {
            box-shadow: 
                0 0 0 0 rgba(59, 130, 246, 0.5),
                0 8px 32px rgba(59, 130, 246, 0.4),
                0 16px 48px rgba(37, 99, 235, 0.25),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
        }
        50% {
            box-shadow: 
                0 0 20px 2px rgba(59, 130, 246, 0.6),
                0 12px 40px rgba(59, 130, 246, 0.5),
                0 20px 56px rgba(37, 99, 235, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
        }
    }

    /* Shine sweep animation */
    @keyframes ctaShine {
        0% {
            left: -100%;
        }
        20%, 100% {
            left: 150%;
        }
    }
}

/* ========================================
   BACKDROP (separate from menu overlay)
   ======================================== */

.mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 9400;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   BODY SCROLL LOCK WHEN MENU OPEN
   ======================================== */

body.mobile-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ========================================
   HEADER Z-INDEX FIX (ensure above menu)
   ======================================== */

@media (max-width: 768px) {
    #header,
    .site-header {
        z-index: 9999 !important;
    }

    /* Keep hamburger button clickable when menu is open */
    #mobile-menu-button {
        z-index: 10000 !important;
        position: relative;
    }
}

/* ========================================
   TABLET OPTIMIZATIONS
   ======================================== */

@media (min-width: 481px) and (max-width: 768px) {
    #mobile-menu > a:not([class*="bg-"]),
    #mobile-menu .nav-accordion summary,
    #mobile-menu details summary {
        font-size: 1.35rem;
        min-height: 64px;
    }

    #mobile-menu > a[href*="tickets"]:last-of-type,
    #mobile-menu > a.mobile-cta-button {
        font-size: 1.4rem;
        min-height: 72px;
    }
}

/* ========================================
   LANDSCAPE MODE ADJUSTMENTS
   ======================================== */

@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    #mobile-menu {
        padding: 4rem 2rem 2rem;
        justify-content: flex-start;
        gap: 0.5rem;
    }

    #mobile-menu > a:not([class*="bg-"]),
    #mobile-menu .nav-accordion summary,
    #mobile-menu details summary {
        min-height: 44px;
        font-size: 1rem;
    }

    #mobile-menu > a[href*="tickets"]:last-of-type,
    #mobile-menu > a.mobile-cta-button {
        min-height: 52px;
        font-size: 1.1rem;
        margin-top: 0.75rem;
    }
}

/* ========================================
   REDUCED MOTION PREFERENCE
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    #mobile-menu {
        transition: opacity 0.15s ease;
        transform: none !important;
    }

    #mobile-menu > a[href*="tickets"]:last-of-type::after,
    #mobile-menu > a.mobile-cta-button::after {
        animation: none !important;
    }

    #mobile-menu > a[href*="tickets"]:last-of-type,
    #mobile-menu > a.mobile-cta-button {
        animation: none !important;
    }
}

/* ========================================
   HIGH CONTRAST MODE
   ======================================== */

@media (prefers-contrast: high) {
    #mobile-menu > a:not([class*="bg-"]) {
        border-width: 2px;
        border-color: rgba(255, 255, 255, 0.3);
    }

    #mobile-menu > a.nav-link-active,
    #mobile-menu > a[aria-current] {
        border-width: 2px;
        border-color: #3b82f6;
    }
}

/* ========================================
   FOCUS STATES FOR KEYBOARD NAVIGATION
   ======================================== */

#mobile-menu > a:focus-visible,
#mobile-menu .nav-accordion summary:focus-visible,
#mobile-menu details summary:focus-visible,
#mobile-menu .nav-accordion > div a:focus-visible,
#mobile-menu details > div a:focus-visible {
    outline: 3px solid rgba(6, 182, 212, 0.8);
    outline-offset: 2px;
    background: rgba(6, 182, 212, 0.1);
}

#mobile-menu-button:focus-visible {
    outline: 3px solid rgba(6, 182, 212, 0.8);
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.1);
}
