/* BarChart — stacked, selectable bars with value labels, hover card, badges
   (kit: ui/bar_chart.rs). */

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.bar-chart__legend {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--space-6);
  row-gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.bar-chart__legend-item {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
}

.bar-chart__legend-label {
  color: var(--text-muted);
  font-size: var(--ui-text-caption, 0.8125rem);
}

.bar-chart__legend-value {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bar-chart__swatch {
  align-self: center;
  width: var(--space-3);
  height: var(--space-3);
  border-radius: 2px;
}

.bar-chart__seg--primary { background: var(--success); }
.bar-chart__seg--caution { background: var(--caution); }
.bar-chart__seg--danger  { background: var(--danger); }

.bar-chart__plot {
  display: flex;
  align-items: stretch;
  gap: var(--space-2);
  height: calc(var(--u) * 64);
  padding-top: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  box-sizing: border-box;
}

.bar-chart__col {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.bar-chart__col:hover .bar-chart__stack,
.bar-chart__col:focus-visible .bar-chart__stack {
  filter: brightness(1.08);
}

.bar-chart__col:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bar-chart__col.is-selected {
  background: var(--selection);
}

.bar-chart__total {
  position: absolute;
  left: 0;
  right: 0;
  padding-bottom: var(--space-1);
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
  color: var(--text);
  font-size: var(--ui-text-caption, 0.8125rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.bar-chart__stack {
  display: flex;
  flex-direction: column-reverse;
  min-height: 2px;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.bar-chart__seg {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-basis: 0;
  flex-shrink: 0;
  min-height: 1px;
  overflow: hidden;
  white-space: nowrap;
  color: var(--bg-elevated);
  font-size: var(--ui-text-caption, 0.8125rem);
  font-variant-numeric: tabular-nums;
}

.bar-chart__axis {
  display: flex;
  gap: var(--space-2);
}

.bar-chart__tick {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: var(--ui-text-caption, 0.8125rem);
}

.bar-chart--dense .bar-chart__plot,
.bar-chart--dense .bar-chart__axis {
  gap: var(--space-1);
}

.bar-chart__badges .bar-chart__tick {
  display: flex;
  justify-content: center;
}

.bar-chart__tip {
  position: absolute;
  top: 0;
  left: calc(100% + var(--space-2));
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: calc(var(--u) * 48);
  max-width: calc(var(--u) * 72);
  padding: var(--space-3);
  border: 1px solid var(--border-inner);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  text-align: left;
  pointer-events: none;
}

.bar-chart__tip--flip {
  left: auto;
  right: calc(100% + var(--space-2));
}

.bar-chart__tip-title { font-weight: 600; }
.bar-chart__tip-line  { color: var(--text-muted); }

.bar-chart__empty {
  margin: 0;
  color: var(--text-muted);
}
