@import "../../globals.md";
@import "./button";

// Material Design Button
// --------------------------------------------------

$button-md-margin:                         .4rem .2rem !default;
$button-md-padding:                        0 1.1em !default;
$button-md-font-size:                      1.4rem !default;
$button-md-height:                         3.6rem !default;
$button-md-box-shadow:                     0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12) !default;
$button-md-box-shadow-active:              0 3px 5px rgba(0, 0, 0, .14), 0 3px 5px rgba(0, 0, 0, .21) !default;

$button-md-border-radius:                  2px !default;
$button-md-animation-curve:                cubic-bezier(.4, 0, .2, 1) !default;
$button-md-transition-duration:            300ms !default;

$button-md-clear-hover-background-color:   rgba(158, 158, 158, .1) !default;
$button-md-clear-active-background-color:  rgba(158, 158, 158, .2) !default;
$button-md-clear-ripple-background-color:  #999 !default;

$button-md-fab-box-shadow:                 0 4px 6px 0 rgba(0, 0, 0, .14), 0 4px 5px rgba(0, 0, 0, .1) !default;
$button-md-fab-box-shadow-active:          0 5px 15px 0 rgba(0, 0, 0, .4), 0 4px 7px 0 rgba(0, 0, 0, .1) !default;

$button-md-color:                          color($colors-md, primary) !default;
$button-md-color-activated:                color-shade($button-md-color) !default;
$button-md-text-color:                     color-contrast($colors-md, $button-md-color) !default;
$button-md-hover-opacity:                  .8 !default;

$button-md-large-font-size:                2rem !default;
$button-md-large-height:                   2.8em !default;
$button-md-large-padding:                  1em !default;
$button-md-small-font-size:                1.3rem !default;
$button-md-small-height:                   2.1em !default;
$button-md-small-padding:                  .9em !default;
$button-md-small-icon-font-size:           1.4em !default;


// Material Design Default Button
// --------------------------------------------------

.button {
  margin: $button-md-margin;
  padding: $button-md-padding;

  height: $button-md-height;

  border-radius: $button-md-border-radius;

  font-size: $button-md-font-size;
  font-weight: 500;

  text-transform: uppercase;
  color: $button-md-text-color;
  background-color: $button-md-color;
  box-shadow: $button-md-box-shadow;

  transition: box-shadow $button-md-transition-duration $button-md-animation-curve,
              background-color $button-md-transition-duration $button-md-animation-curve,
              color $button-md-transition-duration $button-md-animation-curve;

  &:hover:not(.disable-hover) {
    background-color: $button-md-color;
  }

  &.activated {
    background-color: $button-md-color-activated;
    box-shadow: $button-md-box-shadow-active;
  }

  ion-button-effect {
    background-color: $button-md-text-color;
  }
}


// Material Design Default Button Color Mixin
// --------------------------------------------------

@mixin md-button-default($color-name, $color-base, $color-contrast) {

  .button-#{$color-name} {
    $background-color: $color-base;
    $background-color-activated: color-shade($background-color);
    $fg-color: $color-contrast;

    color: $fg-color;
    background-color: $background-color;

    &:hover:not(.disable-hover) {
      background-color: $background-color;
    }

    &.activated {
      background-color: $background-color-activated;
      opacity: 1;
    }

    ion-button-effect {
      background-color: $fg-color;
    }
  }

}


// Material Design Button Sizes
// --------------------------------------------------

.button-large {
  padding: 0 $button-md-large-padding;

  height: $button-md-large-height;

  font-size: $button-md-large-font-size;
}

.button-small {
  padding: 0 $button-md-small-padding;

  height: $button-md-small-height;

  font-size: $button-md-small-font-size;

  &.button-icon-only ion-icon {
    font-size: $button-md-small-icon-font-size;
  }
}

// Material Design Block Button
// --------------------------------------------------

.button-block {
  margin-right: 0;
  margin-left: 0;
}

// Material Design Full Button
// --------------------------------------------------

.button-full {
  margin-right: 0;
  margin-left: 0;

  border-right-width: 0;
  border-left-width: 0;
  border-radius: 0;
}

// Material Design Outline Button
// --------------------------------------------------

.button-outline {
  border-width: 1px;
  border-style: solid;
  border-color: $button-md-color;
  color: $button-md-color;
  background-color: transparent;
  box-shadow: none;

  &:hover:not(.disable-hover) {
    background-color: $button-md-clear-hover-background-color;
  }

  &.activated {
    background-color: transparent;
    box-shadow: none;
    opacity: 1;
  }

  ion-button-effect {
    background-color: $button-md-color;
  }
}


// Material Design Outline Button Color Mixin
// --------------------------------------------------

@mixin md-button-outline($color-name, $color-base, $color-contrast) {

  .button-outline-#{$color-name} {
    $fg-color: color-shade($color-base, 5%);
    border-color: $fg-color;
    color: $fg-color;
    background-color: transparent;

    &:hover:not(.disable-hover) {
      background-color: $button-md-clear-hover-background-color;
    }

    &.activated {
      background-color: transparent;
    }

    ion-button-effect {
      background-color: $fg-color;
    }
  }

}


// Material Design Clear Button
// --------------------------------------------------

.button-clear {
  border-color: transparent;
  color: $button-md-color;
  background-color: transparent;
  box-shadow: none;
  opacity: 1;

  &.activated {
    background-color: $button-md-clear-active-background-color;
    box-shadow: none;
  }

  &:hover:not(.disable-hover) {
    background-color: $button-md-clear-hover-background-color;
  }

  ion-button-effect {
    background-color: $button-md-clear-ripple-background-color;
  }
}


// Material Design Clear Button Color Mixin
// --------------------------------------------------

@mixin md-button-clear($color-name, $color-base, $color-contrast) {

  .button-clear-#{$color-name} {
    $fg-color: $color-base;
    border-color: transparent;
    color: $fg-color;
    background-color: transparent;

    &.activated {
      background-color: $button-md-clear-active-background-color;
      box-shadow: none;
    }

    &:hover:not(.disable-hover) {
      color: $fg-color;
    }
  }
}


// Material Design Round Button
// --------------------------------------------------

.button-round {
  padding: $button-round-padding;

  border-radius: $button-round-border-radius;
}


// Material Design FAB Button
// --------------------------------------------------

.button-fab {
  border-radius: 50%;
  box-shadow: $button-md-fab-box-shadow;

  transition: box-shadow $button-md-transition-duration $button-md-animation-curve,
              background-color $button-md-transition-duration $button-md-animation-curve,
              color $button-md-transition-duration $button-md-animation-curve;

  &.activated {
    box-shadow: $button-md-fab-box-shadow-active;
  }
}

.button-icon-only {
  padding: 0;
}


// Material Design Ripple Effect
// --------------------------------------------------

$ripple-background-color:       #555 !default;

ion-button-effect {
  position: absolute;
  z-index: 0;
  display: block;

  border-radius: 50%;

  background-color: $ripple-background-color;
  opacity: .2;

  transition-timing-function: ease-in-out;

  pointer-events: none;
}


// Generate Material Design Button Colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-md) {
  @include md-button-default($color-name, $color-base, $color-contrast);
  @include md-button-outline($color-name, $color-base, $color-contrast);
  @include md-button-clear($color-name, $color-base, $color-contrast);
}


// Core Button Overrides
// --------------------------------------------------

@import "./button-fab";
@import "./button-icon";
