/* styles/main.css */

/* --- 1. CSS 变量定义 (核心部分) --- */
:root {
    /* 浅色模式 (默认) 变量 */
    --primary-color: #3182ce;
    --primary-hover: #2c5aa0;
    --accent-color: #667eea;
    --bg-color: #ffffff;
    --bg-secondary: #f7fafc;
    --text-color: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --navbar-bg: rgba(255, 255, 255, 0.95);
    --hero-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --card-shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.1);
    --progress-bar-bg: linear-gradient(90deg, #3182ce, #667eea);
    --toc-bg: #f7fafc;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(255, 255, 255, 0.7);
    --indicator-hover-bg: rgba(255, 255, 255, 0.15);
}

/* 深色模式变量 */
html.dark-mode {
    --primary-color: #63b3ed;
    --primary-hover: #4299e1;
    --accent-color: #9f7aea;
    --bg-color: #1a202c;
    --bg-secondary: #2d3748;
    --text-color: #e2e8f0;
    --text-secondary: #cbd5e0;
    --text-muted: #a0aec0;
    --border-color: #4a5568;
    --navbar-bg: rgba(26, 32, 44, 0.9);
    --hero-gradient: linear-gradient(135deg, #2c3e50 0%, #000000 100%);
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --card-shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.5);
    --toc-bg: #2d3748;
    --glass-bg: rgba(26, 32, 44, 0.85);
    --glass-border: rgba(255, 255, 255, 0.2);
    --indicator-hover-bg: rgba(0, 0, 0, 0.2);
}


/* --- 2. 全局样式 --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- 3. 导航栏 --- */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    z-index: 1000;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1); /* 更平滑的过渡 */
    padding: 10px 0;
    border-bottom: 1px solid transparent;
    box-shadow: none; /* 初始状态无阴影 */
}

.navbar.scrolled {
    top: 0;
    background: transparent; /* 完全透明背景 */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none; /* 移除阴影 */
    padding: 0;
    border-bottom: 1px solid transparent; /* 透明边框 */
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

html.dark-mode .navbar.scrolled {
    box-shadow: none; /* 深色模式下也移除阴影 */
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.nav-logo a {
    text-decoration: none; /* 取消logo下划线 */
    color: inherit;
    display: inline-block;
}

.nav-logo h2 {
    font-weight: 700;
    color: var(--text-color); /* 使用主题文本颜色，确保与背景对比度 */
    font-size: 1.6rem;
    letter-spacing: -0.5px;
    transition: all 0.3s ease;
    margin: 0;
}

/* 优化导航栏字体在浅色模式下的显示效果 */
.navbar {
    color: white; /* 默认设置为白色，适合深色背景 */
}

/* 确保导航栏链接颜色正确 */
.navbar .nav-link {
    color: inherit; /* 继承父元素颜色 */
}

/* 浅色模式下，针对特定页面（如冬至页面）的导航栏优化 */
:root:not(.dark-mode) .navbar {
    color: var(--text-color); /* 浅色模式下使用深色文本 */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); /* 添加轻微阴影增强可读性 */
}

/* 滚动时保持清晰的文本颜色 */
.navbar.scrolled {
    color: var(--text-color);
    text-shadow: none;
}

.navbar.scrolled .nav-logo h2 {
    color: var(--text-color);
}

.nav-logo h2:hover {
    color: var(--primary-color);
    transform: scale(1.05);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2.5rem;
    align-items: center;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-link {
    text-decoration: none;
    color: inherit; /* 继承父元素颜色 */
    font-weight: 500;
    font-size: 1.05rem;
    position: relative;
    padding: 8px 0;
    transition: color 0.3s ease;
}

.navbar.scrolled .nav-link {
    color: var(--text-color);
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--primary-color);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.3s ease;
}

.nav-link:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

.nav-link:hover {
    color: var(--primary-color);
}

.theme-toggle {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.navbar.scrolled .theme-toggle,
.navbar.scrolled .hamburger .bar {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

html.dark-mode .navbar.scrolled .theme-toggle,
html.dark-mode .navbar.scrolled .hamburger .bar {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
}

/* 优化主题切换按钮图标颜色 */
.theme-toggle i {
    color: inherit;
}

/* 优化汉堡菜单颜色 */
.hamburger .bar {
    background-color: currentColor;
}

.theme-toggle:hover {
    transform: translateY(-2px) scale(1.05);
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
}

.hamburger .bar {
    width: 22px;
    height: 2px;
    background-color: var(--text-color);
    margin: 2px 0;
    transition: 0.3s;
}

.navbar.scrolled .hamburger .bar {
    background-color: var(--text-color);
}

.hamburger:hover {
    background: var(--primary-color);
    transform: scale(1.1);
    border-color: var(--primary-color);
}

.hamburger:hover .bar {
    background-color: white;
}

.navbar.scrolled .hamburger:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}
html.dark-mode .navbar.scrolled .hamburger:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
}

.hamburger.active .bar:nth-child(2) {
    opacity: 0;
}

.hamburger.active .bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger.active .bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* --- 4. Hero Section --- */
.hero-section {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: var(--hero-gradient);
    color: white;
    position: relative;
    overflow: hidden; /* 防止内容溢出 */
}

.hero-content {
    max-width: 600px;
    padding: 0 20px;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.8s ease-out forwards;
}

.hero-subtitle {
    font-size: 1.3rem;
    font-weight: 300;
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.8s ease-out 0.2s forwards; /* 延迟动画 */
}

.cta-button {
    display: inline-block;
    padding: 12px 30px;
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    text-decoration: none;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.8s ease-out 0.4s forwards;
}

.cta-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px) scale(1.05);
    text-decoration: none;
    color: white;
}

/* --- 新优化的滚动指示器样式 --- */
.scroll-indicator {
    position: fixed;
    left: 50%;
    bottom: 25px;
    transform: translateX(-50%);
    pointer-events: none; /* 允许点击穿透，防止误触 */
    z-index: 100;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.scroll-indicator.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto; /* 让它可以被点击 */
}

.indicator-ring {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
    
    /* 新动画：浮游 + 闪烁 */
    animation: float 2.5s ease-in-out infinite;
}

.indicator-ring i {
    color: #fff;
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.indicator-ring:hover {
    background: var(--indicator-hover-bg); /* 悬停时背景变深 */
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.1);
}

.indicator-ring:hover i {
    transform: translateY(3px); /* 箭头向下微移，暗示滚动 */
}

/* 深色模式下的指示器样式调整 */
html.dark-mode .scroll-indicator.visible .indicator-ring {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
}
html.dark-mode .scroll-indicator.visible .indicator-ring:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}
html.dark-mode .scroll-indicator.visible .indicator-ring i {
    color: var(--text-color);
}


/* 新增/修改的动画定义 */
@keyframes float {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    50% {
        transform: translateY(-8px);
        opacity: 0.6;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* --- 5. 通用 Section 样式 --- */
.section-title {
    font-size: 2.5rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 3rem;
    color: var(--text-color);
    position: relative;
}
.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: var(--primary-color);
    margin: 10px auto 0;
    border-radius: 2px;
}

section {
    padding: 100px 0;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- 6. About Section --- */
.about-section {
    background: var(--bg-secondary);
}

.about-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 4rem;
    align-items: center;
}

.about-text h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.about-text p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.8;
}

.skills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.skill-tag {
    background: var(--bg-color);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.skill-tag:hover {
    background: var(--primary-color);
    color: var(--bg-color);
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.about-image {
    display: flex;
    justify-content: center;
}

.avatar {
    width: 200px;
    height: 200px;
    background: var(--hero-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: white;
}

/* --- 7. Blog Section --- */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

.blog-card {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.blog-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-shadow-hover);
    border-color: var(--primary-color);
}

.card-date {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.blog-card h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.blog-card p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
    flex-grow: 1;
}

.blog-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.read-more {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.read-more:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* --- 8. Contact Section --- */
.contact-section {
    background: var(--bg-secondary);
}

.contact-content {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.contact-info h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.contact-info p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.contact-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.contact-link i {
    font-size: 1.1rem;
}

.contact-link:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    text-decoration: none;
    color: white;
}

/* --- 9. Footer --- */
.footer {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
}

/* --- 10. 进度条 (JS 生成) --- */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--progress-bar-bg);
    z-index: 1001;
    transition: width 0.1s ease;
}


/* --- 12. 弹窗公告样式 --- */
.announcement-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease, backdrop-filter 0.5s ease;
    backdrop-filter: blur(0px);
    animation: backdropBlur 0.5s ease forwards 0.2s;
}

.announcement-modal.active {
    opacity: 1;
    visibility: visible;
}

.announcement-modal .modal-content {
    background: var(--bg-color);
    border-radius: 12px;
    box-shadow: var(--card-shadow-hover);
    width: 90%;
    max-width: 500px;
    animation: fadeInUp 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid var(--border-color);
    font-family: inherit;
    overflow: hidden;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes backdropBlur {
    from {
        backdrop-filter: blur(0px);
    }
    to {
        backdrop-filter: blur(8px);
    }
}

@keyframes pulseCountdown {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

.announcement-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.announcement-modal .modal-header h3 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.25rem;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.announcement-modal .modal-header h3 i {
    font-size: 1.5rem;
    color: var(--primary-color);
    animation: pulse 2s ease-in-out infinite;
}

.announcement-modal .close-modal {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-family: inherit;
    line-height: 1;
    box-shadow: var(--card-shadow);
}

.announcement-modal .close-modal:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px) rotate(90deg);
    box-shadow: var(--card-shadow-hover);
}

.announcement-modal .close-modal i {
    transition: all 0.3s ease;
}

.announcement-modal .modal-body {
    padding: 1.5rem;
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 1rem;
    font-family: inherit;
}

.announcement-modal .modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg-secondary);
}

.announcement-modal .countdown {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.875rem;
    animation: pulseCountdown 1s ease-in-out infinite;
    display: inline-block;
    font-family: inherit;
}

/* 确保弹窗在深色模式下正确显示 */
.dark-mode .announcement-modal {
    background: rgba(0, 0, 0, 0.7);
}

.dark-mode .announcement-modal .modal-content {
    border-color: var(--border-color);
    box-shadow: var(--card-shadow-hover);
}

/* 响应式优化 */
@media (max-width: 768px) {
    .announcement-modal .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .announcement-modal .modal-header,
    .announcement-modal .modal-body,
    .announcement-modal .modal-footer {
        padding: 1rem;
    }
    
    .announcement-modal .modal-header h3 {
        font-size: 1.1rem;
    }
}

/* --- 11. 响应式设计 --- */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
    
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 80%;
        max-width: 300px;
        flex-direction: column;
        background-color: var(--bg-color);
        text-align: center;
        transition: 0.4s ease;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
        padding-top: 80px;
        gap: 2rem;
        justify-content: flex-start;
        align-items: center;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-link {
        color: var(--text-color);
        font-size: 1.2rem;
        width: 100%;
        display: block;
        padding: 15px 0;
    }
    
    .nav-link:hover {
        background: var(--bg-secondary);
        width: 100%;
    }
    
    .nav-link::after {
        display: none;
    }

    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
    }
    
    .about-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .blog-grid {
        grid-template-columns: 1fr;
    }

    .contact-links {
        flex-direction: column;
        gap: 1rem;
    }

    .about-image .avatar {
        margin: 0 auto;
    }

    .skills {
        justify-content: center;
    }

    /* 响应式下，滚动指示器可以适当减小尺寸 */
    .indicator-ring {
        width: 38px;
        height: 38px;
    }
    
    /* 弹窗响应式 */
    .announcement-modal .modal-content {
        width: 95%;
        margin: 20px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    .container {
        padding: 0 15px;
    }
    .scroll-indicator {
        bottom: 15px; /* 更小的屏幕底部间距更小 */
    }
}
