/* ═══════════════════════════════
   文法章節頁樣式（chapter.css）
   由 tools/build_grammar_pages.py 產生的 grammar/NN.html 與 grammar/index.html 共用。
   Design tokens 與根目錄 index.html 一致（--paper/--ink/--accent/--soft/--rule/--muted）。
   PRODUCT.md：文字即設計、≥18px、WCAG AA、tap target ≥44px、
   禁 gradient text／glassmorphism／等高卡片格／側條 border。
   ═══════════════════════════════ */
:root {
  --paper:   #f5f0e8;
  --ink:     oklch(7%  0.012 250);
  --accent:  oklch(47% 0.160 25);
  --soft:    oklch(40% 0.030 250);
  --rule:    oklch(88% 0.006 80);
  --muted:   oklch(55% 0.015 250);
  --code-bg: oklch(94% 0.006 80);
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 18px;
  line-height: 1.7;
  padding: clamp(28px, 5vw, 64px) clamp(20px, 5vw, 48px) clamp(48px, 8vw, 96px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── 麵包屑 ── */
.crumb {
  width: 100%;
  max-width: 40rem;
  display: flex;
  gap: 20px;
  margin-bottom: clamp(32px, 6vw, 56px);
}
.crumb a {
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  padding: 12px 0;             /* 撐起 44px tap target */
  transition: color 0.15s;
}
.crumb a:hover { color: var(--accent); }

/* ── 章節主體 ── */
.chapter { width: 100%; max-width: 40rem; }

.chapter-head { margin-bottom: clamp(36px, 6vw, 56px); }

.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 16px;
}

h1 {
  font-family: 'Klee One', 'Noto Sans TC', sans-serif;
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: 0.02em;
}

/* 章內小標（來源 ###／####）——分隔靠留白與字重，不畫線不加框 */
.chapter-body h2 {
  font-family: 'Klee One', 'Noto Sans TC', sans-serif;
  font-size: 1.35rem;
  font-weight: 600;
  margin: 3.2rem 0 0.9rem;
  letter-spacing: 0.02em;
}
.chapter-body h3 {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--soft);
  margin: 2.2rem 0 0.7rem;
}
.chapter-body > p { margin: 0 0 1.1em; }
.chapter-body strong { font-weight: 600; }
.chapter-body code {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ── 表格：無斑馬紋、無框線；thead 一條實線、tbody 虛線列規 ── */
.table-wrap { overflow-x: auto; margin: 0 0 1.4em; }
.chapter-body table { border-collapse: collapse; width: 100%; min-width: 320px; }
.chapter-body th {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: left;
  padding: 6px 16px 8px 0;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.chapter-body td {
  padding: 10px 16px 10px 0;
  border-bottom: 1px dashed var(--rule);
  vertical-align: top;
}
.chapter-body tr:last-child td { border-bottom: none; }

/* ── 引言（來源 >）：上下 hairline，不用側條 ── */
.chapter-body blockquote {
  margin: 1.6em 0;
  padding: 0.9em 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  color: var(--soft);
  font-size: 0.95rem;
}
.chapter-body blockquote p { margin: 0 0 0.5em; }
.chapter-body blockquote p:last-child { margin-bottom: 0; }

/* ── 句型框（來源 ``` 圍欄）── */
.chapter-body pre {
  background: var(--code-bg);
  padding: 16px 20px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0 0 1.4em;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.92rem;
  line-height: 1.8;
}
.chapter-body pre code { background: none; padding: 0; font-size: inherit; }

.chapter-body ul, .chapter-body ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.chapter-body li { margin-bottom: 0.35em; }

/* ── 練習 CTA ── */
.chapter-cta {
  width: 100%;
  max-width: 40rem;
  margin-top: clamp(40px, 7vw, 64px);
  display: flex;
  flex-wrap: wrap;
  gap: clamp(16px, 4vw, 32px);
}

/* 一課配到兩批以上單字時，逐字講解收進 details，只讓完整表保持展開——
   兩批各自「先逐字教、最後給完整表」的節奏疊在同一頁會很難讀 */
.vocab-detail {
  margin: clamp(20px, 3vw, 28px) 0;
}
.vocab-detail > summary {
  cursor: pointer;
  font-family: 'Klee One', 'Noto Sans TC', sans-serif;
  font-size: 1rem;
  color: var(--accent);
  padding: 12px 0;
  border-bottom: 1px dashed var(--rule);
  list-style: none;
}
.vocab-detail > summary::-webkit-details-marker { display: none; }
.vocab-detail > summary::before { content: '▸ '; }
.vocab-detail[open] > summary::before { content: '▾ '; }
.vocab-detail[open] > summary {
  border-bottom-style: solid;
  margin-bottom: clamp(16px, 2.5vw, 24px);
}

/* 嵌在文法頁裡的「這一課的單字」一節——上方一條細線分隔，不另做卡片 */
.lesson-vocab {
  margin-top: clamp(40px, 7vw, 64px);
  padding-top: clamp(24px, 4vw, 36px);
  border-top: 1px solid var(--rule);
}
.lesson-vocab > h2:first-child {
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: 0.06em;
  margin-top: 0;
}
.chapter-cta a {
  font-family: 'Klee One', 'Noto Sans TC', sans-serif;
  font-size: 1.15rem;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 1px;
  padding: 12px 0;
  display: inline-block;
}

/* ── 前後章導覽 ── */
.chapter-nav {
  width: 100%;
  max-width: 40rem;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: clamp(28px, 5vw, 44px);
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}
.chapter-nav a {
  color: var(--soft);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 12px 0;
  max-width: 48%;
}
.chapter-nav a:hover { color: var(--accent); }
.chapter-nav .next { text-align: right; margin-left: auto; }
@media (max-width: 480px) {
  .chapter-nav { flex-direction: column; }
  .chapter-nav a { max-width: none; }
  .chapter-nav .next { text-align: left; margin-left: 0; }
}

/* ── 頁尾 ── */
.chapter-foot {
  width: 100%;
  max-width: 40rem;
  margin-top: clamp(32px, 6vw, 48px);
  font-size: 0.82rem;
  color: var(--muted);
}
.chapter-foot a { color: var(--muted); }
.chapter-foot a:hover { color: var(--soft); }

/* ── 朗讀鍵 ── */
.speak-btn {
  background: none; border: none; font-size: 1rem; cursor: pointer;
  padding: 0 4px; vertical-align: middle; opacity: 0.55; line-height: 1;
}
.speak-btn:hover { opacity: 1; }

/* ── 章節總覽（index.html）── */
.grammar-index { width: 100%; max-width: 40rem; }
.grammar-index .lead {
  color: var(--soft);
  font-size: 0.98rem;
  max-width: 44ch;
  margin-top: 12px;
}
.entries { list-style: none; border-top: 1px solid var(--rule); margin-top: clamp(32px, 6vw, 48px); }
.entry { border-bottom: 1px solid var(--rule); }
.entry a {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 24px;
  padding: 22px 0;
  text-decoration: none;
  color: inherit;
  transition: padding-left 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.entry a:hover { padding-left: 12px; }
.entry .num {
  font-family: 'Klee One', 'Noto Sans TC', sans-serif;
  font-size: 1.5rem;
  color: var(--accent);
  text-align: center;
  opacity: 0.85;
}
.entry .meta { display: flex; flex-direction: column; gap: 4px; }
.entry .label { font-size: 1.05rem; letter-spacing: 0.02em; }
.entry .desc { font-size: 0.82rem; color: var(--muted); }
.pending {
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* 章節總覽的補充說明——比 lead 小一級、用次要色，不跟主文案搶 */
.lead.note {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: -0.5rem;
}
.lead.note a { color: var(--accent); }
