/* ==========================================================================
   PiLive — 数据可视化
   图表被当作设计系统的一部分：同一套刻度、同一套字体、同一套色序
   ========================================================================== */

.chart { width: 100%; height: auto; overflow: visible; display: block; }

/* ---- 网格与轴 ---------------------------------------------------------- */
.ch-grid   { stroke: var(--ds-grid); stroke-width: 1; }
.ch-axis   { stroke: var(--line); stroke-width: 1; }
.ch-guide  { stroke: var(--line-soft); stroke-width: 1; stroke-dasharray: 2 3; }

.ch-label {
  font-family: var(--font-mono);
  font-size: var(--t-axis);
  letter-spacing: 0.04em;
  fill: var(--ink-400);
}

.ch-label--cn {
  font-family: var(--font-sans);
  font-size: var(--t-2xs);
  letter-spacing: 0;
  fill: var(--ink-500);
}

.ch-value {
  font-family: var(--font-mono);
  font-size: var(--t-axis);
  font-weight: 600;
  fill: var(--ink-900);
}

.ch-value--sig { fill: var(--violet); }

/* ---- 序列色 ------------------------------------------------------------ */
.s1-f { fill: var(--ds-1); }
.s2-f { fill: var(--ds-2); }
.s3-f { fill: var(--ds-3); }
.s4-f { fill: var(--ds-4); }
.s5-f { fill: var(--ds-5); }

.s1-s { stroke: var(--ds-1); fill: none; }
.s2-s { stroke: var(--ds-2); fill: none; }
.s3-s { stroke: var(--ds-3); fill: none; }
.s4-s { stroke: var(--ds-4); fill: none; }

/* ---- 柱 ---------------------------------------------------------------- */
.ch-bar {
  fill: var(--ds-1);
  transition: fill var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
}

.ch-bar--mute { fill: var(--ds-2); opacity: 0.42; }
.ch-bar--cool { fill: var(--ds-3); }
.ch-bar[data-tip] { cursor: pointer; }
.ch-bar:hover { fill: var(--violet-deep); opacity: 1; }

/* ---- 线 / 面积 --------------------------------------------------------- */
.ch-line {
  fill: none;
  stroke: var(--ds-1);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ch-line--cool { stroke: var(--ds-3); }
.ch-line--mute { stroke: var(--ink-300); stroke-width: 1.25; stroke-dasharray: 3 3; }

.ch-area { fill: url(#gradViolet); }
.ch-area--cool { fill: url(#gradSteel); }

.ch-dot { fill: var(--paper-0); stroke: var(--ds-1); stroke-width: 1.75; }
.ch-dot--solid { fill: var(--ds-1); stroke: none; }

/* ---- 雷达 -------------------------------------------------------------- */
.ch-radar-web { fill: none; stroke: var(--ds-grid); stroke-width: 1; }
.ch-radar-spoke { stroke: var(--ds-grid); stroke-width: 1; }

.ch-radar-a { fill: var(--violet-a14); stroke: var(--ds-1); stroke-width: 1.75; stroke-linejoin: round; }
.ch-radar-b { fill: none; stroke: var(--ink-300); stroke-width: 1.25; stroke-dasharray: 3 2.5; stroke-linejoin: round; }
.ch-radar-c { fill: none; stroke: var(--ds-3); stroke-width: 1.25; stroke-linejoin: round; }

/* ---- 环形 -------------------------------------------------------------- */
.ch-donut-track { fill: none; stroke: var(--paper-3); }
.ch-donut-seg { fill: none; stroke-linecap: butt; transition: opacity var(--dur-fast) var(--ease-out); }
.ch-donut-seg:hover { opacity: 0.82; }

/* ---- 图例 -------------------------------------------------------------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  font-size: var(--t-xs);
  color: var(--ink-500);
}

.legend li { display: flex; align-items: center; gap: 7px; }

.legend i {
  width: 9px; height: 9px;
  border-radius: 2px;
  flex: none;
  background: var(--ds-5);
}

.legend i.k1 { background: var(--ds-1); }
.legend i.k2 { background: var(--ds-2); }
.legend i.k3 { background: var(--ds-3); }
.legend i.k4 { background: var(--ds-4); }
.legend i.k5 { background: var(--ds-5); }

.legend i.line-key { height: 2px; border-radius: 1px; width: 14px; }

.legend b {
  margin-left: 2px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}

/* ---- 稀疏柱阵（用于"时段热度"这类紧凑视图） --------------------------- */
.spark-bars { display: flex; align-items: flex-end; gap: 3px; height: 46px; }

.spark-bars i {
  flex: 1;
  background: var(--paper-3);
  border-radius: 1.5px 1.5px 0 0;
  transition: background var(--dur-fast) var(--ease-out);
}

.spark-bars i.on   { background: var(--ds-2); }
.spark-bars i.peak { background: var(--ds-1); }

/* ---- 热力条（24 小时） ------------------------------------------------- */
.heat-row { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; }

.heat-row i {
  aspect-ratio: 1;
  border-radius: 1.5px;
  background: var(--paper-3);
}

.heat-row i[data-v="1"] { background: oklch(45% 0.188 291 / 0.12); }
.heat-row i[data-v="2"] { background: oklch(45% 0.188 291 / 0.26); }
.heat-row i[data-v="3"] { background: oklch(45% 0.188 291 / 0.44); }
.heat-row i[data-v="4"] { background: oklch(45% 0.188 291 / 0.66); }
.heat-row i[data-v="5"] { background: oklch(45% 0.188 291 / 0.92); }

/* --------------------------------------------------------------------------
   悬浮交互
   -------------------------------------------------------------------------- */

.chart-tip {
  position: fixed;
  top: 0; left: 0;
  z-index: var(--z-toast, 500);
  pointer-events: none;
  opacity: 0;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  background: var(--ink-900);
  color: oklch(100% 0 0);
  font-size: var(--t-xs);
  line-height: 1.5;
  white-space: nowrap;
  box-shadow: var(--shadow-lift);
  transition: opacity var(--dur-fast) var(--ease-out);
}

.chart-tip.is-on { opacity: 1; }
.chart-tip b { display: block; font-weight: 600; }

.chart-tip span {
  display: block;
  margin-top: 1px;
  color: oklch(100% 0 0 / 0.62);
  font-variant-numeric: tabular-nums;
}

/* 折线命中区与悬浮指示 */
.ch-hit { fill: transparent; stroke: none; cursor: crosshair; }

.ch-hover {
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.ch-hover.is-on { opacity: 1; }
.ch-hover-guide { stroke: var(--violet); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.45; }
.ch-hover-dot {
  fill: var(--paper-0);
  stroke: var(--violet);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

/* 环形段 */
.ch-donut-seg[data-tip] { cursor: pointer; }
.ch-donut-seg:hover { opacity: 1; filter: brightness(0.9); }

/* 雷达顶点：必须排除命中区与环形段，二者同为 circle，改半径会毁掉图形 */
.chart circle[data-tip]:not(.ch-hit):not(.ch-donut-seg) {
  cursor: pointer;
  transition: r var(--dur-fast) var(--ease-out);
}

.chart circle[data-tip]:not(.ch-hit):not(.ch-donut-seg):hover { r: 4.4; }

/* 热力格 */
.heat-row i[data-tip] { cursor: pointer; transition: outline-color var(--dur-fast) var(--ease-out); outline: 1.5px solid transparent; outline-offset: 1px; }
.heat-row i[data-tip]:hover { outline-color: var(--violet); }

/* 稀疏柱阵 */
.spark-bars i[data-tip] { cursor: pointer; }
.spark-bars i[data-tip]:hover { background: var(--violet-deep); }
