/* ===== 德州撲克參考書 — 全域樣式 =====
   移植自 investing-handbook styles.css（本身移植自 board-exam）。
   改：accent 改撲克牌桌 felt 深青綠（與投資版森林綠區隔）；加「小遊戲框架」+ range-grid 樣式。 */
:root {
  --ink: #1a1a1a;
  --paper: #faf9f7;
  --accent: #0f5e5a;        /* 深青綠 felt — 章節標題（撲克牌桌感，與投資版 #14532d 區隔）*/
  --accent-soft: #eaf5f3;
  --rule: #d4d4d4;
  --keynote-bg: #fffbea;
  --keynote-border: #facc15;
  --keynote-fg: #854d0e;
  --trap-bg: #fef2f2;
  --trap-border: #fca5a5;
  --trap-fg: #991b1b;
  --clinical-bg: #f0f9ff;   /* 範例 spot（原理示範）*/
  --clinical-border: #7dd3fc;
  --clinical-fg: #075985;
  --note-bg: #f5f3ff;       /* 取捨 / 爭議 / GTO vs 剝削 */
  --note-border: #c4b5fd;
  --note-fg: #5b21b6;
  --kol-bg: #f7f5ef;        /* §實務補充（T3 非學術來源）*/
  --kol-border: #b08d3a;
  --kol-fg: #6b521b;
  --suit-red: #c1272d;      /* 紅心/方塊 */
  --suit-black: #1a1a1a;    /* 黑桃/梅花 */
}

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;
}

/* ===== 撲克牌面 pip（內文/遊戲共用）===== */
.card-pip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.7em; height: 2.3em; padding: 0 0.3em; margin: 0 0.12em;
  border: 1px solid var(--rule); border-radius: 4px; background: #fff;
  font-family: "Helvetica Neue", Arial, sans-serif; font-weight: 700; font-size: 1em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08); vertical-align: middle; line-height: 1;
}
.card-pip.red { color: var(--suit-red); }
.card-pip.black { color: var(--suit-black); }

/* ===== 來源分層 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: #0f5e5a; color: #fff; }       /* 經典 / 理論 */
.tier-tag.t2 { background: #1e40af; color: #fff; }       /* 權威實務 / solver */
.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: #0f766e; 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; }

/* ============================================================
   ===== 小遊戲框架（games.js hydrate 的宣告式元件）=========
   宣告：<div class="poker-game" data-game="pot-odds" data-config='{...}'></div>
   ============================================================ */
.poker-game { margin: 1.6em 0; }
.pg-card {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  padding: 1.1em 1.3em;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.pg-title {
  font-weight: 700; color: var(--accent); font-size: 0.95em;
  margin-bottom: 0.7em; display: flex; align-items: center; gap: 0.4em;
}
.pg-title .pg-badge {
  font-size: 0.72em; font-weight: 700; letter-spacing: 0.04em; color: #fff;
  background: var(--accent); border-radius: 99px; padding: 0.1em 0.6em;
}
.pg-prompt { line-height: 1.7; margin-bottom: 0.8em; }
.pg-prompt .no-indent { text-indent: 0; }
.pg-error { color: var(--trap-fg); background: var(--trap-bg); border:1px solid var(--trap-border);
  padding: 0.6em 0.9em; border-radius: 6px; font-size: 0.9em; }

.pg-btn {
  border: 1px solid var(--accent); background: #fff; color: var(--accent);
  padding: 0.5em 1.1em; border-radius: 6px; cursor: pointer; font-size: 0.92em;
  font-family: inherit; transition: all 0.12s;
}
.pg-btn:hover { background: var(--accent-soft); }
.pg-btn.primary { background: var(--accent); color: #fff; }
.pg-btn.primary:hover { background: #0c4d4a; }
.pg-btn:disabled { opacity: 0.5; cursor: default; }
.pg-actions { display: flex; gap: 0.6em; flex-wrap: wrap; margin: 0.6em 0; }

.pg-result {
  margin-top: 0.9em; padding: 0.8em 1em; border-radius: 6px; line-height: 1.65;
  border: 1px solid var(--rule); background: #f7faf9;
}
.pg-result.correct { background: #ecfdf5; border-color: #6ee7b7; }
.pg-result.wrong { background: var(--trap-bg); border-color: var(--trap-border); }
.pg-result .pg-verdict { font-weight: 700; }
.pg-result.correct .pg-verdict { color: #065f46; }
.pg-result.wrong .pg-verdict { color: var(--trap-fg); }
.pg-result .pg-why { margin-top: 0.4em; font-size: 0.94em; }

/* slider / number 互動 */
.pg-control { display: flex; align-items: center; gap: 0.7em; margin: 0.5em 0; flex-wrap: wrap; }
.pg-control label { font-size: 0.88em; color: #555; min-width: 7.5em; }
.pg-control input[type=range] { flex: 1; min-width: 140px; accent-color: var(--accent); }
.pg-control .pg-val { font-family: "Menlo", monospace; font-weight: 700; color: var(--accent); min-width: 4em; text-align: right; }
.pg-control input[type=number] {
  width: 5.5em; padding: 0.3em 0.5em; border: 1px solid var(--rule); border-radius: 4px; font-family: inherit;
}
.pg-readout { font-size: 1.05em; line-height: 1.7; margin-top: 0.6em; }
.pg-readout b { color: var(--accent); font-family: "Menlo", monospace; }
.pg-bar { height: 10px; background: #e7e5e4; border-radius: 5px; overflow: hidden; margin: 0.4em 0; }
.pg-bar .pg-fill { height: 100%; background: linear-gradient(90deg,#5eead4,#0f766e); transition: width 0.25s; }
.pg-bar .pg-fill.neg { background: linear-gradient(90deg,#fca5a5,#dc2626); }

/* ===== 13×13 起手牌 range grid ===== */
.pg-grid {
  display: grid; grid-template-columns: repeat(13, 1fr); gap: 2px;
  max-width: 460px; margin: 0.6em 0; user-select: none;
}
.pg-cell {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  font-size: 0.62rem; font-family: "Menlo", monospace; font-weight: 700;
  border-radius: 3px; cursor: pointer; color: #555; transition: background 0.1s, color 0.1s;
}
.pg-cell.pair    { background: #e7efee; }
.pg-cell.suited  { background: #f1f5f4; }
.pg-cell.offsuit { background: #faf9f7; border: 1px solid #eee; }
.pg-cell.selected { background: var(--accent); color: #fff; }
.pg-cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.pg-grid-legend { display: flex; gap: 1em; font-size: 0.78em; color: #666; flex-wrap: wrap; margin-top: 0.3em; }
.pg-grid-legend span { display: inline-flex; align-items: center; gap: 0.35em; }
.pg-grid-legend .swatch { width: 0.9em; height: 0.9em; border-radius: 2px; display: inline-block; border:1px solid #ddd; }

/* ===== 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, #5eead4, #0f766e); 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; color: #c4c4c4; }
.concept-row.read .mark { color: #0f766e; }
.concept-row.read { background: #f3faf9; }
.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: #0f766e; }
.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; }
  .pg-grid { max-width: 100%; }
  .pg-cell { font-size: 0.5rem; }
  .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, .pg-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; }
  /* 遊戲互動在紙本無意義 → 隱藏操作、保留標題提示讀者線上玩 */
  .pg-actions, .pg-control input[type=range], .fc-reveal, .fc-rate { display: none !important; }
}
