/* ═══════════════════════════════════════════════════════════
   py2htmlblog  Default Theme  —  style.css
   Clean, modern, reading-focused design
   ═══════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg:          #fafafa;
    --card-bg:     #ffffff;
    --text:        #2c2c2c;
    --text-light:  #666;
    --text-muted:  #999;
    --accent:      #2563eb;
    --accent-hover:#1d4ed8;
    --border:      #e5e5e5;
    --border-light:#f0f0f0;
    --code-bg:     #1e1e2e;
    --code-fg:     #cdd6f4;
    --radius:      6px;
    --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
                   "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono:   "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}
a:hover { color: var(--accent-hover); }

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ── Header ────────────────────────────────────────────── */
.site-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 24px 0 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-branding {
    margin-bottom: 16px;
}

.site-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.site-title a {
    color: var(--text);
}
.site-title a:hover { color: var(--accent); }

.site-tagline {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.site-nav {
    display: flex;
    gap: 4px;
    padding-bottom: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-link {
    display: inline-block;
    padding: 8px 16px;
    font-size: 0.875rem;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.nav-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.nav-link.nav-rss {
    margin-left: auto;
    color: #f97316;
    font-weight: 600;
}

/* ── Main Content ──────────────────────────────────────── */
.site-main {
    padding: 32px 0 48px;
    min-height: 60vh;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

/* ── Post Card (列表页) ────────────────────────────────── */
.post-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    transition: box-shadow 0.2s;
}
.post-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.post-card .post-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 8px;
}
.post-card .post-title a {
    color: var(--text);
}
.post-card .post-title a:hover {
    color: var(--accent);
}

.post-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.post-meta a { color: var(--text-light); }
.post-meta a:hover { color: var(--accent); }

.post-excerpt {
    font-size: 0.9375rem;
    color: var(--text-light);
    line-height: 1.75;
    margin-bottom: 12px;
}

.read-more {
    display: inline-block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent);
}
.read-more:hover { color: var(--accent-hover); }

/* ── Post Full (文章详情) ──────────────────────────────── */
.post-full {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.post-full .post-title {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.35;
    margin-bottom: 12px;
    color: var(--text);
}

.post-content {
    font-size: 1rem;
    line-height: 1.85;
    color: #333;
}

/* Typography inside post content */
.post-content h1 { font-size: 1.6rem; margin: 28px 0 14px; }
.post-content h2 { font-size: 1.4rem; margin: 24px 0 12px; }
.post-content h3 { font-size: 1.2rem; margin: 20px 0 10px; }
.post-content h4 { font-size: 1.05rem; margin: 18px 0 8px; }
.post-content p { margin-bottom: 16px; }
.post-content a { text-decoration: underline; text-underline-offset: 2px; }

.post-content ul, .post-content ol {
    margin: 12px 0 16px 24px;
}
.post-content li { margin-bottom: 6px; }

.post-content blockquote {
    border-left: 3px solid var(--accent);
    margin: 16px 0;
    padding: 8px 20px;
    background: #f8fafc;
    color: var(--text-light);
    font-style: italic;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.post-content pre {
    background: var(--code-bg);
    color: var(--code-fg);
    padding: 16px 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 16px 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.65;
}

.post-content code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.875em;
    color: #d63384;
}
.post-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.post-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
}
.post-content th, .post-content td {
    border: 1px solid var(--border);
    padding: 10px 14px;
    text-align: left;
}
.post-content th {
    background: #f5f7fa;
    font-weight: 600;
    font-size: 0.875rem;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
}

.post-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

/* Post footer */
.post-footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.tag-link {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.75rem;
    color: var(--accent);
    background: #eff6ff;
    border-radius: 12px;
    transition: background 0.15s;
}
.tag-link:hover {
    background: #dbeafe;
    color: var(--accent-hover);
}

.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.post-nav-prev, .post-nav-next {
    font-size: 0.875rem;
    color: var(--text-light);
    max-width: 48%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.post-nav-prev:hover, .post-nav-next:hover { color: var(--accent); }

.post-comments {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.related-posts {
    margin-top: 24px;
    padding: 16px 20px;
    background: #f8fafc;
    border-radius: var(--radius);
}
.related-posts h3 {
    font-size: 0.9375rem;
    margin-bottom: 8px;
    color: var(--text);
}
.related-posts ul { margin-left: 20px; }
.related-posts li { margin-bottom: 4px; font-size: 0.875rem; }

/* ── Pagination ────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
    padding: 16px 0;
}

.page-btn {
    display: inline-block;
    padding: 8px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    transition: all 0.15s;
}
.page-btn:hover {
    background: var(--accent);
    color: #fff;
}

.page-info {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ── Archives / Category / Tag / Year / Month Lists ────── */
.archive-list {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.archive-group {
    margin-bottom: 24px;
}
.archive-group:last-child { margin-bottom: 0; }

.archive-year-month {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}
.archive-year-month .count {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

.archive-posts {
    list-style: none;
    padding: 0;
}
.archive-posts li {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 6px 0;
    font-size: 0.875rem;
}
.archive-posts li time {
    color: var(--text-muted);
    font-size: 0.8125rem;
    white-space: nowrap;
    min-width: 80px;
    font-family: var(--font-mono);
}
.archive-posts li a { color: var(--text); }
.archive-posts li a:hover { color: var(--accent); }

/* ── Categories Grid ───────────────────────────────────── */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.category-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    font-weight: 600;
    color: var(--accent);
    transition: all 0.15s;
}
.category-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(37,99,235,0.1);
}

/* ── Tag Cloud ─────────────────────────────────────────── */
.tag-cloud-large {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.tag-item {
    display: inline-block;
    padding: 6px 14px;
    background: #eff6ff;
    color: var(--accent);
    border-radius: 16px;
    font-size: 0.875rem;
    transition: all 0.15s;
}
.tag-item:hover {
    background: var(--accent);
    color: #fff;
}
.tag-count {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-left: 2px;
}

/* ── Footer ────────────────────────────────────────────── */
.site-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 40px 0 24px;
}

.footer-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.footer-widget h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.footer-widget ul {
    list-style: none;
    padding: 0;
}
.footer-widget ul li {
    padding: 4px 0;
    font-size: 0.8125rem;
}
.footer-widget ul li a {
    color: var(--text-light);
}
.footer-widget ul li a:hover {
    color: var(--accent);
}

.footer-widget .tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.footer-widget .tag-cloud a {
    display: inline-block;
    padding: 3px 10px;
    background: #f0f0f0;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-light);
}
.footer-widget .tag-cloud a:hover {
    background: #eff6ff;
    color: var(--accent);
}
.footer-widget .tag-cloud sup {
    font-size: 0.65rem;
    opacity: 0.6;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.footer-bottom p { margin-bottom: 4px; }
.footer-bottom a {
    color: var(--text-light);
}
.footer-bottom a:hover { color: var(--accent); }

/* ── Back to Top ───────────────────────────────────────── */
.back-to-top {
    display: none;
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 42px;
    height: 42px;
    line-height: 42px;
    text-align: center;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: 700;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: background 0.2s, transform 0.2s;
}
.back-to-top:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    color: #fff;
}

/* ── Empty State ───────────────────────────────────────── */
.empty {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 40px 0;
}

/* ── Page (独立页面) ────────────────────────────────────── */
.page-content .post-title {
    margin-bottom: 24px;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
    html { font-size: 15px; }

    .site-header { padding: 16px 0 0; }
    .site-nav { gap: 0; }

    .post-full { padding: 20px; }

    .post-nav {
        flex-direction: column;
        gap: 8px;
    }
    .post-nav-prev, .post-nav-next {
        max-width: 100%;
    }

    .archive-posts li {
        flex-direction: column;
        gap: 0;
    }

    .footer-widgets {
        grid-template-columns: 1fr;
    }

    .back-to-top {
        bottom: 16px;
        right: 16px;
    }
}
