// Primary Color Variables
$btn-primary: $ta-red500;
$btn-primary-hover: #f13333;
$btn-primary-active: #be0000;
$btn-primary-focus: #d80303;

// Secondary Color Variables
$btn-secondary: $ta-blue500;
$btn-secondary-hover: #3387c3;
$btn-secondary-focus: #0361a4;
$btn-secondary-active: #365a84;

// Inverse Color Variables
$btn-inverse: $white;
$btn-inverse-disabled: rgba($ta-grey300, 0.6);

// Inverse Focus Fallback for I.E
$btn-inverse-focus-fallback: $black;

.ta-button,
a.ta-button {
  background-color: transparent;
  border: rem(2px) solid transparent;
  border-radius: rem(2px);
  box-sizing: border-box;
  cursor: pointer;
  display: inline-block;
  font-family: $whitney;
  font-size: rem(16px);
  font-weight: $font-weight-semibold;
  letter-spacing: rem(0.2px);
  line-height: normal;
  margin: 0;
  outline: none;
  padding: rem(10.5px) 1rem;
  position: relative;
  text-decoration: none;
  text-transform: uppercase;
  transition: background-color 0.3s ease 0s, color 0.3s ease 0s, box-shadow 0.3s ease 0s;
  vertical-align: middle;

  // Text Button Modifiers
  &:not(.-filled):not(.-outline) {
    color: $btn-primary;

    &:hover:not(:active):not(:focus):not(:disabled) {
      background-color: rgba($btn-primary-hover, 0.1);
      color: $btn-primary-hover;
    }

    &:active:not(:disabled) {
      background-color: rgba($btn-primary-active, 0.2);
      border: rem(2px) solid rgba($btn-primary-active, 0.2);
      color: $btn-primary-active;
    }

    &:focus:not(:active):not(.-inverse) {
      background-color: rgba($btn-primary-focus, 0.2);
      border: rem(2px) solid $btn-primary-focus;
      color: $btn-primary-focus;
    }

    &.-secondary {
      color: $btn-secondary;

      &:hover:not(:active):not(:focus):not(:disabled) {
        background-color: rgba($btn-secondary-hover, 0.1);
        color: $btn-secondary-hover;
      }

      &:active:hover:not(:disabled),
      &:active:not(:disabled) {
        background-color: rgba($btn-secondary-active, 0.2);
        border: rem(2px) solid rgba($btn-secondary-active, 0.2);
        color: $btn-secondary-active;
      }

      &:focus:not(:active) {
        background-color: rgba($btn-secondary-focus, 0.2);
        border: rem(2px) solid $btn-secondary-focus;
        color: $btn-secondary-focus;
      }
    }

    &.-inverse {
      color: $white;

      &:hover:not(:active):not(:focus):not(:disabled) {
        background-color: rgba($btn-inverse, 0.1);
        color: rgba($btn-inverse, 0.8);
      }

      &:active:not(:disabled) {
        background-color: rgba($btn-inverse, 0.2);
        border: rem(2px) solid rgba($btn-inverse, 0.2);
        color: rgba($btn-inverse, 0.6);
      }

      &:focus:not(:active) {
        box-shadow: 0 0 rem(0.5px) rem(4px) rgba($btn-inverse, 0.8);
        color: $btn-inverse;
      }

      &:disabled {
        color: $btn-inverse-disabled;
      }

      transition: background-color 0.3s ease 0s, border-color 0.3s ease 0s, color 0.3s ease 0s;
    }

    &:disabled:not(.-inverse) {
      color: $disabled;
    }
  }

  &:disabled {
    color: $disabled;
    cursor: not-allowed;
  }

  // Icon Styling
  &:not(.-iconRight)::before,
  &.-iconRight::after {
    @extend .ta-icon;

    color: inherit;
    line-height: 0.75;
  }

  &:not(.-iconRight)::before {
    margin-right: $spacing-xs;
  }

  // Icont Right Position Modifier
  &.-iconRight::after {
    @extend .ta-icon;

    margin-left: $spacing-xs;
  }

  // Outline Button Styles
  &.-outline {
    background-color: transparent;
    border: rem(2px) solid $btn-primary;
    color: $ta-red500;

    &:hover:not(:active):not(:focus):not(:disabled) {
      background-color: rgba($btn-primary-hover, 0.1);
      border: rem(2px) solid $btn-primary-hover;
      color: $btn-primary-hover;
    }

    &:active:not(:disabled) {
      background-color: rgba($btn-primary-active, 0.2);
      border-color: $btn-primary-active;
      box-shadow: none;
      color: $btn-primary-active;
    }

    &:focus:not(:active) {
      @supports (mix-blend-mode: multiply) {
        mix-blend-mode: multiply;
      }

      border-color: $white;
      color: $white;
    }

    &:focus {
      background-color: $btn-primary-focus;
      box-shadow: 0 0 0 rem(2px) $btn-primary-focus;
    }

    &.-secondary {
      border-color: $btn-secondary;
      color: $btn-secondary;

      &:hover:not(:active):not(:focus):not(:disabled) {
        background-color: rgba($btn-secondary-hover, 0.1);
        border-color: $btn-secondary-hover;
        color: $btn-secondary-hover;
      }

      &:active:not(:disabled) {
        background-color: rgba($btn-secondary-active, 0.2);
        border-color: $btn-secondary-active;
        box-shadow: none;
        color: $btn-secondary-active;
      }

      &:focus {
        background-color: $btn-secondary-focus;
        box-shadow: 0 0 0 rem(2px) $btn-secondary-focus;
      }
    }

    &.-inverse {
      border-color: $btn-inverse;
      color: $btn-inverse;

      &:hover:not(:active):not(:focus):not(:disabled) {
        background-color: rgba($btn-inverse, 0.1);
        border-color: rgba($btn-inverse, 0.8);
        color: rgba($btn-inverse, 0.8);
      }

      &:active:not(:disabled) {
        background-color: rgba($btn-inverse, 0.2);
        border-color: rgba($btn-inverse, 0.6);
        color: rgba($btn-inverse, 0.6);
      }

      &:focus:not(:active) {
        @supports (mix-blend-mode: screen) {
          mix-blend-mode: screen;
        }

        background-color: $btn-inverse;
        border-color: $btn-inverse-focus-fallback;
        box-shadow: 0 0 0 rem(2px) $btn-inverse;
        color: $btn-inverse-focus-fallback;
      }

      &:disabled {
        border-color: $btn-inverse-disabled;
        color: $btn-inverse-disabled;
      }
    }

    &:disabled {
      border-color: $ta-grey400;
      color: $disabled;
    }
  }

  // Filled Button Styles
  &.-filled {
    background-color: $btn-primary;
    box-shadow: $ta-z-depth-sm;
    color: $white;

    &:hover:not(:active):not(:focus):not(:disabled) {
      background-color: $btn-primary-hover;
      box-shadow: $ta-z-depth-md;
    }

    &:active:not(:disabled) {
      box-shadow: $ta-z-depth-sm;
    }

    &:active:not(:disabled):not(.-secondary) {
      background-color: $btn-primary-active;
    }

    &:focus:not(:active) {
      background-color: $btn-primary-focus;
      box-shadow: 0 0 0.5px rem(4px) rgba($btn-primary-focus, 0.3);
    }

    &.-secondary {
      background-color: $btn-secondary;

      &:hover:not(:active):not(:disabled):not(:focus) {
        background-color: $btn-secondary-hover;
      }

      &:focus:not(:active) {
        background-color: $btn-secondary-focus;
        box-shadow: 0 0 0.5px rem(4px) rgba($btn-secondary-focus, 0.3);
      }

      &:active:not(:disabled) {
        background-color: $btn-secondary-active;
      }
    }

    &:disabled {
      background-color: $disabled;
    }
  }
}

.ta-iconButton,
a.ta-iconButton {
  @extend .ta-button;

  align-items: center;
  border-radius: 50% !important;
  display: inline-flex;
  justify-content: center;
  height: rem(36px);
  padding: 0;
  width: rem(36px);

  &::before {
    @extend .ta-icon;

    margin-right: 0 !important;
  }
}

a.ta-iconButton,
a.ta-button {
  text-decoration: none;
}
