/* ==========================================================================
   抖音热点宝 · 话题详情页样式（T04）
   ------------------------------------------------------------
   前缀统一为 tdt-（topic detail），避免与视频详情页 vd- 冲突。
   颜色全部沿用 style.css 的 CSS 变量（浅/深主题自动适配），
   点缀色使用抖音品牌色 #fe2c55 / #c1123d。
   ========================================================================== */

/* ---------------------------------------------------------------- *
   1. 概览：话题头
 * ---------------------------------------------------------------- */

.tdt-wrap { display: flex; flex-direction: column; gap: 16px; }

.tdt-head {
  display: flex; gap: 14px; align-items: center;
  padding: 14px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--bg-soft);
}
.tdt-cover {
  width: 64px; height: 64px; flex: 0 0 auto; border-radius: 12px;
  object-fit: cover; background: var(--surface); border: 1px solid var(--border);
}
.tdt-cover-ph {
  display: grid; place-items: center; font-size: 26px; font-weight: 900;
  color: #fe2c55; background: var(--surface-hover);
}
.tdt-headmain { min-width: 0; }
.tdt-name {
  font-size: 17px; font-weight: 820; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tdt-sub { font-size: 12.5px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }
.tdt-sub b { color: var(--text-2); font-weight: 750; }
.tdt-sub i { font-style: normal; color: var(--border-strong); margin: 0 4px; }

/* ---------------------------------------------------------------- *
   2. 概览：指标卡
 * ---------------------------------------------------------------- */

.tdt-metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px;
}
.tdt-metric {
  border: 1px solid var(--border); border-radius: 12px; padding: 13px 14px;
  background: linear-gradient(158deg, var(--surface-hover), var(--bg-soft));
  transition: border-color .16s, transform .16s;
}
.tdt-metric:hover { border-color: rgba(254, 44, 85, .38); transform: translateY(-2px); }
.tdt-metric-k { font-size: 12px; color: var(--text-3); font-weight: 650; }
.tdt-metric-v {
  font-size: 21px; font-weight: 820; color: var(--text); margin-top: 7px;
  font-variant-numeric: tabular-nums; letter-spacing: .2px;
}

/* ---------------------------------------------------------------- *
   3. 通用区块 / 标题
 * ---------------------------------------------------------------- */

.tdt-sec {
  border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; background: var(--bg-soft);
}
.tdt-sec-h {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px;
  font-size: 14px; font-weight: 820; color: var(--text);
}
.tdt-sec-sub { font-size: 11.5px; color: var(--text-3); font-weight: 600; margin-left: auto; }

/* ---------------------------------------------------------------- *
   4. 概览：热度趋势折线（内联 SVG）
 * ---------------------------------------------------------------- */

.tdt-chart { position: relative; width: 100%; }
.tdt-svg { width: 100%; height: auto; display: block; overflow: visible; }
.tdt-grid { stroke: var(--border); stroke-width: 1; }
.tdt-axis { fill: var(--text-3); font-size: 10px; font-family: inherit; }
.tdt-line { fill: none; stroke: #fe2c55; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tdt-area { fill: rgba(254, 44, 85, .12); stroke: none; }
.tdt-avg { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 5 4; }
.tdt-avg-lb { fill: var(--text-3); font-size: 10px; font-weight: 650; }
.tdt-dot { fill: #fe2c55; }
.tdt-guide { stroke: #fe2c55; stroke-width: 1; stroke-dasharray: 3 3; }
.tdt-focus { fill: var(--surface-solid, #fff); stroke: #fe2c55; stroke-width: 2; }
.tdt-hit { cursor: crosshair; }

.tdt-tip {
  position: absolute; left: 0; top: 0; opacity: 0; z-index: 3; pointer-events: none;
  transform: translate(-50%, -130%); transition: opacity .12s;
  display: flex; flex-direction: column; gap: 2px; white-space: nowrap;
  padding: 6px 10px; border-radius: 8px; font-size: 11.5px; color: var(--text);
  background: var(--surface-solid, var(--surface));
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-md);
}
.tdt-tip b { font-weight: 800; color: var(--text-2); }

/* ---------------------------------------------------------------- *
   5. 概览：热门视频 TOP30 网格
 * ---------------------------------------------------------------- */

.tdt-gridv {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
}
.tdt-vcard {
  display: flex; flex-direction: column; overflow: hidden; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-solid, var(--surface));
  transition: border-color .16s, transform .16s, box-shadow .16s;
  -webkit-tap-highlight-color: transparent;
}
.tdt-vcard:hover, .tdt-vcard:focus-visible {
  border-color: rgba(254, 44, 85, .45); transform: translateY(-2px);
  box-shadow: var(--shadow-md); outline: none;
}
.tdt-vcover { position: relative; aspect-ratio: 16 / 9; background: var(--bg-soft); overflow: hidden; }
.tdt-vcover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tdt-vno { display: grid; place-items: center; height: 100%; font-size: 11px; color: var(--text-3); }
.tdt-vdur {
  position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 5px;
  font-size: 10.5px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .68);
  font-variant-numeric: tabular-nums;
}
.tdt-vbody { display: flex; flex-direction: column; gap: 6px; padding: 9px 10px 11px; min-width: 0; }
.tdt-vtitle {
  font-size: 12.8px; font-weight: 700; color: var(--text); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tdt-vauthor { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); min-width: 0; }
.tdt-vauthor img { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.tdt-vauthor span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tdt-vdate { margin-left: auto; flex: 0 0 auto; }
.tdt-vstats { display: flex; flex-wrap: wrap; gap: 4px 11px; font-size: 11px; color: var(--text-2); }
.tdt-vstat { display: inline-flex; align-items: baseline; gap: 3px; }
.tdt-vstat i { font-style: normal; font-size: 10.5px; color: var(--text-3); }
.tdt-vstat b { font-weight: 750; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- *
   6. 画像分析
 * ---------------------------------------------------------------- */

.tdt-portrait { display: flex; flex-direction: column; gap: 16px; }
.tdt-psec {
  border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; background: var(--bg-soft);
}
.tdt-psec-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.tdt-psec-t { font-size: 14px; font-weight: 820; color: var(--text); }
.tdt-psec-note { font-size: 11px; color: var(--text-3); font-weight: 600; margin-left: auto; }

.tdt-bars { display: flex; flex-direction: column; gap: 9px; }
.tdt-bar { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.tdt-bar-rank {
  flex: 0 0 20px; text-align: center; font-weight: 800;
  color: var(--text-3); font-variant-numeric: tabular-nums;
}
.tdt-bar-name {
  flex: 0 0 104px; font-weight: 650; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tdt-bar-track {
  flex: 1 1 auto; min-width: 40px; height: 9px; border-radius: 5px;
  background: var(--surface-hover); overflow: hidden;
}
.tdt-bar-track i {
  display: block; height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, #fe2c55, #ff7a97);
}
.tdt-bar-val {
  flex: 0 0 auto; min-width: 54px; text-align: right; font-weight: 750;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.tdt-bar-tgi { flex: 0 0 auto; font-size: 10.5px; font-weight: 700; color: #22d3ee; white-space: nowrap; }
.tdt-bar-hidden { display: none; }
/* 排行形态：序号列高亮 */
.tdt-bars-rank .tdt-bar-rank { color: #fe2c55; }

.tdt-more {
  margin-top: 12px; min-height: 40px; padding: 8px 16px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); color: var(--text-2);
  font-family: inherit; font-size: 12px; font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}
.tdt-more:hover { border-color: #fe2c55; color: #fe2c55; }

/* 组合图（柱状 + 折线，双 Y 轴） */
.tdt-combo { width: 100%; }
.tdt-combo-legend {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 8px; font-size: 11.5px; color: var(--text-3);
}
.tdt-lg-item { display: inline-flex; align-items: center; gap: 6px; }
.tdt-lg-bar { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.tdt-lg-line { width: 16px; height: 3px; border-radius: 2px; display: inline-block; background: #f5c400; }
.tdt-combo-plot { position: relative; width: 100%; }
.tdt-combo-svg { width: 100%; height: auto; display: block; margin: 0 auto; overflow: visible; }
.tdt-combo-svg .tdt-combo-grid { stroke: var(--border); stroke-width: 1; }
.tdt-combo-svg .tdt-combo-base { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 4 4; }
.tdt-combo-svg .tdt-combo-ax {
  fill: var(--text-3); font-size: 10.5px; font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.tdt-combo-svg .tdt-combo-axr { fill: var(--text-3); }
.tdt-combo-svg .tdt-combo-axtitle { fill: var(--text-3); font-size: 10px; font-weight: 700; }
.tdt-combo-svg .tdt-combo-bar { transition: opacity .15s; }
.tdt-combo-svg .tdt-combo-bar:hover { opacity: .85; }
.tdt-combo-svg .tdt-combo-line { stroke: #f5c400; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tdt-combo-svg .tdt-combo-dot { fill: #f5c400; stroke: var(--surface-solid); stroke-width: 1.5; }
.tdt-combo-svg .tdt-combo-guide { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.tdt-combo-svg .tdt-combo-focus { fill: var(--surface-solid); stroke: #f5c400; stroke-width: 2; }
.tdt-combo-tip {
  position: absolute; transform: translate(-50%, -130%); pointer-events: none; z-index: 3;
  display: flex; flex-direction: column; gap: 1px; white-space: nowrap;
  padding: 5px 9px; border-radius: 8px; font-size: 12px; line-height: 1.35;
  background: var(--surface-solid, var(--surface)); border: 1px solid var(--border-strong); box-shadow: var(--shadow-md);
}
.tdt-combo-tip b { color: var(--text); }
.tdt-combo-tip span { color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.tdt-combo-tip[hidden] { display: none; }

/* 地域明细表（省份 / 占比 / TGI） */
.tdt-tbl-wrap { width: 100%; }
.tdt-tbl-scroll { width: 100%; overflow-x: auto; }
.tdt-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.tdt-table thead th {
  text-align: right; font-weight: 700; color: var(--text-3); font-size: 11.5px;
  padding: 6px 8px; border-bottom: 1px solid var(--border-strong);
  white-space: nowrap; user-select: none;
}
.tdt-table thead th.tdt-th-name { text-align: left; }
.tdt-table thead th.tdt-th-val,
.tdt-table thead th.tdt-th-tgi { cursor: pointer; }
.tdt-table thead th.tdt-th-val:hover,
.tdt-table thead th.tdt-th-tgi:hover { color: #fe2c55; }
.tdt-table tbody tr { border-bottom: 1px solid var(--border); }
.tdt-table tbody tr:nth-child(even) { background: var(--surface); }
.tdt-table td { padding: 5px 8px; color: var(--text-2); }
.tdt-td-name {
  text-align: left; color: var(--text); font-weight: 600;
  max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tdt-td-val { text-align: right; color: var(--text); font-weight: 750; }
.tdt-td-tgi { text-align: right; color: var(--text-3); }
.tdt-td-tgi.up { color: #00c48c; }
.tdt-td-tgi.down { color: #ff7a45; }
.tdt-tbl-more {
  margin-top: 10px; min-height: 40px; padding: 8px 16px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); color: var(--text-2);
  font-family: inherit; font-size: 12px; font-weight: 700;
}
.tdt-tbl-more:hover { border-color: #fe2c55; color: #fe2c55; }

/* 地域「地图 + 表格」 */
.tdt-region {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px; align-items: start;
}
.tdt-region-map, .tdt-region-tbl { min-width: 0; }
.tdt-map-wrap { position: relative; width: 100%; }
.tdt-map { width: 100%; height: auto; display: block; }
.tdt-map-prov { stroke: var(--bg-soft); stroke-width: .6; transition: stroke .15s; cursor: default; }
.tdt-map-prov.on { stroke: #fff; stroke-width: 1.2; }
.tdt-map-jdx { fill: none; stroke: var(--text-2); stroke-width: 1.2; }
.tdt-map-tip {
  position: absolute; transform: translate(-50%, -125%); pointer-events: none; z-index: 4;
  white-space: nowrap; padding: 4px 8px; border-radius: 7px; font-size: 11.5px;
  background: var(--surface-solid, var(--surface)); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md); color: var(--text); font-variant-numeric: tabular-nums;
}
.tdt-map-tip[hidden] { display: none; }
.tdt-map-legend { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11px; color: var(--text-3); }
.tdt-map-lg-bar { flex: 1 1 auto; height: 8px; border-radius: 4px; }
.tdt-map-note { margin-top: 6px; font-size: 10.5px; color: var(--text-3); opacity: .8; line-height: 1.5; }
.tdt-map-loading, .tdt-map-fallback {
  padding: 40px 12px; text-align: center; font-size: 12px; color: var(--text-3);
  border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface);
}
@media (max-width: 640px) {
  .tdt-region { grid-template-columns: 1fr; gap: 12px; }
}

/* ---------------------------------------------------------------- *
   7. 降级 / 加载 / 原始数据
 * ---------------------------------------------------------------- */

.tdt-na {
  padding: 16px; text-align: center; font-size: 12.5px; color: var(--text-3);
  border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface);
}
.tdt-na-hint { font-size: 11.5px; color: var(--text-3); opacity: .85; margin-left: 4px; }
.tdt-psec-na .tdt-psec-t { color: var(--text-3); }
.tdt-gap {
  padding: 11px 14px; border-radius: 10px; font-size: 12px; color: var(--text-2);
  background: var(--surface); border: 1px dashed var(--border-strong);
}
.tdt-loading { padding: 26px; text-align: center; font-size: 13px; color: var(--text-3); }

.tdt-raw {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 13px; background: var(--surface);
}
.tdt-raw summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--text-3); }
.tdt-raw summary:hover { color: #fe2c55; }
.tdt-raw pre {
  max-height: 320px; overflow: auto; margin-top: 8px;
  font-size: 11px; line-height: 1.5; color: var(--text-2);
}

/* ---------------------------------------------------------------- *
   8. 响应式
 * ---------------------------------------------------------------- */

@media (max-width: 860px) {
  .tdt-gridv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .tdt-gridv { grid-template-columns: 1fr; }
  .tdt-head { padding: 12px; }
  .tdt-cover { width: 54px; height: 54px; }
  .tdt-name { font-size: 15.5px; }
  .tdt-metric-v { font-size: 19px; }
  .tdt-bar { gap: 8px; }
  .tdt-bar-name { flex-basis: 78px; }
  .tdt-bar-val { min-width: 46px; }
  .tdt-table { font-size: 12px; }
  .tdt-table thead th, .tdt-table td { padding: 5px 6px; }
  .tdt-td-name { max-width: 40%; }
  .tdt-combo-legend { gap: 12px; }
  .tdt-sec, .tdt-psec { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .tdt-metric, .tdt-vcard { transition: none !important; }
}
