/* 新闻来源统计页。
 * 版式沿用「来源构成」参考稿;配色是经 CVD 校验的 8 槽分类色 + 中性灰「其余」,
 * 槽位顺序就是安全机制,别为了好看重排。 */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --line: #e2e2df;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7a74;
  --accent: #2a78d6;
  /* 分类色:hotspot / weibo_official / che12365 / gasgoo / chedongxi
     / sohu / autohome / cada / 其余 */
  --c1: #2a78d6;
  --c2: #eb6834;
  --c3: #1baf7a;
  --c4: #eda100;
  --c5: #e87ba4;
  --c6: #008300;
  --c7: #4a3aa7;
  --c8: #e34948;
  --c-other: #a8a7a0;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --line: #33332e;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e85;
    --accent: #3987e5;
    --c1: #3987e5;
    --c2: #d95926;
    --c3: #199e70;
    --c4: #c98500;
    --c5: #d55181;
    --c6: #008300;
    --c7: #9085e9;
    --c8: #e66767;
    --c-other: #6f6e66;
  }
}

* { box-sizing: border-box; }
/* .gate/.error-bar 自带 display,会盖掉 hidden 属性的 UA 样式,这里补一刀 */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--surface-1);
  color: var(--text-primary);
  font: 15px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  padding: clamp(1.3rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 4rem;
}
#app { max-width: 56rem; margin: 0 auto; }

header { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: flex-start; }
h1 { font-size: clamp(1.5rem, 3.6vw, 2rem); letter-spacing: -0.02em; margin: 0 0 0.3rem; }
.subtitle { color: var(--text-secondary); margin: 0; font-size: 0.92rem; max-width: 34rem; }
.header-actions { display: flex; gap: 0.7rem; align-items: center; }

.range-picker { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.range-picker button {
  border: none; background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 0.85rem; padding: 0.35rem 0.75rem; cursor: pointer;
}
.range-picker button + button { border-left: 1px solid var(--line); }
.range-picker button.active { color: var(--accent); font-weight: 650; }
.range-picker button:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }

.back-link {
  color: var(--accent); text-decoration: none; font-size: 0.85rem;
  padding: 0.35rem 0.75rem; border: 1px solid var(--accent); border-radius: 8px;
}
.back-link:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

h2 { font-size: 1.02rem; margin: 2.6rem 0 0.3rem; padding-top: 1.3rem; border-top: 1px solid var(--line); }
.section-note { color: var(--text-secondary); margin: 0 0 1.2rem; font-size: 0.92rem; max-width: 42rem; }

/* ── hero 大数字 ── */
.hero { display: flex; flex-wrap: wrap; gap: 2.2rem; padding: 1.6rem 0 0.3rem; }
.hero div { min-width: 9rem; }
.hero b {
  display: block; font-size: 2.1rem; line-height: 1.15; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.hero small { color: var(--text-secondary); font-size: 0.84rem; }

/* ── 图例 ── */
.legend {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin: 0.2rem 0 1rem;
  font-size: 0.85rem; color: var(--text-secondary);
}
.lg { display: inline-flex; align-items: center; gap: 0.4rem; }
.dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }

/* ── 每周堆叠柱 ── */
/* 一屏正好 12 周,更早的左右滑 —— 与控制台时间线同一套做法。
   宽度按**容器**算而不写死像素:写死的话宽屏能露二十几周、窄屏只露七周,
   「一屏一页」的直觉就没了。gap 固定 10px 才好参与计算,
   12 格 + 11 个 10px 间隙正好铺满。 */
.chart {
  display: flex; gap: 10px; align-items: flex-end;
  overflow-x: auto; padding-bottom: 0.3rem; scroll-behavior: smooth;
}
.col { flex: 0 0 calc((100% - 110px) / 12); text-align: center; }
.bar {
  height: 230px; display: flex; flex-direction: column-reverse;
  border-radius: 4px; overflow: hidden; background: var(--line);
}
.seg { width: 100%; box-shadow: 0 -2px 0 var(--surface-1); }
.seg:first-child { box-shadow: none; }
.seg:hover { filter: brightness(1.12); }
.bar-empty {
  height: 230px; border-radius: 4px; background: var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 0.76rem;
}
.tick { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.45rem; font-variant-numeric: tabular-nums; }
.tot { font-size: 0.76rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ── 采集 vs 事件:两个饼 ── */
.split {
  display: flex; flex-wrap: wrap; gap: clamp(1.2rem, 5vw, 3.5rem);
  margin-top: 0.6rem; align-items: flex-start;
}
.pie-box { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.pie { width: clamp(150px, 34vw, 210px); height: auto; display: block; }
/* 扇形之间留一道与背景同色的缝,相邻同色系才分得开 */
.pie path, .pie circle { stroke: var(--surface-1); stroke-width: 1.1; }
.pie path { transition: opacity 0.1s; cursor: default; }
.pie:hover path:not(:hover) { opacity: 0.45; }
.pie-empty {
  width: clamp(150px, 34vw, 210px); aspect-ratio: 1; border-radius: 50%;
  background: var(--line); display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 0.82rem;
}
.pie-box figcaption {
  font-size: 0.88rem; color: var(--text-secondary); font-variant-numeric: tabular-nums;
}

/* ── 悬浮提示 ── */
.tip {
  /* 用 display 开关而不是 opacity 过渡:提示框本来就该即时出现(原生 title
     要停约一秒才弹,正是它被嫌弃的地方);而且淡入依赖过渡推进,
     在过渡被冻结的场合(后台标签页等)会永远停在透明,等于没有提示。 */
  display: none;
  position: fixed; left: 0; top: 0; z-index: 60;
  pointer-events: none;            /* 绝不挡住底下的色块,否则会自己把自己弹掉 */
  max-width: 18rem; white-space: nowrap;
  padding: 0.34rem 0.58rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface-1); color: var(--text-primary);
  font-size: 0.82rem; line-height: 1.45; font-variant-numeric: tabular-nums;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}
.tip.on { display: block; }
/* 悬浮时点亮当前色块:提示文字说「是谁」,这道白边说「是哪一块」 */
.chart .seg:hover { outline: 2px solid var(--surface-1); outline-offset: -2px; }
.legend .dot[data-tip], td .dot[data-tip] { cursor: default; }

/* ── 明细表 ── */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; margin-top: 0.3rem; }
th, td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 0.72rem; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 500; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td .dot { margin-right: 0.45rem; vertical-align: -1px; }
.rate { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; min-width: 5rem; }
.rate-fill { height: 100%; border-radius: 4px; }
.muted-note { color: var(--text-muted); font-size: 0.78rem; }

footer {
  margin-top: 2.6rem; padding-top: 1rem; border-top: 1px solid var(--line);
  color: var(--text-muted); font-size: 0.82rem;
}

/* ── 口令门(与周报页同款) ── */
.gate { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.gate-card {
  display: flex; flex-direction: column; gap: 0.8rem; width: min(20rem, 90vw);
  padding: 2rem; border: 1px solid var(--line); border-radius: 12px;
}
.gate-card h1 { font-size: 1.2rem; margin: 0; }
.muted { color: var(--text-secondary); margin: 0; font-size: 0.9rem; }
.gate-card input {
  font: inherit; padding: 0.5rem 0.7rem; border: 1px solid var(--line);
  border-radius: 8px; background: transparent; color: var(--text-primary);
}
.gate-card button {
  font: inherit; padding: 0.5rem; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.gate-error { color: #e34948; font-size: 0.85rem; margin: 0; }

.error-bar {
  margin-top: 1rem; padding: 0.7rem 1rem; border: 1px solid #e34948;
  border-radius: 8px; color: #e34948; font-size: 0.9rem;
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
}
.error-bar button {
  font: inherit; font-size: 0.85rem; padding: 0.3rem 0.8rem; cursor: pointer;
  border: 1px solid currentColor; border-radius: 8px; background: transparent; color: inherit;
}

@media (max-width: 560px) {
  .split .row { grid-template-columns: 1fr; }
  .split .lab { text-align: left; }
}
