@import "../../themes/ionic.globals.md";

// Material Design Button
// --------------------------------------------------

// deprecated
$button-md-margin:                         null !default;

/// @prop - Margin top of the button
$button-md-margin-top:                     .4rem !default;

/// @prop - Margin end of the button
$button-md-margin-end:                     .2rem !default;

/// @prop - Margin bottom of the button
$button-md-margin-bottom:                  .4rem !default;

/// @prop - Margin start of the button
$button-md-margin-start:                   .2rem !default;

// deprecated
$button-md-padding:                        null !default;

/// @prop - Padding top of the button
$button-md-padding-top:                    0 !default;

/// @prop - Padding end of the button
$button-md-padding-end:                    1.1em !default;

/// @prop - Padding bottom of the button
$button-md-padding-bottom:                 $button-md-padding-top !default;

/// @prop - Padding start of the button
$button-md-padding-start:                  $button-md-padding-end !default;

/// @prop - Height of the button
$button-md-height:                         3.6rem !default;

/// @prop - Border radius of the button
$button-md-border-radius:                  2px !default;

/// @prop - Font size of the button text
$button-md-font-size:                      1.4rem !default;

/// @prop - Font weight of the button text
$button-md-font-weight:                    500 !default;

/// @prop - Capitalization of the button text
$button-md-text-transform:                 uppercase !default;

/// @prop - Background color of the button
$button-md-background-color:               color($colors-md, primary) !default;

/// @prop - Text color of the button
$button-md-text-color:                     color-contrast($colors-md, $button-md-background-color) !default;

/// @prop - Box shadow of the button
$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;

/// @prop - Duration of the transition of the button
$button-md-transition-duration:            300ms !default;

/// @prop - Speed curve of the transition of the button
$button-md-transition-timing-function:     cubic-bezier(.4, 0, .2, 1) !default;

/// @prop - Background color of the button on hover
$button-md-background-color-hover:         $button-md-background-color !default;

/// @prop - Background color of the activated button
$button-md-background-color-activated:     color-shade($button-md-background-color) !default;

/// @prop - Opacity of the activated button
$button-md-opacity-activated:              1 !default;

/// @prop - Box shadow of the activated button
$button-md-box-shadow-activated:           0 3px 5px rgba(0, 0, 0, .14), 0 3px 5px rgba(0, 0, 0, .21), 0 0 0 0 transparent !default;

/// @prop - Background color of the ripple on the button
$button-md-ripple-background-color:       #555 !default;


// Material Design Large Button
// --------------------------------------------------

// deprecated
$button-md-large-padding:                  null !default;

/// @prop - Padding top of the large button
$button-md-large-padding-top:              0 !default;

/// @prop - Padding end of the large button
$button-md-large-padding-end:              1em !default;

/// @prop - Padding bottom of the large button
$button-md-large-padding-bottom:           $button-md-large-padding-top !default;

/// @prop - Padding start of the large button
$button-md-large-padding-start:            $button-md-large-padding-end !default;

/// @prop - Height of the large button
$button-md-large-height:                   2.8em !default;

/// @prop - Font size of the large button
$button-md-large-font-size:                2rem !default;


// Material Design Small Button
// --------------------------------------------------

// deprecated
$button-md-small-padding:                  null !default;

/// @prop - Padding top of the small button
$button-md-small-padding-top:              0 !default;

/// @prop - Padding end of the small button
$button-md-small-padding-end:              .9em !default;

/// @prop - Padding bottom of the small button
$button-md-small-padding-bottom:           $button-md-small-padding-top !default;

/// @prop - Padding start of the small button
$button-md-small-padding-start:            $button-md-small-padding-end !default;

/// @prop - Height of the small button
$button-md-small-height:                   2.1em !default;

/// @prop - Font size of the small button
$button-md-small-font-size:                1.3rem !default;

/// @prop - Font size of an icon in the small button
$button-md-small-icon-font-size:           1.4em !default;


// Material Design Outline Button
// --------------------------------------------------

/// @prop - Border width of the outline button
$button-md-outline-border-width:                1px !default;

/// @prop - Border style of the outline button
$button-md-outline-border-style:                solid !default;

/// @prop - Border color of the outline button
$button-md-outline-border-color:                $button-md-background-color !default;

/// @prop - Text color of the outline button
$button-md-outline-text-color:                  $button-md-background-color !default;

/// @prop - Background color of the outline button
$button-md-outline-background-color:            transparent !default;

/// @prop - Box shadow of the outline button
$button-md-outline-box-shadow:                  none !default;

/// @prop - Background color of the outline button on hover
$button-md-outline-background-color-hover:      rgba(158, 158, 158, .1) !default;

/// @prop - Background color of the activated outline button
$button-md-outline-background-color-activated:  transparent !default;

/// @prop - Box shadow of the activated outline button
$button-md-outline-box-shadow-activated:        none !default;

/// @prop - Opacity of the activated outline button
$button-md-outline-opacity-activated:           1 !default;

/// @prop - Background color of the ripple on the outline button
$button-md-outline-ripple-background-color:     $button-md-background-color !default;


// Material Design Clear Button
// --------------------------------------------------

/// @prop - Border color of the clear button
$button-md-clear-border-color:                  transparent !default;

/// @prop - Text color of the clear button
$button-md-clear-text-color:                    $button-md-background-color !default;

/// @prop - Background color of the clear button
$button-md-clear-background-color:              transparent !default;

/// @prop - Box shadow of the clear button
$button-md-clear-box-shadow:                    none !default;

/// @prop - Opacity of the clear button
$button-md-clear-opacity:                       1 !default;

/// @prop - Background color of the activated clear button
$button-md-clear-background-color-activated:    rgba(158, 158, 158, .2) !default;

/// @prop - Box shadow of the activated clear button
$button-md-clear-box-shadow-activated:          $button-md-clear-box-shadow !default;

/// @prop - Background color of the clear button on hover
$button-md-clear-background-color-hover:        rgba(158, 158, 158, .1) !default;

/// @prop - Background color of the ripple on the clear button
$button-md-clear-ripple-background-color:       #999 !default;


// Material Design Round Button
// --------------------------------------------------

// deprecated
$button-md-round-padding:                       null !default;

/// @prop - Padding top of the round button
$button-md-round-padding-top:                   $button-round-padding-top !default;

/// @prop - Padding end of the round button
$button-md-round-padding-end:                   $button-round-padding-end !default;

/// @prop - Padding bottom of the round button
$button-md-round-padding-bottom:                $button-round-padding-bottom !default;

/// @prop - Padding start of the round button
$button-md-round-padding-start:                 $button-round-padding-start !default;

/// @prop - Border radius of the round button
$button-md-round-border-radius:                 $button-round-border-radius !default;


// Material Design Decorator Button
// --------------------------------------------------

/// @prop - Font weight of the strong button
$button-md-strong-font-weight:                  bold !default;


// Material Design Default Button
// --------------------------------------------------

.button-md {
  @include border-radius($button-md-border-radius);

  overflow: hidden;

  height: $button-md-height;

  font-size: $button-md-font-size;
  font-weight: $button-md-font-weight;

  text-transform: $button-md-text-transform;
  color: $button-md-text-color;
  background-color: $button-md-background-color;
  box-shadow: $button-md-box-shadow;

  transition: box-shadow $button-md-transition-duration $button-md-transition-timing-function,
              background-color $button-md-transition-duration $button-md-transition-timing-function,
              color $button-md-transition-duration $button-md-transition-timing-function;

  @include deprecated-variable(margin, $button-md-margin) {
    @include margin($button-md-margin-top, $button-md-margin-end, $button-md-margin-bottom, $button-md-margin-start);
  }

  @include deprecated-variable(padding, $button-md-padding) {
    @include padding($button-md-padding-top, $button-md-padding-end, $button-md-padding-bottom, $button-md-padding-start);
  }
}

.button-md:hover:not(.disable-hover) {
  background-color: $button-md-background-color-hover;
}

.button-md.activated {
  background-color: $button-md-background-color-activated;
  box-shadow: $button-md-box-shadow-activated;
}

.button-md .button-effect {
  background-color: $button-md-text-color;
}


// Material Design Default Button Color Mixin
// --------------------------------------------------

@mixin md-button-default($color-name, $color-base, $color-contrast) {
  $bg-color: $color-base;
  $bg-color-activated: color-shade($bg-color);
  $fg-color: $color-contrast;

  .button-md-#{$color-name} {
    color: $fg-color;
    background-color: $bg-color;
  }

  .button-md-#{$color-name}:hover:not(.disable-hover) {
    background-color: $bg-color;
  }

  .button-md-#{$color-name}.activated {
    background-color: $bg-color-activated;
    opacity: $button-md-opacity-activated;
  }

  .button-md-#{$color-name} .button-effect {
    background-color: $fg-color;
  }
}


// Material Design Button Sizes
// --------------------------------------------------

.button-large-md {
  height: $button-md-large-height;

  font-size: $button-md-large-font-size;

  @include deprecated-variable(padding, $button-md-large-padding) {
    @include padding($button-md-large-padding-top, $button-md-large-padding-end, $button-md-large-padding-bottom, $button-md-large-padding-start);
  }
}

.button-small-md {
  height: $button-md-small-height;

  font-size: $button-md-small-font-size;

  @include deprecated-variable(padding, $button-md-small-padding) {
    @include padding($button-md-small-padding-top, $button-md-small-padding-end, $button-md-small-padding-bottom, $button-md-small-padding-start);
  }
}

.button-small-md[icon-only] ion-icon {
  font-size: $button-md-small-icon-font-size;
}

// Material Design Block Button
// --------------------------------------------------

.button-block-md {
  @include margin-horizontal(0);
}

// Material Design Full Button
// --------------------------------------------------

.button-full-md {
  @include margin-horizontal(0);
  @include border-radius(0);

  border-right-width: 0;
  border-left-width: 0;
}

// Material Design Outline Button
// --------------------------------------------------

.button-outline-md {
  border-width: $button-md-outline-border-width;
  border-style: $button-md-outline-border-style;
  border-color: $button-md-outline-border-color;
  color: $button-md-outline-text-color;
  background-color: $button-md-outline-background-color;
  box-shadow: $button-md-outline-box-shadow;
}

.button-outline-md:hover:not(.disable-hover) {
  background-color: $button-md-outline-background-color-hover;
}

.button-outline-md.activated {
  background-color: $button-md-outline-background-color-activated;
  box-shadow: $button-md-outline-box-shadow-activated;
  opacity: $button-md-outline-opacity-activated;
}

.button-outline-md .button-effect {
  background-color: $button-md-outline-ripple-background-color;
}


// Material Design Outline Button Color Mixin
// --------------------------------------------------

@mixin md-button-outline($color-name, $color-base, $color-contrast) {
  $fg-color: color-shade($color-base, 5%);

  .button-outline-md-#{$color-name} {
    border-color: $fg-color;
    color: $fg-color;
    background-color: $button-md-outline-background-color;
  }

  .button-outline-md-#{$color-name}:hover:not(.disable-hover) {
    background-color: $button-md-outline-background-color-hover;
  }

  .button-outline-md-#{$color-name}.activated {
    background-color: $button-md-outline-background-color-activated;
  }

  .button-outline-md-#{$color-name} .button-effect {
    background-color: $fg-color;
  }
}


// Material Design Clear Button
// --------------------------------------------------

.button-clear-md {
  border-color: $button-md-clear-border-color;
  color: $button-md-background-color;
  background-color: $button-md-clear-background-color;
  box-shadow: $button-md-clear-box-shadow;
  opacity: $button-md-clear-opacity;
}

.button-clear-md.activated {
  background-color: $button-md-clear-background-color-activated;
  box-shadow: $button-md-clear-box-shadow-activated;
}

.button-clear-md:hover:not(.disable-hover) {
  background-color: $button-md-clear-background-color-hover;
}

.button-clear-md .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) {
  $fg-color: $color-base;

  .button-clear-md-#{$color-name} {
    border-color: $button-md-clear-border-color;
    color: $fg-color;
    background-color: $button-md-clear-background-color;
  }

  .button-clear-md-#{$color-name}.activated {
    background-color: $button-md-clear-background-color-activated;
    box-shadow: $button-md-clear-box-shadow-activated;
  }

  .button-clear-md-#{$color-name}:hover:not(.disable-hover) {
    color: $fg-color;
  }
}


// Material Design Round Button
// --------------------------------------------------

.button-round-md {
  @include border-radius($button-md-round-border-radius);

  @include deprecated-variable(padding, $button-md-round-padding) {
    @include padding($button-md-round-padding-top, $button-md-round-padding-end, $button-md-round-padding-bottom, $button-md-round-padding-start);
  }
}

.button-md [icon-only] {
  @include padding(0);
}


// Material Design Ripple Effect
// --------------------------------------------------
// Only Material uses the button effect, so by default
// it's display none, and .md sets to display block.

.button-effect {
  @include border-radius(50%);
  @include transform-origin(center, center);

  position: absolute;
  z-index: 0;
  display: none;

  background-color: $button-md-ripple-background-color;
  opacity: .2;

  transition-timing-function: ease-in-out;

  pointer-events: none;

  @include multi-dir() {
    // scss-lint:disable PropertySpelling
    top: 0;

    left: 0;
  }
}

.md button .button-effect {
  display: block;
}


// 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);
}


// MD strong Button
// --------------------------------------------------

.button-strong-md {
  font-weight: $button-md-strong-font-weight;
}
