/* ==================================================================
   声律启蒙 —— 主题样式
   配色与版式取自 guwendao.net（见 img/theme/credits.json）：
     #E1E0C7 页面底 / #F0EFE2 卡片 / #FBFAF6 亮面 / #5D6146 主色
     #DAD9D1 分隔线 / #999 次要文字
   ================================================================== */

:root {
  --bg: #e1e0c7;
  --paper: #f0efe2;
  --paper-light: #fbfaf6;
  --ink: #3f3e37;
  --ink-soft: #65645f;
  --ink-faint: #999999;
  --brand: #5d6146;
  --brand-soft: #7c7b58;
  --line: #dad9d1;
  --line-soft: #e9e8dc;
  --accent: #8c3b2e;
  --topbar-h: 45px;
  --hero-h: 180px;

  --font-song: "Songti SC", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --font-kai: "Kaiti SC", "KaiTi", "STKaiti", "Noto Serif CJK SC", serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background-color: var(--bg);
  background-image: url("../img/theme/paper.png");
  color: var(--ink);
  font-family: var(--font-song);
  font-size: 16px;
  line-height: 1.9;
  overflow-anchor: none;
}

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

[hidden] { display: none !important; }

/* ---------- 顶栏：古画背景 ---------- */
.hero {
  position: relative;
  height: var(--hero-h);
  background-color: #cdcbb4;
  background-image: url("../img/theme/jie-lichun.jpg");
  background-position: top center;
  background-repeat: no-repeat;
  background-size: cover;
}

.topbar {
  height: var(--topbar-h);
  background-color: rgba(240, 239, 226, 0.72);
  backdrop-filter: saturate(120%);
}

.topbar__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--topbar-h);
}

.brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 2px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.brand small {
  font-size: 12px;
  font-weight: 400;
  color: var(--brand-soft);
  letter-spacing: 0;
  margin-left: 8px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.topnav a {
  display: inline-block;
  padding: 0 12px;
  height: var(--topbar-h);
  line-height: var(--topbar-h);
  color: var(--brand);
  font-size: 16px;
}
.topnav a:hover,
.topnav a[aria-current="page"] {
  color: var(--accent);
  text-decoration: none;
  box-shadow: inset 0 -3px 0 var(--accent);
}

.topbar__spacer { flex: 1; }

.season-switch {
  display: flex;
  gap: 4px;
  align-items: center;
}
.season-switch button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--brand-soft);
  background: var(--paper-light);
  color: var(--brand);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.season-switch button[aria-pressed="true"] {
  background: var(--brand);
  color: var(--paper-light);
  border-color: var(--brand);
}

.account-chip {
  font-size: 14px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.account-chip a { color: var(--brand); }

/* ---------- 版心 ---------- */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--paper);
  border-radius: 5px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card:last-child { margin-bottom: 0; }

.card__title {
  margin: 0 0 12px;
  font-size: 17px;
  color: var(--brand);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.card__title small { font-weight: 400; color: var(--ink-faint); font-size: 13px; }

/* ---------- 首页 ---------- */
.intro { margin: 0 0 16px; color: var(--ink-soft); }
/* 题解是大段说明文字：限宽到易读行宽，行高放松，别糊成一片灰墙 */
.intro p {
  margin: 0 0 12px;
  max-width: 46em;
  line-height: 2.05;
  text-align: justify;
}
.intro p:last-child { margin-bottom: 0; }

.volume { margin-bottom: 18px; }
.volume:last-child { margin-bottom: 0; }
.volume__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.volume__head h3 { margin: 0; font-size: 16px; color: var(--brand); }
.volume__head span { font-size: 13px; color: var(--ink-faint); }

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.chapter-card {
  display: block;
  background: var(--paper-light);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 14px 16px;
  color: var(--ink);
}
.chapter-card:hover {
  text-decoration: none;
  border-color: var(--brand-soft);
  box-shadow: 0 2px 8px rgba(93, 97, 70, 0.12);
}
.chapter-card__title {
  font-size: 19px;
  color: var(--brand);
  font-family: var(--font-kai);
  margin-bottom: 4px;
}
.chapter-card__rhyme { font-size: 13px; color: var(--ink-faint); margin-bottom: 8px; }
.chapter-card__summary {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chapter-card__meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-faint);
}

/* 进度条 */
.bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.bar__fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--brand-soft);
  transition: width 0.3s ease;
}
.bar__fill[data-done="true"] { background: var(--accent); }

/* ---------- 章节页 ---------- */
.chapter-head { margin-bottom: 18px; }
.chapter-head h1 {
  margin: 0 0 6px;
  font-size: 30px;
  font-family: var(--font-kai);
  color: var(--brand);
  letter-spacing: 3px;
}
.chapter-head .chapter-head__meta {
  font-size: 13px;
  color: var(--ink-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.part {
  background: var(--paper);
  border-radius: 5px;
  padding: 18px 24px 20px;
  margin-bottom: 20px;
}
.part__actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.btn {
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--paper-light);
  color: var(--ink-soft);
  cursor: pointer;
}
.btn:hover { border-color: var(--brand-soft); color: var(--brand); }
.btn[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--paper-light);
}
.btn--fav[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }

.section-title {
  font-size: 14px;
  color: var(--brand);
  margin: 18px 0 8px;
  padding-left: 10px;
  border-left: 3px solid var(--brand-soft);
  letter-spacing: 1px;
}

/* ---------- 原文 + 拼音 ---------- */
/* 一行 = 原书的一个对仗单位（见 data-store 的 groupPhrases）：
   短对并排一行、长对各占一行；放不下时行内换行，但不会跟下一行粘连 */
.verses { margin-bottom: 8px; }

.verse {
  margin: 0 0 10px;
  line-height: 1.15;
}

.verse__line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  row-gap: 6px;
  margin-bottom: 8px;
}
.verse__line:last-child { margin-bottom: 0; }

/* 译文：与原文行一一对应，直接跟在每行下面 */


.zi {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 40px;
  padding: 2px 0 4px;
}
.zi--punct { min-width: 20px; }

.zi__py {
  font-family: var(--font-song);
  font-size: 12px;
  line-height: 1.4;
  height: 17px;
  color: var(--ink-faint);
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.zi__hz {
  font-family: var(--font-kai);
  font-size: 26px;
  line-height: 38px;
  width: 38px;
  height: 38px;
  text-align: center;
  color: var(--ink);
  background-image: url("../img/theme/hanzi-block.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 36px 36px;
  border-radius: 3px;
}
.zi--punct .zi__hz {
  width: auto;
  min-width: 20px;
  font-size: 22px;
  background-image: none;
}
/* 注释序号 ①②③ 是**上角注**：字号明显小、并抬到所在行的顶端。
   注意：这一行是 flex + align-items:flex-end，注号块比字块矮，
   底部对齐会让它**低于**汉字顶部 —— 所以必须显式顶对齐（真踩过：
   注号 top 844 > 正文 top 826，看着就是"跟正文一样平"）。 */
.zi--mark {
  min-width: 14px;
  align-self: flex-start;
  /* 抬到拼音行的高度：字块是「拼音 17px + 汉字 38px」，注号要落在拼音那一层 */
  margin-top: -15px;
}
.zi--mark .zi__hz {
  width: auto;
  min-width: 12px;
  font-size: 12px;
  line-height: 14px;
  height: auto;
  background-image: none;
  color: var(--accent);
}

/* 入声字：原书字下加黑点 */
/* 入声字：原书是字下加黑点，但用户不要那个圆点（2026-10-16）。
   数据里仍保留 underlines，鼠标悬停仍能看到「入声字」提示。 */

/* 拼音一律同色同粗细 —— 用户明确不要"花花绿绿、有粗有细"
   （2026-10-16，参照古文之家的素净样式）。声调/多音信息仍保留在数据里，
   鼠标悬停单字可以看到；多音字只在悬停提示里说明。 */

/* 拼音开关：关掉时只留汉字，行高收紧 */
.pinyin-off .zi__py { display: none; }

/* ---------- 注释 / 译文 ---------- */
.notes {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: none;
  border-top: 1px solid var(--line-soft);
}
.notes li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
  line-height: 1.95;
  color: var(--ink-soft);
}
.notes li:nth-child(odd) { background: rgba(251, 250, 246, 0.6); }
/* 序号独立一列：小号、上抬，跟正文里的上角注一个体例 */
.note__mark {
  font-size: 12px;
  line-height: 1.6;
  color: var(--accent);
  text-align: right;
  padding-top: 3px;
}
.note__body { min-width: 0; }
.note__body b {
  color: var(--brand);
  font-weight: 700;
}

.translation p {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 2;
  color: var(--ink-soft);
  max-width: 62em;
}

/* ---------- 侧栏 ---------- */
.side { position: sticky; top: 16px; }
.side .card { padding: 16px 18px; }

.progress-ring {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.progress-ring b { font-size: 30px; color: var(--accent); font-family: var(--font-kai); }
.progress-ring span { font-size: 13px; color: var(--ink-faint); }

.legend { font-size: 13px; color: var(--ink-soft); }
.legend div { display: flex; justify-content: space-between; padding: 3px 0; }

.toc { list-style: none; margin: 0; padding: 0; font-size: 15px; }
.toc li { border-bottom: 1px dashed var(--line-soft); }
.toc li:last-child { border-bottom: 0; }
.toc a { display: flex; align-items: center; gap: 8px; padding: 7px 0; }
.toc a[aria-current="page"] { color: var(--accent); font-weight: 700; }
.toc .toc__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--line); flex: none;
}
.toc .toc__dot[data-level="1"] { background: var(--brand-soft); }
.toc .toc__dot[data-level="2"] { background: var(--accent); }
.toc .toc__pct { margin-left: auto; font-size: 12px; color: var(--ink-faint); }

.source-note {
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.8;
}
.source-note a { color: var(--brand-soft); }

/* ---------- 页脚 ---------- */
.footer {
  background: rgba(240, 239, 226, 0.9);
  border-top: 1px solid var(--line);
  padding: 18px 16px 26px;
  font-size: 13px;
  color: var(--ink-faint);
}
.footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
}
.footer__inner a { color: var(--brand-soft); }

/* ---------- 窄屏 ---------- */
@media (max-width: 900px) {
  .wrap {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px 12px 40px;
  }
  .side { position: static; }
  .hero { height: 130px; }
  .topbar { height: auto; }
  .topbar__inner {
    height: auto;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px 12px;
  }
  .brand { font-size: 19px; }
  .topnav a { height: 34px; line-height: 34px; padding: 0 8px; font-size: 15px; }
  .topbar__spacer { display: none; }
  .chapter-head h1 { font-size: 24px; }
  .card, .part { padding: 14px 14px 16px; }
  .zi { min-width: 34px; }
  .zi__hz { font-size: 23px; width: 34px; height: 34px; line-height: 34px; background-size: 32px 32px; }
  .zi__py { font-size: 11px; }
  }

/* ---------- 轻提示 ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(63, 62, 55, 0.94);
  color: #fbfaf6;
  padding: 8px 18px;
  border-radius: 4px;
  font-size: 14px;
  z-index: 9;
  max-width: 84vw;
  text-align: center;
}

/* ---------- 备案号（工信部要求：页脚展示且可点击） ---------- */
.footer__legal {
  color: var(--ink-faint);
  word-break: break-word;
}
.footer__legal:hover { color: var(--brand-soft); }

/* ---------- 章节内导航（题解 / 一 / 二 / 三） ---------- */
.chapter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 4px;
}
.chapter-nav a[aria-current="page"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--paper-light);
}

/* 入声字：只做数据标记与悬停提示，不画圆点（用户要求去掉） */
.zi--ru .zi__hz { position: relative; }
