/*
 * Level and track progress: a native <progress> (role and value come for free) plus the visible
 * percentage in .progress__value. --with-label puts a <label> above the bar; --sm is the thin bar
 * used inside cards. The fill uses the action color on the sunken track (3:1 checked in tokens.css).
 */
@layer components {
  .progress {
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }

  .progress__bar {
    flex: 1;
    min-width: 0;
    height: var(--space-2);
    border: 0;
    border-radius: var(--radius-full);
    overflow: hidden;
    background: var(--color-surface-sunken);
    color: var(--color-action);
    appearance: none;

    /* Each engine has its own parts; they cannot share one rule or the whole rule is dropped. */
    &::-webkit-progress-bar {
      background: var(--color-surface-sunken);
    }

    &::-webkit-progress-value {
      border-radius: var(--radius-full);
      background: var(--progress-fill, var(--color-action));
    }

    &::-moz-progress-bar {
      border-radius: var(--radius-full);
      background: var(--progress-fill, var(--color-action));
    }
  }

  .progress__value {
    flex: none;
    min-width: 4ch;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    font-variant-numeric: tabular-nums;
    text-align: end;
  }

  .progress__label {
    flex: 1;
    font-size: var(--text-sm);
  }

  /* Label and value share the first row, the bar spans the second. */
  .progress--with-label {
    flex-wrap: wrap;
    row-gap: var(--space-2);

    & .progress__bar {
      flex-basis: 100%;
      order: 1;
    }
  }

  .progress--sm {
    gap: var(--space-2);

    & .progress__bar {
      height: var(--space-1);
    }

    & .progress__value {
      font-size: var(--text-xs);
    }
  }
}
