/* ===== 投資參考書 — 全域樣式 =====
   移植自 board-exam reference-book/site/styles.css，去醫學特化、
   加投資專屬（來源分層標籤、§實務補充 KOL 區塊、Part 導向 dashboard）。 */
:root {
  --ink: #1a1a1a;
  --paper: #fafaf7;
  --accent: #14532d;        /* 深綠 — 章節標題（投資 / 沉穩，與 board-exam 棕紅區隔）*/
  --accent-soft: #f1f7f2;
  --rule: #d4d4d4;
  --keynote-bg: #fffbea;
  --keynote-border: #facc15;
  --keynote-fg: #854d0e;
  --trap-bg: #fef2f2;
  --trap-border: #fca5a5;
  --trap-fg: #991b1b;
  --clinical-bg: #f0f9ff;   /* 範例情境 */
  --clinical-border: #7dd3fc;
  --clinical-fg: #075985;
  --note-bg: #f5f3ff;       /* 取捨 / 爭議 */
  --note-border: #c4b5fd;
  --note-fg: #5b21b6;
  --kol-bg: #f7f5ef;        /* §實務補充（T3 非學術來源）*/
  --kol-border: #b08d3a;
  --kol-fg: #6b521b;
}

body {
  font-family: "Noto Serif TC", "PingFang TC", "Helvetica Neue", serif;
  color: var(--ink);
  background: var(--paper);
  margin: 0;
}

/* ===== 排版（中文 prose）===== */
.prose-zh { line-height: 1.85; letter-spacing: 0.02em; }
.prose-zh p { text-indent: 2em; margin-bottom: 1em; }
.prose-zh p.no-indent { text-indent: 0; }
.prose-zh ul, .prose-zh ol { line-height: 1.8; }

.book-title { font-family: "Times New Roman", serif; }
.section-num { font-family: "Times New Roman", serif; font-weight: 700; color: var(--accent); }

/* ===== 標題層級（spec: 所有 §1-§N 統一用 h2.section）===== */
h1.page-title { font-size: 2.25rem; font-weight: 700; line-height: 1.2; }
h2.section {
  color: var(--accent);
  border-left: 4px solid var(--accent);
  padding-left: 0.6em;
  margin-top: 2em;
  font-size: 1.4rem;
  font-weight: 700;
}
h2.section .section-num { margin-right: 0.5em; }
h3.subsection {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 1.5em;
  color: var(--ink);
}

/* ===== Pull quote（章節導讀心法）===== */
.pull-quote {
  border-left: 4px solid var(--accent);
  padding: 0.6em 1.2em;
  background: var(--accent-soft);
  font-style: italic;
  margin: 1em 0;
  border-radius: 0 4px 4px 0;
}

/* ===== Callout boxes ===== */
.keynote, .trap, .clinical, .nuance, .kol-note {
  border-radius: 6px;
  padding: 1em 1.2em;
  margin: 1.5em 0;
  border: 1px solid;
}
.keynote  { background: var(--keynote-bg);   border-color: var(--keynote-border); }
.keynote  h4 { font-weight: 700; color: var(--keynote-fg);  margin: 0 0 0.5em; }
.trap     { background: var(--trap-bg);      border-color: var(--trap-border); }
.trap     h4 { font-weight: 700; color: var(--trap-fg);     margin: 0 0 0.5em; }
.clinical { background: var(--clinical-bg);  border-color: var(--clinical-border); }
.clinical h4 { font-weight: 700; color: var(--clinical-fg); margin: 0 0 0.5em; }
.nuance   { background: var(--note-bg);      border-color: var(--note-border); }
.nuance   h4 { font-weight: 700; color: var(--note-fg);     margin: 0 0 0.5em; }

/* ===== §實務補充（T3 中文 KOL / 社群觀點 — G6：非學術來源，必標註）===== */
.kol-note { background: var(--kol-bg); border-color: var(--kol-border); border-left-width: 4px; }
.kol-note h4 { font-weight: 700; color: var(--kol-fg); margin: 0 0 0.5em; }
.kol-note .kol-tag {
  display: inline-block; font-size: 0.72em; font-weight: 700; letter-spacing: 0.05em;
  background: var(--kol-border); color: #fff; padding: 0.1em 0.6em; border-radius: 99px;
  vertical-align: middle; margin-left: 0.5em;
}

/* ===== 自我檢測卡（active recall self-check）===== */
.oral-card {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 1.1em 1.3em;
  margin: 1.1em 0;
  background: #fffdfa;
}
.oral-q { line-height: 1.7; }
.oral-q .oral-tag {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.72em;
  font-weight: 600;
  padding: 0.1em 0.6em;
  border-radius: 99px;
  vertical-align: middle;
  margin-right: 0.4em;
  letter-spacing: 0.05em;
}
.oral-card .ans-block { background: #f5f5f4; margin-top: 1em; padding: 0.8em 1em; border-radius: 6px; }
.ans-block.hidden-content { display: none; }
.oral-card button[data-toggle="answer"] {
  font-size: 0.85em; margin-top: 0.6em; color: var(--accent);
  background: none; border: none; cursor: pointer; text-decoration: underline;
}
@media print { .oral-card { break-inside: avoid; page-break-inside: avoid; } }

/* ===== 表格 ===== */
table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 0.92em; }
th, td { border: 1px solid var(--rule); padding: 0.5em 0.75em; text-align: left; }
th { background: #f5f5f4; font-weight: 700; }

/* ===== ASCII 圖 ===== */
.ascii-figure {
  font-family: "Menlo", "Consolas", monospace;
  white-space: pre;
  background: #f5f5f4;
  padding: 1em;
  border-radius: 6px;
  font-size: 0.85em;
  line-height: 1.4;
  overflow-x: auto;
}

/* ===== 來源分層 footer ===== */
.sources { font-size: 0.9em; color: #555; border-top: 1px solid var(--rule); margin-top: 3em; padding-top: 1em; }
.sources ul { list-style: none; padding-left: 0; }
.sources li { margin: 0.4em 0; }
.tier-tag {
  display: inline-block; font-size: 0.72em; font-weight: 700; letter-spacing: 0.04em;
  border-radius: 4px; padding: 0.1em 0.5em; margin-right: 0.5em; vertical-align: middle;
}
.tier-tag.t1 { background: #14532d; color: #fff; }       /* 經典 / 學術 */
.tier-tag.t2 { background: #1e40af; color: #fff; }       /* 權威實務 */
.tier-tag.t3 { background: #b08d3a; color: #fff; }       /* 中文 KOL（非學術）*/
.market-tag {
  display: inline-block; font-size: 0.78em; border: 1px solid var(--rule);
  border-radius: 99px; padding: 0.05em 0.6em; color: #555; background: #fff;
}

/* ===== 全站 chrome (header/footer 由 app.js 注入) ===== */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: #fff;
  padding: 0.7em 1em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9em;
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header a { color: var(--accent); text-decoration: none; }
.site-header a:hover { text-decoration: underline; }
.site-header .breadcrumb { color: #666; }
.site-header .toolbar { display: flex; gap: 0.5em; }
.site-header button {
  border: 1px solid var(--rule);
  background: #fff;
  padding: 0.3em 0.8em;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
}
.site-header button:hover { background: #f5f5f4; }
.site-header button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.site-header button.primary:hover { background: #333; }
.site-header button.read-toggle.read-on {
  background: #ecfdf5; border-color: #16a34a; color: #064e3b; font-weight: 600;
}
.site-header button.read-toggle.read-on:hover { background: #d1fae5; }

.site-footer {
  margin-top: 4em;
  padding: 1.5em 1em;
  border-top: 1px solid var(--rule);
  font-size: 0.85em;
  color: #666;
  text-align: center;
}

/* ===== 頁首 metadata 條 ===== */
.page-meta {
  font-size: 0.85em;
  color: #666;
  margin-top: 0.4em;
}
.page-meta code { background: #f5f5f4; padding: 0.1em 0.4em; border-radius: 3px; }
.priority-stars { color: var(--accent); font-weight: 700; }

/* ===== Cross-link 狀態（app.js 自動加 class）===== */
a[data-concept-link] { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent); }
a[data-concept-link].dead-link { color: #999 !important; text-decoration: line-through; border-bottom: none; }
a[data-concept-link].pending-link { border-bottom: 1px dashed #aaa; color: #777; }

/* ===== Dashboard（Part 導向）===== */
.dashboard { max-width: 1000px; margin: 0 auto; padding: 1.5em 1.2em 4em; }
.book-cover { text-align: center; padding: 2em 1em 1.5em; border-bottom: 2px solid var(--ink); margin-bottom: 1.5em; }
.book-cover h1 { font-family: "Times New Roman", "Noto Serif TC", serif; font-size: 2.4rem; margin: 0 0 0.3em; }
.book-cover .subtitle { color: #666; font-size: 1rem; }
.book-cover .cover-cta { margin-top: 1.2em; display: flex; gap: 0.7em; justify-content: center; flex-wrap: wrap; }
.book-cover .cover-cta a {
  text-decoration: none; padding: 0.5em 1.1em; border-radius: 6px; font-size: 0.92em;
  border: 1px solid var(--accent); color: var(--accent); background: #fff;
}
.book-cover .cover-cta a.primary { background: var(--accent); color: #fff; }
.book-cover .cover-cta a:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.08); }

.summary-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.8em; margin-bottom: 1.5em; }
.stat-card { background: #fff; border: 1px solid var(--rule); border-radius: 6px; padding: 0.8em 1em; text-align: center; }
.stat-card .num { font-size: 1.5em; font-weight: 700; color: var(--accent); }
.stat-card .lbl { font-size: 0.8em; color: #666; }

.coverage-bar { height: 8px; background: #e7e5e4; border-radius: 4px; overflow: hidden; margin: 0.5em 0 2em; }
.coverage-bar .fill { height: 100%; background: linear-gradient(90deg, #86efac, #16a34a); transition: width 0.6s; }

.part-section { margin-bottom: 2.4em; scroll-margin-top: 1em; }
.part-head {
  display: flex; align-items: baseline; gap: 0.8em; flex-wrap: wrap;
  border-bottom: 2px solid var(--ink); padding-bottom: 0.4em; margin-bottom: 0.9em;
}
.part-head .eyebrow {
  font-family: "Times New Roman", serif; font-size: 0.8em; font-weight: 700;
  color: var(--accent); letter-spacing: 0.15em; text-transform: uppercase;
}
.part-head h2 { margin: 0; font-size: 1.3rem; }
.part-head .progress { font-size: 0.85em; color: #666; margin-left: auto; }
.concept-rows { display: flex; flex-direction: column; gap: 0.35em; }
.concept-row {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 0.7em; align-items: center;
  padding: 0.6em 0.9em; border: 1px solid var(--rule); border-radius: 6px;
  background: #fff; text-decoration: none; color: var(--ink); transition: all 0.12s;
}
.concept-row:hover { border-color: var(--accent); transform: translateX(2px); }
.concept-row .mark { text-align: center; font-weight: 700; }
.concept-row.done .mark { color: #16a34a; }
.concept-row.todo .mark { color: #c4c4c4; }
.concept-row.read { background: #f7faf8; }
.concept-row .title { font-weight: 600; }
.concept-row.todo .title { color: #999; }
.concept-row.read .title { color: #555; }
.concept-row .cid { font-size: 0.74em; color: #aaa; font-family: "Menlo", monospace; }
.concept-row .badges { display: flex; gap: 0.4em; align-items: center; }
.concept-row .opt-pill {
  font-size: 0.7em; color: #777; background: #f0ede6; border-radius: 99px; padding: 0.05em 0.55em;
}

/* ===== Cram（active recall）===== */
.cram-wrap { max-width: 720px; margin: 0 auto; padding: 1.5em 1.2em 4em; }
.cram-toolbar { display: flex; gap: 0.6em; align-items: center; flex-wrap: wrap; margin: 1em 0; }
.cram-toolbar select, .cram-toolbar button {
  padding: 0.45em 0.8em; border: 1px solid var(--rule); border-radius: 4px; background: #fff; cursor: pointer; font-size: 0.9em;
}
.cram-progress { font-size: 0.9em; color: #555; margin: 0.6em 0; }
.flashcard { border: 1px solid var(--rule); border-radius: 10px; padding: 1.4em 1.5em; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.fc-meta { display: flex; gap: 0.5em; align-items: center; font-size: 0.78em; color: #888; margin-bottom: 0.8em; }
.fc-topic { background: var(--accent); color: #fff; padding: 0.1em 0.6em; border-radius: 99px; }
.fc-title { font-weight: 700; font-size: 1.05em; margin-bottom: 0.6em; }
.fc-recall { font-size: 1.05em; line-height: 1.7; margin-bottom: 1em; }
.fc-reveal { padding: 0.6em 1.1em; border: 1px solid var(--accent); background: #fff; color: var(--accent); border-radius: 6px; cursor: pointer; }
.fc-answer.hidden { display: none; }
.fc-oneliner { background: #f5f5f4; border-radius: 6px; padding: 0.8em 1em; line-height: 1.7; }
.fc-rate { display: flex; gap: 0.6em; margin-top: 1em; }
.fc-rate button { flex: 1; padding: 0.6em; border-radius: 6px; border: 1px solid var(--rule); cursor: pointer; font-size: 0.95em; }
.fc-rate button[data-r="unknown"]:hover { background: var(--trap-bg); border-color: var(--trap-border); }
.fc-rate button[data-r="shaky"]:hover { background: var(--keynote-bg); border-color: var(--keynote-border); }
.fc-rate button[data-r="know"]:hover { background: #ecfdf5; border-color: #16a34a; }
.empty-state { text-align: center; color: #999; padding: 3em 1em; line-height: 1.8; }

/* ===== Mini-TOC（右側浮動章節導航）===== */
.mini-toc a:hover { color: var(--accent) !important; }

/* ===== Mobile + Tablet (≤ 1099px) ===== */
@media (max-width: 1099px) {
  .site-header { flex-direction: column; align-items: stretch; gap: 0.4em; padding: 0.5em 0.7em; }
  .site-header .breadcrumb { font-size: 0.8em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .site-header .toolbar { flex-wrap: wrap; justify-content: flex-end; gap: 0.3em; }
  .site-header .toolbar button { font-size: 0.78em; padding: 0.3em 0.6em; white-space: nowrap; min-height: 44px; }
  main[style*="max-width: 880px"] { padding-left: 0.9em !important; padding-right: 0.9em !important; }
  h1.page-title, h1.book-title { font-size: 1.6rem; line-height: 1.25; word-break: break-word; overflow-wrap: anywhere; }
  h2.section { font-size: 1.2rem; word-break: break-word; }
  .keynote, .trap, .clinical, .nuance, .kol-note { padding: 0.8em 0.9em; }
  main table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pull-quote { font-size: 0.95em; padding: 0.7em 0.9em; }
  .concept-row { grid-template-columns: 22px 1fr; grid-template-areas: "mark title" "mark badges"; gap: 0.15em 0.6em; min-height: 44px; }
  .concept-row .mark { grid-area: mark; align-self: center; }
  .concept-row .title { grid-area: title; }
  .concept-row .badges { grid-area: badges; justify-self: start; }
}

/* ===== Print CSS ===== */
@page { size: A4; margin: 18mm 16mm 20mm 16mm; }
@media print {
  body { background: #fff; font-size: 10.5pt; orphans: 3; widows: 3; }
  .no-print, .site-header, .site-footer, .mini-toc, #mini-toc-pill { display: none !important; }
  .ans-block { display: block !important; background: transparent; border: 1px dashed #ccc; }
  h1.page-title, h1.book-title { break-after: avoid; page-break-after: avoid; break-before: page; page-break-before: page; }
  h2.section, h3.subsection { break-after: avoid; page-break-after: avoid; }
  .keynote, .trap, .clinical, .nuance, .kol-note, .oral-card { break-inside: avoid; page-break-inside: avoid; }
  table { break-inside: avoid; page-break-inside: avoid; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; page-break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
