/* OneOne 设计体系 · 图表样式（assets/js/chart.js 的 OOT.chart，2026-11-10）
   颜色只用 tokens.css 的变量（--chart-*、--c-* 色阶），所以前台、后台、深色都不用另写。 */

.ch-plot { position: relative; min-width: 0; }
.ch-center { display: flex; justify-content: center; }
.ch-svg { display: block; overflow: visible; font-family: var(--font-sans); }
.ch-empty { display: grid; place-items: center; min-height: 140px; padding: 24px 16px; border-radius: var(--r-md); background: var(--bg-soft); color: var(--text-dim); font-size: 13px; text-align: center; }

/* 坐标轴和网格 */
.ch-grid { stroke: var(--chart-grid); stroke-width: 1; }
.ch-grid.is-base { stroke: var(--line); }
.ch-ax { fill: var(--text-dim); font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; }
.ch-ax.is-now { fill: var(--text-strong); font-weight: var(--fw-bold); }
.ch-lab { fill: var(--text-muted); font-size: 12.5px; font-weight: var(--fw-semibold); }
.ch-hover { fill: var(--accent-tint); opacity: 0.75; }
.ch-cross { stroke: var(--line); stroke-dasharray: 3 3; }

/* 柱、线、面积 */
.ch-bar.is-on { filter: brightness(1.08); }
.ch-bar.is-open { opacity: 0.45; }
.ch-bar-prev { fill: var(--chart-prev); opacity: 0.8; }
.ch-zero { fill: var(--line); }
.ch-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.ch-line-prev { fill: none; stroke: var(--chart-prev); stroke-width: 2; stroke-dasharray: 4 4; }
.ch-dot { fill: var(--bg-elevated); stroke-width: 2.5; }
.ch-target { stroke: var(--c-blue-300); stroke-width: 1.5; stroke-dasharray: 5 5; }
.ch-avg { fill: none; stroke: var(--chart-avg); stroke-width: 2.5; stroke-linecap: round; }
.ch-avg.is-dash { stroke-width: 2; stroke-dasharray: 6 5; }
.ch-avg-glow { fill: none; stroke: var(--chart-avg); stroke-width: 10; stroke-linecap: round; opacity: 0.22; }
.ch-avg-glow.is-halo { stroke: var(--bg-elevated); stroke-width: 6; opacity: 0.9; }
.ch-avg-dot { fill: var(--bg-elevated); stroke: var(--chart-avg); stroke-width: 3; }
.ch-err { fill: var(--chart-error); }
.ch-you { stroke: var(--text-strong); stroke-width: 2; }
.ch-bin { fill: var(--c-gray-200); }
.ch-bin.is-passed { fill: var(--c-blue-200); }
.ch-bin.is-mine { fill: var(--chart-1); }
html[data-theme='dark'] .ch-bin { fill: var(--c-gray-800); }
html[data-theme='dark'] .ch-bin.is-passed { fill: var(--c-blue-800); }
html[data-theme='dark'] .ch-bin.is-mine { fill: var(--chart-1); }
.ch-radar { fill-opacity: 0.18; stroke-width: 2.5; stroke-linejoin: round; }
.ch-radar-prev { fill: none; stroke: var(--chart-prev); stroke-width: 2; stroke-dasharray: 4 4; }

/* 叠在图上的小牌子：最好（金色皇冠）、最后一次、你、目标 */
.ch-badge { position: absolute; display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--r-pill); font-size: 12.5px; line-height: 1.25; white-space: nowrap; pointer-events: none; transform: translate(-50%, -100%); font-variant-numeric: tabular-nums; }
.ch-badge b { font-weight: var(--fw-bold); }
.ch-badge svg { width: 13px; height: 13px; }
.ch-badge.is-best { background: linear-gradient(180deg, var(--c-gold-100), var(--c-gold-200)); color: var(--gold-ink); box-shadow: var(--elev-2); }
.ch-badge.is-last { background: var(--bg-elevated); color: var(--text-strong); box-shadow: var(--elev-2); }
.ch-badge.is-you { background: var(--text-strong); color: var(--bg-elevated); }
.ch-badge.is-pin::after { content: ''; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px; margin-left: -5px; background: inherit; border-radius: 0 0 2px 0; transform: rotate(45deg); z-index: -1; }
.ch-badge.is-pin { isolation: isolate; }
html[data-theme='dark'] .ch-badge.is-best { background: linear-gradient(180deg, var(--c-gold-300), var(--c-gold-400)); }
.ch-target-pill { position: absolute; padding: 2px 9px; border-radius: var(--r-pill); background: var(--accent-tint); color: var(--accent-ink); font-size: 12px; font-weight: var(--fw-bold); white-space: nowrap; pointer-events: none; transform: translateY(-50%); }
.ch-target-pill.is-avg { background: var(--gold-soft); color: var(--gold-soft-ink); }

/* 提示框：一种样子 */
.ch-tip { position: absolute; top: 4px; z-index: var(--z-raised); min-width: 160px; padding: 10px 12px; border-radius: var(--r-md); background: var(--bg-elevated); box-shadow: var(--elev-3); font-size: 12.5px; pointer-events: none; }
.ch-tip[hidden] { display: none; }
.ch-tip b { display: block; margin-bottom: 6px; color: var(--text-strong); font-size: 13px; }
.ch-tip div { display: flex; justify-content: space-between; gap: 14px; padding: 2px 0; color: var(--text-muted); }
.ch-tip span { display: inline-flex; align-items: center; gap: 6px; }
.ch-tip em { color: var(--text-strong); font-style: normal; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }

/* 图例：颜色旁边一定有字 */
.ch-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 10px; color: var(--text-muted); font-size: 12.5px; }
.ch-legend span { display: inline-flex; align-items: center; gap: 7px; }
.ch-legend.is-scale { gap: 4px; }
.ch-legend.is-scale span { margin: 0 4px; color: var(--text-dim); font-size: 12px; }
.ch-key { display: inline-block; flex: 0 0 auto; width: 10px; height: 10px; border-radius: 3px; }
.ch-key.is-bar { width: 8px; height: 12px; border-radius: 3px 3px 0 0; }   /* 柱状图的图例：一根小柱子 */
.ch-key.is-prev { background: var(--chart-prev); }
.ch-key.is-avg { width: 16px; height: 3px; border-radius: 2px; background: var(--chart-avg); }
.ch-key.is-target { width: 16px; height: 0; border-top: 2px dashed var(--c-blue-300); border-radius: 0; }
.ch-key.is-err { border-radius: 50%; background: var(--chart-error); }
.ch-note { margin: 8px 0 0; color: var(--text-muted); font-size: 13px; }
.ch-note.is-center { text-align: center; }
.ch-note b { color: var(--text-strong); font-variant-numeric: tabular-nums; }

/* 读屏用的数字表：看不见，读得到 */
.ch-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 迷你走势 */
.ch-spark { display: inline-block; vertical-align: middle; overflow: visible; }

/* 热力日历：沿用 --cal-0…4 */
.ch-heat { overflow-x: auto; }
.ch-cell { stroke: var(--cal-line); stroke-width: 1; }
.ch-cell.l0, .ch-cell-key.l0 { fill: var(--cal-0); background: var(--cal-0); }
.ch-cell.l1, .ch-cell-key.l1 { fill: var(--cal-1); background: var(--cal-1); }
.ch-cell.l2, .ch-cell-key.l2 { fill: var(--cal-2); background: var(--cal-2); }
.ch-cell.l3, .ch-cell-key.l3 { fill: var(--cal-3); background: var(--cal-3); }
.ch-cell.l4, .ch-cell-key.l4 { fill: var(--cal-4); background: var(--cal-4); }
.ch-cell.is-on { stroke: var(--text-strong); stroke-width: 1.5; }
.ch-cell-key { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }

/* 环形进度 */
.ch-ring { position: relative; display: inline-grid; place-items: center; flex: 0 0 auto; }
.ch-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ch-ring-track { fill: none; stroke: var(--bg-sunken); }
.ch-ring-bar { fill: none; stroke-linecap: round; }
.ch-ring-txt { position: relative; display: grid; justify-items: center; line-height: 1.1; }
.ch-ring-txt b { color: var(--text-strong); font-size: 16px; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.ch-ring-txt small { color: var(--text-dim); font-size: 11px; }

/* 横条排行 */
.ch-bars { display: grid; gap: 10px; }
.ch-bars-row { display: grid; grid-template-columns: minmax(64px, 30%) minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.ch-bars-row.is-me .ch-bars-lab { color: var(--accent-ink); font-weight: var(--fw-bold); }
.ch-bars-lab { display: grid; min-width: 0; overflow: hidden; color: var(--text-strong); font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.ch-bars-lab small { overflow: hidden; color: var(--text-dim); font-size: 11.5px; text-overflow: ellipsis; }
.ch-bars-track { height: 10px; overflow: hidden; border-radius: var(--r-pill); background: var(--bg-sunken); }
.ch-bars-track i { display: block; height: 100%; border-radius: inherit; }
.ch-bars-val { color: var(--text-strong); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.ch-bars-val small { margin-left: 3px; color: var(--text-dim); font-size: 11.5px; font-weight: var(--fw-medium); }

/* 键盘热力：键盘本身就是图 */
.ch-kb { display: grid; gap: 5px; max-width: 560px; }
/* 十列网格跟着卡片宽度走；下面两排往右错开一点，像真键盘 */
.ch-kb-row { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px; padding-left: calc(var(--indent, 0) * 4.5%); }
.ch-kb-row:last-child { padding-left: 0; }
.ch-k { display: grid; place-items: center; align-content: center; min-width: 0; height: 42px; overflow: hidden; border-radius: var(--r-sm); background: var(--bg-sunken); color: var(--text-muted); font-family: var(--font-mono); line-height: 1.1; }
.ch-k b { font-size: 13px; font-weight: var(--fw-bold); }
.ch-k small { max-width: 100%; overflow: hidden; font-size: 11px; opacity: 0.85; text-overflow: clip; white-space: nowrap; }
.ch-k.is-home b { text-decoration: underline; text-underline-offset: 3px; }
.ch-k.is-none { opacity: 0.45; }
.ch-k.is-space { grid-column: 3 / span 6; }
.is-bad .ch-k.l0, .is-bad .ch-k-key.l0 { background: var(--c-gray-100); color: var(--text-muted); }
.is-bad .ch-k.l1, .is-bad .ch-k-key.l1 { background: var(--c-red-50); color: var(--c-red-700); }
.is-bad .ch-k.l2, .is-bad .ch-k-key.l2 { background: var(--c-red-200); color: var(--c-red-800); }
.is-bad .ch-k.l3, .is-bad .ch-k-key.l3 { background: var(--c-red-400); color: var(--c-red-900); }
.is-bad .ch-k.l4, .is-bad .ch-k-key.l4 { background: var(--c-red-600); color: var(--c-gray-50); }
.is-good .ch-k.l0, .is-good .ch-k-key.l0 { background: var(--c-gray-100); color: var(--text-muted); }
.is-good .ch-k.l1, .is-good .ch-k-key.l1 { background: var(--c-blue-50); color: var(--c-blue-700); }
.is-good .ch-k.l2, .is-good .ch-k-key.l2 { background: var(--c-blue-200); color: var(--c-blue-800); }
.is-good .ch-k.l3, .is-good .ch-k-key.l3 { background: var(--c-blue-400); color: var(--c-blue-900); }
.is-good .ch-k.l4, .is-good .ch-k-key.l4 { background: var(--c-blue-600); color: var(--c-gray-50); }
html[data-theme='dark'] .is-bad .ch-k.l0, html[data-theme='dark'] .is-good .ch-k.l0,
html[data-theme='dark'] .is-bad .ch-k-key.l0, html[data-theme='dark'] .is-good .ch-k-key.l0 { background: var(--c-gray-800); color: var(--text-muted); }
html[data-theme='dark'] .is-bad .ch-k.l1, html[data-theme='dark'] .is-bad .ch-k-key.l1 { background: var(--c-red-900); color: var(--c-red-200); }
html[data-theme='dark'] .is-bad .ch-k.l2, html[data-theme='dark'] .is-bad .ch-k-key.l2 { background: var(--c-red-800); color: var(--c-red-100); }
html[data-theme='dark'] .is-good .ch-k.l1, html[data-theme='dark'] .is-good .ch-k-key.l1 { background: var(--c-blue-900); color: var(--c-blue-200); }
html[data-theme='dark'] .is-good .ch-k.l2, html[data-theme='dark'] .is-good .ch-k-key.l2 { background: var(--c-blue-800); color: var(--c-blue-100); }
.ch-k-key { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }
@media (max-width: 560px) {
  .ch-kb, .ch-kb-row { gap: 3px; }
  .ch-k { height: 34px; }
  .ch-k small { display: none; }
}
}

/* 出现的动画：柱子长出来、线画出来、环转到位。减少动态效果时都不做 */
.ch-svg.is-grow .ch-bar { transform-box: fill-box; transform-origin: bottom; animation: ch-grow var(--dur-smooth, 0.6s) var(--spring-smooth, ease) both; animation-delay: calc(min(var(--i, 0), 30) * 18ms); }
@keyframes ch-grow { from { transform: scaleY(0); } }
.ch-line.is-draw { stroke-dasharray: 4000; stroke-dashoffset: 4000; animation: ch-draw 1.1s ease-out forwards; }
@keyframes ch-draw { to { stroke-dashoffset: 0; } }
.ch-ring.is-grow .ch-ring-bar { animation: ch-ring var(--dur-gentle, 0.8s) var(--spring-gentle, ease) both; }
@keyframes ch-ring { from { stroke-dashoffset: var(--c); } }
.ch-radar.is-grow { animation: ch-pop var(--dur-bouncy, 0.6s) var(--spring-bouncy, ease) both; }
@keyframes ch-pop { from { transform: scale(0.3); opacity: 0; } }
.ch-bars-track i.is-grow { transform-origin: left; animation: ch-grow-x var(--dur-smooth, 0.6s) var(--spring-smooth, ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes ch-grow-x { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  .ch-svg .ch-bar, .ch-line.is-draw, .ch-ring-bar, .ch-radar, .ch-bars-track i { animation: none !important; stroke-dashoffset: 0; }
}
