/*
 * livre-cjk · Vivliostyle 原型主題（spec v1.2）
 * A5 · 繁體中文橫排 · 明體正文＋黑體標題 · 禁則 · 頁碼 · 腳註 · 雙欄
 * 字體：@font-face 內嵌 Noto TC VF 為可攜預設；sys101 另有系統
 * Noto Serif/Sans CJK TC（fonts-noto-cjk），fallback 鏈並列兩名。
 * 建置一律走 config.js 的 theme: 流程；CLI 11.3.3 的 -T/--theme 掛純 CSS
 * 會被靜默忽略（round3 vf-emphasis 證實），不可用。
 */

/* ---------- 字體：內嵌字型檔與 fallback 鏈 ---------- */
@font-face {
  font-family: "Noto Serif TC";
  src: url("fonts/NotoSerifTC-VF.ttf");
  font-weight: 100 900;
  font-style: normal;
}
@font-face {
  font-family: "Noto Sans TC";
  src: url("fonts/NotoSansTC-VF.ttf");
  font-weight: 100 900;
  font-style: normal;
}

:root {
  /* fallback 鏈：內嵌 VF → 系統 CJK TC → 文鼎／文泉驛 → 兜底 */
  --font-serif: "EB Garamond", "Noto Serif TC", "Noto Serif CJK TC", "AR PL Mingti2L Big5", "Droid Sans Fallback", serif;
  --font-sans: "Noto Sans TC", "Noto Sans CJK TC", "WenQuanYi Zen Hei", "Droid Sans Fallback", sans-serif;
}

/* ---------- 頁面：A5 紙面，橫排（水平書寫方向），頁碼於地腳 ---------- */
@page {
  size: A5; /* 148mm x 210mm ISO 216 */
  margin: 20mm 18mm 22mm 18mm;

  /* 頁碼 */
  @bottom-center {
    content: counter(page);
    font-family: var(--font-sans);
    font-size: 9pt;
    color: #555;
  }
  /* 天頭頁眉：當前章節名（由 h1/h2 的 string-set 提供） */
  @top-center {
    content: string(chap-title);
    font-family: var(--font-sans);
    font-size: 8pt;
    letter-spacing: 0.2em;
    color: #888;
  }
  /* 腳註區：頂線分隔 */
  @footnote {
    border-top: 0.5pt solid #999;
    margin-top: 3mm;
    padding-top: 1.5mm;
  }
}

/* 首頁不排頁眉 */
@page :first {
  @top-center {
    content: none;
  }
}

/* ---------- 內文 ---------- */
html {
  font-family: var(--font-serif);
  font-size: 10.5pt;
}

body {
  line-height: 1.9;
  text-align: justify;
  /* 禁則（避頭尾）：句讀不可行首，開括號、開引號不可行尾；
     語言判定依 <html lang="zh-Hant">（config.js 設定）。 */
  line-break: strict;
  word-break: normal;
  overflow-wrap: break-word;
  hanging-punctuation: none;
  text-spacing-trim: normal;
  orphans: 2;
  widows: 2;
}

h1 {
  font-family: var(--font-sans);
  font-size: 20pt;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 1.2em;
  string-set: chap-title content();
}

h2 {
  font-family: var(--font-sans);
  font-size: 13pt;
  font-weight: 700;
  margin: 1.6em 0 0.8em;
  break-after: avoid;
  string-set: chap-title content();
}

p {
  margin: 0 0 0.85em;
  text-indent: 2em; /* 段首縮排兩字 */
}

/* 著重號：鎖 filled circle（Chrome 153 下 filled／filled dot 不出點，round3 證實）。
   位置字下（under right），與 xeCJK CJKunderdot 同位。 */
em {
  font-style: normal;
  text-emphasis: filled circle;
  text-emphasis-position: under right;
}

/* ---------- 腳註：Markdown [^n] 由 CLI 轉為 span.footnote ---------- */
span.footnote {
  float: footnote;
  font-size: 8.5pt;
  line-height: 1.55;
  text-indent: 0;
}
::footnote-call {
  font-size: 0.7em;
  vertical-align: super;
  line-height: 0;
}
::footnote-mark {
  font-weight: 700;
  margin-right: 0.35em;
}

/* v1.1：章後首段零縮排（書籍慣例，與 weasy h1 + p 對齊） */
h1 + p, h2 + p { text-indent: 0; }

/* ---------- 雙欄資訊版（spec §6 v1.2） ---------- */
/* root multicol：全書雙欄時 body 加 twocol（Vivliostyle 自家實作）。
   限制：root multicol 下 column-span:all 僅 page float 有效，
   h1 不會跨欄而是落左欄頂；章標題跨欄請走 div.flow。 */
body.twocol {
  column-count: 2;
  column-gap: 8mm;
}
/* non-root multicol：章標題跨欄（h1 置於 div 內，round3 實測跨欄成功） */
div.flow {
  columns: 2;
  column-gap: 8mm;
}
div.flow > h1:first-child {
  column-span: all;
  font-family: var(--font-sans);
  font-size: 20pt;
  font-weight: 700;
  line-height: 1.4;
}
/*
 * Ma cuisine 成書附加樣式（疊加於 livre-cjk theme v1.2 之後）
 * 封面全出血、分頁、詞彙表表格
 */

/* ── 封面：具名頁面，零邊距，無頁碼頁眉 ── */
@page cover {
  margin: 0;
  @bottom-center { content: none; }
  @top-center { content: none; }
}
.cover-page {
  page: cover;
  break-after: page;
}
.cover-page img {
  width: 148mm;
  height: 210mm;
  object-fit: cover;
  display: block;
}

/* ── 分頁 div ── */
div.pagebreak {
  break-before: page;
}

/* ── 書名頁 ── */
.titlepage {
  break-after: page;
  text-align: center;
  padding-top: 30mm;
}
.titlepage h1 {
  font-size: 2.6em;
  border: none;
  margin-bottom: 0.2em;
}
.titlepage h2 {
  border: none;
  font-size: 1.5em;
  color: #444;
}
.titlepage h3 {
  border: none;
  font-size: 1em;
  font-weight: normal;
  color: #666;
}
.titlepage p {
  font-size: 0.85em;
  color: #555;
  text-align: left;
  margin: 2em 10mm 0;
}

/* ── 詞彙對照表表格 ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8pt;
  font-family: var(--font-sans);
}
thead {
  display: table-header-group;
}
th, td {
  border-bottom: 0.5pt solid #bbb;
  padding: 2pt 4pt;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}
th {
  background: #f2f2ee;
  font-weight: 600;
}

/* ── 譯注塊與頁碼錨點淡化 ── */
h3 ~ em, .note-note { color: #555; }

/* ── 目次連結：外觀不變，僅可點 ── */
a { color: inherit; text-decoration: none; }
