/* ========================================
   古诗词苑 - 样式表
   字体：微软雅黑
   ======================================== */

/* 1. CSS 变量（便于主题定制） */
:root {
    --color-bg: #f9f9f8;
    --color-white: #ffffff;
    --color-text-primary: #111827;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;
    --color-border: #e5e7eb;
    --color-accent: #1f2937;
    --color-accent-hover: #374151;
    --color-link-hover: #1e3a8a;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    /* 【修改】字体改为微软雅黑，并提供跨平台回退方案 */
    --font-main: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

/* 2. 基础重置 */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* 3. 全局样式 */
body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
}

/* 4. 容器布局 */
.container {
    max-width: 896px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .container {
        padding: 2rem;
    }
}

/* 5. 头部样式 */
.site-header {
    text-align: center;
    padding: 1.5rem 0;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .site-header {
        margin-bottom: 2.5rem;
    }
}

.site-title {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
    .site-title {
        font-size: 2.25rem;
    }
}

.site-title a {
    transition: color 0.2s ease;
}

.site-title a:hover {
    color: var(--color-link-hover);
}

.site-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-style: italic;
}

@media (min-width: 768px) {
    .site-subtitle {
        font-size: 1rem;
    }
}

/* 6. 主内容区 */
.main-content {
    flex: 1;
}

/* 7. 诗歌网格布局 */
.poem-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .poem-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* 8. 诗歌卡片 */
.poem-card {
    background-color: var(--color-white);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border-top: 4px solid var(--color-accent);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease;
}

.poem-card:hover {
    box-shadow: var(--shadow-md);
}

.poem-link {
    display: block;
    flex: 1;
}

.poem-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
    transition: color 0.2s ease;
}

@media (min-width: 768px) {
    .poem-title {
        font-size: 1.5rem;
    }
}

.poem-link:hover .poem-title {
    color: var(--color-link-hover);
}

.poem-author {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
    font-family: var(--font-main);
}

.poem-preview {
    font-size: 0.875rem;
    color: var(--color-text-primary);
    line-height: 1.75;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: pre-wrap;
}

@media (min-width: 768px) {
    .poem-preview {
        font-size: 1rem;
    }
}

.poem-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    text-align: right;
}

.read-more {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    transition: color 0.2s ease;
}

.poem-link:hover .read-more {
    color: var(--color-link-hover);
}

/* 9. 空状态 */
.empty-state {
    grid-column: 1 / -1;
    padding: 4rem 1.5rem;
    text-align: center;
    background-color: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: var(--color-text-muted);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-title {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.empty-hint {
    font-size: 0.875rem;
}

/* 10. 分页导航 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 3rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

@media (min-width: 768px) {
    .pagination {
        gap: 1rem;
    }
}

.pagination-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    text-align: center;
}

.pagination-btn-primary {
    background-color: var(--color-accent);
    color: var(--color-white);
}

.pagination-btn-primary:hover {
    background-color: var(--color-accent-hover);
}

.pagination-btn-secondary {
    background-color: var(--color-white);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

.pagination-btn-secondary:hover {
    background-color: var(--color-bg);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    padding: 0 0.5rem;
}

@media (min-width: 768px) {
    .pagination-info {
        padding: 0 1rem;
    }
}

/* 11. 页脚 */
.site-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    padding: 1.5rem 0;
    border-top: 1px solid var(--color-border);
}

/* 12. 打印样式优化 */
@media print {
    .pagination,
    .site-footer,
    .read-more {
        display: none;
    }
    
    .poem-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
/* 3列网格（每页6首最适合这种布局） */
.poem-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* 详情页头像 */
.avatar-img {
    width: 50px; height: 50px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 10px;
    border: 2px solid #f0f0f0;
}

/* 标签样式 */
.tag-badge {
    font-size: 12px;
    color: #888;
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 5px;
    text-decoration: none;
}
.tag-badge:hover { background: #eee; }
/* 详情页书卷风格 */
.poem-detail-card {
    background: #fff;
    border: 1px solid #dcdcdc;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    background-image: linear-gradient(to right, rgba(200,200,200,0.05) 1px, transparent 1px);
    background-size: 30px 100%; /* 模拟竖线稿纸感 */
}

.poem-section {
    margin-top: 30px;
    padding: 20px;
    background: #fdfdfd;
    border-left: 4px solid #1f2937;
}

.poem-section h3 {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 15px;
    border-bottom: 1px dashed #eee;
    padding-bottom: 5px;
}

.section-content {
    color: #4b5563;
    font-size: 1rem;
    line-height: 1.8;
}
/* --- 移动端适配与折叠面板 --- */

/* --- 移动端详情页优化 --- */
@media (max-width: 600px) {
    .container { padding: 1rem 0.5rem; }
    .poem-card-detail { padding: 1.5rem 1rem !important; }
    .poem-detail-content { font-size: 1.25rem !important; margin: 1.5rem 0 !important; }
}

/* --- 详情页深度适配 --- */

/* --- 详情页深度适配 --- */

/* 1. 作者信息布局：顶对齐 */
.author-info {
    display: flex;
    gap: 20px;
    align-items: flex-start; /* 顶部对齐 */
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

/* 2. 头像 (105x150) */
.author-avatar {
    width: 105px;
    height: 150px;
    border-radius: 8px; /* 圆角处理 */
    object-fit: cover;
    flex-shrink: 0;
}

/* 3. 右侧内容区 */
.author-content-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* 关键：防止过长的连续文本撑破 flex 容器 */
}

.author-name-line {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 10px;
}

/* 4. 详情页标题：左对齐 */
.poem-detail-title {
    text-align: left !important;
    font-size: 1.8rem;
    margin: 1.5rem 0 1rem;
    color: #111;
}

/* 5. 折叠面板样式优化 */
.poem-section {
    margin-top: 10px;
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 6px;
}

.poem-section summary {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--color-text-secondary);
    list-style: none; /* 隐藏原生箭头 */
    display: flex;
    justify-content: space-between;
}

/* 自定义右侧箭头指示器 */
.poem-section summary::after { content: "▼"; font-size: 0.7rem; opacity: 0.5; }
.poem-section[open] summary::after { content: "▲"; }

.section-content {
    padding: 10px 12px;
    font-size: 0.95rem;
    line-height: 1.6;
    border-top: 1px solid #eee;
}

/* 6. 移动端边距缩窄 */
@media (max-width: 600px) {
    .poem-card-detail {
        padding: 1.5rem 1rem !important; /* 缩窄内边距 */
    }
}
/* --- 搜索框列一排 --- */
.search-form {
    display: flex;
    align-items: center;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.search-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--color-border);
    border-radius: 4px 0 0 4px;
    outline: none;
}

.search-btn {
    padding: 10px 20px;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

/* --- 详情页：返回列表固定置顶 --- */
.sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(249, 249, 248, 0.9); /* 半透明背景 */
    backdrop-filter: blur(5px);
    z-index: 100;
    padding: 10px 20px;
    border-bottom: 1px solid var(--color-border);
    max-width: 896px;
    margin: 0 auto;
}

.sticky-header a {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* --- 详情页：折叠面板边距调窄 --- */
.poem-section {
    margin-top: 8px; /* 减小面板间的间距 */
    background: #fdfdfd;
}

.poem-section summary {
    padding: 6px 10px; /* 减小内边距 */
    font-size: 0.85rem;
}

.section-content {
    padding: 8px 10px; /* 减小展开后的内边距 */
    font-size: 0.95rem;
    color: #444;
}

/* --- 页脚样式 --- */
.site-footer {
    margin-top: auto;
    padding: 2rem 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
