/* Bar chart race (bar-race.js). The script builds .mw-race__axis (ticks that
   follow the leader) and .mw-race__rows (one absolutely placed row per series,
   moved by transform), and writes --mw-race-top (rows shown) and
   --mw-race-span (px length of the longest bar). Rows below the top N slide
   under the clip of .mw-race__rows. */

.mw-race {
  --mw-race-row: 52px;
  --mw-race-thick: .72;
  --mw-race-label-w: 8rem;
  --mw-race-gap: 14px;
  --mw-race-radius: 6px;
  --mw-race-axis-h: 30px;
  --mw-race-grid: currentColor;
  --mw-race-bg: transparent;
  position: relative;
  padding-top: var(--mw-race-axis-h);
}
/* The author's static fallback (the final ranking) is hidden while the race runs. */
.mw-race > [hidden] { display: none !important; }

/* Ticks sit over the tracks only; every line starts under its label. */
.mw-race__axis {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--mw-race-label-w) + var(--mw-race-gap));
  right: 0;
  pointer-events: none;
}
.mw-race__axis::before,
.mw-race__tick::before {
  content: "";
  position: absolute;
  top: var(--mw-race-axis-h);
  bottom: 0;
  left: 0;
  width: 1px;
  background: var(--mw-race-grid);
}
.mw-race__tick {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  animation: mw-race-tick-in .3s var(--mw-ease, cubic-bezier(.16, 1, .3, 1)) both;
}
.mw-race__tick-label {
  position: absolute;
  top: 0;
  left: 0;
  translate: -50% 0;
  font-size: .8rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
@keyframes mw-race-tick-in { from { opacity: 0; } }

.mw-race__rows {
  position: relative;
  height: calc(var(--mw-race-top, 8) * var(--mw-race-row));
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  overflow: clip;
}
.mw-race__row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: var(--mw-race-label-w) minmax(0, 1fr);
  align-items: center;
  column-gap: var(--mw-race-gap);
  height: var(--mw-race-row);
}
.mw-race__row[hidden] { display: none; }
.mw-race__label {
  grid-area: 1 / 1;
  min-width: 0;
  line-height: 1.1;
  text-align: right;
  overflow-wrap: anywhere;
}
.mw-race__track {
  grid-area: 1 / 2;
  position: relative;
  height: calc(var(--mw-race-row) * var(--mw-race-thick));
  overflow: hidden;
  overflow: clip;
}
.mw-race__bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--mw-race-span, 100%);
  border-radius: 0 var(--mw-race-radius) var(--mw-race-radius) 0;
  background: var(--mw-race-c, currentColor);
}
/* The value rides the bar end; its background hides the grid lines behind it. */
.mw-race__value {
  grid-area: 1 / 2;
  justify-self: start;
  position: relative;
  padding: 0 .4em;
  background: var(--mw-race-bg);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mw-race__label,
.mw-race__value { transition: opacity .24s, visibility 0s; }
.mw-race__row--out .mw-race__label,
.mw-race__row--out .mw-race__value {
  opacity: 0;
  visibility: hidden;
  transition: opacity .24s, visibility 0s .24s;
}

@media (prefers-reduced-motion: reduce) {
  .mw-race__tick { animation: none; }
  .mw-race__label,
  .mw-race__value { transition: none; }
}
