/* nav.css */
:root {
    --nav-height: 56px;
    --subnav-height: 52px;
    --accent-red: #8e443d;
    --border-color: #d1ccc0;
}

/* 第一層：主導覽列 - 設為最高層級 */
.global-nav {
    width: 100%;
    height: var(--nav-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0; left: 0;
    z-index: 10010; /* 確保在最頂層 */
    display: flex;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.nav-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.nav-brand {
    font-family: 'Noto Serif TC', serif;
    font-weight: 900;
    color: var(--accent-red);
    font-size: 1.15rem;
}

/* 漢堡按鈕 */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10012;
}

.nav-toggle span {
    width: 24px;
    height: 2px;
    background: var(--accent-red);
    border-radius: 10px;
    transition: all 0.3s linear;
    position: relative;
    transform-origin: 1px;
}

.nav-toggle.is-active span:nth-child(1) { transform: rotate(45deg); }
.nav-toggle.is-active span:nth-child(2) { opacity: 0; }
.nav-toggle.is-active span:nth-child(3) { transform: rotate(-45deg); }

.nav-links a {
    text-decoration: none;
    color: #7f8c8d;
    margin-left: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover { color: var(--accent-red); }
.nav-links a.active { color: #2c3e50; font-weight: bold; border-bottom: 2px solid var(--accent-red); padding-bottom: 4px; }

/* 行動版選單適配 - 層級介於主導覽與搜尋列之間 */
@media (max-width: 600px) {
    .nav-toggle { display: flex; }
    
    .nav-links {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        width: 100%;
        background: white;
        flex-direction: column;
        display: none;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        z-index: 10009; /* 僅次於 global-nav */
    }
    
    .nav-links.is-visible { display: flex; }
    
    .nav-links a {
        margin: 0;
        padding: 18px 25px;
        border-bottom: 1px solid #f0f0f0;
        font-size: 1rem;
    }
}

/* 第二層：次級搜尋列 - 層級低於主導覽列以實現「滑出」效果 */
.search-subnav {
    width: 100%;
    height: var(--subnav-height);
    background: rgba(253, 251, 246, 0.98);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: var(--nav-height);
    left: 0;
    z-index: 10008; /* 高於內容，低於導覽列 */
    display: flex;
    justify-content: center;
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s;
    opacity: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

.search-subnav.visible {
    transform: translateY(0);
    opacity: 1;
}

.subnav-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
}

.subnav-label {
    font-size: 0.85rem;
    color: #4a6572;
    margin-right: 15px;
    font-family: 'Noto Serif TC', serif;
    font-weight: 600;
}

.mini-grid { display: flex; gap: 8px; }

.input-mini {
    width: 38px;
    height: 38px;
    text-align: center;
    font-family: 'Noto Serif TC', serif;
    font-size: 22px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #ffffff;
    color: var(--accent-red);
    outline: none;
    background-image:
        linear-gradient(to right, transparent 12px, rgba(142,68,61,0.08) 12px, rgba(142,68,61,0.08) 13px, transparent 13px),
        linear-gradient(to right, transparent 25px, rgba(142,68,61,0.08) 25px, rgba(142,68,61,0.08) 26px, transparent 26px),
        linear-gradient(to bottom, transparent 12px, rgba(142,68,61,0.08) 12px, rgba(142,68,61,0.08) 13px, transparent 13px),
        linear-gradient(to bottom, transparent 25px, rgba(142,68,61,0.08) 25px, rgba(142,68,61,0.08) 26px, transparent 26px);
}

body { padding-top: var(--nav-height); }