Files
2026-02-13 17:02:12 +08:00

266 lines
6.0 KiB
CSS

/* =========================================
页眉布局 (Header & Navigation)
========================================= */
.site-header {
height: 80px;
background-color: var(--bg-body);
border-bottom: 1px solid var(--border-muted);
position: sticky; /* 粘性定位,确保始终置顶 */
top: 0;
z-index: 1000;
backdrop-filter: blur(12px); /* 毛玻璃效果 */
-webkit-backdrop-filter: blur(12px);
/* 使用半透明背景以增强毛玻璃效果 */
background-color: rgba(255, 255, 255, 0.85);
transition: background-color var(--duration-normal), border-color var(--duration-normal), transform 0.45s var(--ease-in-out);
will-change: transform;
flex-shrink: 0; /* 防止被父容器 Flex 布局压缩 */
}
.site-header .container {
height: 100%; /* 关键修复:让容器撑满 Header 高度,使内部 flex 垂直居中生效 */
}
[data-theme="dark"] .site-header {
background-color: rgba(13, 17, 23, 0.85);
}
.header-content {
display: flex;
justify-content: space-between;
align-items: center;
height: 100%;
}
/* --- Logo 区域 --- */
.logo-container,
.logo-link {
display: flex;
align-items: center;
height: 100%;
}
.logo-main {
height: 60px; /* 增大 Logo 尺寸 (原52px) */
width: auto;
color: var(--text-primary);
}
/* --- 主导航 (Navigation) --- */
.main-navigation {
display: flex;
align-items: center;
gap: 24px;
}
.nav-menu {
display: flex;
list-style: none;
gap: 8px; /* 菜单项间距 */
margin: 0;
padding: 0;
}
.nav-menu a {
color: var(--text-secondary);
font-weight: 500;
font-size: 16px; /* 增大导航字号 (原15px) */
padding: 8px 16px;
border-radius: var(--radius-sm);
transition: all var(--duration-fast);
display: flex;
align-items: center;
}
.nav-menu a:hover,
.nav-menu a:focus {
color: var(--text-primary);
background-color: var(--bg-surface);
}
/* --- 社交链接与工具 (Social & Tools) --- */
.social-links {
display: flex;
align-items: center;
gap: 12px;
padding-left: 12px;
margin-left: 12px;
border-left: 1px solid var(--border-muted);
}
.social-links a,
.theme-toggle,
.lang-toggle {
width: 40px; /* 增大图标按钮尺寸 (原36px) */
height: 40px;
display: flex;
align-items: center;
justify-content: center;
color: var(--text-secondary);
background: transparent;
border: 1px solid transparent; /* 预留边框位置防止抖动 */
border-radius: var(--radius-sm);
cursor: pointer;
transition: all var(--duration-fast);
}
.social-links a:hover,
.theme-toggle:hover,
.lang-toggle:hover {
background-color: var(--bg-surface);
color: var(--color-primary);
border-color: var(--border-default);
}
/* --- 主题切换动画 (Theme Toggle) --- */
.theme-toggle {
position: relative; /* 为内部 SVG 绝对定位做准备 */
overflow: hidden;
}
.theme-toggle svg {
position: absolute;
transition: transform 0.5s var(--ease-in-out), opacity 0.5s;
}
/* 默认 / 浅色模式状态: 显示月亮 (提示切换到深色) */
/* 修正逻辑:通常浅色模式下,按钮为了表示“点击切换到深色”,会显示月亮;
但也有一种逻辑是显示“当前是太阳”。
根据之前的代码意图,我们从 CSS 变量来看:
浅色模式下,.moon-icon 显示,.sun-icon 隐藏 */
/* 浅色模式下:太阳隐藏 */
html:not([data-theme="dark"]) .sun-icon {
opacity: 0;
transform: rotate(90deg) scale(0);
}
/* 浅色模式下:月亮显示 */
html:not([data-theme="dark"]) .moon-icon {
opacity: 1;
transform: rotate(0) scale(1);
}
/* 深色模式下:太阳显示 */
[data-theme="dark"] .sun-icon {
opacity: 1;
transform: rotate(0) scale(1);
}
/* 深色模式下:月亮隐藏 */
[data-theme="dark"] .moon-icon {
opacity: 0;
transform: rotate(-90deg) scale(0);
}
/* 语言切换按钮文字 */
.lang-toggle {
font-weight: 600;
font-size: 15px; /* 增大切换字号 (原14px) */
width: auto;
padding: 0 12px;
}
/* --- 移动端菜单开关 (Hamburger) --- */
.mobile-menu-toggle {
display: none; /* 默认隐藏 */
flex-direction: column;
justify-content: space-between;
width: 24px;
height: 18px;
background: transparent;
border: none;
cursor: pointer;
z-index: 1100;
padding: 0;
}
.mobile-menu-toggle span {
display: block;
width: 100%;
height: 2px;
background-color: var(--text-secondary);
border-radius: 2px;
transition: all 0.3s var(--ease-in-out);
transform-origin: left center;
}
/* 激活状态 (X 形状) */
.mobile-menu-toggle.active span:nth-child(1) {
transform: rotate(45deg) translate(0px, -2px);
width: 115%;
}
.mobile-menu-toggle.active span:nth-child(2) {
opacity: 0;
transform: translateX(-10px);
}
.mobile-menu-toggle.active span:nth-child(3) {
transform: rotate(-45deg) translate(0px, 2px);
width: 115%;
}
/* 默认情况:显示主 Logo,隐藏移动端 Logo */
.logo-mobile {
display: none;
height: 48px; /* 调整高度 */
width: auto;
}
/* --- 响应式适配 --- */
@media (max-width: 900px) {
/* 移动端隐藏主Logo,显示移动端Logo */
.logo-main {
display: none;
}
.logo-mobile {
display: block;
}
.mobile-menu-toggle {
display: flex;
order: 2; /* 放在最右侧 */
}
.nav-menu {
position: absolute;
top: 100%;
left: 0;
right: 0;
background-color: var(--bg-body);
border-bottom: 1px solid var(--border-default);
flex-direction: column;
padding: 1rem;
gap: 0;
/* 默认收起状态 */
opacity: 0;
transform: translateY(-10px);
pointer-events: none;
transition: all var(--duration-normal) var(--ease-in-out);
box-shadow: var(--shadow-md);
z-index: 1000;
}
.nav-menu.active {
opacity: 1;
transform: translateY(0);
pointer-events: auto;
}
.nav-menu a {
width: 100%;
padding: 12px 16px;
justify-content: flex-start;
}
/* 移动端隐藏社交分割线 */
.social-links {
border-left: none;
margin-left: auto; /* 推到右侧 */
order: 1; /* 放在 toggle 左侧 */
margin-right: 12px; /* 和 toggle 之间增加一点间距 */
}
}