@layer components {
  /* A floor on a measured spec: the price filter's track with one handle. */
  .spec-scale {
    --scale-from: 0%;
    --scale-to: 100%;
  }

  /* On the listing a full-width scale would part the value from its price */
  section.spec-scale {
    max-inline-size: 36rem;
  }

  .spec-scale__readout {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 0 0 var(--block-space);
    font-size: var(--text-sm);
    gap: var(--inline-space-half);

    strong {
      font-weight: 600;
    }

    span {
      color: var(--color-muted);
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }
  }

  .spec-scale__track {
    position: relative;
    height: 6px;
    border-radius: 3px;
    background: var(--color-separator);
    margin-block: 0.5rem;
  }

  .spec-scale__fill {
    position: absolute;
    right: calc(100% - var(--scale-to));
    left: var(--scale-from);
    height: 100%;
    border-radius: 3px;
    background: var(--color-primary);
  }

  /* A tall, transparent input so a finger can grab the handle */
  .spec-scale__track input[type="range"] {
    position: absolute;
    top: 50%;
    width: 100%;
    height: 2.75rem;
    margin: 0;
    appearance: none;
    background: transparent;
    cursor: pointer;
    transform: translateY(-50%);

    &:focus-visible {
      outline: none;
    }

    &::-webkit-slider-thumb {
      width: 1.25rem;
      height: 1.25rem;
      border: 2px solid var(--color-primary);
      border-radius: 50%;
      appearance: none;
      background: var(--color-surface);
      box-shadow: 0 2px 4px oklch(var(--lch-black) / 10%);
      transition: transform 0.15s ease-out;
    }

    &::-moz-range-thumb {
      width: 1.25rem;
      height: 1.25rem;
      box-sizing: border-box;
      border: 2px solid var(--color-primary);
      border-radius: 50%;
      background: var(--color-surface);
      box-shadow: 0 2px 4px oklch(var(--lch-black) / 10%);
      transition: transform 0.15s ease-out;
    }

    &:focus-visible::-webkit-slider-thumb {
      outline: var(--focus-ring);
      outline-offset: var(--focus-ring-offset);
    }

    &:focus-visible::-moz-range-thumb {
      outline: var(--focus-ring);
      outline-offset: var(--focus-ring-offset);
    }

    @media (hover: hover) {
      &:hover::-webkit-slider-thumb {
        transform: scale(1.1);
      }

      &:hover::-moz-range-thumb {
        transform: scale(1.1);
      }
    }
  }

  .spec-scale__ends {
    display: flex;
    justify-content: space-between;
    color: var(--color-muted);
    font-size: var(--text-xs);
    margin-block-start: var(--block-space-half);
  }
}
