/* =========================
   Chips
   Figma: Badge type / filter chips.
========================= */

@use "../kit-deps" as *;

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: $space-1;
  min-height: 30px;
  padding: $space-1 $space-3;
  font-family: $font-family-base;
  font-size: $font-size-xs;
  font-weight: $font-weight-semibold;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: $radius-full;
  border: $border-width-base $border-style-base $border-color-muted;
  background-color: $neutral-0;
  color: $neutral-700;
  transition:
    background-color $motion-base $motion-ease,
    border-color $motion-base $motion-ease,
    color $motion-base $motion-ease;

  .chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: $icon-size-sm;
    height: $icon-size-sm;
    padding: 0;
    margin-left: $space-1;
    margin-right: -$space-1;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: currentColor;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity $motion-base $motion-ease;

    &:hover {
      opacity: 1;
    }

    &:focus-visible {
      @include focus_ring;
    }
  }

  // Variants
  &.chip-primary {
    color: $neutral-900;
    background-color: $neutral-100;
    border-color: $neutral-900;
  }

  &.chip-secondary {
    color: $mint-800;
    background-color: $mint-50;
    border-color: $mint-600;
  }

  &.chip-accent {
    color: $neutral-900;
    background-color: $yellow-100;
    border-color: $yellow-400;
  }

  &.chip-success {
    color: $success-text;
    background-color: $success-bg;
    border-color: $success-text;
  }

  &.chip-warning {
    color: $warning-text;
    background-color: $warning-bg;
    border-color: $warning-text;
  }

  &.chip-danger,
  &.chip-error {
    color: $danger-text;
    background-color: $danger-bg;
    border-color: $danger-text;
  }

  &.chip-outline {
    background-color: transparent;
    border-color: $neutral-300;
    color: $neutral-700;

    &:hover {
      border-color: $neutral-400;
      color: $neutral-900;
    }
  }

  // Selectable / pressed state
  &.chip-selected,
  &[aria-pressed="true"],
  &[aria-selected="true"] {
    color: $neutral-0;
    background-color: $neutral-900;
    border-color: $neutral-900;

    &.chip-secondary {
      color: $neutral-0;
      background-color: $mint-600;
      border-color: $mint-600;
    }

    &.chip-accent {
      color: $neutral-900;
      background-color: $yellow-400;
      border-color: $yellow-400;
    }
  }

  &.chip-disabled,
  &:disabled {
    color: $neutral-500;
    background-color: $neutral-100;
    border-color: $border-color-muted;
    cursor: not-allowed;
    opacity: 0.7;
  }

  // Sizes
  &.chip-sm {
    min-height: 22px;
    padding: 2px $space-2;
    font-size: 11px;

    .chip-remove {
      width: 12px;
      height: 12px;
    }
  }

  &.chip-lg {
    min-height: 34px;
    padding: $space-1 $space-4;
    font-size: 14px;
  }
}

button.chip,
a.chip {
  cursor: pointer;

  &:focus-visible {
    @include focus_ring;
  }

  &:hover:not(:disabled):not(.chip-disabled) {
    color: $neutral-900;
    background-color: $neutral-100;
    border-color: $neutral-400;
  }
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: $space-2;
}
