/* ============================================================
   base.css · 结构基准层（四套主题共用，勿写主题化视觉）
   - 间距/字号/颜色全部走 :root 变量，8pt 间距刻度
   - 深浅两套色板集中定义，语义变量按 prefers-color-scheme 切换
   - 类名即全局契约（.site-header/.card/.btn/...），
     主题只在各自 theme.css 里覆写视觉，不改结构
   - 无 @import、无外部字体、无第三方库
   ============================================================ */

:root {
    /* ---- 8pt 间距刻度 ---- */
    --sp-1: 0.5rem;   /*  8px */
    --sp-2: 1rem;     /* 16px */
    --sp-3: 1.5rem;   /* 24px */
    --sp-4: 2rem;     /* 32px */
    --sp-6: 3rem;     /* 48px */
    --sp-8: 4rem;     /* 64px */
    --sp-10: 5rem;    /* 80px */

    /* ---- 字号刻度 ---- */
    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-md: 1.125rem;
    --fs-lg: 1.5rem;
    --fs-xl: 2rem;
    --fs-2xl: 2.5rem;

    /* ---- 行高 ---- */
    --lh-tight: 1.25;
    --lh-body: 1.75;

    /* ---- 字体栈（系统可得字体 + generic 兜底，无外部加载）---- */
    --font-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC",
                 "Source Han Sans SC", "Helvetica Neue", Arial, system-ui, sans-serif;
    --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun,
                  Georgia, serif;

    /* ---- 版式 ---- */
    --container: 72rem;      /* 1152px */
    --radius: 4px;
    --radius-lg: 8px;
    --transition: 160ms ease;

    /* ---- 亮色板（WCAG AA：正文对比 >= 12:1，弱文 >= 6:1）---- */
    --lt-bg: #ffffff;
    --lt-bg-soft: #f4f5f7;
    --lt-bg-mute: #e8eaee;
    --lt-text: #1f2428;
    --lt-text-soft: #525d68;
    --lt-line: #d3d8de;
    --lt-accent: #1d4ed8;
    --lt-accent-text: #ffffff;

    /* ---- 暗色板 ---- */
    --dk-bg: #15181c;
    --dk-bg-soft: #1c2025;
    --dk-bg-mute: #272c33;
    --dk-text: #e8eaee;
    --dk-text-soft: #a6b0ba;
    --dk-line: #383f48;
    --dk-accent: #8ab4f8;
    --dk-accent-text: #10141a;

    /* ---- 语义映射（默认亮色，随系统切深色）---- */
    --bg: var(--lt-bg);
    --bg-soft: var(--lt-bg-soft);
    --bg-mute: var(--lt-bg-mute);
    --text: var(--lt-text);
    --text-soft: var(--lt-text-soft);
    --line: var(--lt-line);
    --accent: var(--lt-accent);
    --accent-text: var(--lt-accent-text);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: var(--dk-bg);
        --bg-soft: var(--dk-bg-soft);
        --bg-mute: var(--dk-bg-mute);
        --text: var(--dk-text);
        --text-soft: var(--dk-text-soft);
        --line: var(--dk-line);
        --accent: var(--dk-accent);
        --accent-text: var(--dk-accent-text);
    }
}

/* ============ 基础 ============ */

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

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

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-body);
    color: var(--text);
    background: var(--bg);
}

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

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3, h4 { line-height: var(--lh-tight); text-wrap: balance; }

/* 焦点可见——无障碍验收项，任何主题不得移除 */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius);
}

/* 屏幕阅读器专用 */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* 跳转正文的无障碍链接：首个可聚焦元素 */
.skip-link {
    position: absolute;
    left: var(--sp-1);
    top: var(--sp-1);
    z-index: 100;
    padding: var(--sp-1) var(--sp-2);
    background: var(--accent);
    color: var(--accent-text);
    border-radius: var(--radius);
    text-decoration: none;
    transform: translateY(-200%);   /* 不可见但保持可聚焦 */
}
.skip-link:focus { transform: none; }

/* 内容容器 */
.page-wrap {
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--sp-3);
}

.site-main { min-height: 50vh; }

/* ============ 页头 / 导航 ============ */

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

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    min-height: var(--sp-8);
    padding-block: var(--sp-1);
    flex-wrap: wrap;
}

.brand {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}
.brand:hover { color: var(--accent); }

.nav-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-1);
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item { position: relative; }

.nav-link {
    display: inline-block;
    padding: var(--sp-1) var(--sp-2);
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: var(--fs-md);
}

.nav-link:hover { color: var(--accent); background: var(--bg-soft); }

.nav-link.is-active {
    color: var(--accent);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--accent);
}

/* 二级下拉：桌面 hover / 键盘 focus-within 均可达 */
.nav-item > .nav-list {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    display: none;
    flex-direction: column;
    min-width: 10rem;
    padding: var(--sp-1);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: 0 var(--sp-1) var(--sp-3) rgba(0, 0, 0, 0.12);
}

.nav-item:hover > .nav-list,
.nav-item:focus-within > .nav-list { display: flex; }

/* 移动端菜单按钮（桌面隐藏） */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: var(--sp-6);
    height: var(--sp-6);
    padding: 0;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    align-items: center;
}

.nav-toggle-bar {
    width: 18px;
    height: 2px;
    background: var(--text);
    transition: transform var(--transition), opacity var(--transition);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 55rem) {
    .nav-toggle { display: flex; }

    .site-nav { display: none; flex-basis: 100%; }
    .site-nav.is-open { display: block; }

    .site-nav .nav-list { flex-direction: column; align-items: stretch; gap: 0; }

    .nav-item > .nav-list {
        position: static;
        display: flex;
        border: 0;
        border-left: 2px solid var(--line);
        box-shadow: none;
        border-radius: 0;
        margin-left: var(--sp-2);
        padding: 0;
        background: transparent;
    }

    .nav-link { display: block; width: 100%; }
}

/* ============ 主视觉 ============ */

.hero { background: var(--bg-soft); }

.hero-slides { display: grid; }

.hero-slide {
    position: relative;
    display: grid;
    align-items: center;
    min-height: 22rem;
    border-bottom: 1px solid var(--line);
}

.hero-media {
    position: absolute;
    inset: 0;
}

.hero-body {
    position: relative;
    max-width: var(--container);
    margin-inline: auto;
    padding: var(--sp-8) var(--sp-3);
    width: 100%;
}

.hero-title {
    margin: 0 0 var(--sp-2);
    font-family: var(--font-serif);
    font-size: var(--fs-2xl);
    font-weight: 700;
}

.hero-sub {
    margin: 0 0 var(--sp-3);
    font-size: var(--fs-md);
    color: var(--text-soft);
    max-width: 40rem;
}

.hero-cta { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0; }

/* ============ 区块 ============ */

.section {
    padding-block: var(--sp-8);
}

.section + .section { padding-top: 0; }

.section-stats { padding-block: var(--sp-4); }

.section-head {
    display: flex;
    align-items: baseline;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--line);
}

.section-index {
    font-family: var(--font-serif);
    font-size: var(--fs-sm);
    color: var(--text-soft);
    letter-spacing: 0.1em;
}

.section-title {
    margin: 0;
    font-size: var(--fs-lg);
    font-weight: 700;
}

.section-more {
    margin-left: auto;
    font-size: var(--fs-sm);
    text-decoration: none;
    white-space: nowrap;
}
.section-more:hover { text-decoration: underline; }

/* ============ 栅格 ============ */

.grid {
    display: grid;
    gap: var(--sp-3);
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(21rem, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }

/* ============ 卡片 ============ */

.card {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-media {
    display: block;
    aspect-ratio: 16 / 10;
    background: var(--bg-mute);
    overflow: hidden;
}

.card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    padding: var(--sp-2);
    flex: 1;
}

.card-title {
    margin: 0;
    font-size: var(--fs-md);
    line-height: var(--lh-tight);
}

.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--accent); }

.card-excerpt {
    margin: 0;
    color: var(--text-soft);
    font-size: var(--fs-sm);
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    margin: 0;
    margin-top: auto;
    color: var(--text-soft);
    font-size: var(--fs-xs);
}

.card-tag {
    display: inline-block;
    align-self: flex-start;
    padding: 0.125rem var(--sp-1);
    font-size: var(--fs-xs);
    color: var(--accent);
    border: 1px solid currentColor;
    border-radius: var(--radius);
    text-decoration: none;
}

.card-tag.is-active { background: var(--accent); color: var(--accent-text); }

/* 图片占位（cover_image 为空 / banner 未联调时的色块） */
.ph {
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(45deg,
            var(--bg-mute) 0 0.75rem,
            var(--bg-soft) 0.75rem 1.5rem);
}

/* ============ 按钮 ============ */

.btn {
    display: inline-block;
    padding: var(--sp-1) var(--sp-3);
    font: inherit;
    font-size: var(--fs-md);
    line-height: var(--lh-tight);
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ============ 面包屑 / 分页 ============ */

.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    list-style: none;
    margin: 0;
    padding: var(--sp-2) 0;
    font-size: var(--fs-sm);
    color: var(--text-soft);
}

.breadcrumb li + li::before {
    content: "/";
    margin-right: var(--sp-1);
    color: var(--text-soft);
}

.breadcrumb a { color: var(--text-soft); }

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-1);
    margin-top: var(--sp-4);
}

.pager-item {
    display: inline-block;
    min-width: var(--sp-6);
    padding: var(--sp-1) var(--sp-1);
    text-align: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: var(--fs-sm);
}

a.pager-item:hover { border-color: var(--accent); color: var(--accent); }

.pager-item.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}

.pager-item.is-disabled {
    opacity: 0.5;
    border-style: dashed;
    cursor: not-allowed;
}

.pager-ellipsis { border: 0; }

.post-neighbors {
    margin-top: var(--sp-4);
    border-top: 1px solid var(--line);
    padding-top: var(--sp-3);
}
.post-neighbors .pager-item { max-width: 48%; }
.pager-label { display: block; font-size: var(--fs-xs); color: var(--text-soft); }

/* ============ 数据条 ============ */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: var(--sp-3);
}

.stat-num {
    margin: 0;
    font-family: var(--font-serif);
    font-size: var(--fs-xl);
    font-weight: 700;
    line-height: 1;
}

.stat-unit { font-size: var(--fs-md); margin-left: 0.125rem; }

.stat-label {
    margin: var(--sp-1) 0 0;
    color: var(--text-soft);
    font-size: var(--fs-sm);
}

/* ============ 表单 ============ */

.form-field {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    margin-bottom: var(--sp-3);
}

.form-label { font-size: var(--fs-sm); font-weight: 600; }

.form-input, .form-textarea {
    width: 100%;
    padding: var(--sp-1) var(--sp-2);
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.form-input:focus-visible, .form-textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.form-textarea { resize: vertical; min-height: 8rem; }

.form-error {
    margin: 0 0 var(--sp-3);
    padding: var(--sp-1) var(--sp-2);
    border: 1px solid #b3261e;
    border-left-width: 4px;
    border-radius: var(--radius);
    color: #b3261e;
    background: color-mix(in srgb, #b3261e 8%, transparent);
}

.form-ok {
    margin: 0 0 var(--sp-3);
    padding: var(--sp-1) var(--sp-2);
    border: 1px solid #1b6e3d;
    border-left-width: 4px;
    border-radius: var(--radius);
    color: #1b6e3d;
    background: color-mix(in srgb, #1b6e3d 8%, transparent);
}

@media (prefers-color-scheme: dark) {
    .form-error { color: #f2b8b5; border-color: #f2b8b5; background: rgba(242, 184, 181, 0.08); }
    .form-ok { color: #7ddb9a; border-color: #7ddb9a; background: rgba(125, 219, 154, 0.08); }
}

/* 蜜罐：对人类与读屏器均隐藏 */
.form-honey {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.search-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}
.search-form .form-field { flex: 1 1 16rem; margin-bottom: 0; }

/* ============ 页头（内页）/ 正文容器 ============ */

.page-head {
    padding-block: var(--sp-4) var(--sp-3);
    border-bottom: 1px solid var(--line);
    margin-bottom: var(--sp-4);
}

.page-title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: var(--fs-xl);
    font-weight: 700;
}

.page-head-meta { margin: var(--sp-1) 0 0; color: var(--text-soft); font-size: var(--fs-sm); }

.page-cover { margin: 0 0 var(--sp-3); border-radius: var(--radius-lg); overflow: hidden; }

.post-extra {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: var(--sp-2);
    margin: 0 0 var(--sp-3);
    padding: var(--sp-2);
    background: var(--bg-soft);
    border-radius: var(--radius-lg);
}

.post-extra div { display: flex; gap: var(--sp-1); margin: 0; }
.post-extra dt { color: var(--text-soft); }
.post-extra dd { margin: 0; font-weight: 600; }

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    margin: 0 0 var(--sp-3);
}

.empty-state {
    padding: var(--sp-6) var(--sp-3);
    text-align: center;
    color: var(--text-soft);
}

/* ============ 页脚 ============ */

.site-footer {
    margin-top: var(--sp-10);
    border-top: 1px solid var(--line);
    background: var(--bg-soft);
    padding-block: var(--sp-6) var(--sp-3);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: var(--sp-4);
}

.footer-title {
    margin: 0 0 var(--sp-2);
    font-size: var(--fs-base);
    font-weight: 700;
}

.footer-title a { color: var(--text); text-decoration: none; }
.footer-title a:hover { color: var(--accent); }

.footer-slogan { margin: 0 0 var(--sp-2); color: var(--text-soft); font-size: var(--fs-sm); }

.footer-contact {
    font-style: normal;
    font-size: var(--fs-sm);
    color: var(--text-soft);
}
.footer-contact p { margin: 0 0 var(--sp-1); }
.footer-contact a { color: var(--text-soft); }

.footer-links {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: var(--fs-sm);
}
.footer-links li { margin-bottom: var(--sp-1); }
.footer-links a { color: var(--text-soft); text-decoration: none; }
.footer-links a:hover { color: var(--accent); text-decoration: underline; }

.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--sp-1);
    margin-top: var(--sp-4);
    padding-top: var(--sp-2);
    border-top: 1px solid var(--line);
    color: var(--text-soft);
    font-size: var(--fs-xs);
}
.footer-bottom p { margin: 0; }
.footer-bottom a { color: var(--text-soft); }

/* ============ 滚动淡入（site.js 加 .is-in；JS 未启用时内容始终可见） ============ */

html.js .reveal {
    opacity: 0;
    transform: translateY(var(--sp-1));
    transition: opacity 400ms ease, transform 400ms ease;
}

html.js .reveal.is-in {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    html.js .reveal { opacity: 1; transform: none; transition: none; }
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
