/* ─────────────────────────────────────────────────────────────────
   《断流》— novel-specific styles
   ─────────────────────────────────────────────────────────────────
   Loaded on top of:  ../../level3.css  (site-anchor, end-mark, tokens)
   Scope:             this novel's folder only.  Don't reuse across novels;
                      copy + retune per work.

   Sections:
     1.  Theme tokens  (paper / 夜 themes via [data-theme])
     2.  Page shell    (responsive reading column + helpers)
     3.  TOC           (扉页 + 14-章目录)
     4.  Chapter       (章首大字 + 正文 + 分场 + 章末导航)
     5.  Reader bar    (top-right 字号 / 主题 控件 + 顶部进度条)
     6.  Responsive    (≤960 平板 · ≤640 手机)
   ───────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;400;500;600;700&display=swap');

/* ─── 1. THEME TOKENS ─────────────────────────────────────────── */
:root {
  --paper:       #f4efe2;   /* 主纸色 — 比首页略浅一点，做内页 */
  --paper-soft:  #ece6d6;   /* 章节带、悬浮态 */
  --ink:         #1f1c17;   /* 墨 */
  --ink-soft:    #57534b;   /* 次级文本 */
  --ink-muted:   #918a7e;   /* 元信息 */
  --rule:        rgba(31, 28, 23, 0.14);
  --rule-strong: rgba(31, 28, 23, 0.32);

  --accent:      #8a2b1e;   /* 朱砂 — 章序号、印章、当前章 */
  --accent-soft: #b07a6d;

  --serif:       'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'STSong', 'STKaiti', serif;
  --mono:        'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --read-size:   18px;       /* 字号变量，被 JS 调节 */
  --read-lh:     1.95;
}

/* 夜读主题 */
[data-theme="night"] {
  --paper:       #16140f;
  --paper-soft:  #1f1c16;
  --ink:         #e8e2d4;
  --ink-soft:    #b4ab98;
  --ink-muted:   #7a7263;
  --rule:        rgba(232, 226, 212, 0.14);
  --rule-strong: rgba(232, 226, 212, 0.32);
  --accent:      #c97a6d;
  --accent-soft: #8a5a52;
}

/* 字号档位 — JS 切换 data-size，CSS 给出值 */
[data-size="s"] { --read-size: 16px; --read-lh: 1.9; }
[data-size="m"] { --read-size: 18px; --read-lh: 1.95; }
[data-size="l"] { --read-size: 20px; --read-lh: 2.05; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--read-size);
  line-height: var(--read-lh);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 320ms ease, color 320ms ease;
}
::selection { background: var(--accent); color: var(--paper); }

/* ─── 2. PAGE SHELL ───────────────────────────────────────────── */
.wx-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 132px 36px 32px;
}
.wx-page--wide { max-width: 880px; }

.wx-mono   { font-family: var(--mono); }
.wx-kicker { font-family: var(--mono); font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-muted); }
.wx-rule   { height: 1px; background: var(--rule); border: 0; margin: 0; }

/* 古风 双线 — 上粗下细 / 两线相挨 */
.wx-rule--double {
  height: 4px;
  background: none;
  border: 0;
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule);
}

/* ─── 3. TOC  目录扉页 ────────────────────────────────────────── */
.toc-cover {
  display: grid;
  grid-template-columns: 1fr;
  gap: 48px;
  padding-top: 24px;
}

.toc-title {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
}
.toc-title__zh {
  font-family: var(--serif);
  font-size: clamp(48px, 7vw, 48px);
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1;
  margin: 0;
}
.toc-title__en {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.toc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.toc-meta__dot { color: var(--ink-muted); }

/* 印 — 朱砂方印小色块，章末或扉页的角标 */
.toc-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: var(--paper);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: 0.05em;
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.15);
}

.toc-synopsis {
  max-width: 56ch;
  font-size: 17px;
  line-height: 1.85;
  color: var(--ink);
  text-wrap: pretty;
}
.toc-synopsis p { margin: 0 0 14px; }
.toc-synopsis p:last-child { margin: 0; }

/* 章节列表 — 像线装书目录 */
.toc-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule-strong);
}
.toc-list__item { border-bottom: 1px solid var(--rule); }
.toc-list__link {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: baseline;
  gap: 20px;
  padding: 18px 4px;
  text-decoration: none;
  color: inherit;
  transition: background 200ms ease, padding-left 220ms cubic-bezier(.2,.7,.2,1);
}
.toc-list__link:hover,
.toc-list__link:focus-visible {
  outline: none;
  background: var(--paper-soft);
  padding-left: 14px;
}
.toc-list__num {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.toc-list__title {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.02em;
  line-height: 1.4;
}
.toc-list__title .en {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: 4px;
}
.toc-list__meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  text-align: right;
  white-space: nowrap;
}
.toc-list__link[data-last-read]:after {
  /* 上次读到 — 标记 */
  content: '上次读到 ↪';
  position: absolute;
}

/* "继续阅读" 大按钮（来自 localStorage） */
.toc-resume {
  display: none;            /* JS 在有进度时打开 */
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  border-radius: 3px;
  transition: transform 220ms cubic-bezier(.2,.7,.2,1), background 220ms;
}
.toc-resume.is-open { display: flex; }
.toc-resume:hover { transform: translateY(-2px); background: var(--accent); }
.toc-resume__label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.7; }
.toc-resume__where { font-family: var(--serif); font-size: 18px; letter-spacing: 0.02em; margin-top: 4px; }
.toc-resume__arrow { font-family: var(--mono); font-size: 18px; }

/* ─── 4. CHAPTER 章页 ─────────────────────────────────────────── */
.ch-head {
  text-align: center;
  margin: 24px 0 56px;
}
.ch-head__crumb {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 28px;
}
.ch-head__crumb a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--rule); padding-bottom: 1px; }
.ch-head__crumb a:hover { color: var(--ink); border-bottom-color: var(--ink); }
.ch-head__num {
  font-family: var(--serif);
  font-size: clamp(64px, 11vw, 112px);
  font-weight: 400;
  color: var(--accent);
  line-height: 1;
  letter-spacing: 0.05em;
  margin: 0;
}
.ch-head__num-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 14px;
}
.ch-head__title {
  font-family: var(--serif);
  font-size: clamp(26px, 3.6vw, 36px);
  font-weight: 500;
  letter-spacing: 0.06em;
  margin: 26px 0 0;
  text-wrap: balance;
}
.ch-head__deco {
  display: block;
  width: 36px;
  height: 1px;
  background: var(--ink);
  margin: 32px auto 0;
  opacity: 0.5;
}

.ch-body { text-wrap: pretty; }
.ch-body p {
  margin: 0 0 1.05em;
  text-indent: 2em;      /* 中文小说常见首行缩进 */
}
.ch-body p:first-of-type { /* 首段不缩进，留给 drop-cap */ }



/* 分场分隔 ※ */
.scene-break {
  display: block;
  text-align: center;
  margin: 2.2em 0;
  color: var(--ink-muted);
  letter-spacing: 1.5em;     /* 三个字符撑开间距 */
  font-size: 0.9em;
}
.scene-break::before { content: '※ ※ ※'; letter-spacing: 0.8em; padding-left: 0.8em; }

/* 章末双线 + 印 */
.ch-end {
  margin: 64px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.ch-end__rule {
  width: 80px;
  height: 5px;
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule);
}
.ch-end__stamp {
  display: inline-block;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.18em;
  color: var(--paper);
  background: var(--accent);
  padding: 3px 10px;
  border-radius: 2px;
}

/* 章末导航 — 上一章 / 目录 / 下一章 */
.ch-nav {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin: 64px 0 0;
  padding: 28px 0 0;
  border-top: 1px solid var(--rule);
}
.ch-nav__cell {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 4px;
  transition: background 200ms;
}
.ch-nav__cell:hover { background: var(--paper-soft); }
.ch-nav__cell.is-disabled { opacity: 0.35; pointer-events: none; }
.ch-nav__cell--center { text-align: center; align-items: center; }
.ch-nav__cell--next { text-align: right; align-items: flex-end; }
.ch-nav__label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.ch-nav__where {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--ink);
}

/* ─── 5. READER BAR (top-right) + 进度条 ─────────────────────── */
.read-bar {
  position: fixed;
  top: 22px;
  right: 28px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 8px;
  background: rgba(244, 239, 226, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 6px 18px -8px rgba(0,0,0,0.10);
  color: var(--ink-soft);
  transition: background 220ms, box-shadow 220ms;
}
[data-theme="night"] .read-bar {
  background: rgba(22, 20, 15, 0.66);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 6px 18px -8px rgba(0,0,0,0.5);
}
.read-bar button {
  font: inherit;
  color: inherit;
  background: none;
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: background 180ms, color 180ms, border-color 180ms;
}
.read-bar button:hover { background: rgba(0,0,0,0.05); color: var(--ink); }
[data-theme="night"] .read-bar button:hover { background: rgba(255,255,255,0.08); color: var(--ink); }
.read-bar button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}
.read-bar__sep { width: 1px; height: 14px; background: var(--rule-strong); margin: 0 2px; }

/* 顶部进度条 */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  z-index: 99;
  transition: width 60ms linear;
}

/* ─── 6. RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 960px) {
  .wx-page { padding: 116px 28px 28px; }
  .toc-list__link { grid-template-columns: 44px 1fr auto; gap: 16px; padding: 16px 4px; }
}

@media (max-width: 640px) {
  body { font-size: var(--read-size); }
  [data-size="s"] { --read-size: 15px; }
  [data-size="m"] { --read-size: 17px; }
  [data-size="l"] { --read-size: 19px; }

  .wx-page { padding: 96px 20px 24px; }
  .wx-page--wide { padding-left: 20px; padding-right: 20px; }

  .read-bar {
    top: 14px;
    right: 14px;
    padding: 4px 6px;
    gap: 2px;
  }
  .read-bar button { padding: 4px 7px; font-size: 11px; }

  /* TOC — 章节列表压缩为两列 */
  .toc-list__link { grid-template-columns: 36px 1fr; gap: 14px; padding: 16px 6px; }
  .toc-list__meta { display: none; }
  .toc-title { gap: 10px; }
  .toc-cover { gap: 32px; }

  /* 章页 — 中间格变成"目录" 文字按钮，左右只留箭头 */
  .ch-nav { grid-template-columns: 1fr auto 1fr; gap: 8px; padding-top: 22px; margin-top: 48px; }
  .ch-nav__cell { padding: 8px 10px; }
  .ch-nav__where { font-size: 14px; }
  .ch-nav__label { font-size: 9px; letter-spacing: 0.18em; }


}
