/**
 * TopBar 样式
 * 通用顶部导航栏组件
 */

/* TopBar 容器 */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 60px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 1000;
    box-sizing: border-box;
    pointer-events: none;
    transition: transform 0.3s ease;
}

/* 滚动模式：topbar 随页面滚动 */
body.topbar-scrolling .topbar {
    position: absolute;
}

/* 恢复交互元素的可点击性 */
.topbar > * {
    pointer-events: auto;
}

/* Logo 区域 */
.topbar__logo {
    display: flex;
    align-items: center;
    height: 100%;
}

.topbar__logo img {
    height: 50px;
    width: auto;
    /* 白色半透明 55% 填充效果 */
    filter: brightness(0) invert(1) opacity(0.55);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.topbar__logo img:hover {
    filter: brightness(0) invert(1) opacity(0.8);
}

/* 导航栏容器 */
.topbar__nav {
    display: flex;
    align-items: center;
    gap: 40px;
}

/* 导航链接 */
.topbar__nav-link {
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.5px;
    transition: color 0.3s ease, opacity 0.3s ease;
    position: relative;
    padding: 8px 0;
}

.topbar__nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.8);
    transition: width 0.3s ease;
}

.topbar__nav-link:hover {
    color: rgba(255, 255, 255, 0.9);
}

.topbar__nav-link:hover::after {
    width: 100%;
}

.topbar__nav-link.active {
    color: rgba(255, 255, 255, 0.9);
}

.topbar__nav-link.active::after {
    width: 100%;
}

/* 汉堡菜单按钮（移动端） */
.topbar__menu-button {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 30px;
    height: 30px;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
}

.topbar__menu-button span {
    display: block;
    width: 24px;
    height: 2px;
    background: rgba(255, 255, 255, 0.55);
    margin: 4px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.topbar__menu-button.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

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

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

/* 响应式设计 - 平板和移动端 */
@media (max-width: 768px) {
    .topbar {
        padding: 0 20px;
        height: 50px;
    }

    .topbar__logo img {
        height: 40px;
    }

    /* 显示汉堡菜单按钮 */
    .topbar__menu-button {
        display: flex;
    }

    /* 导航栏折叠样式 */
    .topbar__nav {
        position: fixed;
        top: 50px;
        right: -100%;
        width: 250px;
        height: calc(100vh - 50px);
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding: 20px 0;
        transition: right 0.3s ease;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
    }

    .topbar__nav.open {
        right: 0;
    }

    .topbar__nav-link {
        width: 100%;
        padding: 15px 30px;
        font-size: 18px;
        border-left: 3px solid transparent;
    }

    .topbar__nav-link::after {
        display: none;
    }

    .topbar__nav-link:hover,
    .topbar__nav-link.active {
        background: rgba(255, 255, 255, 0.1);
        border-left-color: rgba(255, 255, 255, 0.8);
    }
}

/* 响应式设计 - 小屏幕手机 */
@media (max-width: 480px) {
    .topbar {
        padding: 0 15px;
    }

    .topbar__logo img {
        height: 36px;
    }

    .topbar__nav {
        width: 100%;
        right: -100%;
    }

    .topbar__nav-link {
        font-size: 16px;
        padding: 12px 20px;
    }
}

/* 页面内容上移，避免被 topbar 遮挡 */
body.has-topbar {
    padding-top: 60px;
}

/* 固定 topbar 模式的内容样式 */
body:not(.topbar-scrolling).has-topbar {
    position: fixed;
    width: 100%;
    height: 100vh;
    overflow-y: auto;
}

body:not(.topbar-scrolling).has-topbar > * {
    display: none;
}

body:not(.topbar-scrolling).has-topbar .topbar {
    position: fixed;
    /* 确保固定模式下 topbar 始终可见 */
}

body:not(.topbar-scrolling).has-topbar > .topbar-container {
    display: block;
}

/* 滚动 topbar 模式：页面正常布局 */
body.topbar-scrolling {
    position: relative;
    padding-top: 60px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    body.has-topbar {
        padding-top: 50px;
    }

    body.topbar-scrolling {
        padding-top: 50px;
    }
}
