/* /spectrum/ 議題光譜熱圖 ＋ /spectrum/<slug>/ 議題頁。
   熱圖只用 accent 單色序列 --seq-0..6；格內文字用文字 token（深格翻成 inverse）。 */

/* ---------- controls ---------- */
.spectrum-controls { display: flex; flex-direction: column; gap: var(--space-3); }
.spectrum-controls .filter-label { min-width: 4.5rem; }
.spectrum-toggle[aria-pressed="false"] {
  color: var(--color-text-muted); background: var(--color-surface);
  border-style: dashed; text-decoration: line-through; text-decoration-thickness: 1px;
}
.spectrum-toggle[aria-pressed="false"] .chip-count { text-decoration: none; }
.spectrum-status {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-small); color: var(--color-text-secondary);
}
.spectrum-status[hidden] { display: none; }
.spectrum-status progress { width: 8rem; height: 6px; accent-color: var(--color-action-primary); }
.spectrum-result { margin-top: var(--space-6); }
.spectrum-result.is-busy .spectrum-view { opacity: 0.55; transition: opacity var(--motion-fast); }

/* ---------- heatmap table ---------- */
.spectrum-scroll {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border-subtle); border-radius: var(--radius-lg);
  background: var(--color-surface-raised);
}
.spectrum-scroll:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.spectrum-table {
  --who-w: 11.5rem;
  width: 100%; border-collapse: separate; border-spacing: 2px; padding: 4px;
  font-size: var(--text-small); font-variant-numeric: tabular-nums;
}
.spectrum-table th, .spectrum-table td { padding: 0; }
.spectrum-table thead th {
  height: 40px; padding: 0 4px; vertical-align: bottom;
  font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); text-align: center;
}
.spectrum-topic a {
  display: inline-flex; align-items: flex-end; justify-content: center; min-height: 36px; padding: 4px 2px;
  color: var(--color-text-secondary); line-height: 1.25; word-break: keep-all;
}
.spectrum-topic a:hover { color: var(--color-text-brand); text-decoration: underline; }
.spectrum-who-head { text-align: left !important; }

/* sticky identity column */
.spectrum-table .spectrum-who, .spectrum-table .spectrum-who-head {
  position: sticky; left: 0; z-index: 2;
  width: var(--who-w); min-width: var(--who-w); max-width: var(--who-w);
  background: var(--color-surface-raised); text-align: left;
  box-shadow: 2px 0 0 var(--color-surface-raised);
}
.spectrum-who { padding: 4px 8px 4px 4px !important; font-weight: 400; }
.spectrum-identity { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--color-text-primary); }
.spectrum-identity:hover { text-decoration: none; }
.spectrum-identity:hover strong { color: var(--color-text-brand); }
.spectrum-who-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.spectrum-who-text strong { font-size: 0.92rem; font-weight: 700; }
.spectrum-who-meta { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.spectrum-city-row th { padding: var(--space-3) 4px var(--space-1) !important; text-align: left; }
.spectrum-city-label {
  position: sticky; left: 8px;
  font-size: var(--text-small); font-weight: 700; color: var(--color-text-primary);
}

.spectrum-cell {
  min-width: 3.25rem; height: 48px; border-radius: var(--radius-xs);
  text-align: center; font-weight: 600; font-size: 0.8rem;
  background: var(--seq-0); color: var(--color-text-primary);
}
.spectrum-cell[data-step="0"] { color: var(--color-text-muted); font-weight: 400; }
.spectrum-cell[data-step="1"] { background: var(--seq-1); }
.spectrum-cell[data-step="2"] { background: var(--seq-2); }
.spectrum-cell[data-step="3"] { background: var(--seq-3); }
.spectrum-cell[data-step="4"] { background: var(--seq-4); }
.spectrum-cell[data-step="5"] { background: var(--seq-5); color: var(--color-text-inverse); }
.spectrum-cell[data-step="6"] { background: var(--seq-6); color: var(--color-text-inverse); }
/* 粗框：外 2px 墨色 ＋ 內 2px 表面色，任何格色上都分得出來 */
.spectrum-cell-max {
  box-shadow: inset 0 0 0 2px var(--color-text-primary), inset 0 0 0 4px var(--color-surface-raised);
  font-weight: 800;
}
.spectrum-table tbody tr[data-candidate]:hover .spectrum-who { background: var(--color-surface-soft); box-shadow: 2px 0 0 var(--color-surface-soft); }

/* ---------- legend / footnote ---------- */
.spectrum-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4);
  margin-top: var(--space-4); font-size: var(--text-xs); color: var(--color-text-muted);
}
.spectrum-legend-title { font-weight: 600; color: var(--color-text-secondary); }
.spectrum-legend-scale { display: inline-flex; gap: 2px; flex-wrap: wrap; }
.spectrum-legend-step {
  display: inline-flex; align-items: center; justify-content: center; min-width: 3.4rem; height: 22px; padding: 0 6px;
  border-radius: var(--radius-xs); background: var(--seq-0); color: var(--color-text-primary); font-variant-numeric: tabular-nums;
}
.spectrum-legend-step[data-step="1"] { background: var(--seq-1); }
.spectrum-legend-step[data-step="2"] { background: var(--seq-2); }
.spectrum-legend-step[data-step="3"] { background: var(--seq-3); }
.spectrum-legend-step[data-step="4"] { background: var(--seq-4); }
.spectrum-legend-step[data-step="5"] { background: var(--seq-5); color: var(--color-text-inverse); }
.spectrum-legend-step[data-step="6"] { background: var(--seq-6); color: var(--color-text-inverse); }
.spectrum-legend-max { display: inline-flex; align-items: center; gap: 6px; }
.spectrum-legend-maxbox {
  width: 22px; height: 16px; border-radius: 4px; background: var(--seq-4);
  box-shadow: inset 0 0 0 2px var(--color-text-primary), inset 0 0 0 3px var(--color-surface-raised);
}
.spectrum-footnote { margin-top: var(--space-2); max-width: var(--layout-reading); font-size: var(--text-small); color: var(--color-text-muted); }

/* ---------- phone cards（<700px 取代表格） ---------- */
.spectrum-cards { display: none; }
.spectrum-card-city + .spectrum-card-city { margin-top: var(--space-6); }
.spectrum-card-city-title { margin-bottom: var(--space-3); font-size: var(--text-heading); font-weight: 700; color: var(--color-text-primary); }
.spectrum-card + .spectrum-card { margin-top: var(--space-3); }
.spectrum-card-meters { display: flex; flex-direction: column; margin-top: var(--space-2); }
.spectrum-card .meter-row { grid-template-columns: 5.5rem minmax(0, 1fr) 3rem; min-height: 34px; }
.spectrum-card .meter-label { font-weight: 500; color: var(--color-text-secondary); }
.spectrum-card .meter-row.is-max .meter-label { font-weight: 700; color: var(--color-text-primary); }
.spectrum-card .meter-row.is-max .meter-value { font-weight: 700; color: var(--color-text-primary); }
.spectrum-card-empty { margin-top: var(--space-2); font-size: var(--text-small); color: var(--color-text-muted); }

@media (max-width: 699px) {
  .spectrum-scroll { display: none; }
  .spectrum-cards { display: block; }
  .spectrum-controls { padding: var(--space-3); }
  .spectrum-controls .filter-row { flex-direction: column; gap: var(--space-1); }
  .spectrum-controls .filter-label { height: auto; }
  .spectrum-controls .seg { max-width: 100%; }
  .spectrum-legend-step { min-width: 0; }
}

/* ---------- topic page ---------- */
.topic-nav { display: flex; gap: var(--space-2); overflow-x: auto; padding: 2px 0 var(--space-2); scrollbar-width: none; }
.topic-nav::-webkit-scrollbar { display: none; }
.topic-nav .chip[aria-current="page"] {
  background: var(--color-action-primary); border-color: var(--color-action-primary); color: var(--color-action-on-primary);
}
.topic-nav-back { font-weight: 600; color: var(--color-text-primary); }
.topic-ranking .section-head { margin-bottom: var(--space-2); }
.topic-note { max-width: var(--layout-reading); font-size: var(--text-small); color: var(--color-text-muted); }
.topic-legend { margin: var(--space-3) 0 var(--space-2); }
.topic-rank-list { list-style: none; margin: 0; padding: 0; }
.topic-rank { padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border-subtle); }
.topic-rank:last-child { border-bottom: 0; }
.topic-rank-row.meter-row { grid-template-columns: minmax(9rem, 13rem) minmax(0, 1fr) minmax(7.5rem, auto); }
.topic-rank-who { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--color-text-primary); }
.topic-rank-who:hover { text-decoration: none; }
.topic-rank-who:hover .topic-rank-name { color: var(--color-text-brand); }
.topic-rank-name { font-weight: 700; white-space: nowrap; }
.topic-rank-city { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; }
.topic-rank-row .meter-value { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.topic-rank-row .meter-value strong { color: var(--color-text-primary); font-size: 0.95rem; }
.topic-rank-n { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; }
.topic-rank-kws { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 0 32px; }
.topic-kw { height: 22px; padding: 0 8px; font-size: 0.72rem; }
.topic-kw .chip-count { margin-left: 2px; }
.topic-picker { margin-bottom: var(--space-4); }
.topic-river .feed-more[hidden] { display: none; }
.topic-river-status[hidden] { display: none; }
.topic-river-status { text-align: center; }

@media (max-width: 699px) {
  .topic-rank-row.meter-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; }
  .topic-rank-row .meter { grid-column: 1 / -1; grid-row: 2; }
  .topic-rank-row .meter-value { flex-direction: row; align-items: baseline; gap: 6px; }
  .topic-rank-kws { margin-left: 0; }
  .topic-picker { flex-direction: column; gap: var(--space-1); }
  .topic-picker .filter-label { height: auto; }
}
