// Button variants
//
// Easily pump out default styles, as well as :hover, :focus, :active,
// and disabled options for all buttons

@mixin button-variant(
  $background,
  $border,
  $hover-background: rgba($background, 0.16),
  $hover-border: rgba($border, 0.24),
  $active-background: rgba($background, 0.16),
  $active-border: rgba($border, 0.24)
) {
  color: $background;
  background-color: rgba($background, 0.08);
  border-color: rgba($border, 0.08);
  @include box-shadow($btn-box-shadow);

  @include hover() {
    color: $background;
    background-color: $hover-background;
    border-color: $hover-border;
  }

  &:focus,
  &.focus {
    color: $background;
    background-color: $hover-background;
    border-color: $hover-border;
    @if $enable-shadows {
      @include box-shadow(
        $btn-box-shadow,
        0 0 0 $btn-focus-width
          rgba(mix(color-yiq($background), $border, 15%), 0.5)
      );
    } @else {
      // Avoid using mixin so we can pass custom focus shadow properly
      box-shadow: 0
        0
        0
        $btn-focus-width
        rgba(mix(color-yiq($background), $border, 15%), 0.5);
    }
  }

  // Disabled comes first so active can properly restyle
  &.disabled,
  &:disabled {
    color: $background;
    background-color: $background;
    border-color: $border;
    // Remove CSS gradients if they're enabled
    @if $enable-gradients {
      background-image: none;
    }
  }

  &:not(:disabled):not(.disabled):active,
  &:not(:disabled):not(.disabled).active,
  .show > &.dropdown-toggle {
    color: $background;
    background-color: $active-background;
    @if $enable-gradients {
      background-image: none; // Remove the gradient for the pressed/active state
    }
    border-color: $active-border;

    &:focus {
      @if $enable-shadows and $btn-active-box-shadow != none {
        @include box-shadow(
          $btn-active-box-shadow,
          0 0 0 $btn-focus-width
            rgba(mix(color-yiq($background), $border, 15%), 0.5)
        );
      } @else {
        // Avoid using mixin so we can pass custom focus shadow properly
        box-shadow: 0
          0
          0
          $btn-focus-width
          rgba(mix(color-yiq($background), $border, 15%), 0.5);
      }
    }
  }
}
