@layer layout {
  .stage {
    --stage-max: 1100px;
    --stage-min: 220px;
  }
}

@layer components {
  .readout {
    --state: 0;
    display: grid;
    gap: var(--space-l);
    /* --state is a registered <number> (see _shared.css), so easing it here
       smooths every calc(var(--state)) below it too, no per-property
       transitions needed. Threshold-triggered only, not continuous, so the
       cost is one short ease per resize step. */
    transition: --state .2s ease-out;

    @media (prefers-reduced-motion: reduce) {
      transition: none;
    }

    @container (width >= 320px) { --state: 1; }
    @container (width >= 560px) { --state: 2; }
    @container (width >= 800px) { --state: 3; }
    @container (width >= 1040px) { --state: 4; }
  }

  .state-label {
    margin: 0;
    font-size: 1.05rem;
    color: var(--color-muted);

    span {
      display: none;
      font-weight: 600;
      color: var(--color-accent);
    }

    @container (width < 320px) { & .s0 { display: inline; } }
    @container (320px <= width < 560px) { & .s1 { display: inline; } }
    @container (560px <= width < 800px) { & .s2 { display: inline; } }
    @container (800px <= width < 1040px) { & .s3 { display: inline; } }
    @container (width >= 1040px) { & .s4 { display: inline; } }
  }

  .meter {
    block-size: var(--space-s);
    border-radius: var(--radius-full);
    background: var(--color-surface-2);
    overflow: hidden;
  }

  .meter-fill {
    block-size: 100%;
    border-radius: inherit;
    background: var(--color-accent);
    inline-size: calc(var(--state) / 4 * 100%);
  }

  .thresholds {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-s);
    margin: 0;
    padding: 0;
    list-style: none;

    li {
      padding-block: var(--space-2xs);
      padding-inline: var(--space-s);
      border-radius: var(--radius-full);
      background: var(--color-surface-2);
      color: var(--color-muted);
      font-size: .8rem;
      font-variant-numeric: tabular-nums;

      &::after {
        content: " \2717";
        color: var(--color-muted);
      }
    }

    @container (width >= 320px) { & .t1::after { content: " \2713"; color: var(--color-accent); } }
    @container (width >= 560px) { & .t2::after { content: " \2713"; color: var(--color-accent); } }
    @container (width >= 800px) { & .t3::after { content: " \2713"; color: var(--color-accent); } }
    @container (width >= 1040px) { & .t4::after { content: " \2713"; color: var(--color-accent); } }
  }
}
