/* 史料卡（public/client/history.js）。遊戲頁、首頁、紀念碑區共用。
   色票沿用戰地海報風（docs/kinmen-theme.md §5）。紅色只留給預警圈與爆炸，這裡一律不用。
   色值與字級一律用 tokens.css（最小 18px、正文 24px）。
   層級：標題 28 → 正文與引文 24 → 主張表 20 → 出處 18。 */

.hcard {
  --h-cream: var(--cream);
  --h-olive: var(--olive);
  --h-olive2: var(--olive2);
  --h-ochre: var(--ochre);
  --h-ink: var(--ink);
  --h-stone: var(--stone);
  color: var(--h-ink);
  font: 500 var(--text-base)/1.6 "Noto Sans TC", "PingFang TC", sans-serif;
  display: grid;
  gap: 10px;
  -webkit-user-select: text;
  user-select: text;
}
.hcard > * { margin: 0; }
.hcard__title { font: 900 var(--text-lg)/1.3 "Noto Serif TC", serif; }
.hcard__muted { color: var(--ink2); }
.hcard__quote {
  border-left: 5px solid var(--h-olive);
  background: color-mix(in oklch, var(--olive2) 12%, transparent);
  padding: 8px 12px;
  font-weight: 500;
  line-height: 1.7;
}
.hcard__note { color: var(--ink2); font-size: var(--text-sm); }
.hcard__source { overflow-wrap: anywhere; font-size: var(--text-xs); line-height: 1.6; }
/* 首頁的 a 有按鈕樣式，卡片內的連結要蓋回一般連結 */
.hcard a { display: inline; color: var(--h-ink); background: none; border: 0; box-shadow: none; padding: 0; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.hcard a:hover, .hcard a:focus-visible { background: none; color: var(--h-olive); }
.hcard__locator { color: var(--ink2); }
.hcard__meta { display: flex; flex-wrap: wrap; gap: 6px 8px; }

/* 信度：語意對應特展 Tag（高／中／低／有爭議），色彩換成海報色票 */
.hbadge {
  display: inline-flex; align-items: baseline; gap: 0.4em;
  font: 700 var(--text-xs)/1.3 "Noto Sans TC", sans-serif;
  padding: 2px 10px; border-radius: 4px; border: 2px solid var(--h-ink);
  white-space: nowrap;
}
.hbadge__label { font-weight: 500; }
.hbadge--high { background: var(--h-olive); color: var(--h-cream); }
.hbadge--medium { background: var(--h-ochre); color: var(--h-ink); }
.hbadge--low { background: var(--h-stone); color: var(--h-ink); }
.hbadge--disputed { background: var(--h-ink); color: var(--h-cream); }

.hcard__claims { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hclaim { border: 2px solid var(--h-ink); border-radius: 4px; padding: 8px 10px; display: grid; gap: 6px; background: color-mix(in oklch, var(--paper3) 60%, transparent); }
.hclaim > * { margin: 0; }
.hclaim__head { font-weight: 700; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.hclaim__actor { background: var(--h-ink); color: var(--h-cream); padding: 0 8px; border-radius: 3px; }
.hclaim__dl { font-size: var(--text-sm); display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; }
.hclaim__dl dt { font-weight: 700; color: var(--h-olive); }
.hclaim__dl dd { margin: 0; }

/* ---------- 遊戲頁：角色選擇區的編組說明（選到編組角色時） ---------- */
.hunit {
  display: grid; gap: 6px;
  border-left: 5px solid var(--olive); background: color-mix(in oklch, var(--olive2) 12%, transparent);
  padding: 8px 12px;
  font: 500 var(--text-base)/1.6 "Noto Sans TC", "PingFang TC", sans-serif; color: var(--ink);
}
.hunit > * { margin: 0; }
.hunit__line { font-weight: 700; }
.hunit__name { background: var(--ink); color: var(--cream); padding: 0 8px; border-radius: 3px; margin-right: 8px; white-space: nowrap; }
.hunit__note { color: var(--ink2); }
.hunit .hunit__more { justify-self: start; color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 遊戲頁：大廳、過關、結算的卡片座 ---------- */
.hdock {
  position: fixed;
  left: calc(12px + env(safe-area-inset-left, 0px));
  top: calc(12px + env(safe-area-inset-top, 0px));
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 140px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--cream);
  color: var(--ink);
  border: 4px solid var(--ink);
  box-shadow: 6px 7px 0 var(--ink);
  touch-action: manipulation;
  z-index: 5;
}
.hdock__body { overflow: auto; padding: 14px 16px 12px; overscroll-behavior: contain; touch-action: pan-y; }
.hdock__bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 12px; border-top: 3px solid var(--ink); background: var(--stone);
}
.hdock__bar button, .hdock__more, .hdock__open {
  font: 700 var(--text-xs) "Noto Sans TC", sans-serif;
  color: var(--ink); background: var(--cream);
  border: 3px solid var(--ink); border-radius: 4px;
  padding: 4px 12px; min-height: 40px;
  box-shadow: 3px 3px 0 var(--ink); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center;
}
.hdock__nav { min-width: 44px; justify-content: center; font-size: var(--text-sm) !important; }
.hdock__count { font: 700 var(--text-xs) "Noto Sans TC", sans-serif; min-width: 3.5em; text-align: center; }
.hdock__more { background: var(--ochre); margin-left: auto; }
.hdock__bar button:focus-visible, .hdock__more:focus-visible, .hdock__open:focus-visible, .hnote:focus-visible { outline: 3px solid var(--olive); outline-offset: 2px; }
.hdock__bar button:active, .hdock__open:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
/* 立碑框出現時讓位（過關畫面也可能要立碑） */
body:has(#memorial:not([hidden])) .hdock { display: none; }
/* 收起後只留一顆小按鈕 */
.hdock:has(> .hdock__open:only-child) { width: auto; background: transparent; border: 0; box-shadow: none; display: block; }

/* 史料註腳：左上角一行，遊戲進行中不攔截觸控 */
.hnote {
  position: fixed;
  left: calc(12px + env(safe-area-inset-left, 0px));
  top: calc(12px + env(safe-area-inset-top, 0px));
  max-width: calc(100vw - 150px);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  font: 700 var(--text-xs)/1.4 "Noto Sans TC", sans-serif; text-align: left;
  color: var(--cream); background: color-mix(in oklch, var(--ink) 90%, transparent);
  border: 3px solid var(--ochre); border-radius: 6px; padding: 6px 12px;
  cursor: pointer; z-index: 6;
}
.hnote__label { color: var(--ochre); }
.hnote__hint { font-weight: 500; color: var(--stone); }
.hnote--live { pointer-events: none; cursor: default; }

/* 直式手機：讓出頂部那一列（「橫放手機」提示與音效鈕），底部讓出開始鈕 */
@media (orientation: portrait) and (max-width: 600px) {
  html.touch .hdock { top: calc(64px + env(safe-area-inset-top, 0px)); max-height: calc(100dvh - 64px - 150px); }
  html.touch .hnote { top: calc(64px + env(safe-area-inset-top, 0px)); max-width: calc(100vw - 24px); }
}
/* 手機橫式（高度很矮）：卡片座靠左、寬度收窄，右側留給開始鈕與觸控按鈕 */
@media (max-height: 520px) {
  .hdock { width: min(400px, calc(50vw - 12px)); max-height: calc(100dvh - 24px); }
  .hdock__body { padding: 10px 12px; }
  .hcard__title { font-size: var(--text-sm); }
}
/* 觸控橫放：讓出左側空白給搖桿（main.js 的 TOUCH_GUTTER = 128px），不然大廳時拖不動 */
@media (orientation: landscape) {
  html.touch .hdock, html.touch .hnote { left: calc(128px + 12px); }
  html.touch .hdock { width: min(400px, calc(100vw - 2 * 128px - 24px)); }
}
/* 窄螢幕：按鈕列維持一列 */
@media (max-width: 420px) {
  .hdock__bar { flex-wrap: nowrap; gap: 6px; padding: 8px; }
  .hdock__bar button, .hdock__more { padding: 4px 8px; }
  .hdock__nav { min-width: 40px; }
  .hdock__count { min-width: 2.6em; }
}
