/*
 * Backpack - Skyscanner's Design System
 *
 * Copyright 2016-2021 Skyscanner Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@mixin bpk-chip {
  display: inline-flex;
  height: $bpk-spacing-xl;
  padding: 0 $bpk-spacing-md;
  align-items: center;
  border: none;

  @include bpk-border-radius-pill;

  &--light {
    background-color: $bpk-color-white;
    color: $bpk-color-sky-gray;

    @include bpk-border-sm($bpk-color-sky-gray-tint-03);

    @include bpk-hover {
      background-color: $bpk-color-sky-gray-tint-07;
    }

    &:active:not(:disabled) {
      background-color: $bpk-color-sky-gray-tint-06;
    }

    &-selected {
      @include bpk-themeable-property(
        color,
        --bpk-chip-light-selected-text-color,
        $bpk-color-white
      );
      @include bpk-themeable-property(
        background-color,
        --bpk-chip-light-selected-background-color,
        $bpk-color-sky-blue
      );
      @include bpk-border-sm(transparent);

      @include bpk-hover {
        @include bpk-themeable-property(
          background-color,
          --bpk-chip-light-selected-hover-background-color,
          $bpk-color-sky-blue-shade-01
        );
      }

      &:active:not(:disabled) {
        @include bpk-themeable-property(
          background-color,
          --bpk-chip-light-selected-active-background-color,
          $bpk-color-sky-blue-shade-02
        );
      }
    }
  }

  &--primary {
    background-color: $bpk-color-sky-gray-tint-06;
    color: $bpk-color-sky-gray;

    @include bpk-hover {
      background-color: $bpk-color-sky-gray-tint-05;
    }

    &:active:not(:disabled) {
      background-color: $bpk-color-sky-gray-tint-04;
    }

    &-selected {
      @include bpk-themeable-property(
        color,
        --bpk-chip-primary-selected-text-color,
        $bpk-color-white
      );
      @include bpk-themeable-property(
        background-color,
        --bpk-chip-primary-selected-background-color,
        $bpk-color-sky-blue
      );
      @include bpk-border-sm(transparent);

      @include bpk-hover {
        @include bpk-themeable-property(
          background-color,
          --bpk-chip-primary-selected-hover-background-color,
          $bpk-color-sky-blue-shade-01
        );
      }

      &:active:not(:disabled) {
        @include bpk-themeable-property(
          background-color,
          --bpk-chip-primary-selected-active-background-color,
          $bpk-color-sky-blue-shade-02
        );
      }
    }
  }

  &--success {
    background-color: $bpk-color-sky-gray-tint-06;
    color: $bpk-color-sky-gray;

    @include bpk-hover {
      background-color: $bpk-color-sky-gray-tint-05;
    }

    &:active:not(:disabled) {
      background-color: $bpk-color-sky-gray-tint-04;
    }

    &-selected {
      @include bpk-themeable-property(
        color,
        --bpk-chip-success-selected-text-color,
        $bpk-color-sky-gray
      );
      @include bpk-themeable-property(
        background-color,
        --bpk-chip-success-selected-background-color,
        $bpk-color-glencoe
      );

      @include bpk-hover {
        // There's no suitable token here, so we use darken.
        @include bpk-themeable-property(
          background-color,
          --bpk-chip-success-selected-hover-background-color,
          darken($bpk-color-glencoe, 10%)
        );
      }

      &:active:not(:disabled) {
        @include bpk-themeable-property(
          background-color,
          --bpk-chip-success-selected-active-background-color,
          $bpk-color-monteverde
        );
      }
    }
  }

  &--disabled {
    background-color: $bpk-color-sky-gray-tint-06;
    color: $bpk-color-sky-gray-tint-05;

    @include bpk-border-sm(transparent);
  }

  &__leading-accessory-view {
    display: inline-flex;
    fill: currentColor;

    @include bpk-margin-trailing($bpk-spacing-xs);
  }

  &__trailing-accessory-view {
    display: inline-flex;
    fill: currentColor;

    @include bpk-margin-leading($bpk-spacing-xs);
  }
}
