/* --- 通用導覽列樣式（由 nav.js 負責渲染） --- */
.mc-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(180deg, #333333 0%, #2a2a2a 100%);
    border-bottom: 4px solid #000;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25), 0 10px 20px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    padding: 12px 20px;
    box-sizing: border-box;
}

/* --- 頂部橫幅公告樣式 --- */
.nav-banner {
    background-color: #1a1400;
    border-bottom: 2px dashed #ffaa00;
    color: #ffff55;
    text-align: center;
    padding: 6px 12px;
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: -12px -20px 10px -20px; /* 貼合導覽列最頂端 */
}

/* 橫幅公告按鈕 */
.banner-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #ffaa00;
    color: #000000;
    font-weight: bold;
    font-size: 0.8rem;
    text-decoration: none;
    padding: 2px 10px;
    border: 2px solid #000;
    box-shadow: inset -2px -2px 0px #9f6f00, inset 2px 2px 0px #ffcf40;
    transition: all 0.1s ease;
    white-space: nowrap;
}

.banner-btn:hover {
    background-color: #ffbb22;
}

.banner-btn:active {
    box-shadow: inset 2px 2px 0px #1a1a1a, inset -2px -2px 0px #5c5c5c;
    transform: translateY(1px);
}

.nav-container {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    position: relative;
}

.nav-brand {
    font-family: 'Press Start 2P', cursive;
    color: #ffaa00;
    text-decoration: none;
    font-size: 1rem;
    text-shadow: 2px 2px 0px #3f2a00;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    line-height: 1.2;
    letter-spacing: 0.04em;
}

.nav-brand img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    image-rendering: pixelated;
}

/* 導覽連結 (電腦版自動靠右，靠在工具列左邊) */
.nav-links {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

.nav-item {
    color: #cfcfcf;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 8px 12px;
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    transition: all 0.15s ease;
    box-sizing: border-box;
}

button.nav-item {
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    background: transparent;
}

.nav-item:hover,
.nav-item:focus-visible {
    color: #ffff55;
    background-color: #212121;
    border-color: #000;
    box-shadow: inset -2px -2px 0px #151515, inset 2px 2px 0px #5c5c5c;
    outline: none;
}

.nav-item.active {
    color: #ffffff;
    background-color: #151515;
    border-color: #000;
    box-shadow: inset 2px 2px 0px rgba(0, 0, 0, 0.55);
}

/* 子選單 Dropdown 樣式 */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-toggle {
    background: transparent;
    cursor: pointer;
}

.dropdown-arrow {
    font-size: 0.7rem;
    margin-left: 6px;
    display: inline-block;
    transition: transform 0.2s ease;
}

.nav-dropdown-toggle.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 140px;
    background-color: #252525;
    border: 2px solid #000;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5), inset -2px -2px 0px #151515, inset 2px 2px 0px #444444;
    padding: 6px 0;
    margin-top: 4px;
    z-index: 2005;
    flex-direction: column;
    gap: 2px;
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-item {
    color: #cfcfcf;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 8px 16px;
    display: block;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
    color: #ffff55;
    background-color: #1a1a1a;
}

.dropdown-item.active {
    color: #ffaa00;
    background-color: #101010;
}

/* 右側工具區塊（含最右側的搜尋按鈕與手機漢堡鈕） */
.nav-right-tools {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 像素風搜尋放大鏡按鈕 */
.nav-search-btn {
    background-color: #151515;
    color: #ffaa00;
    border: 2px solid #000;
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: inset -2px -2px 0px #000000, inset 2px 2px 0px #5c5c5c;
    transition: all 0.1s ease;
    user-select: none;
}

.nav-search-btn:hover {
    background-color: #222222;
}

.nav-search-btn:active {
    box-shadow: inset 2px 2px 0px #000000, inset -2px -2px 0px #5c5c5c;
    transform: translateY(1px);
}

.nav-toggle {
    display: none !important;
    align-items: center;
    justify-content: center;
    background-color: #151515;
    color: #ffaa00;
    border: 2px solid #000;
    padding: 8px 12px;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: inset -2px -2px 0px #000, inset 2px 2px 0px #5c5c5c;
    user-select: none;
    transition: all 0.1s ease;
}

.nav-toggle:active {
    box-shadow: inset 2px 2px 0px #000, inset -2px -2px 0px #5c5c5c;
    transform: translateY(1px);
}

/* --- 全螢幕搜尋彈窗樣式 (Mobile & Desktop Friendly) --- */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 99999; /* 修正：提高最高圖層層級，徹底防止被導覽列或其他 Header 覆蓋 */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 80px 20px 20px 20px;
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
}

.search-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.search-modal {
    background-color: #252525;
    border: 4px solid #000;
    box-shadow: inset -4px -4px 0px #151515, inset 4px 4px 0px #444444, 0 12px 30px rgba(0,0,0,0.8);
    width: 100%;
    max-width: 720px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    transform: translateY(-15px);
    transition: transform 0.2s ease-in-out;
}

.search-overlay.active .search-modal {
    transform: translateY(0);
}

.search-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.search-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: #101010;
    border: 3px solid #000;
    box-shadow: inset 2px 2px 0px #000, inset -2px -2px 0px #333;
    padding: 8px 12px;
}

.search-input-icon {
    margin-right: 8px;
    display: flex;
    align-items: center;
}

.search-input-wrapper input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 1.1rem;
    font-family: inherit;
    font-weight: 500;
}

.search-input-wrapper input::placeholder {
    color: #777777;
}

.search-close-btn {
    background-color: #a82020;
    color: #ffffff;
    border: 2px solid #000;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 8px 14px;
    cursor: pointer;
    box-shadow: inset -2px -2px 0px #5c0f0f, inset 2px 2px 0px #e64a4a;
    transition: all 0.1s ease;
}

.search-close-btn:hover {
    background-color: #c42b2b;
}

.search-close-btn:active {
    box-shadow: inset 2px 2px 0px #000, inset -2px -2px 0px #5c5c5c;
    transform: translateY(1px);
}

/* 搜尋結果列表 */
.search-results-list {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.search-results-list::-webkit-scrollbar {
    width: 8px;
}

.search-results-list::-webkit-scrollbar-track {
    background: #111;
}

.search-results-list::-webkit-scrollbar-thumb {
    background: #ffaa00;
    border: 1px solid #000;
}

.search-item {
    display: block;
    background-color: #1a1a1a;
    border: 2px solid #000;
    padding: 12px 16px;
    text-decoration: none;
    box-shadow: inset -2px -2px 0px #0d0d0d, inset 2px 2px 0px #333333;
    transition: all 0.1s ease;
}

.search-item:hover {
    background-color: #2d2d2d;
    border-color: #ffaa00;
}

.search-item-title {
    color: #ffaa00;
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 4px;
}

.search-item-desc {
    color: #aaaaaa;
    font-size: 0.85rem;
    line-height: 1.4;
}

.search-no-result {
    text-align: center;
    color: #888888;
    padding: 30px 10px;
    font-size: 0.95rem;
}

/* RWD 響應式佈局適應 */
@media (max-width: 768px) {
    .mc-nav {
        padding: 12px 16px;
    }

    .nav-container {
        align-items: center;
        justify-content: space-between;
    }

    .nav-right-tools {
        order: 2;
    }

    .nav-toggle {
        display: inline-flex !important;
    }

    /* 修正：手機版下拉選單改為懸浮絕對定位，防止開合選單時擠壓導覽列高度觸發 ResizeObserver 跳動 */
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: -16px;
        right: -16px;
        width: calc(100% + 32px);
        background-color: #252525;
        border: 3px solid #000;
        border-top: none;
        padding: 10px;
        margin-top: 12px;
        box-shadow: 0 10px 20px rgba(0,0,0,0.8), inset -2px -2px 0px #151515, inset 2px 2px 0px #444;
        gap: 8px;
        box-sizing: border-box;
        z-index: 2001;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-item {
        width: 100%;
        text-align: center;
        padding: 10px;
        display: block;
    }

    .nav-dropdown {
        width: 100%;
    }

    .nav-dropdown-toggle {
        width: 100%;
        justify-content: center;
    }

    .dropdown-menu {
        position: static;
        width: 100%;
        box-shadow: none;
        border: 2px solid #000;
        background-color: #1a1a1a;
        margin-top: 4px;
        box-sizing: border-box;
    }
}

@media (max-width: 600px) {
    .nav-banner {
        font-size: 0.8rem;
        padding: 6px 8px;
        gap: 6px;
    }

    .search-overlay {
        padding: 60px 16px 16px 16px;
    }

    .search-modal {
        max-height: 90vh;
        padding: 14px;
    }

    .search-input-wrapper input {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .nav-brand {
        font-size: 0.9rem;
    }
}