/* 头部导航样式 - 现代化版本 */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-fixed);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    transition: all var(--duration-300) var(--ease-out);
}

.header.scrolled {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-md);
    padding: 0.5rem 0;
}

.header.compact {
    padding: 0.3rem 0;
}

/* 头部隐藏效果 */
.header.header-hidden {
    transform: translateY(-100%);
}

.header.menu-open {
    background: var(--white);
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    transition: padding var(--duration-300) var(--ease-out);
}

/* Logo区域 */
.logo {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    line-height: 1.2;
}

.logo p {
    font-size: 0.75rem;
    color: var(--gray-600);
    margin: 0;
    margin-top: 0.125rem;
}

/* 导航菜单 */
.nav {
    display: flex;
}

.nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.5rem;
}

.nav ul li {
    position: relative;
}

.nav ul li a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--duration-200) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.nav ul li a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left var(--duration-300) var(--ease-out);
}

.nav ul li a:hover::before {
    left: 100%;
}

.nav ul li a:hover,
.nav ul li a:focus {
    color: var(--primary-color);
    background-color: rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.nav ul li a.active {
    color: var(--primary-color);
    background-color: rgba(102, 126, 234, 0.15);
    font-weight: 600;
}

.nav ul li a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 2px;
    background: var(--primary-color);
    border-radius: 1px;
}

/* 移动端菜单切换按钮 */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    border-radius: var(--radius-md);
    transition: all var(--duration-200) var(--ease-out);
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle:focus {
    background: rgba(0, 0, 0, 0.05);
}

.hamburger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--gray-700);
    margin: 2px 0;
    transition: all var(--duration-300) var(--ease-out);
    border-radius: 1px;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* 平板和移动端适配 */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }
    
    .nav {
        position: fixed;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        box-shadow: var(--shadow-lg);
        transform: translateY(-10px);
        opacity: 0;
        visibility: hidden;
        transition: all var(--duration-300) var(--ease-out);
        border-top: 1px solid var(--gray-200);
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
    
    .nav.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    .nav ul {
        flex-direction: column;
        padding: 1rem;
        gap: 0;
    }
    
    .nav ul li {
        border-bottom: 1px solid var(--gray-100);
    }
    
    .nav ul li:last-child {
        border-bottom: none;
    }
    
    .nav ul li a {
        padding: 1rem;
        font-size: 1.1rem;
        justify-content: center;
        text-align: center;
        border-radius: 0;
    }
    
    .nav ul li a:hover,
    .nav ul li a:focus {
        background-color: var(--gray-50);
        transform: none;
    }
    
    .nav ul li a.active::after {
        display: none;
    }
    
    .nav ul li a.active {
        background-color: rgba(102, 126, 234, 0.1);
        border-left: 3px solid var(--primary-color);
    }
    
    .logo h1 {
        font-size: 1.25rem;
    }
    
    .logo p {
        font-size: 0.7rem;
    }
    
    .header .container {
        padding: 0.8rem 0;
    }
}

/* 小屏幕手机适配 */
@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.1rem;
    }
    
    .logo p {
        display: none; /* 极小屏幕隐藏副标题 */
    }
    
    .mobile-menu-toggle {
        width: 36px;
        height: 36px;
    }
    
    .hamburger-line {
        width: 18px;
    }
    
    .nav ul li a {
        font-size: 1rem;
        padding: 0.875rem;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .header {
        background: var(--white);
        border-bottom: 2px solid var(--black);
    }
    
    .nav ul li a {
        border: 1px solid transparent;
    }
    
    .nav ul li a:hover,
    .nav ul li a:focus {
        border-color: var(--primary-color);
        background: var(--white);
    }
    
    .hamburger-line {
        background: var(--black);
    }
}

/* 动画性能优化 */
@media (prefers-reduced-motion: reduce) {
    .header,
    .nav,
    .nav ul li a,
    .hamburger-line,
    .mobile-menu-toggle {
        transition: none;
    }
    
    .nav ul li a::before {
        display: none;
    }
}

/* 打印样式 */
@media print {
    .header {
        position: static;
        background: var(--white);
        box-shadow: none;
        border-bottom: 1px solid var(--black);
    }
    
    .mobile-menu-toggle {
        display: none;
    }
    
    .nav {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        background: transparent;
    }
    
    .nav ul {
        flex-direction: row;
        justify-content: center;
        padding: 0;
    }
    
    .nav ul li a {
        color: var(--black);
        background: none;
        padding: 0.5rem;
    }
}

/* 性能优化 */
.header {
    contain: layout style paint;
    will-change: transform;
}

.nav {
    contain: layout style;
}

/* 可访问性增强 */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* 键盘导航指示器 */
.nav a:focus-visible::before {
    opacity: 0.2;
    animation: pulse var(--duration-1000) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.4; }
} 