/* 移动端导航菜单样式 */

/* 确保移动端菜单按钮在小屏幕上可见 */
@media (max-width: 767px) {
    #menu-toggle {
        display: block !important;
        z-index: 60;
        position: relative;
    }
    
    /* 移动端菜单容器 */
    #mobile-menu {
        position: relative;
        z-index: 50;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
        opacity: 0;
    }
    
    /* 菜单打开状态 */
    #mobile-menu:not(.hidden) {
        max-height: 100vh;
        opacity: 1;
    }
    
    /* 菜单项动画 */
    #mobile-menu a {
        transform: translateX(-20px);
        opacity: 0;
        transition: all 0.3s ease-in-out;
    }
    
    #mobile-menu:not(.hidden) a {
        transform: translateX(0);
        opacity: 1;
    }
    
    /* 为每个菜单项添加延迟动画 */
    #mobile-menu a:nth-child(1) { transition-delay: 0.1s; }
    #mobile-menu a:nth-child(2) { transition-delay: 0.15s; }
    #mobile-menu a:nth-child(3) { transition-delay: 0.2s; }
    #mobile-menu a:nth-child(4) { transition-delay: 0.25s; }
    #mobile-menu a:nth-child(5) { transition-delay: 0.3s; }
    
    /* 防止菜单打开时页面滚动 */
    body.menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

/* 桌面端隐藏移动端菜单 */
@media (min-width: 768px) {
    #menu-toggle {
        display: none !important;
    }
    
    #mobile-menu {
        display: none !important;
    }
}

/* 菜单按钮动画 */
#menu-toggle i {
    transition: transform 0.3s ease-in-out;
}

#menu-toggle.active i {
    transform: rotate(90deg);
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    #mobile-menu a {
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    
    #menu-toggle {
        min-width: 48px;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    #mobile-menu {
        border: 2px solid currentColor;
    }
    
    #mobile-menu a:hover {
        background-color: rgba(255, 255, 255, 0.2) !important;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    #mobile-menu,
    #mobile-menu a,
    #menu-toggle i {
        transition: none !important;
        animation: none !important;
    }
}

/* 暗色模式优化 */
@media (prefers-color-scheme: dark) {
    #mobile-menu {
        background-color: rgba(17, 24, 39, 0.95);
        backdrop-filter: blur(12px);
    }
}

/* 小屏幕优化 */
@media (max-width: 480px) {
    #mobile-menu {
        left: 0;
        right: 0;
    }
    
    #mobile-menu .px-4 {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* 超小屏幕优化 */
@media (max-width: 320px) {
    #mobile-menu a {
        font-size: 0.9rem;
        padding: 0.75rem;
    }
    
    #menu-toggle {
        padding: 0.5rem;
    }
    
    #menu-toggle i {
        font-size: 1.25rem;
    }
}

/* 横屏模式优化 */
@media (max-height: 500px) and (orientation: landscape) {
    #mobile-menu {
        max-height: 80vh;
        overflow-y: auto;
    }
    
    #mobile-menu .space-y-2 > * + * {
        margin-top: 0.25rem;
    }
    
    #mobile-menu a {
        padding: 0.5rem 0.75rem;
    }
}

/* 确保菜单在所有设备上都能正确显示 */
#mobile-menu {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* iOS Safari 优化 */
@supports (-webkit-touch-callout: none) {
    #mobile-menu {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}

/* 确保菜单项可点击 */
#mobile-menu a {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    tap-highlight-color: rgba(0, 0, 0, 0.1);
}
