/* =========================================
   1. 基础变量与深色模式 (Dark Mode)
   ========================================= */
:root {
    --text-color: #333;
    --intro-color: #666;
    --card-bg: #fff;
    --card-shadow: rgba(0,0,0,0.05);
    --reader-bg: rgba(255, 255, 255, 0.98);
    --reader-text: #444;
    --reader-header-border: #eee;
}

/* 深色模式变量覆盖 */
body.dark-mode {
    --primary-color: #81C784; /* 绿色变浅一点，护眼 */
    --background-color: #1a1a1a !important; /* 强制覆盖 main.css */
    --text-color: #e0e0e0;
    --intro-color: #aaa;
    --card-bg: #2d2d2d;
    --card-shadow: rgba(0,0,0,0.3);
    --reader-bg: #242424; /* 阅读器深色背景 */
    --reader-text: #d0d0d0;
    --reader-header-border: #333;
}

/* 应用变量 */
body {
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1 {
	font-size: 3.5em;
    text-align: center;
    color: var(--text-color); /* 使用变量 */
    margin-bottom: 10px;
}

.intro-text {
    text-align: center;
    color: var(--intro-color);
    margin-bottom: 40px;
}

/* 日夜切换按钮样式 */
.theme-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    color: #666;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
}

.theme-btn:hover {
    background-color: #f0f0f0;
    color: var(--primary-color);
}

/* 深色模式下的按钮 */
body.dark-mode .theme-btn {
    border-color: #555;
    color: #aaa;
}
body.dark-mode .theme-btn:hover {
    background-color: #333;
    color: #fff;
}

/* =========================================
   2. 卡片样式
   ========================================= */
.text-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto 50px;
}

.text-card {
    background: var(--card-bg); /* 变量 */
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 15px var(--card-shadow);
    transition: transform 0.3s, box-shadow 0.3s, background-color 0.3s;
    cursor: pointer;
    border: 1px solid transparent; /* 预留边框 */
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* 深色模式下的卡片微调 */
body.dark-mode .text-card {
    border: 1px solid #333;
}

.text-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background-color: var(--primary-color);
    opacity: 0.7;
}

.text-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.card-icon {
    font-size: 24px;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 10px;
    line-height: 1.4;
}

.card-excerpt {
    font-size: 13px;
    color: var(--intro-color);
    line-height: 1.6;
    margin-bottom: 20px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #999;
    padding-top: 15px;
    border-top: 1px solid var(--reader-header-border);
}

.read-btn {
    color: var(--primary-color);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* =========================================
   3. 阅读器弹窗与过渡动画 (重点)
   ========================================= */
.reader-overlay {
    /* 关键修改：使用 visibility 和 opacity 来做过渡，而不是 display */
    visibility: hidden;
    opacity: 0;
    pointer-events: none; /* 隐藏时不可点击 */
    
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* 遮罩层背景 */
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* 这里的 transition 控制关闭时的动画 */
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
    backdrop-filter: blur(5px); /* 背景模糊效果 */
}

/* 显示状态 */
.reader-overlay.show {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.reader-container {
    width: 100%;
    max-width: 800px;
    height: 90%; /* 留出一点边距 */
    max-height: 90vh;
    background: var(--card-bg); /* 跟随日夜模式 */
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    border-radius: 12px; /* 圆角 */
    overflow: hidden;
    
    /* 容器的缩放动画 */
    transform: scale(0.95) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); /* 弹性效果 */
}

/* 弹窗出现时的状态 */
.reader-overlay.show .reader-container {
    transform: scale(1) translateY(0);
}

.reader-header {
    padding: 20px 40px;
    border-bottom: 1px solid var(--reader-header-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    transition: background-color 0.3s;
}

.reader-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--text-color);
}

.close-reader {
    font-size: 28px;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
    line-height: 1;
}

.close-reader:hover {
    color: var(--text-color);
}

.reader-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    padding-bottom: 100px;
    background-color: var(--reader-bg); /* 纸张颜色 */
    transition: background-color 0.3s;
}

.reader-meta {
    display: flex;
    gap: 20px;
    color: #999;
    font-size: 13px;
    margin-bottom: 20px;
    justify-content: center;
}

.reader-divider {
    width: 50px;
    height: 2px;
    background: var(--primary-color);
    margin: 0 auto 40px;
    opacity: 0.5;
}

.article-body {
    font-size: 17px; /* 稍微大一点更适合阅读 */
    line-height: 1.8;
    color: var(--reader-text);
    text-align: justify;
    font-family: var(--font-family);
    transition: color 0.3s;
}

.article-body p {
    margin-bottom: 25px;
    text-indent: 2em;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .reader-container {
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    .reader-content {
        padding: 20px;
    }
    .text-grid {
        padding: 0 20px;
    }
}