// ghost buttons
.button {
  @include font-style;
  @include text-ellipsis;
  background: transparent;
  border-radius: $border-radius;
  border: 2px solid currentColor;
  color: $color-brand--one;
  cursor: pointer;
  font-family: $font-family-theme;
  height: $baseline * 6;
  line-height: ($baseline * 6) - 4;
  min-width: 120px;
  padding: 0 30px;
  position: relative;
  text-align: center;
  text-decoration: none;
  transition: background-color $transition-duration--fast,
    border-color $transition-duration--fast, color $transition-duration--fast;
  vertical-align: middle;

  &:hover {
    background: $color-brand--one;
    border-color: $color-brand--one;
    color: $color-brand--four;
    text-decoration: none;
    transition: background-color $transition-duration--fast,
      border-color $transition-duration--fast, color $transition-duration--fast;
  }

  & {
    @include hover-touch {
      background: $color--one-130;
      border-color: $color--one-130;
      color: $color-brand--four;
      outline: none;
    }
  }

  // sizes
  &--s {
    font-size: 16px;
    height: $baseline * 4;
    line-height: ($baseline * 4) - 5; // Should be 35px because visually alignment
    min-width: 50px;
    padding: 0 $baseline;
  }

  // button with icon
  .icon--inline {
    margin-right: $baseline;
    top: 2px;
  }

  .icon svg {
    fill: $color-brand--one;
  }

  &:hover {
    .icon svg {
      fill: $color-brand--four;
    }
  }

  @include viewport--l {
    height: $baseline * 8;
    line-height: ($baseline * 8) - 4;
    min-width: 140px;

    // sizes
    &--m {
      height: $baseline * 6;
      line-height: ($baseline * 6) - 4;
      min-width: 120px;
    }

    &--s {
      height: $baseline * 4;
      line-height: ($baseline * 4) - 5; // Should be 35px because visually alignment
      min-width: 80px;

      .icon--inline {
        margin-right: $baseline / 2;
      }
    }

    &:not(.button--full-width) {
      max-width: $button-max-size;
    }
  }
}

button.button--s {
  line-height: ($baseline * 4) - 4;
}

// dark blue
.button--dark-blue {
  @include button--dark;
}

// dark blue 180
.button--dark-blue-180 {
  @include button--dark-blue-180;
}
// off-white
.button--off-white {
  @include button--light;
}

// white
.button--white {
  @include button--white;
}

// blue
.button--blue {
  @include button--blue;
}

// background / color default mappings
// ! Deprecation warning, do not use anymore. Will be removed in a later release use bg-variants function instead.
.bg-brand {
  &--blue,
  &--dark-blue {
    .button {
      @include button--white;
    }

    .button--filled {
      background: $color-brand--four;
      color: $color-brand--two;
      border: 2px solid $color-brand--four;

      &:hover {
        background: $color-brand--white;
        color: $color-brand--two;
        border: 2px solid $color-brand--white;
      }
    }
  }

  &--yellow,
  &--turquoise {
    .button {
      @include button--dark;
    }

    .button--filled {
      background: $color-brand--two;
      color: $color-brand--white;
      border: 2px solid $color-brand--two;

      &:hover {
        background: $color--two-80;
        color: $color-brand--white;
        border: 2px solid $color--two-80;
      }
    }

    .modal .button,
    a.modal .button {
      @include button--dark;
    }
  }

  &--off-white {
    .button,
    //poll is exception for modal blue buttons
    .poll .button,
    .poll a.button {
      @include button--dark;
    }

    .button--filled {
      background: $color-brand--two;
      color: $color-brand--white;
      border: 2px solid $color-brand--two;

      &:hover {
        background: $color--two-80;
        color: $color-brand--white;
        border: 2px solid $color--two-80;
      }
    }

    .modal .button,
    a.modal .button,
    &.popover .button {
      @include button--blue;
    }
  }

  &--red {
    .button,
    a.button {
      @include button--dark-blue-180;
    }

    .button--filled {
      background: $color--two-180;
      color: $color-brand--white;

      &:hover {
        background: $color--two-80;
        border-color: $color--two-80;
        color: $color-brand--white;
      }
    }

    .modal .button,
    a.modal .button {
      @include button--dark-blue-180;
    }
  }

  &--blue,
  &--dark-blue,
  &--turquoise,
  &--red,
  &--yellow {
    .popover.bg-brand--off-white .button {
      @include button--blue;

      // override ghost button styling
      &.button--filled {
        background: $color-brand--one;
        border: 2px solid $color-brand--one;
        color: $color-brand--white;

        &:hover {
          background: $color--one-80;
          color: $color-brand--white;
          border: 2px solid $color--one-80;
        }
        // on touch devices hover is similar to ':active' state.
        // outputs regular ':active' state & specific ':hover'
        // state for touch devices
        & {
          @include hover-touch {
            background: $color--one-130;
            color: $color-brand--white;
            border: 2px solid $color--one-130;
          }
        }
        .icon svg {
          fill: $color-brand--white;
        }
      }
    }
  }

  &--blue,
  &--dark-blue,
  &--off-white,
  &--turquoise,
  &--red,
  &--yellow,
  &--white {
    .button--disabled,
    button:disabled {
      &,
      &:hover,
      &:active,
      &:focus {
        background: returnColorCSSVar('gray-20');
        border-color: returnColorCSSVar('gray-20');
        color: returnColorCSSVar('brand-secondary-tint-80');
        pointer-events: none;
      }

      .icon svg {
        fill: returnColorCSSVar('brand-secondary-tint-80');
      }
    }
  }
}

.button {
  @include bg-variants {
    @include button-bg-map;
  }
}
