/* =========================================
   1. 字体引入
   ========================================= */
@import url('https://cdnjs.cloudflare.com/ajax/libs/lxgw-wenkai-web/1.520.0/style.css');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap');

/* =========================================
   2. 变量定义 (浅色/深色自动适配)
   ========================================= */
:root {
    /* --- 浅色模式 (默认) --- */
    --text-main: #334155;       /* 深灰蓝文字 */
    --text-sub: #64748b;        /* 次级文字 */
    --text-muted: #94a3b8;      /* 弱化文字 */
    
    /* 蓝绿渐变强调色 */
    --accent: #06b6d4;          /* 青色 */
    --accent-hover: #0891b2;    /* 深青 */
    --accent-gradient: linear-gradient(135deg, #06b6d4 0%, #10b981 100%); /* 蓝绿渐变 */
    
    /* 背景体系 (浅色) */
    --bg-base: #f0fdfa;         /* 极浅的青色底 */
    
    /* 毛玻璃 (浅色：白色半透明) */
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-highlight: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --backdrop-blur: blur(20px);
    
    /* 导航栏 */
    --nav-bg: rgba(255, 255, 255, 0.8);
    --nav-text: #334155;
    
    /* 代码块 (浅色模式下依然保持深色代码框，对比度更好) */
    --code-bg: #1e293b;
    --code-header: #334155;
}

/* --- 深色模式 (浏览器自动检测) --- */
@media (prefers-color-scheme: dark) {
    :root {
        --text-main: #f1f5f9;
        --text-sub: #cbd5e1;
        --text-muted: #94a3b8;
        
        --accent: #2dd4bf;       /* 亮青色 */
        --accent-hover: #14b8a6;
        --accent-gradient: linear-gradient(135deg, #2dd4bf 0%, #34d399 100%);
        
        --bg-base: #0f172a;      /* 深蓝底色 */
        
        /* 毛玻璃 (深色：黑色半透明) */
        --glass-bg: rgba(15, 23, 42, 0.6);
        --glass-border: rgba(255, 255, 255, 0.1);
        --glass-highlight: rgba(255, 255, 255, 0.15);
        --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
        
        --nav-bg: rgba(15, 23, 42, 0.6);
        --nav-text: #f1f5f9;
        
        --code-bg: #020617;
        --code-header: #1e293b;
    }
}

/* =========================================
   3. 基础样式
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: "LXGW WenKai", sans-serif;
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 0.5s ease, color 0.5s ease;
}

/* 动态背景 - 蓝绿流体渐变 */
.global-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    /* 适配深浅模式的渐变 */
    opacity: 0.8;
}

/* 浅色模式下的背景动画 */
@media (prefers-color-scheme: light) {
    .global-bg {
        background: linear-gradient(120deg, #ecfeff, #d1fae5, #e0f2fe, #ecfeff);
        background-size: 300% 300%;
        animation: fluidLight 15s ease infinite;
    }
    @keyframes fluidLight {
        0% { background-position: 0% 50%; }
        50% { background-position: 100% 50%; }
        100% { background-position: 0% 50%; }
    }
}

/* 深色模式下的背景动画 */
@media (prefers-color-scheme: dark) {
    .global-bg {
        background: linear-gradient(120deg, #0f172a, #115e59, #0e7490, #0f172a);
        background-size: 300% 300%;
        animation: fluidDark 15s ease infinite;
    }
    @keyframes fluidDark {
        0% { background-position: 0% 50%; }
        50% { background-position: 100% 50%; }
        100% { background-position: 0% 50%; }
    }
}

a {
    text-decoration: none;
    color: var(--accent);
    transition: 0.3s;
}

a:hover {
    color: var(--accent-hover);
}

/* =========================================
   4. 导航栏
   ========================================= */
.fixed-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 65px;
    padding: 0 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    transition: all 0.3s;
}

.fixed-nav .logo {
    font-size: 1.4rem;
    font-weight: 900;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; /* logo 使用蓝绿渐变字 */
}

.nav-links { display: flex; gap: 2rem; }

.nav-links a {
    color: var(--nav-text);
    font-weight: bold;
    position: relative;
    padding: 5px 0;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--accent-gradient);
    border-radius: 2px;
    transition: width 0.3s;
}

.nav-links a:hover::after { width: 100%; }

/* =========================================
   5. 全屏滚动
   ========================================= */
.scroll-container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

section {
    height: 100vh;
    width: 100%;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

/* =========================================
   6. 毛玻璃卡片 (自动适配深浅)
   ========================================= */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-highlight);
    border-radius: 24px;
    padding: 3rem;
    width: 90%;
    max-width: 900px;
    box-shadow: var(--glass-shadow);
    position: relative;
    transition: 0.3s ease;
}

.glass-card h2 {
    font-size: 2.2rem;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--text-main);
    border-bottom: 2px solid transparent;
    border-image: var(--accent-gradient);
    border-image-slice: 1;
    display: inline-block;
    padding-bottom: 5px;
}

/* =========================================
   7. 首页各板块
   ========================================= */

/* --- 修复第一屏抖动 --- */
.hero-content {
    text-align: center;
    z-index: 10;
    /* 使用 flex 列布局来更稳定地控制间距 */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem; /* 统一间距，替代 margin，防止外边距合并带来的抖动 */
}

.hero-content h1 {
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-main);
    margin: 0; /* 清除默认边距，由父级 gap 控制 */
    line-height: 1.5; /* 固定行高 */
}

/* 打字机容器：关键修复 */
.typewriter-container {
    /* 字体设置 */
    font-size: 4rem;
    font-weight: 700;
    
    /* 【核心修复1】锁死高度 */
    /* 1.2em (字高) + 上下微调，确保足够容纳文字和光标，且不会因为文字出现而撑开 */
    height: 1.4em; 
    line-height: 1.4em;
    
    /* 【核心修复2】使用 Flex 布局严格对齐光标和文字 */
    display: flex;
    align-items: center;     /* 垂直居中 */
    justify-content: center; /* 水平居中 */
    
    /* 颜色渐变设置给内部文字，而不是容器，防止光标消失 */
    color: transparent; 
}

/* 打字机实际文字 */
#typewriter {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    padding-bottom: 5px; /* 防止文字下沉部分被切掉 */
}

/* 光标修复 */
.cursor {
    display: block;
    width: 4px;
    height: 1em; /* 光标高度固定为 1个字高 */
    background: var(--text-main); /* 确保光标是实色 */
    margin-left: 10px;
    animation: blink 1s step-end infinite;
    /* 移除之前的 vertical-align，因为父级已经是 flex center 了 */
}

@keyframes blink { 50% { opacity: 0; } }

/* 底部提示文字 */
.scroll-hint {
    margin-top: 2rem;
    opacity: 0.7;
    font-size: 0.9rem;
    /* 确保它也有固定高度，虽然它在打字机外面，以防万一 */
    line-height: 1.5; 
}


/* --- 第三屏：时间 --- */
.age-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 4rem;
    font-weight: 700;
    text-align: center;
    color: var(--accent);
    margin: 1.5rem 0;
}
.countdown {
    text-align: center;
    color: var(--text-sub);
    padding-top: 2rem;
    border-top: 1px dashed var(--glass-border);
}
.countdown span {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    color: var(--text-main);
    margin-top: 0.5rem;
}

/* --- 第四屏：数据与项目 --- */
.stats-grid h3 {
    font-size: 4rem;
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
}

.project-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}
.project-item {
    background: rgba(255,255,255,0.05);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    transition: 0.3s;
}
@media (prefers-color-scheme: dark) {
    .project-item { background: rgba(0,0,0,0.2); }
}
.project-item:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 5px 15px rgba(6, 182, 212, 0.2);
}
.project-item h4 {
    font-size: 1.2rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}
.project-item p {
    color: var(--text-sub);
    font-size: 0.95rem;
}

/* --- 第五屏：Q&A --- */
.qa-display { height: 350px; overflow-y: auto; margin-bottom: 1.5rem; padding-right: 10px; }
.qa-pair {
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(127, 127, 127, 0.05);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}
.qa-q { font-weight: bold; color: var(--text-main); margin-bottom: 0.5rem; }
.qa-q::before { content: "Q"; color: #fff; background: var(--accent); padding: 2px 6px; border-radius: 4px; margin-right: 8px; font-size: 0.8rem; }
.qa-a { color: var(--text-sub); padding-left: 2rem; }
.qa-pending { color: #f59e0b; padding-left: 2rem; font-style: italic; }

.qa-form { display: flex; gap: 10px; }
.qa-input {
    flex: 1;
    padding: 12px 20px;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    background: var(--bg-base);
    color: var(--text-main);
}
.qa-btn {
    padding: 12px 25px;
    border-radius: 50px;
    border: none;
    background: var(--accent-gradient);
    color: #fff;
    font-weight: bold;
    cursor: pointer;
}
/* =========================================
   8. 普通页面容器 (Catalog & Article)
   ========================================= */
.page-wrapper {
    min-height: 100vh;
    padding: 100px 20px 60px;
    display: flex;
    justify-content: center;
}

.article-list { display: grid; gap: 1.5rem; width: 100%; }
.article-item {
    display: block;
    background: rgba(127, 127, 127, 0.05);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    transition: 0.3s;
    position: relative;
    overflow: hidden;
}
.article-item::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--accent-gradient); opacity: 0; transition: 0.3s;
}
.article-item:hover { transform: translateX(5px); background: rgba(127,127,127,0.1); }
.article-item:hover::before { opacity: 1; }

.article-item h3 { color: var(--text-main); font-size: 1.3rem; margin-bottom: 0.5rem; }
.article-item p { color: var(--text-sub); font-size: 0.95rem; }

/* =========================================
   9. 文章详情
   ========================================= */
.article-content { font-size: 1.1rem; line-height: 1.8; color: var(--text-main); }
.article-content h1, .article-content h2 {
    color: var(--text-main); margin-top: 2rem; margin-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border); padding-bottom: 0.5rem;
}
.article-content h2 { border-bottom: none; border-left: 4px solid var(--accent); padding-left: 1rem; }
.article-content p { margin-bottom: 1.5rem; color: var(--text-sub); }
.article-content strong { color: var(--accent); }
.article-content blockquote {
    background: rgba(6, 182, 212, 0.05); /* 淡青色背景 */
    border-left: 4px solid var(--accent);
    margin: 1.5rem 0; padding: 1rem; border-radius: 4px; color: var(--text-sub);
}
.article-content img { max-width: 100%; border-radius: 8px; margin: 1rem 0; border: 1px solid var(--glass-border); }

/* =========================================
   10. 代码块 (仿Mac)
   ========================================= */
.code-wrapper {
    position: relative;
    margin: 2rem 0;
    background: var(--code-bg);
    border-radius: 10px;
    border: 1px solid #333; /* 无论深浅，代码框保持深色边框 */
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.code-wrapper::before {
    content: ''; display: block; height: 30px; background: var(--code-header);
    border-bottom: 1px solid #333;
    background-image: radial-gradient(circle, #ff5f56 5px, transparent 6px),
                      radial-gradient(circle, #ffbd2e 5px, transparent 6px),
                      radial-gradient(circle, #27c93f 5px, transparent 6px);
    background-size: 20px 20px; background-position: 15px center, 40px center, 65px center; background-repeat: no-repeat;
}
.code-wrapper pre { margin: 0 !important; padding: 1.5rem !important; background: transparent !important; }
.code-wrapper code { font-family: 'JetBrains Mono', monospace !important; color: #f8f8f2 !important; text-shadow: none !important; }

/* 复制按钮 */
.copy-btn {
    position: absolute; top: 5px; right: 10px;
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
    color: #ccc; padding: 2px 10px; border-radius: 4px; font-size: 0.75rem;
    cursor: pointer; transition: 0.2s;
}
.copy-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.copy-btn.copied { background: #10b981; border-color: #10b981; color: #fff; }

/* =========================================
   11. 底部版权
   ========================================= */
.main-footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: var(--nav-bg); /* 与导航栏一致 */
    border-top: 1px solid var(--glass-border);
}
.divider { margin: 0 8px; opacity: 0.5; }
.gemini-credit { 
    display: inline-flex; align-items: center; 
    font-weight: bold;
    background: linear-gradient(90deg, #4EAGFF, #8E54E9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* =========================================
   12. 响应式
   ========================================= */
@media (max-width: 768px) {
    .typewriter-container { font-size: 2.5rem; }
    .age-display { font-size: 2.5rem; }
    .glass-card { padding: 1.5rem; width: 95%; }
    .stats-grid h3 { font-size: 3rem; }
    .qa-btn { width: 100%; }
}