@charset "UTF-8";
/* ============================================================================
   ux-fixes.css — 全站附加式 UX 修正層
   ----------------------------------------------------------------------------
   設計原則：
     • 只做「附加」（missing variables / offset / a11y / touch），不覆蓋任何版面
     • 必須在各頁自身 <style> 之後載入（由 _inject_ux.py 注入到 </head> 前）
     • 所有顏色變數都帶 fallback，即使頁面沒定義 :root 也不會壞
   ============================================================================ */

:root {
  /* --- 原本被使用但從未定義的變數（bug fix） --- */
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", "Courier New", monospace;
  --green-bg:  rgba(63, 185, 80, .12);
  --red-bg:    rgba(248, 81, 73, .12);
  --orange-bg: rgba(210, 153, 29, .12);
  --cyan-bg:   rgba(57, 197, 207, .12);
  --purple-bg: rgba(163, 113, 247, .12);

  /* --- 版面常數 --- */
  --ux-nav-h: 46px;   /* sticky 導航列高度（nav / .reader-bar） */
  --ux-gap:   16px;
}

/* ---------------------------------------------------------------------------
   1) 錨點跳轉要讓開 sticky 導航列，否則標題會被遮住
   --------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6,
[id] {
  scroll-margin-top: calc(var(--ux-nav-h) + var(--ux-gap));
}
:target {
  scroll-margin-top: calc(var(--ux-nav-h) + var(--ux-gap));
}

/* 被跳轉到的目標加一個短暫高亮，讓使用者知道「跳到這裡了」 */
:target {
  animation: uxTarget 1.2s ease-out 1;
}
@keyframes uxTarget {
  0%   { background-color: rgba(88, 166, 255, .18); }
  100% { background-color: transparent; }
}

/* ---------------------------------------------------------------------------
   2) sticky 表頭要停在導航列之下，而不是滑到它後面
      （只在真的有 sticky 導航的頁面生效 → body.ux-has-nav）
   --------------------------------------------------------------------------- */
/* 2026-11-11：原本這裡把 sticky 表頭的 top 設成 var(--ux-nav-h)（46px）。
   配合 guide.css 的 th{position:sticky}，結果表頭被推低 46px 蓋住第一行資料。
   既然 guide.css 已移除 sticky，這條規則不再需要（保留註解說明歷史）。 */
body.ux-has-nav table th {
  z-index: 3;
}

/* ---------------------------------------------------------------------------
   3) 鍵盤焦點可見（原本完全沒有 focus 樣式）
   --------------------------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent, #58a6ff);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------------------
   4) 尊重「減少動態」偏好
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
}

/* ---------------------------------------------------------------------------
   5) 手機：可點區域加大 + 字級微調
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
  body { font-size: 16px; }

  .subnav-btn,
  .hm-cat-chip,
  .quiz-mode-btn,
  .anchors a,
  .reader-bar a,
  .reader-nav a,
  .badge,
  .pill,
  .tag {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }

  .hm-pal { width: 36px; height: 36px; }

  /* 收納式摘要的點擊區加大（原本只有文字高） */
  summary { padding-top: 4px; padding-bottom: 4px; }
}

/* ---------------------------------------------------------------------------
   6) 寬表格在窄螢幕改為橫向捲動，而不是撐破版面
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .table-wrap,
  .ref-block { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 2026-11-11 修正：原本對未包裝的表格設 display:block。
     那會摧毀表格佈局（表頭與資料列錯位）—— 實測 Chrome 與 Firefox 都壞。
     改由 tablewrap.js 在載入時把未包裝的表格包進 .table-wrap，
     表格本身永遠保持 display:table。 */
}

/* ---------------------------------------------------------------------------
   7) 回到頂端按鈕（由 _inject_ux.py 注入，捲動 400px 後出現）
   --------------------------------------------------------------------------- */
#ux-top {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 9500;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border, #30363d);
  background: rgba(22, 27, 34, .92);
  color: var(--accent, #58a6ff);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: opacity .2s, border-color .2s, transform .2s;
}
#ux-top.show { display: flex; }
#ux-top:hover { border-color: var(--accent, #58a6ff); transform: translateY(-2px); }
#ux-top:active { transform: translateY(0); }

/* 列印時全部關掉 */
@media print {
  #ux-top { display: none !important; }
}

/* ===========================================================================
   8) 全站搜尋覆蓋層（Track B — 配合 search-overlay.js / search-data.js）
      ux-fixes.css 已注入全部 52 頁，所以這裡的樣式不需要額外注入。
   =========================================================================== */

/* --- 浮動觸發鈕（疊在 #ux-top 上方，避免重疊） --- */
#sx-open {
  position: fixed;
  right: 14px;
  bottom: 66px;
  z-index: 9500;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border, #30363d);
  background: rgba(22, 27, 34, .92);
  color: var(--accent, #58a6ff);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: opacity .2s, border-color .2s, transform .2s;
}
#sx-open:hover { border-color: var(--accent, #58a6ff); transform: translateY(-2px); }
#sx-open:active { transform: translateY(0); }

/* --- 覆蓋層 --- */
#sx-overlay {
  position: fixed;
  inset: 0;
  z-index: 9600;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 16px;
  background: rgba(1, 4, 9, .72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
#sx-overlay.on { display: flex; }

/* --- 對話框 --- */
#sx-box {
  width: 100%;
  max-width: 680px;
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: var(--bg, #0d1117);
  border: 1px solid var(--border, #30363d);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  overflow: hidden;
}

#sx-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #30363d);
}
#sx-icon { font-size: 15px; opacity: .7; }
#sx-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text, #e6edf3);
  font-size: 1.02em;
  font-family: inherit;
  padding: 6px 0;
}
#sx-input::placeholder { color: var(--text-dim, #8b949e); opacity: .75; }
#sx-close {
  font-family: var(--font-mono);
  font-size: .72em;
  letter-spacing: .04em;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border, #30363d);
  background: var(--surface, #161b22);
  color: var(--text-dim, #8b949e);
}
#sx-close:hover { color: var(--text, #e6edf3); border-color: var(--accent, #58a6ff); }

#sx-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 14px;
  font-size: .74em;
  color: var(--text-dim, #8b949e);
  border-bottom: 1px solid var(--border, #30363d);
}
#sx-hint { opacity: .75; }

/* --- 結果清單 --- */
#sx-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
}
.sx-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--text, #e6edf3);
}
.sx-item:hover { background: rgba(88, 166, 255, .07); }
.sx-item.sel { background: rgba(88, 166, 255, .13); border-color: var(--accent, #58a6ff); }

.sx-lv {
  flex: none;
  margin-top: 2px;
  padding: 3px 6px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: .66em;
  font-weight: 700;
  background: rgba(128, 128, 128, .18);
  color: var(--text-dim, #8b949e);
}
.sx-lv.lv1 { background: rgba(163, 113, 247, .20); color: var(--purple, #a371f7); }
.sx-lv.lv2 { background: rgba(88, 166, 255, .18); color: var(--accent, #58a6ff); }

.sx-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sx-t { font-size: .92em; line-height: 1.45; word-break: break-word; }
.sx-t mark {
  background: rgba(210, 153, 29, .28);
  color: var(--orange, #d2991d);
  border-radius: 3px;
  padding: 0 2px;
}
.sx-p { font-size: .72em; color: var(--text-dim, #8b949e); opacity: .85; }

.sx-empty {
  padding: 22px 14px;
  text-align: center;
  color: var(--text-dim, #8b949e);
  font-size: .86em;
  line-height: 1.9;
}
.sx-sub { font-size: .86em; opacity: .8; }

@media (max-width: 640px) {
  #sx-overlay { padding: 5vh 10px 10px; }
  #sx-box { max-height: 84vh; }
  #sx-hint { display: none; }
}

/* ============================================================================
   §9 開放式題庫（惰性渲染）— 由 qbank-data.js 注入的內容樣式
   原本逐格寫 inline style（~1500 個），改用 class；同時讓 HTML 縮小約 25%
   ============================================================================ */
.qb-mod {
  margin-bottom: 14px;
  background: var(--surface, #161b22);
  border: 1px solid var(--border, #30363d);
  border-radius: 10px;
  padding: 10px 16px;
}
.qb-mod > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent, #58a6ff);
  padding: 2px 0;
}
.qb-sub {
  font-size: .75em;
  color: var(--text-dim, #8b949e);
  font-weight: 400;
}
.qb-mount { margin-top: 10px; }
.qb-loading {
  color: var(--text-dim, #8b949e);
  font-size: .88em;
  padding: 6px 0;
  margin: 0;
}

.qb-table { width: 100%; border-collapse: collapse; }
.qb-table th {
  text-align: left;
  font-size: .85em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border, #30363d);
}
.qb-table td {
  vertical-align: top;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border, #30363d);
  word-break: break-word;
}
.qb-c-no, .qb-no { width: 4%; }
.qb-c-lv, .qb-lv { width: 7%; white-space: nowrap; }
.qb-c-q,  .qb-q  { width: 24%; font-weight: 600; }
.qb-c-a,  .qb-a  { width: 51%; font-size: .9em; line-height: 1.65; }
.qb-c-r,  .qb-r  { width: 14%; white-space: nowrap; font-size: .85em; }
.qb-no { color: var(--text-dim, #8b949e); font-weight: 400; }
.qb-na { color: var(--text-dim, #8b949e); }

.qb-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 9px;
  font-size: .72em;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid currentColor;
}
.qb-b1 { color: var(--green, #3fb950); }
.qb-b2 { color: var(--cyan, #39c5cf); }
.qb-b3 { color: var(--orange, #d29922); }
.qb-b4 { color: var(--red, #f85149); }

@media (max-width: 640px) {
  .qb-mod { padding: 8px 10px; }
  .qb-table { font-size: .92em; }
  .qb-c-a, .qb-a { font-size: .86em; }
}

/* ============================================================================
   §10 「⚡ 30 秒濃縮版」— 長頁頂部的「要點 + 用途 + 連接」區塊
   （由 _tools/_inject_condensed.py 注入；內容在 _tools/_condensed.json）
   ========================================================================= */
.cz {
  margin: 14px 0 20px;
  border: 1px solid var(--border);
  border-left: 4px solid #0e7c66;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 76, 129, .05);
  overflow: hidden;
}
.cz > summary {
  cursor: pointer;
  padding: 11px 15px;
  font-weight: 600;
  font-size: .98em;
  color: #0e7c66;
  background: linear-gradient(135deg, #f2faf5, #ffffff);
  border-bottom: 1px solid var(--border);
}
.cz-sub { font-weight: 400; font-size: .85em; color: var(--text-dim); margin-left: 6px; }
.cz-body { padding: 2px 16px 14px; }
.cz-what { margin: 12px 0 4px; line-height: 1.78; }
.cz-points { margin: 10px 0 4px; padding-left: 24px; line-height: 1.8; }
.cz-points > li { margin-bottom: 10px; }
.cz-points > li > b { color: var(--accent); }
.cz-use { display: block; margin-top: 3px; font-size: .9em; color: var(--text-dim); }
.cz-link, .cz-check {
  margin: 12px 0 4px;
  padding-top: 9px;
  border-top: 1px dashed var(--border);
  line-height: 1.8;
}
.cz-go { white-space: nowrap; font-weight: 600; }

@media (max-width: 640px) {
  .cz-sub { display: block; margin: 3px 0 0; }
  .cz-body { padding: 2px 12px 12px; }
  .cz-points { padding-left: 20px; }
}

/* ── §11 執行卡變體（variant=runbook）— 決策鏈／runbook 型頁面 ────────────── */
.cz-rule {
  margin: 12px 0 14px;
  padding: 11px 15px;
  border-left: 3px solid #0e7c66;
  border-radius: 0 8px 8px 0;
  background: #f2faf5;
  line-height: 1.85;
}
.cz-rule u { text-decoration-color: #0e7c66; text-underline-offset: 3px; }
.cz-route { margin: 14px 0 6px; line-height: 2.1; }
.cz-route b { color: var(--accent); font-weight: 600; }
.cz-route .cz-arw { color: var(--text-dim); margin: 0 6px; }
.cz-route-note { margin: 6px 0 4px; font-size: .92em; color: var(--text-dim); line-height: 1.75; }
.cz-th { margin: 14px 0 4px; border-collapse: collapse; width: 100%; font-size: .93em; }
.cz-th th, .cz-th td {
  border: 1px solid var(--border);
  padding: 7px 11px;
  text-align: left;
  vertical-align: top;
  line-height: 1.65;
}
.cz-th th { background: #f2faf5; color: #0e7c66; font-weight: 600; }
.cz-th td:first-child { white-space: nowrap; font-weight: 600; }
.cz-traps { margin: 14px 0 4px; padding-left: 22px; line-height: 1.8; }
.cz-traps > li { margin-bottom: 8px; }
.cz-h { display: block; margin: 16px 0 2px; font-weight: 600; color: #0e7c66; font-size: .95em; }

@media (max-width: 640px) {
  .cz-th, .cz-th tbody, .cz-th tr, .cz-th td, .cz-th th { display: block; width: auto; }
  .cz-th td:first-child { border-bottom: none; background: #f7fafd; }
  .cz-th tr { margin-bottom: 6px; }
  .cz-th tr:first-child { display: none; }
}

/* ── §12 結構地圖（map.html）──────────────────────────────────────────── */
.mp-badge {
  display: inline-block;
  font-size: .76em;
  padding: 1px 8px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: 1px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.mp-canon  { background: #e6f4ef; color: #0e6b58; border-color: #9ed7c2; }
.mp-view   { background: #eef2f9; color: #0f4c81; border-color: #b9cbe6; }
.mp-detail { background: #f4f1fb; color: #534ab7; border-color: #cfc9ef; }
.mp-pract  { background: #fdf2e3; color: #8a5a00; border-color: #efd6a8; }
.mp-fact   { background: #eef7ee; color: #2f6b2f; border-color: #b9dcb9; }
.mp-hub    { background: #f0f0f2; color: #444; border-color: #d2d2d6; }
.mp-h { display: block; margin: 28px 0 8px; font-weight: 600; color: #0e7c66; font-size: 1.02em; }
.mp-l3 { font-size: .9em; color: var(--text-dim); line-height: 1.75; }
.mp-dup {
  margin: 14px 0;
  padding: 11px 16px;
  border-left: 3px solid #b8860b;
  border-radius: 0 8px 8px 0;
  background: #fffaf0;
  line-height: 1.85;
}
.mp-fold { margin: 8px 0 20px; }
.mp-fold > summary { cursor: pointer; font-size: .92em; color: var(--text-dim); padding: 4px 0; }
.mp-fold .cz-th { font-size: .9em; }

@media (max-width: 640px) {
  .mp-badge { margin-bottom: 3px; }
}

/* ── §13 首頁意圖路由（由 _tools/_build_map.py 注入，勿手改）──────────────── */
.ir {
  margin: 6px 0 18px;
  padding: 14px 18px 12px;
  border: 1px solid var(--border);
  border-left: 4px solid #0f4c81;
  border-radius: 10px;
  background: var(--surface);
}
.ir-h {
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  font-size: 1em;
  font-weight: 600;
  color: #0f4c81;
}
.ir-list {
  margin: 0;
  padding-left: 20px;
  columns: 2;
  column-gap: 32px;
  line-height: 1.95;
  font-size: .94em;
}
.ir-list > li { margin: 0 0 2px; break-inside: avoid; }
.ir-list a { font-weight: 600; }
.ir-arw { color: var(--text-dim); margin: 0 2px; }
.ir-more {
  margin: 12px 0 0;
  padding-top: 9px;
  border-top: 1px dashed var(--border);
  font-size: .9em;
  color: var(--text-dim);
  line-height: 1.8;
}

@media (max-width: 760px) {
  .ir-list { columns: 1; }
}

/* ── §14 信任等級橫幅（由 _tools/_inject_trust.py 注入，勿手改）───────────── */
.tl {
  margin: 10px 0 16px;
  padding: 8px 13px;
  border-radius: 8px;
  border-left: 3px solid #888;
  background: #f7f8fa;
  font-size: .9em;
  line-height: 1.75;
  color: var(--text-dim);
}
.tl-b { font-weight: 600; margin-right: 7px; }
.tl-man   { border-left-color: #2f6b2f; background: #f2f8f2; }
.tl-man   .tl-b { color: #2f6b2f; }
.tl-teach { border-left-color: #0f4c81; background: #f2f6fb; }
.tl-teach .tl-b { color: #0f4c81; }
.tl-mix   { border-left-color: #b8860b; background: #fffaf0; }
.tl-mix   .tl-b { color: #8a5a00; }
.tl-prac  { border-left-color: #7a5ba8; background: #f7f4fb; }
.tl-prac  .tl-b { color: #5b3f85; }
.tl-paper { border-left-color: #0e7c66; background: #f2faf5; }
.tl-paper .tl-b { color: #0e6b58; }

/* map.html 的信任等級小標 */
.mp-trust { display: inline-block; font-size: .76em; padding: 1px 7px; border-radius: 4px;
            margin-left: 4px; vertical-align: 1px; color: #555; background: #f0f0f2;
            border: 1px solid #dcdce0; }
.mp-t-man { color: #2f6b2f; background: #f2f8f2; border-color: #bcdcbc; }
.mp-t-teach { color: #0f4c81; background: #f2f6fb; border-color: #c3d5ea; }
.mp-t-mix { color: #8a5a00; background: #fffaf0; border-color: #ecd9ae; }
.mp-t-prac { color: #5b3f85; background: #f7f4fb; border-color: #d8cdea; }
.mp-t-paper { color: #0e6b58; background: #f2faf5; border-color: #b3ddcd; }

/* §15 停產／淘汰平台標記（2026-09-25）
   用途：平台生命週期是考點（16S 用哪台、細菌草圖用哪台），而舊資料仍會出現
   已停產的機器名。與其刪掉名字（讀者看到舊簡報會對不上），不如保留名字並標明狀態。 */
.tag-retired {
  display: inline-block !important;
  font-size: 11px !important;
  font-weight: 500;
  line-height: 1.5;
  padding: 0 6px !important;
  margin-left: 4px;
  border-radius: 999px;
  color: #8a1f1f !important;
  background: #fdecec !important;
  border: 1px solid #f0c2c2 !important;
  vertical-align: baseline;
  white-space: nowrap;
}

@media print {
  #sx-open, #sx-overlay { display: none !important; }
  .qb-mod { break-inside: avoid; }
  .cz { break-inside: avoid; }
  .cz > summary { background: #f2faf5; }
  .mp-fold { display: none; }
}

/* ---------------------------------------------------------------------------
   §12 導覽列淺色化（2026-09-25）
   ---------------------------------------------------------------------------
   背景：11 個頁面的 `nav` / `.subnav` 仍是深色主題時代的
   `background: rgba(13,17,23,.95)`，而連結文字用 `var(--text-dim)`（#5b6472）
   → 對比只有約 3.2:1，低於 WCAG AA 對一般文字的 4.5:1。

   做法：**不改 11 個頁面**（改了一頁就漏一頁，而且下次重生成會被打回），
   在共用層覆蓋一次。選擇器寫 `body nav` / `body .subnav`（0,0,2）就是為了
   穩定勝過頁面自己的 `nav {…}`（0,0,1）；不需要 !important。
   `reader.css` 在之後載入，但它沒有任何 nav 規則，所以不會被蓋回去。
   study-path 的 `.qnav` 是 class 選擇器（0,1,0），優先於本節，不受影響。

   要還原：刪掉這個 sentinel 區塊即可。
   --------------------------------------------------------------------------- */
/* ux:navlight v1 */
body nav,
body .subnav {
  background: rgba(246, 247, 251, .95);
}
/* 淺色底上，hover 用淡藍染而不用純白（純白在淺灰底上幾乎看不出來） */
body nav button:hover,
body .subnav a:hover {
  background: rgba(15, 76, 129, .08);
}
/* /ux:navlight v1 */
