/* 典籍阅读页统一样式 —— 延续「道」研究项目的羊皮纸调性 */

:root {
    --parchment: #f7f3ea;
    --paper: #fffdf8;
    --ink: #1f1b16;
    --text: #2c2620;
    --muted: #6b6257;
    --gold: #b8894a;
    --gold-soft: #e0c39a;
    --border: #e5ddcd;
    --accent: #8c3b2e;
    --accent-soft: #f3e6de;
    --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
    --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    --fs-src: 18px;
    --fs-tr: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
    font-family: var(--serif);
    background: var(--parchment);
    color: var(--text);
    line-height: 1.9;
    font-size: var(--fs-src);
}

/* ---- 顶栏 ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: rgba(247, 243, 234, 0.94);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar .back {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-family: var(--sans);
    white-space: nowrap;
}
.topbar .back:hover { color: var(--gold); }
.topbar .title {
    font-size: 19px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: 0.06em;
}
.topbar .sub {
    font-size: 13px;
    color: var(--muted);
    font-family: var(--sans);
    letter-spacing: 0.02em;
}
.topbar .spacer { flex: 1; }
.tools { display: flex; gap: 6px; }
.tools button {
    font-family: var(--sans);
    font-size: 12px;
    padding: 5px 11px;
    border: 1px solid var(--border);
    background: var(--paper);
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.18s;
}
.tools button:hover { border-color: var(--gold); color: var(--gold); }
.tools button.active {
    background: var(--gold);
    border-color: var(--gold);
    color: #fff;
}

/* ---- 布局 ---- */
.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 32px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 24px 80px;
}

/* ---- 侧栏目录 ---- */
.toc { position: sticky; top: 88px; align-self: start; max-height: calc(100vh - 110px); overflow-y: auto; }
.toc h4 {
    font-size: 12px;
    font-family: var(--sans);
    color: var(--muted);
    letter-spacing: 0.16em;
    font-weight: 500;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.toc a {
    display: block;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    padding: 5px 10px;
    border-left: 2px solid transparent;
    transition: all 0.15s;
    line-height: 1.5;
}
.toc a:hover { color: var(--ink); background: rgba(184, 137, 74, 0.07); }
.toc a.active { color: var(--gold); border-left-color: var(--gold); background: rgba(184, 137, 74, 0.09); font-weight: 500; }

/* ---- 正文 ---- */
.content { min-width: 0; }

.book-head {
    padding: 8px 0 24px;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border);
}
.book-head h1 {
    font-size: 34px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}
.book-head .meta {
    font-family: var(--sans);
    font-size: 13px;
    color: var(--muted);
    line-height: 1.8;
}
.book-head .meta b { color: var(--gold); font-weight: 500; }

.chapter { margin-bottom: 44px; scroll-margin-top: 84px; }
.chapter h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
    letter-spacing: 0.04em;
}
.chapter h2 .no { color: var(--gold); margin-right: 8px; }
.chapter .ch-title {
    font-family: var(--sans);
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 16px;
    letter-spacing: 0.05em;
}

/* ---- 原文 / 译文 对照块 ---- */
.pair {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
}
.pair .src {
    padding: 18px 22px 14px;
    font-family: var(--serif);
    font-size: var(--fs-src);
    line-height: 2.05;
    color: var(--ink);
    letter-spacing: 0.03em;
    background: linear-gradient(to right, rgba(184, 137, 74, 0.05), transparent 40%);
}
.pair .tr {
    padding: 0 22px 16px;
    font-family: var(--sans);
    font-size: var(--fs-tr);
    line-height: 1.95;
    color: var(--muted);
    border-top: 1px dashed var(--border);
    padding-top: 14px;
}
.pair .note {
    padding: 10px 22px 14px;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--accent);
    background: var(--accent-soft);
    line-height: 1.75;
}
.pair .note::before {
    content: "要义 ";
    font-family: var(--serif);
    color: var(--accent);
    opacity: 0.7;
    letter-spacing: 0.08em;
}

/* ---- 段内编号（如论语章号 1.1） ---- */
.pair .src .pno {
    display: inline-block;
    min-width: 3.2em;
    margin-right: 0.5em;
    font-family: var(--sans);
    font-size: 0.72em;
    font-weight: 500;
    color: var(--gold);
    letter-spacing: 0.04em;
    vertical-align: 0.1em;
}

/* ---- 章节导航 ---- */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 56px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    font-family: var(--sans);
    font-size: 13px;
}
.chapter-nav a { color: var(--muted); text-decoration: none; }
.chapter-nav a:hover { color: var(--gold); }
.chapter-nav .next { text-align: right; }

/* ---- 显隐模式 ---- */
body.mode-src .pair .tr, body.mode-src .pair .note { display: none; }
body.mode-tr .pair .src, body.mode-tr .pair .note { display: none; }

/* ---- 阅读进度条 + 回到顶部（reader.js 按页长自动注入，与主页同款） ---- */
#dao-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, #c23b27, #d4a574);
    z-index: 200;
    transition: width 0.15s linear;
    pointer-events: none;
}
#dao-totop {
    position: fixed;
    right: 18px;
    bottom: 22px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(31, 27, 22, 0.88);
    color: #e0c39a;
    border: 1px solid rgba(184, 137, 74, 0.55);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 150;
    font-family: var(--serif);
}
#dao-totop.show { opacity: 1; pointer-events: auto; }
#dao-totop:hover { transform: translateY(-3px); color: var(--gold); }

/* ---- 响应式 ---- */
@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; gap: 0; padding: 20px 16px 60px; }
    .toc {
        position: static;
        max-height: 220px;
        margin-bottom: 24px;
        padding-bottom: 16px;
        border-bottom: 1px solid var(--border);
    }
    .topbar { flex-wrap: wrap; padding: 10px 16px; }
    .topbar .title { font-size: 17px; }
    .book-head h1 { font-size: 26px; }
    #dao-totop { right: 12px; bottom: 16px; width: 40px; height: 40px; font-size: 15px; }
}

/* ---- 典籍总览页（index.html） ---- */
.works-hero {
    max-width: 1180px;
    margin: 0 auto;
    padding: 44px 24px 20px;
}
.works-hero h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.14em;
    margin-bottom: 10px;
}
.works-hero .lead {
    font-family: var(--sans);
    font-size: 14px;
    color: var(--muted);
    line-height: 1.9;
    max-width: 760px;
}
.works-hero .stat {
    margin-top: 16px;
    font-family: var(--sans);
    font-size: 13px;
    color: var(--gold);
}
.works-hero .stat b { font-size: 20px; font-weight: 600; }

.works-wrap { max-width: 1180px; margin: 0 auto; padding: 12px 24px 80px; }
.works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}
.school-card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 22px;
}
.school-card > h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: 0.08em;
    padding-bottom: 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.school-card > h3 .cnt {
    font-family: var(--sans);
    font-size: 12px;
    color: var(--muted);
    font-weight: 400;
    margin-left: 8px;
}
.school-card h4 {
    font-family: var(--sans);
    font-size: 12px;
    color: var(--gold);
    letter-spacing: 0.12em;
    font-weight: 500;
    margin: 14px 0 8px;
}
.work-list { list-style: none; }
.work-list li {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 0;
    font-family: var(--sans);
    font-size: 13px;
    border-bottom: 1px dotted rgba(229, 221, 205, 0.7);
}
.work-list li:last-child { border-bottom: none; }
.work-list .wn { color: var(--text); }
.work-list .wa { color: var(--muted); font-size: 12px; flex: 1; }
a.work-link .wn { color: var(--gold); text-decoration: none; font-weight: 500; }
a.work-link:hover .wn { text-decoration: underline; }
a.work-link::after { content: " ›"; color: var(--gold); font-size: 12px; }
li.wip { opacity: 0.55; }
li.lost { opacity: 0.4; }
.badge {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--border);
    color: var(--muted);
    white-space: nowrap;
}
.badge.done { background: var(--gold); color: #fff; }
.badge.selected {
    background: var(--gold-soft);
    color: #6b4a17;
    border: 1px solid rgba(184, 137, 74, 0.45);
}
/* 全本·原文：原文逐字全录，今译尚未全 */
.badge.sfull {
    background: #2e6b57;
    color: #fff;
}
.badge.partial {
    background: var(--paper);
    color: var(--accent);
    border: 1px solid rgba(140, 59, 46, 0.35);
}
.badge.lost { background: var(--accent-soft); color: var(--accent); }

@media (max-width: 860px) {
    .works-hero { padding: 28px 16px 12px; }
    .works-hero h1 { font-size: 24px; }
    .works-wrap { padding: 8px 16px 60px; }
    .works-grid { grid-template-columns: 1fr; }
}

@media print {
    .topbar, .toc, .chapter-nav { display: none; }
    #dao-progress, #dao-totop { display: none !important; }
    .layout { display: block; padding: 0; }
    body { background: #fff; }
}
