/* Japanese 50 Sounds - Mobile Navigation Styles */
/* 手機版導航欄樣式 - 漢堡選單 */

/* ==================== 漢堡選單按鈕 ==================== */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
}

.hamburger span {
    display: block;
    width: 25px;
    height: 3px;
    background: #FFFFFF;
    transition: all 0.3s ease;
    border-radius: 2px;
}

/* 漢堡按鈕動畫 - 變成 X */
.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* ==================== Tablet 響應式 ==================== */
@media (max-width: 1024px) {
    nav {
        padding: 0 4rem;
    }
}

/* ==================== Mobile 響應式 ==================== */
@media (max-width: 768px) {
    /* 導航列佈局 */
    nav {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 1rem 2rem;
    }

    /* 顯示漢堡按鈕 */
    .hamburger {
        display: flex;
    }

    /* Logo 樣式調整 */
    .logo {
        font-size: 1.1rem;
    }

    .logo span {
        font-size: 0.65rem;
    }

    /* 預設隱藏導航選單 */
    .nav-links {
        position: fixed;
        top: 80px;
        left: 0;
        right: 0;
        background: var(--accent-primary);
        flex-direction: column;
        align-items: center;
        padding: 2rem 1rem;
        gap: 1rem;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: all 0.3s ease;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        z-index: 999;
    }

    /* 顯示導航選單 */
    .nav-links.active {
        max-height: calc(100vh - 80px);
        opacity: 1;
        overflow-y: auto;
    }

    /* 選單項目樣式 */
    .nav-links li {
        width: 100%;
        text-align: center;
        padding: 0;
        margin: 0.5rem 0;  /* 增加垂直間距 */
    }

    /* 主導航連結（不包括下拉選單內的連結） */
    .nav-links > li > a,
    .nav-links .nav-right > li > a {
        padding: 1rem 1.5rem;  /* 增加內邊距 */
        font-size: 1.05rem;    /* 稍微增大字體 */
        display: block;
        width: 100%;
        border-radius: 8px;    /* 添加圓角 */
        transition: background 0.2s ease;
    }

    /* 主導航連結 hover 效果 */
    .nav-links > li > a:hover,
    .nav-links .nav-right > li > a:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    /* 右側導航項目 */
    .nav-right {
        margin-left: 0;
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }

    .nav-right > li {
        width: 100%;
    }

    /* Header 高度調整 */
    header {
        height: 80px;
    }

    /* 禁用 header hover 展開效果 */
    header:has(.dropdown:hover) {
        height: 80px;
    }

    /* 防止選單開啟時頁面滾動 */
    body.menu-open {
        overflow: hidden;
    }

    /* Body padding 調整 */
    body {
        padding-top: 90px;
    }

    /* ==================== 下拉選單手機樣式 ==================== */
    
    /* 下拉選單容器 */
    .dropdown {
        width: 100%;
    }

    /* 下拉選單觸發按鈕添加箭頭指示 - 只在手機版顯示 */
    .nav-links .dropdown > a::after {
        content: ' ▼';
        margin-left: 0.5rem;
        font-size: 0.7rem;
        transition: transform 0.3s ease;
        display: inline-block;
    }

    .nav-links .dropdown.active > a::after {
        transform: rotate(180deg);
    }

    /* 下拉選單內容 */
    .dropdown-menu {
        position: static;
        width: 100%;
        padding: 0;
        background: rgba(255, 255, 255, 0.08);
        top: auto;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        margin-top: 0.5rem;
        border-radius: 8px;
    }

    /* 展開下拉選單 - 手機版需要點擊，不用 hover */
    .dropdown.active .dropdown-menu {
        max-height: 1000px;
        opacity: 1;
        visibility: visible;
        padding: 1rem 0.5rem;
    }

    /* 完全禁用手機版的 hover 和 focus-within 效果 */
    .nav-links .dropdown:hover > .dropdown-menu,
    .nav-links .dropdown:focus-within > .dropdown-menu,
    .dropdown:hover > .dropdown-menu,
    .dropdown:focus-within > .dropdown-menu {
        max-height: 0 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        padding: 0 !important;
        transform: none !important;
    }

    /* 禁用 header 在 hover 時的高度變化 */
    header:has(.dropdown:hover) {
        height: 80px !important;
        min-height: 80px !important;
    }
    
    /* 只有 active 狀態才顯示 - 覆蓋所有可能的 hover 規則 */
    .nav-links .dropdown.active .dropdown-menu {
        max-height: 1000px !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        padding: 1rem 0.5rem !important;
    }

    /* 下拉選單內層容器 */
    .dropdown-inner {
        flex-direction: column;
        padding: 1rem 2rem;
    }

    /* 練習模式和 Profile 單欄式下拉選單 */
    .dropdown-inner.single-column {
        padding: 1rem 2rem;
        text-align: center;
    }

    /* 下拉選單分欄 */
    .dropdown-column {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        padding: 0;
        padding-bottom: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .dropdown-column:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    /* 分欄標題 */
    .dropdown-column-title {
        font-size: 0.9rem;
        margin-bottom: 1rem;
        padding-bottom: 0.3rem;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.8);
    }

    /* 下拉選單連結 - 預設樣式（先定義通用規則） */
    .dropdown-menu a {
        padding: 0.5rem 0;
        font-size: 1rem;
        display: block;
        margin: 0;
        transition: opacity 0.2s ease;
        width: 100%;
        text-align: left;
    }

    .dropdown-menu a:hover {
        opacity: 0.6;
    }

    /* ==================== 練習模式和 Profile 下拉選單 - 置中對齊（後定義覆蓋） ==================== */
    
    .dropdown-menu .dropdown-inner.single-column {
        text-align: center !important;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .dropdown-menu .dropdown-inner.single-column .dropdown-column {
        text-align: center !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        width: 100%;
    }

    .dropdown-menu .dropdown-inner.single-column .dropdown-column-title {
        text-align: center !important;
    }

    .dropdown-menu .dropdown-inner.single-column a {
        text-align: center !important;
        display: inline-block !important;
        width: auto !important;
        min-width: 120px !important;
        padding: 0.6rem 1.5rem !important;
        margin: 0.3rem 0 !important;
    }

    /* ==================== 五十音表下拉選單 - 左對齊 ==================== */
    .dropdown-menu .dropdown-inner:not(.single-column) {
        text-align: left;
    }

    .dropdown-menu .dropdown-inner:not(.single-column) .dropdown-column {
        text-align: left;
    }

    .dropdown-menu .dropdown-inner:not(.single-column) .dropdown-column-title {
        text-align: left;
    }

    .dropdown-menu .dropdown-inner:not(.single-column) a {
        text-align: left;
    }

    /* ==================== 玻璃效果調整 ==================== */
    .glass-overlay {
        display: none;
    }

    /* ==================== 語言選擇器 ==================== */
    header .language-select,
    .nav-right .language-select {
        width: 100%;
        justify-content: center;
    }

    /* ==================== 用戶相關 ==================== */
    .user-greeting {
        font-size: 0.85rem;
        padding: 0.5rem;
        text-align: center;
    }

    .logout-btn {
        width: 100%;
        text-align: center;
        padding: 0.6rem 1rem;
    }
}

/* ==================== 超小螢幕 (< 480px) ==================== */
@media (max-width: 480px) {
    nav {
        padding: 0.8rem 1rem;
    }

    .logo {
        font-size: 1rem;
    }

    .logo span {
        font-size: 0.6rem;
    }

    .hamburger span {
        width: 22px;
    }

    .nav-links {
        padding: 1.5rem 0.5rem;
    }

    .nav-links > li > a,
    .nav-links .nav-right > li > a {
        font-size: 0.95rem;
        padding: 0.7rem 0.8rem;
    }

    .dropdown-menu a {
        font-size: 0.85rem;
    }
}

