/* ============================================================
   style.css｜全域共用樣式（跨章共用才放這裡）
   ------------------------------------------------------------
   維護須知：
   1. 改整本顏色／字體 → 只改下面【樣式】區塊
   2. 本檔「沒有」任何圖片網址；圖片網址都在各章 HTML 裡，搜【圖片網址】
   3. 各章「獨有」樣式寫在該章 HTML 的 <style> 裡（01 章已示範）
   ============================================================ */

/* ============================================================
   【樣式】全域變數（整本手冊唯一調色盤）
   ============================================================ */
:root {
  --accent: #1e4d8c;
  --accent-dark: #16396a;
  --ink: #23272e;
  --muted: #5c6470;
  --bg: #ffffff;
  --bg-soft: #f4f5f7;
  --line: #dfe2e7;
  --radius: 8px;
  --sidebar-w: 280px;
  --content-w: 760px;
  --font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Heiti TC", sans-serif;
  --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
}

/* ---------- 基本 ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.8; color: var(--ink); background: var(--bg); overflow-x: hidden; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================
   書籍外殼：電腦版＝左目錄＋右內容
   ============================================================ */
.book { display: flex; max-width: 1240px; margin: 0 auto; }
.book-sidebar { width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--line); background: var(--bg); }
#toc-container { padding: 28px 20px; }
.book-main { flex: 1; min-width: 0; padding: 44px 48px 88px; }
.chapter { max-width: var(--content-w); margin: 0 auto; }
.chapter section[id] { scroll-margin-top: 24px; }

/* ============================================================
   目錄（book.js 自動產生）
   ============================================================ */
.toc-head { position: relative; margin-bottom: 20px; padding-bottom: 16px; padding-right: 56px; border-bottom: 1px solid var(--line); }
.toc-book { display: block; font-size: 18px; font-weight: 700; letter-spacing: .12em; color: var(--ink); text-decoration: none; }
.toc-book:hover { color: var(--accent); }
.toc-version { font-size: 12px; color: var(--muted); }
.toc-pdfbtn { position: absolute; top: 0; right: 0; padding: 6px; color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; border-radius: 8px; }
.toc-pdfbtn:hover { background: var(--bg-soft); color: var(--accent-dark); }
.toc-group { margin-bottom: 22px; }
.toc-group-title { font-size: 13px; font-weight: 700; letter-spacing: .15em; color: var(--muted); margin: 0 0 6px; }
.toc-group ul { list-style: none; margin: 0; padding: 0; }
.toc-link { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 6px; font-size: 14.5px; color: var(--ink); text-decoration: none; }
.toc-link:hover { background: var(--bg-soft); color: var(--accent); }
.toc-link.active { background: rgba(30, 77, 140, .10); color: var(--accent); font-weight: 600; }
.toc-pdf { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.toc-badge { font-size: 11px; letter-spacing: .05em; color: var(--accent); border: 1px solid currentColor; border-radius: 999px; padding: 0 7px; flex-shrink: 0; }
.toc-globe { display: inline-flex; align-self: center; flex-shrink: 0; color: var(--accent); }
.toc-sub { font-size: 12px; color: var(--muted); }
.toc-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.toc-pill { padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--ink); text-decoration: none; }
.toc-pill:hover { border-color: var(--accent); color: var(--accent); }
.toc-fallback { font-size: 14px; color: var(--muted); }
.toc-fallback p { margin: 0 0 8px; }

/* ============================================================
   手機版：懸浮按鈕＋左滑目錄
   ============================================================ */
#toc-toggle { display: none; }
#toc-overlay { display: none; }
@media (max-width: 1023px) {
  .book { display: block; }
  .book-sidebar { position: fixed; top: 0; left: 0; height: 100%; width: min(320px, 86vw); z-index: 1000; transform: translateX(-105%); transition: transform .25s ease; border-right: none; box-shadow: 2px 0 18px rgba(0,0,0,.15); }
  body.toc-open .book-sidebar { transform: translateX(0); }
  body.toc-open { overflow: hidden; }
  .book-main { padding: 28px 20px 96px; }
  #toc-toggle { display: flex; align-items: center; justify-content: center; position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 1100; width: 52px; height: 52px; color: #fff; background: var(--accent); border: none; border-radius: 50%; box-shadow: 0 4px 14px rgba(0,0,0,.22); cursor: pointer; }
  #toc-toggle:active { transform: translateY(1px); }
  #toc-overlay { position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,.4); }
  body.toc-open #toc-overlay { display: block; }
}

/* ============================================================
   右上角無邊框 X 關閉鈕（book.js 注入）
   ============================================================ */
#book-close { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 800; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: none; background: transparent; color: #9aa2ad; cursor: pointer; border-radius: 8px; }
#book-close:hover { color: var(--accent); background: var(--bg-soft); }

/* ============================================================
   章節內文排版（全域）
   ============================================================ */
.chapter-head { margin-bottom: 40px; }
.chapter-num {
  margin: 0; font-family: var(--font-serif);
  font-size: 64px; line-height: 1; font-weight: 700;
  font-style: italic; letter-spacing: .04em;
  color: var(--accent); opacity: .5;
  -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent 78%);
          mask-image: linear-gradient(to bottom, #000 78%, transparent 78%);
  position: relative; z-index: 0;
}
/* H1＝黑體粗（跟 H2 襯線分家） */
.chapter h1 { margin: -12px 0 0; font-family: var(--font); font-weight: 700; font-size: 32px; line-height: 1.3; letter-spacing: .04em; color: var(--accent); position: relative; z-index: 1; }
.chapter h2 { margin: 56px 0 16px; padding-bottom: 8px; font-family: var(--font-serif); font-size: 24px; letter-spacing: .06em; color: var(--accent); border-bottom: 2px solid var(--line); }
.chapter h3 { margin: 32px 0 12px; font-family: var(--font-serif); font-size: 19px; }
.chapter .group-head { margin: 32px 0 12px; font-size: 19px; font-weight: 700; color: var(--accent-dark); }
.chapter p { margin: 0 0 16px; }
.chapter ol li, .chapter ul li { margin-bottom: 10px; }
.chapter strong { color: var(--accent-dark); }

/* 編號清單：自動補零成 01. 02. */
.chapter ol { list-style: none; counter-reset: znum; padding-left: 0; }
.chapter ol li { position: relative; padding-left: 2.0em; }
.chapter ol ol li, .chapter h3 ~ ol li { padding-left: 1.5em; }
.chapter ol li::before {
  counter-increment: znum;
  content: counter(znum, decimal-leading-zero) ".";
  position: absolute; left: 0; top: 0;
  color: var(--muted);
}
/* H3 下的清單、編號清單內嵌套的清單：自動 a. b. c. */
.chapter h3 ~ ol,
.chapter ol ol { counter-reset: anum; }
.chapter h3 ~ ol > li::before,
.chapter ol ol > li::before {
  counter-increment: anum;
  content: counter(anum, lower-alpha) ".";
}

.pdf-ref { margin-left: 10px; font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.lead { font-size: 17px; font-weight: 500; }
.footnote { font-size: 13px; color: var(--muted); }
.notice { margin: 20px 0; padding: 14px 20px; background: var(--bg-soft); border-left: 4px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; font-size: 15px; }
.mission-quote { margin: 24px 0; padding: 20px 24px; background: var(--bg-soft); border-left: 4px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; font-size: 17px; }

/* ---------- 表格（全域） ---------- */
.table-wrap { overflow-x: auto; margin: 20px 0; }
.chapter table { border-collapse: collapse; width: 100%; font-size: 15px; }
/* 內容格：垂直置中、水平靠左 */
.chapter th, .chapter td { border: 1px solid var(--line); padding: 10px 14px; text-align: left; vertical-align: middle; }
.chapter th { background: var(--bg-soft); font-weight: 600; }
/* 第一欄：不換行、自動縮到內容寬、垂直＋水平置中 */
.chapter th:first-child, .chapter td:first-child { white-space: nowrap; width: 1%; text-align: center; }
/*表頭列文字置中*/
.chapter thead th { text-align: center; }
/*表格項目符號位置調整*/
.chapter td ul { padding-left: 1.4em; }
/*修掉瀏覽器預設紫*/
.chapter a { color: var(--accent); }

/* ---------- 圖位基礎（全域；各章尺寸寫在各章 <style>） ---------- */
.img-slot { position: relative; margin: 20px 0; border: 1px dashed var(--line); border-radius: var(--radius); background-color: var(--bg-soft); background-position: center; background-repeat: no-repeat; }
.img-slot .cap { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 4px 12px; font-size: 12px; color: var(--muted); background: rgba(255,255,255,.88); border-top: 1px dashed var(--line); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- 上一頁／下一頁（慣例：← 章名 ／ 章名 →） ---------- */
.chapter-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); }
.chapter-nav a { padding: 12px 20px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 15px; color: var(--ink); text-decoration: none; }
.chapter-nav a:hover { border-color: var(--accent); color: var(--accent); }
.chapter-nav .next { margin-left: auto; }

/* ============================================================
   封面
   ============================================================ */
.cover { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: var(--bg-soft); }
.cover-card { width: 100%; max-width: 640px; padding: 56px 44px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; }
.cover-school { margin: 0 0 24px; font-size: 14px; letter-spacing: .35em; color: var(--muted); }
.cover-title { margin: 0 0 8px; font-family: var(--font-serif); font-size: 44px; letter-spacing: .14em; color: var(--accent); }
.cover-version { margin: 0 0 20px; color: var(--muted); }
.cover-desc { margin: 0 auto 32px; max-width: 38ch; color: var(--muted); }
.cover-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-bottom: 36px; }
.btn { display: inline-block; padding: 12px 30px; border-radius: var(--radius); font-size: 16px; letter-spacing: .1em; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.quick-links { border-top: 1px solid var(--line); padding-top: 26px; }
.quick-title { margin: 0 0 14px; font-size: 13px; letter-spacing: .2em; color: var(--muted); }
.quick-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.quick-grid a { padding: 6px 16px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; color: var(--ink); text-decoration: none; }
.quick-grid a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 列印 ---------- */
@media print {
  .book-sidebar, #toc-toggle, #toc-overlay, .chapter-nav, #book-close { display: none; }
  .book-main { padding: 0; }
}

/* ---------- 延伸閱讀手風琴（全域；原生 details，零 JS） ---------- */
.acc { margin: 20px 0; border-left: 4px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; overflow: hidden; }
.acc summary { position: relative; cursor: pointer; list-style: none; padding: 12px 40px 12px 20px; background: var(--bg-soft); font-size: 15px; font-weight: 700; letter-spacing: .06em; color: var(--accent-dark); transition: color .2s; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary:hover { color: var(--accent); }
.acc summary:active { transform: translateY(1px); }
/* +/- icon：兩槓近黑；開時直槓轉平＝plus 變 minus */
.acc summary::before,
.acc summary::after { content: ""; position: absolute; right: 16px; top: 50%; width: 16px; height: 2px; border-radius: 2px; background: var(--ink); opacity: .7; transition: transform .3s cubic-bezier(.16, 1, .3, 1), opacity .2s; }
.acc summary::before { transform: translateY(-50%); }
.acc summary::after { transform: translateY(-50%) rotate(90deg); }
.acc summary:hover::before,
.acc summary:hover::after { opacity: 1; }
.acc[open] summary::after { transform: translateY(-50%) rotate(0deg); }
/* 展開：白內容區＋hairline 分隔；留白收緊 */
.acc-body { padding: 12px 20px 14px; background: var(--bg); border-top: 1px solid var(--line); }
.acc-body > :first-child { margin-top: 0; }
.acc-body > :last-child { margin-bottom: 0; }
.acc-body li:last-child { margin-bottom: 0; }
.acc[open] .acc-body { animation: acc-in .3s cubic-bezier(.16, 1, .3, 1); }
@keyframes acc-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.acc-more { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 15px; }
.acc-more a { color: var(--accent); }
/* 連續手風琴緊貼成組 */
.acc + .acc { margin-top: 0; border-radius: 0 0 var(--radius) 0; }
.acc:has(+ .acc) { margin-bottom: 0; border-radius: 0 var(--radius) 0 0; }
.acc + .acc:has(+ .acc) { border-radius: 0; }
.acc + .acc summary { border-top: 1px solid var(--line); }
/* 展開時：裝飾線留縫、恢復獨立塊 */
.acc[open]:has(+ .acc),
.acc:has(+ .acc[open]) { margin-bottom: 12px; }
.acc[open], .acc[open] + .acc { border-top-right-radius: var(--radius); }
.acc[open], .acc:has(+ .acc[open]) { border-bottom-right-radius: var(--radius); }
.acc[open] + .acc summary,
.acc + .acc[open] summary { border-top: 0; }

/* ---------- 手機版全域字級 ---------- */
@media (max-width: 1023px) {
  .chapter-num { font-size: 52px; }
  .chapter h1 { font-size: 27px; }
  .chapter h2 { font-size: 21px; margin-top: 44px; }
}