/* ============================================================
   Melov — a calm, minimal theme for Pelican
   Pure local CSS, no CDN dependencies.
   ============================================================ */

:root {
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --font-heading: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
                    "Songti SC", "SimSun", serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

    --bg: #ffffff;
    --bg-soft: #f7f7f5;
    --bg-code: #f2f2f0;
    --text: #2a2a2a;
    --text-soft: #6b6b6b;
    --heading: #1a1a1a;
    --accent: #3a6ea5;
    --accent-hover: #2d5a8a;
    --accent-bg: #eef3f8;
    --border: #e6e6e2;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16181d;
        --bg-soft: #1d2026;
        --bg-code: #24272e;
        --text: #c9cdd4;
        --text-soft: #9aa0aa;
        --heading: #e8eaee;
        --accent: #6ea8dc;
        --accent-hover: #8fbde8;
        --accent-bg: #20262e;
        --border: #2e323a;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
    }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 100%;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1.0625rem; /* 17px */
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color 0.25s ease, color 0.25s ease;
}

img { max-width: 100%; height: auto; border: 0; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.18s ease;
}
a:hover, a:focus { color: var(--accent-hover); }

/* ---------- Layout ---------- */
.wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 2.5rem;
    padding-top: 2.5rem;
    padding-bottom: 3rem;
    align-items: start;
}

@media (max-width: 860px) {
    .layout {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding-top: 1.75rem;
    }
}

/* ---------- Site header ---------- */
.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(1.2) blur(8px);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    padding-top: 1rem;
    padding-bottom: 1rem;
    gap: 0.5rem 1.5rem;
}

.site-title {
    font-family: var(--font-heading);
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--heading);
    margin: 0;
    letter-spacing: -0.01em;
}
.site-title a {
    color: inherit;
}
.site-title a:hover {
    color: var(--accent);
}

.site-subtitle {
    font-size: 0.875rem;
    color: var(--text-soft);
    margin: 0.15rem 0 0;
}

/* ---------- Navigation ---------- */
.nav-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-menu a {
    display: inline-block;
    font-size: 0.9375rem;
    color: var(--text);
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
    transition: color 0.18s ease, border-color 0.18s ease;
}
.nav-menu a:hover,
.nav-menu a.current,
.nav-menu a[aria-current="page"] {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.nav-toggle { display: none; }

/* ---------- Content ---------- */
.site-content { min-width: 0; }

/* ---------- Article list (home / author / category / tag) ---------- */
.post-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.post-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.post-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.post-card-title {
    font-family: var(--font-heading);
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 0.5rem;
}
.post-card-title a {
    color: var(--heading);
}
.post-card-title a:hover {
    color: var(--accent);
}

.post-meta {
    font-size: 0.875rem;
    color: var(--text-soft);
    margin-bottom: 0.625rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem 1rem;
}
.post-meta .dot::before {
    content: "·";
    margin-right: 1rem;
}

.post-card-summary {
    color: var(--text-soft);
    margin: 0 0 0.75rem;
}
.post-card-summary p { margin: 0; }

.read-more {
    display: inline-block;
    font-size: 0.875rem;
    font-weight: 500;
}

/* ---------- Single article / page ---------- */
.single-post, .page-body {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem 2.25rem;
    box-shadow: var(--shadow);
}
@media (max-width: 600px) {
    .single-post, .page-body { padding: 1.5rem 1.25rem; }
}

.entry-title {
    font-family: var(--font-heading);
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--heading);
    margin: 0 0 0.75rem;
}
@media (max-width: 600px) {
    .entry-title { font-size: 1.5rem; }
}

.post-info {
    font-size: 0.875rem;
    color: var(--text-soft);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
}
.post-info a {
    color: var(--accent);
}

/* ---------- Article content typography ---------- */
.entry-content { font-size: 1.0625rem; }
.entry-content > *:first-child { margin-top: 0; }
.entry-content > *:last-child { margin-bottom: 0; }

.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
    font-family: var(--font-heading);
    color: var(--heading);
    line-height: 1.35;
    margin: 1.75em 0 0.6em;
}
.entry-content h2 { font-size: 1.5rem; }
.entry-content h3 { font-size: 1.25rem; }
.entry-content h4 { font-size: 1.125rem; }

.entry-content p { margin: 0 0 1.125em; }

.entry-content ul,
.entry-content ol {
    margin: 0 0 1.125em;
    padding-left: 1.5em;
}
.entry-content li { margin-bottom: 0.35em; }
.entry-content li > ul,
.entry-content li > ol { margin-top: 0.35em; }

.entry-content blockquote {
    margin: 1.5em 0;
    padding: 0.5em 1.25em;
    border-left: 3px solid var(--accent);
    background: var(--bg-soft);
    color: var(--text-soft);
    font-style: italic;
}
.entry-content blockquote p:last-child { margin-bottom: 0; }

.entry-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--bg-code);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.entry-content pre {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1em 1.25em;
    overflow-x: auto;
    margin: 1.25em 0;
}
.entry-content pre code {
    background: none;
    border: none;
    padding: 0;
}

/* 语言标签 */
.highlight[data-language]::before {
    content: attr(data-language);
    display: block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    padding: 0.5em 1em 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
}

.entry-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2.25em 0;
}

.entry-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25em 0;
    font-size: 0.9375rem;
}
.entry-content th,
.entry-content td {
    border: 1px solid var(--border);
    padding: 0.5em 0.75em;
    text-align: left;
}
.entry-content th {
    background: var(--bg-soft);
    font-weight: 600;
    color: var(--heading);
}

.entry-content a {
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
    text-underline-offset: 2px;
}
.entry-content a:hover {
    text-decoration-color: var(--accent);
}

/* ---------- Tag list ---------- */
.tag-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0;
    margin: 1.25rem 0 0;
}
.tag-list li {
    font-size: 0.8125rem;
}
.tag-list a {
    display: inline-block;
    padding: 0.15em 0.65em;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 4px;
    border: 1px solid var(--border);
    transition: background-color 0.18s ease, border-color 0.18s ease;
}
.tag-list a:hover {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

/* ---------- Sidebar ---------- */
.site-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
@media (max-width: 860px) {
    .site-sidebar { flex-direction: row; flex-wrap: wrap; }
    .site-sidebar .widget { flex: 1 1 240px; }
}

.widget {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.375rem;
    box-shadow: var(--shadow);
}

.widget-title {
    font-family: var(--font-heading);
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--heading);
    margin: 0 0 0.625rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.widget-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}
.widget-list li { font-size: 0.9375rem; }
.widget-list .count { color: var(--text-soft); font-size: 0.875rem; }

.widget-tags {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.widget-tags a {
    display: inline-block;
    font-size: 0.8125rem;
    padding: 0.15em 0.6em;
    background: var(--bg-soft);
    color: var(--text-soft);
    border-radius: 4px;
    transition: background-color 0.18s ease, color 0.18s ease;
}
.widget-tags a:hover {
    background: var(--accent);
    color: var(--bg);
}

.widget-about p {
    font-size: 0.9375rem;
    color: var(--text-soft);
    margin: 0 0 0.5rem;
}
.widget-about p:last-child { margin-bottom: 0; }
.widget-about .about-author {
    color: var(--heading);
    font-weight: 600;
    font-size: 1rem;
}

/* ---------- Archives / simple lists ---------- */
.archive-list, .category-list, .author-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.archive-list li, .category-list li, .author-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9375rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}
.archive-list li:last-child, .category-list li:last-child, .author-list li:last-child {
    border-bottom: none;
}
.archive-list .date { color: var(--text-soft); font-size: 0.875rem; white-space: nowrap; }

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.75rem;
    font-size: 0.9375rem;
}
.pagination a {
    display: inline-block;
    padding: 0.4em 0.9em;
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.pagination a:hover {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}
.pagination .prev { margin-right: auto; }
.pagination .next { margin-left: auto; }

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    font-size: 0.875rem;
    color: var(--text-soft);
}
.site-footer p { margin: 0; }
.site-footer .beian {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.4rem 1rem;
}
.site-footer .beian a {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
}
.site-footer .beian-icon {
    width: 1.15em;
    height: 1.15em;
    object-fit: contain;
    border-radius: 2px;
}
.site-footer a { color: var(--accent); }

/* ---------- Utilities ---------- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--accent);
    color: #fff;
    padding: 0.5em 1em;
    z-index: 100;
    border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

.empty-state {
    text-align: center;
    color: var(--text-soft);
    padding: 2.5rem 0;
}

/* ---------- Print ---------- */
@media print {
    .site-header, .site-sidebar, .site-footer, .pagination { display: none; }
    .layout { grid-template-columns: 1fr; padding: 0; }
    body { background: #fff; color: #000; font-size: 12pt; }
    .single-post, .post-card { box-shadow: none; border: none; }
    .entry-content a { color: #000; text-decoration: none; }
}
