@use '../../00-settings/settings' as *;
@use '../../00-mixins/mixins' as *;
@use '../../11-base/base' as *;

////
///
/// This file defines the bulk of all button styling.
///
/// @group buttons
/// @author Gert-Jan Meire
///
////

///
/// Button - small variant.
///
/// @since 3.0.0
/// @group buttons
/// @access public
/// @author Gert-Jan Meire
///
@mixin button-small {
  @include medium-text;

  padding: 4px 10px;
  line-height: 175%;
}

///
/// Button - medium variant.
///
/// @since 3.0.0
/// @group buttons
/// @access public
/// @author Gert-Jan Meire
///
@mixin button-medium {
  @include medium-text;

  line-height: 175%;
}

///
/// Button - large variant.
///
/// @since 3.0.0
/// @group buttons
/// @access public
/// @author Gert-Jan Meire
///
@mixin button-large {
  @include large-text;

  padding: 10px 20px;
  line-height: 177.778%;

  &::before {
    font-size: 1.5rem;
  }
}


///
/// Button - extra large variant.
///
/// @since 5.0.20
/// @group buttons
/// @access public
/// @author Thomas De Vriese
///
@mixin button-extra-large {
  @include large-text;

  padding: 25px 26px;
  line-height: 177.778%;

  &::before {
    font-size: 1.5rem;
  }
}

///
/// Button - disabled variant.
///
/// @since 3.0.0
/// @group buttons
/// @access public
/// @author Gert-Jan Meire
/// @require color
///
@mixin button-disabled {
  // @include theme('color', 'color-zero');
  // @include theme('background-color', 'color-zero');

  & {
    border: 0;
    background-image: none;
  }

  &:hover {
    @include theme('color', 'color-zero');
    @include theme('background-color', 'color-zero');

    cursor: not-allowed;
  }
}

///
/// General button styling.
///
/// @since 3.0.0
/// @group buttons
/// @access public
/// @author Gert-Jan Meire
///
@mixin button {
  @include button-medium; // Default.
  @include semi-bold-text;

  padding: 8px 15px;
  font-family: $default-font-family;
  text-align: center;
  cursor: pointer;

  &:disabled {
    @include button-disabled;
  }

  &.button-small {
    @include button-small;
  }

  &.button-medium {
    @include button-medium;
  }

  &.button-large {
    @include button-large;
  }

  &.button-extra-large {
    @include button-extra-large;
  }

  &.button-block {
    @include button-block;
  }

  &[class*="icon-"] {
    @include button-icon;

    &.icon-left {
      @include button-icon-left;
    }
  }
}

///
/// Defines hover behavior for a button.
///
/// @since 6.0.0
/// @group buttons
/// @access public
/// @author Lennart Van Vaerenbergh
///
@mixin button-hover {
  transition: .3s;
  background-repeat: no-repeat;
  background-size: 0 100%;

  &:hover {
    background-size: 100% 100%;
  }
}

///
/// Makes a button display block instead of inline.
///
/// @since 3.0.0
/// @group buttons
/// @access public
/// @author Gert-Jan Meire
///
@mixin button-block {
  display: inline-block;
  width: 100%;
}

///
/// Define a button with an icon.
///
/// @since 3.0.0
/// @group buttons
/// @access public
/// @author Gert-Jan Meire
///
@mixin button-icon {
  display: inline-flex;
  position: relative;
  align-items: center;
  justify-content: space-between;
  text-align: left;

  &::before {
    order: 1;
    margin-left: 8px;
    float: right; // Fix for IE11 flex order property.
    font-size: 1.2rem;
  }
}

///
/// Define a button with an icon on the left side.
///

@mixin button-icon-left {
  &::before {
    order: unset;
    margin-right: 8px;
    margin-left: 0;
    // Fix for IE11 flex order property.
    float: left;
  }
}

.button,
input[type="button"] {
  @include button;
  @include button-hover;

  -webkit-appearance: none; // stylelint-disable-line property-no-vendor-prefix
}
