/* Chart chrome, shared by the hub and the client panel.
   Every colour is a --viz-* custom property with a neutral fallback, so an app themes the
   charts by redefining the properties and never by editing this file.
   Sizing is in px and inherits the host's font — nothing here is hub-specific. */

.viz {
  --viz-surface: var(--viz-surface-override, transparent);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.viz-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.viz-titles { min-width: 0; }

.viz-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.005em;
  color: var(--viz-ink, #111);
}

.viz-sub {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--viz-ink-3, #777);
}

.viz-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.viz-toggle {
  appearance: none;
  border: 1px solid var(--viz-border, rgba(128, 128, 128, 0.3));
  background: transparent;
  color: var(--viz-ink-2, #555);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.viz-toggle:hover { color: var(--viz-ink, #111); border-color: var(--viz-border-strong, rgba(128, 128, 128, 0.55)); }
.viz-toggle[aria-pressed='true'] { color: var(--viz-ink, #111); border-color: var(--viz-border-strong, rgba(128, 128, 128, 0.55)); }

.viz-plot {
  position: relative;
  width: 100%;
  min-width: 0;
}

.viz-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* --- marks ------------------------------------------------------------- */

.viz-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.viz-line--compare { stroke-width: 2; opacity: 0.95; }

.viz-col { transition: opacity 120ms ease; }
.viz-col.is-lit { opacity: 0.72; }

.viz-cell { transition: opacity 120ms ease; }
.viz-cell.is-lit { opacity: 0.68; }

.viz-focus-dot {
  stroke: var(--viz-surface-ring, var(--viz-surface, #fff));
  stroke-width: 2;
  paint-order: stroke;
}

.viz-hair {
  stroke: var(--viz-axis, rgba(128, 128, 128, 0.5));
  stroke-width: 1;
}

.viz-gridline {
  stroke: var(--viz-grid, rgba(128, 128, 128, 0.18));
  stroke-width: 1;
}

.viz-tick {
  fill: var(--viz-ink-4, #888);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.viz-capture { cursor: crosshair; outline: none; }
.viz-capture:focus-visible { outline: 2px solid var(--viz-focus, #6a5fd3); outline-offset: -2px; }

/* A day carrying a note: a small solid caret on the baseline, in ink rather than a series hue —
   it is a label, not a value. */
.viz-note-mark { fill: var(--viz-ink-3, #777); }

/* --- draw-in ----------------------------------------------------------- */
/* One reveal, on first paint. Columns grow from the baseline they are measured against; everything
   else fades up a couple of pixels. Nothing bounces and nothing repeats. */

.viz-svg.is-drawing .viz-col,
.viz-svg.is-drawing .viz-cell {
  transform-box: fill-box;
  transform-origin: bottom;
  animation: viz-grow 260ms cubic-bezier(0.22, 0.7, 0.3, 1) both;
}

.viz-svg.is-drawing .viz-line,
.viz-svg.is-drawing .viz-tick,
.viz-svg.is-drawing .viz-note-mark {
  animation: viz-fade 240ms cubic-bezier(0.22, 0.7, 0.3, 1) both;
  animation-delay: 120ms;
}

@keyframes viz-grow { from { transform: scaleY(0.04); opacity: 0.4; } }
@keyframes viz-fade { from { opacity: 0; } }

/* --- tooltip ----------------------------------------------------------- */

.viz-tip {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  min-width: 90px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--viz-tip-bg, #1b1b22);
  border: 1px solid var(--viz-tip-border, rgba(255, 255, 255, 0.12));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--viz-tip-ink, #fff);
}

.viz-tip-head {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--viz-tip-ink-2, rgba(255, 255, 255, 0.6));
  margin-bottom: 3px;
  white-space: nowrap;
}

.viz-tip-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.viz-tip-value {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.viz-tip-label { color: var(--viz-tip-ink-2, rgba(255, 255, 255, 0.6)); }

/* A pinned note reads as a sentence, so it is the one thing in the tooltip allowed to wrap. */
.viz-tip-note {
  max-width: 220px;
  margin-bottom: 4px;
  white-space: normal;
  line-height: 1.35;
  color: var(--viz-tip-ink, #fff);
}

.viz-key { flex: none; align-self: center; }

/* --- legend ------------------------------------------------------------ */

.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
  color: var(--viz-ink-2, #555);
}

.viz-legend-item { display: inline-flex; align-items: center; gap: 5px; }

/* `display: flex` beats the user agent's `[hidden] { display: none }`, so the legend needs to be told
   again — otherwise it stays on screen when the chart is swapped for its table. */
.viz-legend[hidden] { display: none; }

/* --- pinned notes ------------------------------------------------------ */

.viz-notes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.viz-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--viz-ink-2, #555);
  max-width: 62ch;
}

.viz-note-caret { flex: none; font-size: 12px; line-height: 1.7; color: var(--viz-ink-3, #777); }
.viz-note-when { color: var(--viz-ink-3, #777); margin-right: 6px; white-space: nowrap; }

/* --- table twin & empty ------------------------------------------------ */

/* The table twin is the whole alternative to the picture, and it scrolls — so it has to be
   scrollable without a pointer. `tabindex="0"` and a name are set on the element in chart.js. */
.viz-table {
  max-height: 260px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--viz-border, rgba(128, 128, 128, 0.2));
  border-radius: 8px;
}
.viz-table:focus-visible { outline: 2px solid var(--viz-focus, #6a5fd3); outline-offset: 2px; }

/* Shared components render their spoken descriptions into this; both apps also define it. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* An empty chart is a sentence, not a container. The old 22px-padded dashed box took as much
   vertical space as a real plot and made "nothing happened" look like "something is broken". */
.viz-empty {
  margin: 0;
  padding: 2px 0 6px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--viz-ink-3, #777);
}

/* --- ranked bars ------------------------------------------------------- */

.ranked { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }

.ranked-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(70px, 1fr) 56px;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 13.5px;
}

.ranked-label {
  color: var(--viz-ink-2, #555);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranked-track {
  height: 6px;
  border-radius: 3px;
  background: var(--viz-track, rgba(128, 128, 128, 0.16));
  overflow: hidden;
}

.ranked-fill { display: block; height: 100%; border-radius: 3px; }

.ranked-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--viz-ink, #111);
}

@media (max-width: 520px) {
  .ranked-row { grid-template-columns: minmax(0, 1fr) 48px 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .viz-col, .viz-cell { transition: none; }
  .viz-svg.is-drawing .viz-col,
  .viz-svg.is-drawing .viz-cell,
  .viz-svg.is-drawing .viz-line,
  .viz-svg.is-drawing .viz-tick,
  .viz-svg.is-drawing .viz-note-mark { animation: none; }
}

.spark { display: block; overflow: visible; }
