/* =========================================
   1. 核心变量定义
   ========================================= */
   :root {
    /* 品牌色 */
    --primary-color: #1abc9c;
    --secondary-color: #16a085;
    --accent-color: #3498db;

    /* 浅色模式 (默认) */
    --bg-page: #f8f9fa;
    --text-main: #2c3e50;
    --text-muted: #666666;
    
    /* 核心修复：顶栏背景颜色 (浅色半透明) */
    --header-bg: rgba(255, 255, 255, 0.85); 
    --header-text: #2c3e50;
    
    /* 磨砂卡片背景 */
    --bg-card: rgba(255, 255, 255, 0.7);           
    --bg-card-hover: rgba(255, 255, 255, 0.9);
    --backdrop-blur: 12px;        
    
    --bg-list-item: rgba(248, 249, 250, 0.6); 
    --border-color: rgba(0, 0, 0, 0.08); 
    --shadow-color: rgba(0,0,0,0.05); 
    
    --bg-gradient-opacity: 0.15;   
    --dropdown-bg: #ffffff;       
    --footer-bg: #2c3e50;         
    --footer-text: #ffffff;       
}

/* 深色模式覆盖 */
[data-theme="dark"] {
    --bg-page: #121212;
    --text-main: #e0e0e0;
    --text-muted: #aaaaaa;
    
    /* 核心修复：顶栏背景颜色 (深色半透明) */
    --header-bg: rgba(30, 30, 30, 0.85);
    --header-text: #e0e0e0;

    /* 磨砂卡片背景 */
    --bg-card: rgba(30, 30, 30, 0.6); 
    --bg-card-hover: rgba(45, 45, 45, 0.7);
    
    --bg-list-item: rgba(255, 255, 255, 0.05);
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0,0,0,0.3);
    
    --bg-gradient-opacity: 0.08; 
    --dropdown-bg: #2d2d2d;
    --footer-bg: #0f0f0f;
    --footer-text: #888888;
}

/* =========================================
   2. 全局样式 & 背景动画
   ========================================= */
html {
    scroll-behavior: smooth;
}

body {
    position: relative;
    overflow-x: hidden;
    background-color: var(--bg-page);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    margin: 0;
}

/* 动态流光背景 */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        #1abc9c 0%,
        #3498db 25%,
        #9b59b6 50%,
        #e67e22 75%,
        #1abc9c 100%
    );
    background-size: 400% 400%;
    animation: gradientFlow 20s ease infinite;
    z-index: -1;
    opacity: var(--bg-gradient-opacity);
    transition: opacity 0.3s;
    pointer-events: none;
}

@keyframes gradientFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* =========================================
   3. 头部 & 导航栏 (重点修复)
   ========================================= */
header {
    /* 核心修复：使用变量实现半透明，并添加模糊 */
    background: var(--header-bg);
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px); /* 兼容 Safari */
    
    color: var(--header-text);
    padding: 1rem 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    border-bottom: 1px solid var(--border-color);
    
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background 0.3s, color 0.3s, padding 0.3s;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

/* 标题渐变色，增加设计感 */
header h1 {
    margin: 0;
    font-size: 1.5rem;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent; /* 让文字透明显示出背景渐变 */
    font-weight: 800;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

nav a {
    color: var(--header-text); /* 修复：文字颜色跟随主题 */
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    font-size: 0.95rem;
}

nav a:hover {
    background: var(--primary-color);
    color: white; /* 悬停时变白 */
    transform: translateY(-2px);
}

.theme-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--header-text);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 6px 10px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover {
    background: var(--bg-list-item);
    transform: rotate(15deg);
}

/* =========================================
   4. 主要内容区域 & 磨砂效果
   ========================================= */
/* 核心修复：Scroll Margin Top 解决遮挡问题 */
.section {
    padding: 2rem 0 4rem 0;
    scroll-margin-top: 100px; /* 让锚点定位时，顶部预留 100px 空间 */
}

/* Scroll Reveal 动画 */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

.container {
    width: 85%;
    max-width: 1000px;
    margin: 0 auto;
}

h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 2rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--primary-color);
    display: inline-block;
}

/* 毛玻璃内容盒子 */
.content-box {
    background: var(--bg-card);
    color: var(--text-main);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur));
    
    transition: transform 0.3s ease, background 0.3s, border 0.3s;
}

.content-box:hover {
    background: var(--bg-card-hover);
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.1);
}

/* =========================================
   5. 特效组件
   ========================================= */

/* --- 打字机 --- */
.typing-container { display: inline-block; }
.typing-text {
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid var(--primary-color);
    width: 0;
    margin: 0;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 1.2rem;
    animation: typing 3.5s steps(40, end) forwards, blink 0.75s step-end infinite;
}
@keyframes typing { from { width: 0 } to { width: 100% } }
@keyframes blink { from, to { border-color: transparent } 50% { border-color: var(--primary-color) } }

/* --- 时间轴 --- */
.timeline {
    position: relative;
    padding-left: 30px;
    border-left: 2px solid var(--border-color);
}
.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}
.timeline-item:last-child { margin-bottom: 0; }
.timeline-dot {
    position: absolute;
    left: -36px;
    top: 5px;
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    border: 3px solid var(--bg-card); /* 这里会用到当前的卡片背景色，制造空心感 */
    box-shadow: 0 0 0 2px var(--primary-color);
}
.timeline-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: bold;
    font-family: monospace;
}
.timeline-content h3 {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
    color: var(--text-main);
}
.timeline-content p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* --- 列表与链接 --- */
.memo-list, .hobby-list, .contact-list {
    list-style: none;
    padding: 0;
}
.memo-list li, .hobby-list li, .contact-list li {
    padding: 0.8rem 1rem;
    margin: 0.5rem 0;
    background: var(--bg-list-item);
    color: var(--text-main);
    border-left: 4px solid var(--primary-color);
    border-radius: 0 4px 4px 0;
    transition: background 0.3s, transform 0.2s;
}
.memo-list li:hover, .hobby-list li:hover, .contact-list li:hover {
    transform: translateX(5px);
    background: rgba(26, 188, 156, 0.15);
}

.content-box a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}
.content-box a:hover {
    text-decoration: underline;
}

/* =========================================
   6. 资源卡片
   ========================================= */
.resource-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.resource-card {
    padding: 25px;
    border-radius: 12px;
    color: white;
    text-decoration: none;
    transition: transform 0.3s, box-shadow 0.3s;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.resource-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 30px rgba(0,0,0,0.25);
}

.resource-card h3 {
    margin: 0 0 8px;
    font-size: 1.4rem;
    color: white;
    border: none;
}
.resource-card p {
    margin: 0;
    opacity: 0.95;
    font-size: 0.9rem;
    color: white;
}
.resource-card .icon {
    position: absolute;
    right: 15px;
    bottom: 15px;
    font-size: 2.5rem;
    opacity: 0.2;
    transition: transform 0.3s;
}
.resource-card:hover .icon { transform: rotate(15deg) scale(1.1); }

/* 卡片颜色 */
.blog { background: linear-gradient(135deg, #3498db, #2980b9); }
.image-host { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.favorites { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
.cloud-drive { background: linear-gradient(135deg, #e67e22, #d35400); }
.cloud-music { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.retro { background: linear-gradient(135deg, #f1c40f, #f39c12); }
/* 亮黄色卡片文字适配 */
.retro h3, .retro p, .retro .icon { color: #2c3e50; } 

/* =========================================
   7. 页脚与适配
   ========================================= */
footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

@media (max-width: 768px) {
    .container { width: 90%; }
    .header-container { justify-content: center; gap: 10px; }
    nav ul { gap: 0.5rem; justify-content: center; }
    h2 { font-size: 1.5rem; }
}

.cursor-bubble {
    position: fixed;
    pointer-events: none;
    width: 10px;
    height: 10px;
    background: rgba(26, 188, 156, 0.4);
    border-radius: 50%;
    animation: bubble 0.8s forwards;
    transform: translate(-50%, -50%);
    z-index: 9999;
}
@keyframes bubble {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(3); opacity: 0; }
}