/* 統計頁專用樣式。色票沿用 style.css 的語意 token，
   另外宣告兩個系列色——已用 validate_palette.js 在兩種模式下驗證通過。 */

.viz-root {
  --series-1: #2a78d6;   /* 查到候選 */
  --series-2: #eb6834;   /* 查無 */
  --bar: #2a78d6;        /* 單一系列的量值條 */
  --grid: #e6e8ec;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    --series-1: #3987e5;
    --series-2: #d95926;
    --bar: #3987e5;
    --grid: #2f343d;
  }
}
:root[data-theme="dark"] .viz-root {
  --series-1: #3987e5;
  --series-2: #d95926;
  --bar: #3987e5;
  --grid: #2f343d;
}

h2 { font-size: 16px; margin: 0 0 4px; }
.section-note { margin: 0 0 14px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.footnote { text-align: center; font-size: 12px; color: var(--muted); margin: 24px 0 8px; }

/* 篩選列：固定在圖表上方一行 */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-label { font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn {
  appearance: none; background: var(--surface); border: 0; cursor: pointer;
  padding: 7px 13px; font: inherit; font-size: 14px; color: var(--muted);
  border-right: 1px solid var(--border);
}
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: color-mix(in srgb, var(--text) 6%, var(--surface)); color: var(--text); }
.seg-btn.is-active { background: var(--accent); color: var(--accent-text); font-weight: 600; }

.two-col { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.btn-sm { padding: 5px 11px; font-size: 13px; }

/* ── 量值條：單一系列，長度編碼大小，數字直接標在旁邊 ── */
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(74px, auto) 1fr auto; gap: 10px; align-items: center; }
.bar-key { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: color-mix(in srgb, var(--text) 6%, transparent); border-radius: 4px; height: 18px; }
.bar-fill {
  height: 100%; background: var(--bar);
  border-radius: 0 4px 4px 0;   /* 資料端圓角，基線端貼齊 */
  min-width: 2px; transition: width .2s;
}
.bar-val { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-val .pct { color: var(--muted); margin-left: 5px; }
.bar-row:hover .bar-fill { filter: brightness(1.12); }
.bars-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }

/* ── 折線圖 ── */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; }
.chart .series-line { fill: none; stroke-width: 2; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }

.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--text); color: var(--bg);
  padding: 7px 10px; border-radius: 7px; font-size: 12px; line-height: 1.5;
  white-space: nowrap; opacity: 0; transition: opacity .12s;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.tooltip.show { opacity: 1; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.tooltip .tt-swatch { width: 8px; height: 8px; border-radius: 2px; }
.tooltip .tt-date { font-weight: 600; margin-bottom: 3px; }

/* ── 採用率 ── */
.adopt-hero { font-size: 36px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.1; }
.adopt-sub { font-size: 13px; color: var(--muted); margin: 2px 0 14px; }

/* ── 表格與歷程 ── */
.link-code {
  background: none; border: 0; padding: 0; cursor: pointer; font: inherit;
  font-variant-numeric: tabular-nums; color: var(--accent); text-decoration: underline;
}
.history-search { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.history-search input { flex: 1 1 200px; }

.variant {
  border: 1px solid var(--border); border-left: 3px solid var(--series-1);
  border-radius: 8px; padding: 10px 13px; margin-bottom: 9px;
}
.variant.v-none { border-left-color: var(--series-2); }
.variant-head { display: flex; gap: 9px; align-items: baseline; flex-wrap: wrap; margin-bottom: 5px; }
.variant-n { font-weight: 650; }
.variant-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.variant-body { font-size: 13px; }
.variant-body .muted { font-size: 12px; }
.hist-summary { margin: 0 0 12px; font-size: 14px; }
.hist-changed { color: var(--warn-text); background: var(--warn-bg); padding: 2px 8px; border-radius: 999px; font-size: 12px; }
