/* ==========================================================================
   header.css — 公共头部（单一整体导航容器，自身高度随展开调节）
   类别：组件（nav-bar / nav-top / nav-links / nav-mega）
   结构：.nav-bar 是唯一容器、一份背景渲染（毛玻璃 blur 对整个容器生效）。
         一二级菜单共用这一个容器；二级菜单在容器内部文档流中，无独立背景。
         容器自身 height 随展开调节：常规 54px（仅见 nav-top 一行），
         悬停/点击带二级菜单项或点汉堡时容器变高（如 320px），nav-mega 露出。
         position:fixed 使容器脱离文档流 → 高度变化不推挤页面内容，
         天然形成「卷帘遮下 / 收回」效果。
   ========================================================================== */

.site-header {
    height: 54px;   /* 固定占位，与 fixed 导航高度一致 */
}

/* 主菜单栏本体：单一容器 + 单一背景，自身高度随展开调节 */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(7, 11, 18, 0.72);
    -webkit-backdrop-filter: saturate(180%) blur(23px);
    backdrop-filter: saturate(180%) blur(23px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    height: 54px;
    overflow: hidden;
    /* 容器自身高度过渡：收起流畅（fixed height 而非 max-height） */
    transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    /* 无论展开/收起，始终隐藏滚动条（内容仍可滚动） */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-bar::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* 展开：高度由内容撑开（JS 测量 scrollHeight 并受上限约束）
   - PC 端上限 50vh；移动端上限视口高度（可撑到底部）
   - 内容超高时内部上下滚动（overflow-y: auto）
   - 收起时回落到 54px */
.nav-bar.open {
    overflow-y: auto;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

/* 顶部一行：原组件（LOGO + 一级菜单 + 汉堡），位置不动 */
.nav-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
}

.brand iconify-icon {
    color: var(--accent);
    font-size: 1.15rem;
    filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.6));
}

/* 一级菜单项（顶部行内） */
.nav-links {
    display: flex;
    align-items: center;
    height: 100%;
}

.nav-links .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 100%;
    padding: 0 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.92rem;
    opacity: 0.8;
    transition: opacity 0.2s, color 0.2s;
}

.nav-links .nav-link:hover { opacity: 1; color: var(--accent); }

/* 一级菜单按钮（无默认按钮样式） */
.nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--text);
    opacity: 0.8;
    transition: opacity 0.2s, color 0.2s;
}

.nav-btn:hover { opacity: 1; color: var(--accent); }

.caret {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 2px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.2s;
}

.nav-item.dropdown.open .caret {
    transform: rotate(225deg) translateY(-1px);
}

/* 汉堡按钮（仅移动端显示） */
.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.hamburger:hover { border-color: var(--accent); color: var(--accent); }
.hamburger[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   二级菜单区域：容器内部文档流块（无独立背景，共用 .nav-bar 背景）
   ========================================================================== */
.nav-mega {
    padding: 6px 0 34px;
}

.mega-panel {
    display: none;
}

.mega-panel.active {
    display: block;
    animation: mega-in 0.25s ease;
}

@keyframes mega-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 从左至右分栏 */
.mega-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 48px;
    text-align: left;
}

.menu-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 14px;
}

.menu-link {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 9px 10px;
    margin: 0 -10px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s;
}

.menu-link:hover { background: rgba(34, 211, 238, 0.08); }

.menu-link iconify-icon {
    color: var(--accent);
    font-size: 18px;
    margin-top: 2px;
    flex-shrink: 0;
}

.menu-link-text { display: flex; flex-direction: column; }

.menu-link-label {
    font-size: 0.95rem;
    font-weight: 500;
}

.menu-link-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   移动端（≤820px）：一级菜单收进汉堡；点汉堡时容器自身变高，
   在内部从上到下先列一级项、再展开二级分栏（共用容器背景）
   ========================================================================== */
@media (max-width: 820px) {
    .hamburger { display: inline-flex; }

    /* nav-top 允许换行：第一行 LOGO+汉堡，一级列表换到下一行整宽 */
    .nav-top {
        flex-wrap: wrap;
        height: auto;
        min-height: 54px;
        padding-top: 7px;
        padding-bottom: 7px;
    }

    /* 一级菜单项：移动端默认隐藏，容器展开后显示为纵向整行列 */
    .nav-links {
        display: none;
        order: 3;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        height: auto;
        padding: 6px 0 0;
    }

    .nav-bar.open .nav-links { display: flex; }

    .nav-links .nav-link,
    .nav-btn {
        width: 100%;
        height: auto;
        justify-content: flex-start;
        padding: 12px 8px;
        font-size: 1rem;
        text-align: left;
    }

    /* 一级项变纵向：其内的二级菜单在项正下方展开 */
    .nav-item.dropdown {
        flex-direction: column;
        align-items: stretch;
        height: auto;
    }

    /* 二级菜单挂在一级项内：占满宽度，显示在按钮下方 */
    .nav-item.dropdown > .mega-panel {
        width: 100%;
        padding: 4px 0 16px;
    }

    /* 移动端面板已挂入各一级项，原 nav-mega 容器不再使用 */
    .nav-mega { display: none; }

    /* 移动端二级分栏：单列纵向 */
    .mega-columns { grid-template-columns: 1fr; gap: 22px; }

    .menu-group { padding: 0; }
}
