/* TxtPress 核心样式表
   Theme: Sichuan Game Master (Modern Grid) - v2.0
   Description: 适配新版 index.php 结构，修复移动端溢出，支持 <img> 标签封面图。
*/

:root {
    /* --- 核心色盘 (川红/麻将绿) --- */
    --primary-color: #c92a2a; 
    --text-color: #212529;
    --text-light: #868e96;
    --accent-color: #2b8a3e; 
    
    /* --- 布局参数 --- */
    --bg-body: #f8f9fa; 
    --bg-white: #ffffff;
    --container-width: 1100px; 
    --spacing-md: 20px;
    --spacing-lg: 40px;
    --radius: 12px;
    --shadow: 0 2px 10px rgba(0,0,0,0.03);
    --shadow-hover: 0 15px 30px rgba(0,0,0,0.08);
}

/* === 全局重置 === */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background-color: var(--bg-body);
    color: var(--text-color);
    line-height: 1.7;
    font-size: 16px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; transition: all 0.2s ease; }
a:hover { color: var(--primary-color); }

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    width: 100%;
}

/* === Header (顶部) === */
.site-header {
    background: var(--bg-white);
    border-bottom: 3px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo a {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
}
.logo a::before {
    content: "🀄"; 
    margin-right: 8px;
    font-size: 1.8rem;
}

/* === Navigation (导航) === */
.desktop-nav { display: flex; align-items: center; }
.desktop-nav a {
    margin-left: 25px;
    font-weight: 600;
    color: #495057;
    font-size: 1rem;
    padding: 5px 0;
    position: relative;
}
.desktop-nav a:hover, .desktop-nav a.active { color: var(--primary-color); }
.desktop-nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--primary-color);
    transition: width 0.3s;
}
.desktop-nav a:hover::after, .desktop-nav a.active::after { width: 100%; }

/* Mobile Menu Trigger */
.mobile-menu-trigger {
    display: none; 
    cursor: pointer;
    color: var(--text-color);
    padding: 8px;
    border-radius: 4px;
    background: #f1f3f5;
    align-items: center;
}
.trigger-text { margin-right: 5px; font-size: 0.9rem; font-weight: 600; }
.trigger-icon { font-size: 1.2rem; }

/* Mobile Overlay */
.mobile-menu-overlay {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255,255,255,0.98);
    backdrop-filter: blur(5px);
    z-index: 999; 
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.mobile-menu-header { display: flex; justify-content: flex-end; margin-bottom: 30px; }
.close-btn {
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 20px;
    color: var(--text-color);
}
.mobile-nav-links { display: flex; flex-direction: column; align-items: center; }
.mobile-nav-links a {
    font-size: 1.2rem;
    font-weight: 600;
    padding: 15px 0;
    width: 100%;
    text-align: center;
    border-bottom: 1px dashed #e9ecef;
    color: var(--text-color);
}

/* === Main Content === */
.site-main { flex: 1; padding-top: var(--spacing-lg); padding-bottom: var(--spacing-lg); }

.page-header { margin-bottom: 40px; text-align: center; position: relative; }
.page-header h1 { font-size: 2.2rem; color: var(--text-color); font-weight: 800; margin-bottom: 10px; }
.page-header::after {
    content: ""; display: block; width: 50px; height: 4px;
    background: var(--primary-color); margin: 20px auto 0; border-radius: 2px;
}

/* === Post List (网格布局 - 适配 <img> 标签) === */
.post-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
}

.post-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}
.post-card:hover { transform: translateY(-8px); box-shadow: var(--shadow-hover); }

/* 关键修改：让 img 标签适应网格并保持比例 */
.post-cover-link {
    display: block;
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 比例占位 */
    overflow: hidden;
}
.post-cover-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* 核心：裁剪图片以填充容器，不变形 */
    transition: transform 0.5s;
}
.post-card:hover .post-cover-img { transform: scale(1.05); }

.post-content { padding: 25px; flex: 1; display: flex; flex-direction: column; }

.post-meta {
    font-size: 0.8rem; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between;
}
.post-meta .cat {
    color: #fff; background-color: var(--accent-color);
    padding: 2px 10px; border-radius: 12px; font-weight: 600; font-size: 0.75rem;
    transition: background 0.2s;
}
.post-meta .cat:hover { background-color: var(--primary-color); }
.post-meta .date { color: #adb5bd; }

.post-card h2 { font-size: 1.25rem; margin-bottom: 12px; line-height: 1.4; font-weight: 700; }
.post-card h2 a:hover { color: var(--primary-color); }

.summary {
    color: #666; margin-bottom: 20px; font-size: 0.95rem; line-height: 1.6;
    flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.read-more {
    display: block; text-align: center; padding: 10px 0;
    background: #fff0f0; color: var(--primary-color);
    font-weight: 600; border-radius: 6px; font-size: 0.9rem; margin-top: auto;
}
.read-more:hover { background: var(--primary-color); color: #fff; }

.no-content { grid-column: 1 / -1; text-align: center; padding: 60px; border: 2px dashed #eee; }

/* === Pagination === */
.pagination { margin-top: 60px; display: flex; justify-content: center; align-items: center; gap: 10px; }
.btn {
    padding: 10px 24px; background: var(--bg-white); border: 1px solid #eee;
    border-radius: 50px; color: var(--text-color); font-weight: 600;
}
.btn:hover:not(.disabled) {
    background: var(--primary-color); color: #fff; border-color: var(--primary-color);
    transform: translateY(-2px); box-shadow: 0 4px 8px rgba(201, 42, 42, 0.3);
}
.btn.disabled { opacity: 0.6; cursor: not-allowed; background: #f1f3f5; }
.pagination .current { font-weight: 600; margin: 0 15px; color: var(--text-light); }

/* === Single Post (文章详情) === */
.single-post {
    background: var(--bg-white); padding: 60px; border-radius: var(--radius);
    box-shadow: var(--shadow); max-width: 900px; margin: 0 auto;
}
.single-header {
    text-align: center; margin-bottom: 50px; border-bottom: 1px solid #f1f3f5; padding-bottom: 30px;
}

/* === Breadcrumbs (面包屑) === */
.breadcrumb {
    font-size: 0.85rem; color: var(--text-light); margin-bottom: 25px;
    font-weight: 500; letter-spacing: 0.5px;
}
.breadcrumb a { color: var(--text-light); transition: color 0.2s; }
.breadcrumb a:hover { color: var(--primary-color); text-decoration: underline; }
.breadcrumb .sep { margin: 0 8px; color: #dee2e6; }
.breadcrumb span:last-child { color: var(--text-light); opacity: 0.8; cursor: default; }

.single-header h1 { font-size: 2.5rem; color: var(--text-color); margin-bottom: 15px; line-height: 1.2; }
.single-header .meta { margin-top: 15px; color: var(--text-light); font-size: 0.95rem; }
.single-header .cat-link {
    display: inline-block; background: var(--accent-color); color: #fff;
    padding: 4px 12px; border-radius: 4px; font-size: 0.9rem; margin-left: 10px;
}

/* Post Navigation */
.post-navigation { margin-top: 60px; padding-top: 40px; border-top: 1px solid #f1f3f5; }
.nav-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; }
.nav-previous, .nav-next { flex: 1; min-width: 200px; }
.nav-next { text-align: right; }
.nav-label { display: block; font-size: 0.85rem; color: #999; margin-bottom: 5px; }
.nav-links a { font-size: 1.1rem; font-weight: 700; color: var(--text-color); }
.nav-links a:hover { color: var(--primary-color); }

/* === Markdown Elements (正文优化) === */
.markdown-body { font-size: 1.125rem; color: #333; line-height: 1.9; }
.markdown-body h2 { 
    font-size: 1.8rem; border-left: 5px solid var(--primary-color); padding-left: 15px; 
    margin-top: 2em; background: linear-gradient(to right, #fff5f5, transparent);
}
.markdown-body h3 { color: var(--primary-color); margin-top: 1.5em; font-weight: 700; }
.markdown-body p { margin-bottom: 1.6em; text-align: justify; }

/* === 核心修复：防止图片溢出 (修复截图问题) === */
.markdown-body img { 
    max-width: 100%; /* 限制最大宽度 */
    height: auto;    /* 保持比例 */
    display: block;  
    margin: 20px auto; 
    border-radius: 8px; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.05); 
}

.markdown-body blockquote {
    border-left: 5px solid var(--accent-color); background: #f4fcf7;
    padding: 20px; color: #2b8a3e; font-style: italic; border-radius: 0 8px 8px 0;
}
.markdown-body pre {
    background: #212529; color: #f8f9fa; border-radius: 8px;
    padding: 20px; overflow-x: auto;
}
.markdown-body :not(pre) > code {
    background: #fff0f0; color: #c92a2a; padding: 2px 6px; font-size: 0.95em;
}

/* === Footer === */
.site-footer {
    background: #212529; color: #adb5bd; padding: 50px 0;
    margin-top: auto; text-align: center;
}
.site-footer a { color: #fff; border-bottom: 1px dotted #adb5bd; }

/* === Responsive Rules (手机端适配) === */
@media (max-width: 900px) {
    .container { max-width: 100%; }
    .post-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
    .single-post { padding: 30px 20px; }
    .single-header h1 { font-size: 1.8rem; }
}

@media (max-width: 768px) {
    .desktop-nav { display: none; }
    .mobile-menu-trigger { display: flex; }
    .header-inner { padding: 0 15px; height: 60px; }
    
    /* 手机端列表改为单列 */
    .post-list { display: flex; flex-direction: column; }
    .post-cover-link { padding-top: 50%; /* 调整手机端图片比例 */ }
    
    .pagination { flex-wrap: wrap; }
    .btn { padding: 8px 16px; font-size: 0.85rem; }
    
    .single-post { padding: 20px 15px; }
    .nav-next { text-align: left; margin-top: 20px; }
}