/**
 * Gaming-Style Hamburger Navigation Menu
 * Designed for Aura Online
 */

/* Header and Navigation Container */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(135deg, 
        rgba(0, 0, 0, 0.95) 0%, 
        rgba(20, 20, 40, 0.95) 50%, 
        rgba(0, 0, 0, 0.95) 100%);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid #444;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.8);
    height: 60px;
    padding: 0 20px;
}

#main-menu {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Game-style Hamburger Menu Button */
.menu-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    border: 2px solid #555;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    font-family: 'Orbitron', monospace, sans-serif;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    min-width: 60px;
    height: 50px;
}

.menu-toggle:hover {
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
    border-color: #777;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.menu-toggle:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.menu-icon {
    display: flex;
    flex-direction: column;
    width: 20px;
    height: 12px;
    margin-bottom: 4px;
    position: relative;
}

.menu-line {
    width: 100%;
    height: 2px;
    background: #fff;
    margin: 1px 0;
    transition: all 0.3s ease;
    border-radius: 1px;
}

.menu-toggle.active .menu-line:nth-child(1) {
    transform: rotate(45deg) translate(3px, 3px);
}

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

.menu-toggle.active .menu-line:nth-child(3) {
    transform: rotate(-45deg) translate(3px, -3px);
}

.menu-text {
    color: #ccc;
    font-size: 9px;
}

/* Game Logo/Title */
.game-title {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-link {
    text-decoration: none;
}

.game-logo {
    height: 40px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
    transition: transform 0.3s ease;
}

.game-logo:hover {
    transform: scale(1.05);
}

/* User Info Display */
.user-info {
    display: flex;
    align-items: center;
    color: #fff;
    font-family: 'Orbitron', monospace, sans-serif;
    font-size: 12px;
}

.character-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

.character-name {
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    margin-bottom: 2px;
}

.gold-count {
    display: flex;
    align-items: center;
    color: #ffcc00;
    font-size: 11px;
    font-weight: bold;
}

.gold-icon {
    width: 14px;
    height: 14px;
    margin-left: 4px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.user-welcome {
    color: #ccc;
    font-size: 11px;
}

/* Navigation Overlay */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Navigation Menu Panel */
.nav-menu {
    position: fixed;
    top: 0;
    left: -350px;
    width: 320px;
    height: 100%;
    background: linear-gradient(180deg, 
        rgba(10, 10, 30, 0.98) 0%, 
        rgba(5, 5, 15, 0.98) 100%);
    backdrop-filter: blur(15px);
    border-right: 3px solid #444;
    box-shadow: 5px 0 30px rgba(0, 0, 0, 0.8);
    z-index: 1002;
    transition: left 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow-y: auto;
    padding-top: 70px;
}

.nav-menu.active {
    left: 0;
}

/* Navigation Header */
.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #333;
    background: linear-gradient(135deg, rgba(20, 20, 40, 0.8), rgba(10, 10, 20, 0.8));
}

.nav-title {
    color: #ffd700;
    font-family: 'Orbitron', monospace, sans-serif;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    margin: 0;
}

.nav-close {
    background: none;
    border: 2px solid #666;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-close:hover {
    border-color: #ffd700;
    color: #ffd700;
    transform: rotate(90deg);
}

/* Main Menu Items */
.main-menu-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.main-menu-items li {
    margin: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #ccc;
    text-decoration: none;
    font-family: 'Orbitron', monospace, sans-serif;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.nav-link:hover {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.1), transparent);
    color: #ffd700;
    border-left-color: #ffd700;
    transform: translateX(5px);
}

.nav-link:active {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.2), transparent);
}

.nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    min-width: 20px;
    text-align: center;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
    object-fit: contain;
    vertical-align: middle;
}

/* Navigation Dividers */
.nav-divider {
    color: #666;
    font-family: 'Orbitron', monospace, sans-serif;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 15px 20px 8px;
    border-top: 1px solid #333;
    margin-top: 10px;
    text-transform: uppercase;
}

.nav-divider:first-child {
    border-top: none;
    margin-top: 0;
}

/* Navigation Sections */
.nav-section {
    margin-top: 20px;
    border-top: 2px solid #333;
    padding-top: 15px;
}

.nav-section-title {
    color: #888;
    font-family: 'Orbitron', monospace, sans-serif;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 0 20px 10px;
    margin: 0;
    text-transform: uppercase;
}

.nav-section-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Special Logout Button */
.nav-logout {
    color: #ff6b6b !important;
}

.nav-logout:hover {
    background: linear-gradient(90deg, rgba(255, 107, 107, 0.1), transparent) !important;
    color: #ff8888 !important;
    border-left-color: #ff6b6b !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        padding: 0 15px;
        height: 55px;
    }
    
    .menu-toggle {
        min-width: 50px;
        height: 45px;
        padding: 6px 10px;
    }
    
    .game-logo {
        height: 35px;
    }
    
    .nav-menu {
        width: 280px;
        left: -300px;
    }
    
    .user-info {
        font-size: 11px;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .character-name {
        font-size: 11px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .gold-count {
        font-size: 10px;
    }
    
    .nav-link {
        padding: 14px 20px; /* Larger touch target */
    }
    
    /* Adjust icon sizes for better visibility on small screens */
    .nav-icon {
        width: 22px;
        height: 22px;
    }
}

/* Tablet Portrait */
@media (max-width: 600px) {
    .game-title {
        max-width: 150px;
    }
    
    .game-logo {
        height: 30px;
    }
    
    .user-info {
        max-width: 100px;
    }
    
    /* Stack menu items more compactly */
    .nav-link {
        padding: 12px 16px;
    }
    
    .nav-divider {
        padding: 12px 16px 6px;
    }
}

/* Mobile Landscape */
@media (max-width: 480px) {
    .nav-menu {
        width: 85%;
        left: -90%;
    }
    
    .user-info {
        display: none;
    }
    
    .menu-toggle {
        min-width: 45px;
        height: 40px;
    }
    
    .menu-text {
        font-size: 8px;
    }
    
    .nav-header {
        padding: 15px;
    }
    
    .nav-title {
        font-size: 14px;
    }
    
    /* Optimize for touch */
    .nav-link {
        padding: 16px; /* Even larger touch targets */
    }
    
    .nav-section-title {
        padding: 0 16px 8px;
    }
}

/* Mobile Portrait */
@media (max-width: 360px) {
    header {
        height: 50px;
        padding: 0 10px;
    }
    
    .menu-toggle {
        min-width: 40px;
        height: 36px;
    }
    
    .game-logo {
        height: 25px;
    }
    
    .nav-menu {
        width: 100%;
        left: -100%;
    }
    
    /* Further optimize for small screens */
    .nav-link {
        font-size: 12px;
    }
    
    .nav-icon {
        width: 18px;
        height: 18px;
        margin-right: 10px;
    }
    
    .nav-divider {
        font-size: 9px;
    }
}

/* Handle device orientation */
@media (max-height: 500px) and (orientation: landscape) {
    /* Optimize header for landscape */
    header {
        height: 45px;
    }
    
    .menu-toggle {
        height: 35px;
        min-width: 45px;
    }
    
    .game-logo {
        height: 30px;
    }
    
    /* Adjust menu for landscape view */
    .nav-menu {
        padding-top: 50px;
        display: flex;
        flex-direction: row;
        width: 100%;
        max-width: 100%;
        left: -100%;
    }
    
    .nav-header {
        padding: 8px 12px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1;
        height: 40px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    
    /* Create two-column layout for landscape */
    .main-menu-items {
        width: 50%;
        overflow-y: auto;
        max-height: calc(100vh - 50px);
        border-right: 1px solid #333;
        padding-bottom: 50px; /* Add padding at bottom for better scrolling */
    }
    
    .nav-section {
        width: 50%;
        overflow-y: auto;
        max-height: calc(100vh - 50px);
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        padding-bottom: 50px;
    }
    
    /* Compact menu items */
    .nav-link {
        padding: 8px 14px;
    }
    
    .nav-divider {
        padding: 6px 14px 3px;
        margin-top: 4px;
    }
    
    /* Make scrolling smooth */
    .nav-menu {
        overflow-y: hidden; /* Hide outer scrollbar */
        -webkit-overflow-scrolling: touch;
    }
    
    .main-menu-items,
    .nav-section-items {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    
    /* Optimize scrollbars for touch */
    .main-menu-items::-webkit-scrollbar,
    .nav-section-items::-webkit-scrollbar {
        width: 4px;
    }
    
    .main-menu-items::-webkit-scrollbar-thumb,
    .nav-section-items::-webkit-scrollbar-thumb {
        background-color: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
    }
    
    /* Adjust icons for landscape */
    .nav-icon {
        width: 18px;
        height: 18px;
        margin-right: 8px;
    }
    
    /* Optimize section titles */
    .nav-section-title {
        padding: 8px 14px 4px;
        position: sticky;
        top: 0;
        background: rgba(10, 10, 30, 0.95);
        z-index: 1;
    }
    
    /* Adjust body padding for smaller header */
    body {
        padding-top: 45px;
    }
}

/* iPhone SE and other small devices in landscape */
@media (max-height: 380px) and (orientation: landscape) {
    .nav-link {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .nav-icon {
        width: 16px;
        height: 16px;
        margin-right: 6px;
    }
    
    .nav-divider {
        padding: 4px 12px 2px;
        font-size: 8px;
    }
    
    .nav-section-title {
        padding: 6px 12px 3px;
        font-size: 10px;
    }
    
    .nav-header {
        height: 35px;
    }
    
    .nav-menu {
        padding-top: 40px;
    }
    
    .main-menu-items,
    .nav-section-items {
        max-height: calc(100vh - 40px);
    }
    
    .nav-title {
        font-size: 12px;
    }
    
    .nav-close {
        width: 30px;
        height: 30px;
    }
}

/* Animation for menu items */
.nav-menu.active .nav-link {
    animation: slideInFromLeft 0.6s ease forwards;
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Stagger animation for menu items */
.nav-menu.active .nav-link:nth-child(1) { animation-delay: 0.1s; }
.nav-menu.active .nav-link:nth-child(2) { animation-delay: 0.15s; }
.nav-menu.active .nav-link:nth-child(3) { animation-delay: 0.2s; }
.nav-menu.active .nav-link:nth-child(4) { animation-delay: 0.25s; }
.nav-menu.active .nav-link:nth-child(5) { animation-delay: 0.3s; }
.nav-menu.active .nav-link:nth-child(6) { animation-delay: 0.35s; }
.nav-menu.active .nav-link:nth-child(7) { animation-delay: 0.4s; }
.nav-menu.active .nav-link:nth-child(8) { animation-delay: 0.45s; }

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .nav-menu,
    .nav-overlay,
    .nav-link,
    .menu-toggle,
    .nav-close {
        transition-duration: 0.1s !important;
    }
    
    .nav-menu.active .nav-link {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Class for JS-detected low-end devices */
.reduced-motion .nav-menu,
.reduced-motion .nav-overlay,
.reduced-motion .nav-link,
.reduced-motion .menu-toggle,
.reduced-motion .nav-close {
    transition-duration: 0.1s !important;
}

.reduced-motion .nav-menu.active .nav-link {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}

/* Device-specific behaviors */

/* iOS specific styles */
@supports (-webkit-touch-callout: none) {
    /* iOS-specific fixes for overscroll behavior */
    .nav-menu {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix for iOS input focus issues */
    .nav-menu input,
    .nav-menu button {
        -webkit-appearance: none;
        border-radius: 0;
    }
    
    /* Fix for iOS sticky hover states */
    .nav-link:hover {
        transition: none;
    }
    
    /* Fix for iOS safe area */
    @supports (padding-top: env(safe-area-inset-top)) {
        .nav-menu {
            padding-top: calc(70px + env(safe-area-inset-top));
            padding-bottom: env(safe-area-inset-bottom);
        }
        
        .nav-header {
            padding-top: calc(15px + env(safe-area-inset-top));
        }
        
        @media (orientation: landscape) {
            .nav-menu {
                padding-left: env(safe-area-inset-left);
                padding-right: env(safe-area-inset-right);
            }
        }
    }
}

/* Android specific styles */
@supports not (-webkit-touch-callout: none) and (hover: none) {
    /* Android-specific fixes */
    .nav-link {
        /* Increase touch target */
        padding: 16px 20px;
    }
    
    /* Fix for Android ripple effect */
    .nav-link:active {
        background: rgba(255, 215, 0, 0.15);
    }
}

/* Desktop-specific enhancements */
@media (hover: hover) and (pointer: fine) {
    .nav-link:hover {
        transform: translateX(5px);
        background: linear-gradient(90deg, rgba(255, 215, 0, 0.1), transparent);
    }
    
    .menu-toggle:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
    }
    
    .nav-close:hover {
        transform: rotate(90deg);
    }
}

/* Body padding to account for fixed header */
body {
    padding-top: 60px;
}

@media (max-width: 768px) {
    body {
        padding-top: 55px;
    }
}
