/* ============================================================================
   charts.css — 图表容器与图表周边组件
   依赖 tokens.css + base.css
   容器高度令牌：--ch-k(K线) / --ch-line(曲线) / --ch-gauge(仪表) / --ch-heat(热力)
   旧报告迁移映射：.kchart(460px) → .chart-box.h-k
   ============================================================================ */

/* ---------- 图表容器高度变量（手机端在文末媒体查询统一降档） ---------- */
:root {
  --ch-k: 460px;      /* K线+BOLL/KDJ/MACD 主图 */
  --ch-line: 320px;   /* 三轨对比/R30 累计曲线 */
  --ch-gauge: 240px;  /* 胜率仪表盘 */
  --ch-heat: 280px;   /* 涨停/炸板日历热力图 */
}

/* ---------- 图表容器 ---------- */
.chart-box { position: relative; width: 100%; }
.chart-box.h-k { height: var(--ch-k); }
.chart-box.h-line { height: var(--ch-line); }
.chart-box.h-gauge { height: var(--ch-gauge); }
.chart-box.h-heat { height: var(--ch-heat); }

/* 懒加载/初始化占位文字 */
.chart-box .loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--txt-3);
  font-size: var(--fs-sm);
  letter-spacing: 1px;
  animation: sr-chart-pulse 1.4s ease-in-out infinite;
}
@keyframes sr-chart-pulse { 50% { opacity: .35; } }

/* ============================================================================
   ECharts 统一深色 tooltip
   用法：JS 侧 option 配 tooltip.className = 'ec-tip' 即套用；
   !important 用于压过 ECharts 写在元素上的内联样式。
   ============================================================================ */
.ec-tip {
  background: var(--panel-2) !important;
  border: 1px solid var(--bd-2) !important;
  border-radius: var(--r-sm) !important;
  padding: 6px 10px !important;
  color: var(--txt-2) !important;
  font-size: var(--fs-xs) !important;
  font-family: var(--font) !important;
  line-height: 1.6 !important;
  box-shadow: var(--shadow-2) !important;
  font-variant-numeric: tabular-nums !important;
}

/* ECharts option 中无法走 class 的颜色（坐标轴/分割线/十字线/系列色），
   JS 统一从本 CSS 令牌读取——改主题只改 tokens.css 一处：
     const cs = getComputedStyle(document.documentElement);
     const c = (n) => cs.getPropertyValue(n).trim();
     option.textStyle.color            = c('--txt-2');   // 轴标签/图例文字
     xAxis.axisLabel.color             = c('--txt-3');   // 弱化轴文字
     xAxis.splitLine.lineStyle.color   = c('--bd');      // 分割线
     axisPointer.crossStyle.color      = c('--bd-2');   // 十字线
     axisPointer.lineStyle.color       = c('--gold');   // 指示线（终端金）
     tooltip 背景走上方 .ec-tip，或 JS 侧读 c('--panel-2') */

/* ---------- 图例行：色点 + 文字 ---------- */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-4);
  margin: var(--sp-2) 0;
  font-size: var(--fs-sm);
  color: var(--txt-2);
}
.lg-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lg-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; background: var(--txt-3); }
.lg-dot.c-blue { background: var(--blue); }
.lg-dot.c-gold { background: var(--gold); }
.lg-dot.c-up { background: var(--up); }
.lg-dot.c-down { background: var(--down); }
.lg-dot.c-info { background: var(--txt-3); }

/* ---------- 十字光标轴标签 ----------
   两种用法：① kchart/intraday 把下列样式值通过 axisPointer.label 配置传入 option；
   ② 自绘 DOM 覆盖层时直接挂 .axis-tip 类 */
.axis-tip {
  position: absolute;
  z-index: 10;
  transform: translate(-50%, -120%);
  background: var(--bd-2);
  color: var(--txt);
  font-size: var(--fs-xs);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* ---------- 手机端：图表高度统一降档 ---------- */
@media (max-width: 640px) {
  :root {
    --ch-k: 380px;
    --ch-line: 260px;
    --ch-gauge: 220px;
    --ch-heat: 260px;
  }
}
