/* css/topbar.css — macOS Dock 風格：頂部懸浮白色液態玻璃圓角容器
   預設收起於畫面上方，hover 左上角 logo（或觸控點擊 logo，.revealed）才滑出；首頁常駐（.pinned）。
   Logo 獨立為左上角常駐玻璃小卡（.topbar-brand）。 */
.topbar {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%) translateY(calc(-100% - 40px));
    opacity: 0;
    width: max-content;
    max-width: calc(100vw - 40px);
    height: auto;
    z-index: 9999;
    display: flex;
    align-items: center;
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.82) 0%, rgba(255, 255, 255, 0.62) 100%);
    backdrop-filter: blur(30px) saturate(1.7);
    -webkit-backdrop-filter: blur(30px) saturate(1.7);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 30px;
    box-shadow:
        0 24px 60px rgba(20, 32, 38, 0.30),
        0 6px 18px rgba(20, 32, 38, 0.16),
        inset 0 1px 1px rgba(255, 255, 255, 0.95),
        inset 0 -1px 8px rgba(120, 145, 155, 0.10);
    transition:
        transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
        opacity 0.35s ease;
    /* 收合時稍作延遲，讓滑鼠有時間從 logo 移到選單上 */
    transition-delay: 0.5s;
}

/* 顯示狀態：首頁常駐 / hover 左上角 logo / 滑鼠停留在列上 / 觸控展開（.revealed） */
.topbar.pinned,
.topbar.revealed,
.topbar:hover,
.topbar-brand:hover + .topbar {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    transition-delay: 0s;
}

/* 左上角常駐 Logo 玻璃小卡 */
.topbar-brand {
    position: fixed;
    top: 18px;
    left: 20px;
    z-index: 9998;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.82) 0%, rgba(255, 255, 255, 0.62) 100%);
    backdrop-filter: blur(25px) saturate(1.6);
    -webkit-backdrop-filter: blur(25px) saturate(1.6);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 22px;
    padding: 9px 18px;
    box-shadow:
        0 12px 32px rgba(20, 32, 38, 0.22),
        inset 0 1px 1px rgba(255, 255, 255, 0.95);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow var(--transition-standard);
}

.topbar-brand:hover {
    transform: scale(1.06);
    box-shadow:
        0 16px 40px rgba(20, 32, 38, 0.28),
        inset 0 1px 1px rgba(255, 255, 255, 0.95);
}

.topbar-brand a {
    display: flex;
    align-items: center;
}

.topbar-brand img {
    height: 38px;
    object-fit: contain;
    /* 原始 logo 為白色字，翻轉明度使其在白色玻璃上呈深色（色相大致保留） */
    filter: invert(1) hue-rotate(180deg);
}

/* Nav */
.topbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 14px;
    padding-right: 16px;
    border-right: 1px solid rgba(53, 63, 65, 0.12);
}

.nav-item {
    position: relative;
}

.nav-link {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 7px 16px 11px;
    border-radius: 18px;
    transform-origin: top center;
    transition:
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        background-color var(--transition-standard),
        box-shadow var(--transition-standard);
}

/* 英文書寫體小字 */
.nav-en {
    font-family: var(--font-script);
    font-size: 14px;
    line-height: 1;
    color: rgba(74, 87, 89, 0.62);
    letter-spacing: 0.5px;
    transition: color var(--transition-standard);
    pointer-events: none;
}

/* 中文：宋體（Noto Serif TC）加粗 */
.nav-zh {
    font-family: var(--font-serif);
    font-weight: 900;
    font-size: 21px;
    line-height: 1.35;
    color: #353F41;
    letter-spacing: 3px;
    text-indent: 3px; /* 平衡 letter-spacing 造成的右側空隙 */
    transition: color var(--transition-standard);
}

/* Hover：macOS Dock 式放大浮起（頂部版向下浮出） */
.nav-item:hover .nav-link {
    transform: scale(1.14) translateY(5px);
    background: rgba(255, 255, 255, 0.9);
    box-shadow:
        0 12px 26px rgba(20, 32, 38, 0.16),
        inset 0 1px 1px rgba(255, 255, 255, 1);
}

.nav-item:hover .nav-zh,
.nav-item.active .nav-zh {
    color: #B26A78;
}

.nav-item:hover .nav-en,
.nav-item.active .nav-en {
    color: rgba(178, 106, 120, 0.85);
}

/* Active：Dock 式圓點指示 */
.nav-link::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #C9808E;
    box-shadow: 0 0 6px rgba(201, 128, 142, 0.8);
    transition: transform var(--transition-standard);
}

.nav-item.active .nav-link::after {
    transform: translateX(-50%) scale(1);
}

/* Submenu：往下展開 */
.submenu {
    position: absolute;
    top: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0.8) 100%);
    backdrop-filter: blur(25px) saturate(1.6);
    -webkit-backdrop-filter: blur(25px) saturate(1.6);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 18px;
    padding: 10px 8px;
    min-width: 170px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow:
        0 18px 44px rgba(20, 32, 38, 0.22),
        inset 0 1px 1px rgba(255, 255, 255, 0.95);
}

/* 填補 submenu 與 Dock 之間的 hover 空隙 */
.submenu::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    height: 16px;
}

.nav-item:hover .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.submenu-item a {
    display: block;
    padding: 9px 22px;
    border-radius: 12px;
    color: #3A4446;
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 2px;
    text-align: center;
    white-space: nowrap;
    transition: all var(--transition-standard);
}

.submenu-item a:hover {
    background: rgba(201, 128, 142, 0.12);
    color: #B26A78;
    transform: scale(1.05);
}

/* Actions（BGM / 全螢幕） */
.topbar-actions {
    display: flex;
    align-items: center;
}

.fullscreen-btn,
.bgm-btn {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(53, 63, 65, 0.16);
    color: #455254;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        background-color var(--transition-standard),
        color var(--transition-standard),
        border-color var(--transition-standard),
        box-shadow var(--transition-standard);
}

.fullscreen-btn {
    margin-left: 12px;
}

.fullscreen-btn:hover,
.bgm-btn:hover {
    transform: scale(1.15) translateY(3px);
    background: rgba(255, 255, 255, 0.95);
    color: #B26A78;
    border-color: rgba(201, 128, 142, 0.55);
    box-shadow: 0 10px 22px rgba(20, 32, 38, 0.16);
}

/* BGM Control */
.bgm-control {
    position: relative;
    display: flex;
    align-items: center;
}

.bgm-btn {
    z-index: 2;
}

.bgm-volume-slider {
    position: absolute;
    top: 50%;
    right: 100%;
    transform: translateY(-50%) translateX(20px);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-radius: 40px;
    padding: 0 16px 0 20px;
    height: 40px;
    display: flex;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 1;
    pointer-events: none;
    box-shadow: 0 10px 26px rgba(20, 32, 38, 0.18);
}

.bgm-control:hover .bgm-volume-slider {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(10px);
    pointer-events: auto;
}

.volume-range {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    background: rgba(53, 63, 65, 0.18);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.volume-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #C9808E;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(201, 128, 142, 0.5);
    transition: transform 0.2s;
}

.volume-range::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

/* 窄螢幕微調 */
@media (max-width: 1500px) {
    .topbar {
        padding: 8px 14px;
        top: 12px;
    }

    .topbar-nav {
        gap: 0;
        margin-right: 8px;
        padding-right: 8px;
    }

    .nav-link {
        padding: 6px 10px 10px;
    }

    .nav-zh {
        font-size: 18px;
        letter-spacing: 2px;
        text-indent: 2px;
    }

    .nav-en {
        font-size: 12px;
    }

    .topbar-brand {
        top: 12px;
        left: 14px;
        padding: 7px 14px;
    }

    .topbar-brand img {
        height: 32px;
    }
}
