/* ===== CSS 变量 – 亮色/暗色 ===== */
:root {
    --bg-body: #f8fafc;
    --bg-container: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --shadow: 0 4px 20px rgba(0,0,0,0.05);
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --nav-bg: #f1f5f9;
    --tag-bg: #e2e8f0;
    --input-bg: #f8fafc;
    --glass: rgba(255,255,255,0.7);
}
[data-theme="dark"] {
    --bg-body: #0b0e14;
    --bg-container: #131a22;
    --text-primary: #e0f2fe;
    --text-secondary: #94a3b8;
    --border-color: rgba(255,255,255,0.06);
    --card-bg: #1e293b;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --accent: #4ade80;
    --accent-hover: #22d3ee;
    --nav-bg: #1e293b;
    --tag-bg: #334155;
    --input-bg: #1e293b;
    --glass: rgba(20,30,40,0.8);
}

/* ===== 全局重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    width: 100%;
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.7;
    transition: background 0.3s, color 0.3s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ===== 容器 ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 30px;
    background: var(--bg-container);
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(0,0,0,0.02);
    transition: background 0.3s;
}
@media (max-width: 768px) {
    .container { padding: 16px; }
}

/* ===== 顶部栏：时间 + 主题切换 ===== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}
#clock {
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}
.theme-toggle {
    display: flex;
    gap: 8px;
    align-items: center;
}
.theme-toggle button {
    background: var(--nav-bg);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 4px 16px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.theme-toggle button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.theme-toggle button:hover {
    opacity: 0.8;
}

/* ===== 导航 ===== */
.top-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 28px;
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}
.top-nav a {
    color: var(--text-secondary);
    font-size: 1rem;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: 0.2s;
}
.top-nav a:hover,
.top-nav a.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

/* ===== 轮播图 ===== */
.carousel {
    position: relative;
    width: 100%;
    height: 380px;
    overflow: hidden;
    border-radius: 16px;
    margin-bottom: 30px;
    background: var(--bg-body);
}
.carousel-slide {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1s ease;
}
.carousel-slide.active {
    opacity: 1;
}
.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.carousel-dots {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}
.carousel-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: 0.3s;
}
.carousel-dots span.active {
    background: #fff;
    transform: scale(1.2);
}
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.3);
    color: #fff;
    border: none;
    font-size: 2rem;
    padding: 0 12px;
    cursor: pointer;
    z-index: 10;
    border-radius: 4px;
    transition: 0.2s;
}
.carousel-arrow:hover { background: rgba(0,0,0,0.6); }
.carousel-arrow.left { left: 12px; }
.carousel-arrow.right { right: 12px; }
@media (max-width: 600px) {
    .carousel { height: 200px; }
    .carousel-arrow { font-size: 1.2rem; padding: 0 8px; }
}

/* ===== 文章列表（主页仅4条） ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 30px 0 16px;
}
.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}
.section-header .more-link {
    background: var(--nav-bg);
    padding: 6px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    transition: 0.2s;
}
.section-header .more-link:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}
.post-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 18px 20px 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}
.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}
.post-card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.post-card h3 a {
    color: var(--text-primary);
}
.post-card h3 a:hover {
    color: var(--accent);
}
.post-card .meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 6px 0 10px;
}
.post-card .excerpt {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}
/* 全部文章页面（all-articles）使用相同样式，但展示全部 */

/* ===== 视频展示 ===== */
.video-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin: 30px 0;
}
.video-grid iframe {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
    border: none;
}
@media (max-width: 768px) {
    .video-grid { grid-template-columns: 1fr; }
}

/* ===== 评论区（复用原样式，适配主题） ===== */
.comment-section {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}
.comment-form input,
.comment-form textarea {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 10px 14px;
    width: 100%;
    font-family: inherit;
}
.comment-form button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 24px;
    border-radius: 30px;
    cursor: pointer;
}
.comment-item {
    background: var(--card-bg);
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
}


/* ===== 底部（新布局） ===== */
.footer {
    margin-top: 50px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px 40px;
}

/* 左侧：版权、更新时间、主题切换 */
.footer-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
}

.footer-copyright,
.footer-update {
    font-size: 0.9rem;
}

.footer-update {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* 右侧：链接分组 */
.footer-right {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
}

.footer-group {
    min-width: 100px;
}

.footer-group-title {
    font-size: 1.1rem;  /* 稍大 */
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.footer-group-links {
    list-style: none;
    padding-left: 20px;  /* 缩进 */
    margin: 0;
}

.footer-group-links li {
    margin: 3px 0;
}

.footer-group-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-group-links a:hover {
    color: var(--accent);
    text-decoration: none;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .footer-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .footer-left {
        justify-content: center;
    }
    .footer-right {
        justify-content: center;
    }
    .footer-group-links {
        padding-left: 0;  /* 移动端取消缩进 */
        text-align: center;
    }
}
.footer .update-date {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* ===== 字体控制（复用） ===== */
.font-control {
    display: flex;
    gap: 6px;
    margin-left: auto;
}
.font-control button {
    background: var(--nav-bg);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 2px 14px;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-secondary);
}
.font-control button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ===== 返回顶部（适配暗色） ===== */
#backTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--bg-container);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    color: var(--text-primary);
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
}
#backTop.show { opacity: 1; pointer-events: auto; }

/* ===== 加载动画遮罩 ===== */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.4s ease;  /* 0.4s 平滑淡出 */
    pointer-events: none;  /* 防止干扰点击 */
}
#loader.hidden {
    opacity: 0;
    pointer-events: none;
}

/* 动画容器居中 */
#loader .pl {
    width: 6em;
    height: 6em;
}
/* 环形颜色适配（保留原色，也可根据主题微调） */
.pl__ring--a { stroke: #f42f25; }
.pl__ring--b { stroke: #f49725; }
.pl__ring--c { stroke: #255ff4; }
.pl__ring--d { stroke: #f42582; }

/* 动画关键帧（直接使用用户提供的） */
@keyframes ringA {
    from, 4% { stroke-dasharray: 0 660; stroke-width: 20; stroke-dashoffset: -330; }
    12% { stroke-dasharray: 60 600; stroke-width: 30; stroke-dashoffset: -335; }
    32% { stroke-dasharray: 60 600; stroke-width: 30; stroke-dashoffset: -595; }
    40%, 54% { stroke-dasharray: 0 660; stroke-width: 20; stroke-dashoffset: -660; }
    62% { stroke-dasharray: 60 600; stroke-width: 30; stroke-dashoffset: -665; }
    82% { stroke-dasharray: 60 600; stroke-width: 30; stroke-dashoffset: -925; }
    90%, to { stroke-dasharray: 0 660; stroke-width: 20; stroke-dashoffset: -990; }
}
@keyframes ringB {
    from, 12% { stroke-dasharray: 0 220; stroke-width: 20; stroke-dashoffset: -110; }
    20% { stroke-dasharray: 20 200; stroke-width: 30; stroke-dashoffset: -115; }
    40% { stroke-dasharray: 20 200; stroke-width: 30; stroke-dashoffset: -195; }
    48%, 62% { stroke-dasharray: 0 220; stroke-width: 20; stroke-dashoffset: -220; }
    70% { stroke-dasharray: 20 200; stroke-width: 30; stroke-dashoffset: -225; }
    90% { stroke-dasharray: 20 200; stroke-width: 30; stroke-dashoffset: -305; }
    98%, to { stroke-dasharray: 0 220; stroke-width: 20; stroke-dashoffset: -330; }
}
@keyframes ringC {
    from { stroke-dasharray: 0 440; stroke-width: 20; stroke-dashoffset: 0; }
    8% { stroke-dasharray: 40 400; stroke-width: 30; stroke-dashoffset: -5; }
    28% { stroke-dasharray: 40 400; stroke-width: 30; stroke-dashoffset: -175; }
    36%, 58% { stroke-dasharray: 0 440; stroke-width: 20; stroke-dashoffset: -220; }
    66% { stroke-dasharray: 40 400; stroke-width: 30; stroke-dashoffset: -225; }
    86% { stroke-dasharray: 40 400; stroke-width: 30; stroke-dashoffset: -395; }
    94%, to { stroke-dasharray: 0 440; stroke-width: 20; stroke-dashoffset: -440; }
}
@keyframes ringD {
    from, 8% { stroke-dasharray: 0 440; stroke-width: 20; stroke-dashoffset: 0; }
    16% { stroke-dasharray: 40 400; stroke-width: 30; stroke-dashoffset: -5; }
    36% { stroke-dasharray: 40 400; stroke-width: 30; stroke-dashoffset: -175; }
    44%, 50% { stroke-dasharray: 0 440; stroke-width: 20; stroke-dashoffset: -220; }
    58% { stroke-dasharray: 40 400; stroke-width: 30; stroke-dashoffset: -225; }
    78% { stroke-dasharray: 40 400; stroke-width: 30; stroke-dashoffset: -395; }
    86%, to { stroke-dasharray: 0 440; stroke-width: 20; stroke-dashoffset: -440; }
}
/* 环形动画附加 */
.pl__ring {
    animation: ringA 2s linear infinite;
}
.pl__ring--b { animation-name: ringB; }
.pl__ring--c { animation-name: ringC; }
.pl__ring--d { animation-name: ringD; }


/* ===== 底部主题切换开关 ===== */
.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}
.theme-label {
    font-size: 1.1rem;
    line-height: 1;
    user-select: none;
}
.theme-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}
.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-color);
    transition: 0.3s;
    border-radius: 34px;
}
.slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
/* 暗色模式下的开关状态 */
[data-theme="dark"] .slider {
    background: var(--accent);
}
[data-theme="dark"] .slider::before {
    transform: translateX(24px);
    background: #1e293b;
}
/* 亮色模式下的开关状态 */
[data-theme="light"] .slider {
    background: #cbd5e1;
}
[data-theme="light"] .slider::before {
    transform: translateX(0);
    background: #fff;
}
/* 悬停效果 */
.slider:hover {
    opacity: 0.85;
}


/* ===== 轮播图文字覆盖 ===== */
.carousel-slide {
    position: relative;
}
.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.carousel-caption {
    position: absolute;
    bottom: 30px;
    left: 30px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 500;
    backdrop-filter: blur(4px);
    border-left: 4px solid var(--accent);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    max-width: 70%;
    pointer-events: none;
    user-select: none;
}
/* 移动端调整 */
@media (max-width: 600px) {
    .carousel-caption {
        font-size: 0.8rem;
        padding: 6px 14px;
        bottom: 16px;
        left: 16px;
        max-width: 80%;
    }
}


/* ===== 底部链接（地图入口） ===== */
.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 8px 0;
}
.footer-links a {
    display: inline-block;
    padding: 6px 18px;
    background: var(--accent);
    color: #fff !important;
    border-radius: 30px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    font-size: 0.9rem;
    border: none;
}
.footer-links a:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
    text-decoration: none;
}
/* 暗色模式下保持高亮 */
[data-theme="dark"] .footer-links a {
    background: var(--accent);
    color: #fff !important;
}


/* ===== 文章元数据图标与文字对齐 ===== */
.post-card .meta span,
.article-meta span,
#articleMeta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.post-card .meta svg,
.article-meta svg,
#articleMeta svg {
    vertical-align: middle;
}