/*
 * The thumb's own diameter is the one measure a slider cannot take from a scale,
 * so it is a property the sheet declares once and the track's inset reads: the
 * TRACK is inset half a thumb at each end, which is what makes the thumb's
 * CENTRE travel exactly the length of the bar it rides. Base UI's default
 * `center` alignment then puts thumb and indicator on that same span with no
 * measuring of our own.
 *
 * The filled half and the thumb's edge take `--lotics-slider-color`, which the
 * call site may repoint at a family token; everything else is the kit's.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-slider {
    --lotics-slider-thumb: 20px;
    --lotics-slider-color: var(--primary);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--lotics-space-10);
    min-width: 240px;
  }

  .lotics-slider__labels {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .lotics-slider__label {
    font-family: var(--font-sans);
    font-size: var(--lotics-text-sm);
    line-height: var(--lotics-leading-sm);
    letter-spacing: var(--lotics-tracking-sm);
    font-weight: var(--lotics-weight-regular);
    color: var(--lotics-ink-muted);
  }

  .lotics-slider__control {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 28px;
    touch-action: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .lotics-slider__track {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 6px;
    margin-inline: calc(var(--lotics-slider-thumb) / 2);
    border-radius: var(--lotics-radius-full);
    background-color: var(--input);
  }

  .lotics-slider__indicator {
    border-radius: var(--lotics-radius-full);
    background-color: var(--lotics-slider-color);
  }

  .lotics-slider__thumb {
    box-sizing: border-box;
    width: var(--lotics-slider-thumb);
    height: var(--lotics-slider-thumb);
    border-width: 2px;
    border-style: solid;
    border-color: var(--lotics-slider-color);
    border-radius: var(--lotics-radius-full);
    background-color: var(--card);
  }

  /* A soft halo while dragging — no size change, so the thumb never shifts. */
  .lotics-slider__thumb[data-dragging] {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--lotics-shadow-color) 10%, transparent);
  }

  /* The focusable element is the range input INSIDE the thumb, so the ring goes
     on the box a reader sees rather than on a visually-hidden control. */
  .lotics-slider__thumb:has(:focus-visible) {
    outline: var(--lotics-ring-width) solid var(--ring);
    outline-offset: 0;
  }
}
