/*
Theme Name: Kestrel
Description: 面向长期内容站的中文经典主题，右侧栏布局，紧凑文字列表，多列页脚。
Author: 西行手册
Text Domain: kestrel
*/

:root {
    --bg: #f5efe7;
    --fg: #2b2521;
    --muted: #8b7d70;
    --border: #e2d6c8;
    --radius: 4px;
    --shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    --accent: #b0512b;
    --accent-soft: #c98f7d;
    --card-bg: #fdfaf5;
    --gap: 20px;
    --media-ratio: 16 / 9;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background-color: var(--bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23g)'/%3E%3C/svg%3E");
    color: var(--fg);
    font-family: 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 18px;
    line-height: 1.75;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

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

h1, h2, h3, h4 { font-weight: 700; line-height: 1.4; }

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

/* ---------- Header ---------- */

.site-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: var(--gap);
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 20px;
}

.site-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    white-space: nowrap;
}
.site-title a { color: var(--fg); }
.site-title a:hover { text-decoration: none; color: var(--accent); }

.primary-nav { margin-left: auto; }

.primary-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 4px;
}

.primary-nav li { position: relative; }

.primary-nav a {
    display: block;
    padding: 8px 12px;
    color: var(--fg);
    font-size: 16px;
    border-radius: var(--radius);
}
.primary-nav a:hover { background: var(--bg); text-decoration: none; color: var(--accent); }

.primary-nav .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-direction: column;
    padding: 6px;
    z-index: 100;
}
.primary-nav li:hover > .sub-menu,
.primary-nav li:focus-within > .sub-menu,
.primary-nav li.sub-open > .sub-menu { display: flex; }

.primary-nav .sub-menu a { font-size: 15px; padding: 7px 12px; white-space: nowrap; }

.menu-toggle {
    display: none;
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    cursor: pointer;
    color: var(--fg);
    font-size: 16px;
}

.header-search { flex-shrink: 0; }
.header-search .search-form { display: flex; }
.header-search .search-field {
    width: 160px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 14px;
    background: #fff;
    color: var(--fg);
}
.header-search .search-submit {
    padding: 7px 14px;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}
.header-search .search-submit:hover { background: #94421f; }

/* ---------- Hero ---------- */

.hero {
    text-align: center;
    padding: 64px 20px 56px;
    border-bottom: 1px solid var(--border);
}
.hero-compass { margin-bottom: 18px; }
.hero-title {
    margin: 0 0 12px;
    font-size: 34px;
}
.hero-desc {
    margin: 0 auto;
    max-width: 680px;
    color: var(--muted);
    font-size: 17px;
}

/* ---------- Layout ---------- */

.layout {
    display: flex;
    gap: var(--gap);
    align-items: flex-start;
    padding-top: 32px;
    padding-bottom: 48px;
}

.content-area { flex: 1; min-width: 0; }

.sidebar {
    width: 280px;
    flex-shrink: 0;
}

/* ---------- Breadcrumb ---------- */

.breadcrumb {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 20px;
}
.breadcrumb .crumb { color: var(--muted); }
.breadcrumb .crumb:hover { color: var(--accent); }
.breadcrumb .trail { margin: 0 6px; }
.breadcrumb .current { color: var(--fg); }

/* ---------- Post list (compact text list) ---------- */

.post-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.list-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }

.list-title {
    margin: 0 0 6px;
    font-size: 19px;
}
.list-title a { color: var(--fg); }
.list-title a:hover { color: var(--accent); text-decoration: none; }

.list-meta {
    font-size: 14px;
    color: var(--muted);
    display: flex;
    gap: 14px;
}
.list-meta a { color: var(--muted); }
.list-meta a:hover { color: var(--accent); }

.archive-heading {
    margin: 0 0 20px;
    font-size: 26px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}
.archive-desc { color: var(--muted); font-size: 15px; margin: 12px 0 24px; }

/* ---------- Pagination ---------- */

.pagination {
    margin-top: 28px;
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.pagination .page-numbers {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--fg);
    font-size: 15px;
}
.pagination .page-numbers.current {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.pagination a.page-numbers:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.pagination .page-numbers.current:hover { color: #fff; }

/* ---------- Single post ---------- */

article.single-post {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
}

.post-heading { margin: 0 0 12px; font-size: 30px; }

/* 页面模板标题后无 meta,加大与正文的间距,接近段落间距(1.4em) */
body.page .post-heading { margin-bottom: 24px; }

.post-meta {
    font-size: 14px;
    color: var(--muted);
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.post-meta a { color: var(--muted); }
.post-meta a:hover { color: var(--accent); }

.post-featured { margin-bottom: 24px; }
.post-featured img {
    display: block;
    border-radius: var(--radius);
    aspect-ratio: var(--media-ratio);
    object-fit: cover;
    width: 100%;
}

.article-note {
    background: #f8ebe4;
    border-left: 3px solid var(--accent-soft);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 14px 18px;
    margin-bottom: 24px;
    font-size: 15px;
    color: #6b5347;
}

.post-body { overflow-wrap: break-word; }
.post-body p { margin: 0 0 1.4em; }
.post-body .table-wrap { overflow-x: auto; margin: 0 0 1.4em; }
.post-body .table-wrap table { margin: 0; }
.post-body h2 { font-size: 24px; margin: 1.6em 0 0.7em; padding-left: 12px; border-left: 4px solid var(--accent); }
.post-body h3 { font-size: 20px; margin: 1.5em 0 0.6em; }
.post-body ul, .post-body ol { margin: 0 0 1.4em; padding-left: 1.6em; }
.post-body blockquote {
    margin: 0 0 1.4em;
    padding: 4px 0 4px 18px;
    border-left: 3px solid var(--border);
    color: var(--muted);
}
.post-body code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: var(--radius);
    font-size: 15px;
}
.post-body pre {
    background: #33291f;
    color: #f0e6da;
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 14px;
}
.post-body pre code { background: none; padding: 0; color: inherit; }
.post-body table { width: 100%; border-collapse: collapse; margin: 0 0 1.4em; font-size: 15px; }
.post-body th, .post-body td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
    overflow-wrap: normal;
    word-break: normal;
}
.post-body th { background: var(--bg); }

.post-tags { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 14px; }
.post-tags a {
    display: inline-block;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px 10px;
    margin: 0 6px 6px 0;
    color: var(--muted);
    font-size: 13px;
}
.post-tags a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* ---------- Author bio ---------- */

.author-bio {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-top: 32px;
    padding: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.author-bio .avatar { border-radius: 50%; flex-shrink: 0; }
.author-name { margin: 0 0 6px; font-size: 17px; font-weight: 700; }
.author-name a { color: var(--fg); }
.author-name a:hover { color: var(--accent); }
.author-desc { margin: 0; font-size: 14px; color: var(--muted); }

/* ---------- Related posts ---------- */

.related-posts { margin-top: 36px; }
.related-heading { font-size: 20px; margin: 0 0 16px; }
.related-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap);
}
.related-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
}
.related-card h3 { margin: 0 0 8px; font-size: 15px; line-height: 1.5; }
.related-card h3 a { color: var(--fg); }
.related-card h3 a:hover { color: var(--accent); text-decoration: none; }
.related-card time { font-size: 13px; color: var(--muted); }

/* ---------- Comments ---------- */

.comments-area { margin-top: 36px; }
.comments-title, .comment-reply-title { font-size: 20px; }
.comment-list { list-style: none; margin: 0 0 24px; padding: 0; }
.comment-list .comment {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 14px;
}
.comment-list .children { list-style: none; padding-left: 24px; margin-top: 14px; }
.comment-meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.comment-meta .fn { color: var(--fg); font-weight: 700; font-size: 14px; }
.comment-content p { margin: 0 0 0.8em; font-size: 15px; }
.comment-form label { display: block; font-size: 14px; margin-bottom: 4px; }
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: var(--fg);
}
.comment-form .submit {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 10px 26px;
    font-size: 15px;
    cursor: pointer;
}
.comment-form .submit:hover { background: #94421f; }

/* ---------- Sidebar ---------- */

.side-block {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: var(--gap);
}
.side-heading {
    margin: 0 0 14px;
    font-size: 17px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent);
}
.side-block ul { list-style: none; margin: 0; padding: 0; }
.side-block li { padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 15px; }
.side-block li:last-child { border-bottom: none; }
.side-block li a { color: var(--fg); }
.side-block li a:hover { color: var(--accent); }
.side-block .search-form { display: flex; }
.side-block .search-field {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 14px;
    background: #fff;
    color: var(--fg);
}
.side-block .search-submit {
    padding: 8px 14px;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

/* ---------- Footer ---------- */

.site-footer {
    background: #33291f;
    color: #cbbdab;
    margin-top: 24px;
}
.footer-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 44px 20px 28px;
}
.footer-main {
    display: flex;
    gap: 48px;
    align-items: flex-start;
    margin-bottom: 28px;
}
.footer-brand {
    flex-shrink: 0;
    width: 220px;
}
.footer-site-name {
    color: #f0e6da;
    font-size: 20px;
    font-weight: 700;
}
.footer-site-name:hover { color: var(--accent-soft); text-decoration: none; }
.footer-nav { flex: 1; min-width: 0; }
.footer-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--gap);
}
.footer-heading {
    display: block;
    font-weight: 700;
    color: #f0e6da;
    font-size: 16px;
    margin-bottom: 12px;
}
.footer-sub { list-style: none; margin: 0; padding: 0; }
.footer-sub li { margin-bottom: 8px; }
.footer-sub a { color: #cbbdab; font-size: 14px; }
.footer-sub a:hover { color: var(--accent-soft); text-decoration: none; }
.footer-note {
    font-size: 13px;
    color: #9a8b78;
    border-top: 1px solid #4a3d30;
    padding-top: 18px;
    margin: 0 0 8px;
}
.copyright {
    font-size: 13px;
    color: #9a8b78;
    margin: 0;
}

/* ---------- 404 ---------- */

.not-found-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 48px 32px;
    text-align: center;
}
.not-found-box .search-form { display: flex; max-width: 420px; margin: 20px auto 0; }
.not-found-box .search-field {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 15px;
    background: #fff;
}
.not-found-box .search-submit {
    padding: 10px 20px;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; }
    .related-grid { grid-template-columns: repeat(2, 1fr); }
    .footer-main { flex-direction: column; gap: 24px; }
    .footer-brand { width: auto; }

    .header-inner { flex-wrap: wrap; }
    .menu-toggle { display: block; }
    .primary-nav {
        display: none;
        width: 100%;
        margin-left: 0;
        order: 4;
    }
    .primary-nav.nav-open { display: block; }
    .primary-nav ul { flex-direction: column; gap: 0; }
    .primary-nav a { padding: 10px 12px; }
    .primary-nav .sub-menu {
        position: static;
        border: none;
        box-shadow: none;
        background: var(--bg);
        padding-left: 16px;
    }
    .primary-nav li:hover > .sub-menu,
    .primary-nav li:focus-within > .sub-menu { display: none; }
    .primary-nav li.sub-open > .sub-menu { display: flex; }
    .header-search { display: none; }
}

@media (max-width: 560px) {
    body { font-size: 16px; }
    article.single-post { padding: 20px; }
    .post-heading { font-size: 24px; }
    .hero-title { font-size: 26px; }
    .related-grid { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; }
    .list-title, .post-heading, .hero-title, .archive-heading { overflow-wrap: break-word; }
}
