/*
 * Where a reading sits between the lowest and the highest (shared/_range_track;
 * tasks/growth, index R17): a 0–100 track with a marker at the reading's
 * share, set by the markup as `--position` — M10's metric pages for a
 * company's own ten years, M13's valuation percentiles. The ends are
 * labelled under it, and a percentile's track marks its half, the median.
 * A neutral rule with a round green marker: where the reading sits is a
 * place, not a verdict, so the track is never shaded from good to bad.
 */
@layer components {
  .range-track {
    position: relative;
    block-size: var(--space-2xs);
    margin-block: var(--space-sm) var(--space-2xs);
    background-color: var(--color-rule);
  }

  .range-track__middle {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 50%;
    inline-size: var(--rule-width-strong);
    block-size: var(--space-sm);
    background-color: var(--color-ink-muted);
    translate: -50% -50%;
  }

  .range-track__marker {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: var(--position, 50%);
    inline-size: var(--space-sm);
    block-size: var(--space-sm);
    border: var(--rule-width-strong) solid var(--color-surface);
    border-radius: var(--radius-pill);
    background-color: var(--color-accent);
    box-sizing: content-box;
    translate: -50% -50%;
  }

  .range-track__ends {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: var(--space-sm);
    color: var(--color-ink-muted);
    font-size: var(--text-meta-xs);

    /* An end may be a word over its figure. */
    & > * {
      display: grid;
    }

    & > :nth-child(2):not(:last-child) {
      justify-items: center;
      text-align: center;
    }

    & > :last-child {
      justify-items: end;
      text-align: end;
    }
  }
}
