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

// Material Design Checkbox
// --------------------------------------------------

$checkbox-md-border-bottom-width:        1px !default;
$checkbox-md-border-bottom-style:        solid !default;
$checkbox-md-border-bottom-color:        $list-md-border-color !default;
$checkbox-md-padding:                    $item-md-padding-top ($item-md-padding-right / 2) $item-md-padding-bottom 0 !default;
$checkbox-md-margin:                     0 !default;
$checkbox-md-media-margin:               $item-md-padding-media-top 36px $item-md-padding-media-bottom 4px !default;
$checkbox-md-disabled-opacity:           0.3 !default;

$checkbox-md-icon-background-color-off:  $list-md-background-color !default;
$checkbox-md-icon-background-color-on:   map-get($colors-md, primary) !default;
$checkbox-md-icon-size:                  16px !default;

$checkbox-md-icon-checkmark-width:       2px !default;
$checkbox-md-icon-checkmark-style:       solid !default;
$checkbox-md-icon-checkmark-color:       $background-md-color !default;

$checkbox-md-icon-border-width:          2px !default;
$checkbox-md-icon-border-style:          solid !default;
$checkbox-md-icon-border-radius:         2px !default;
$checkbox-md-icon-border-color-off:      darken($list-md-border-color, 40%) !default;
$checkbox-md-icon-border-color-on:       map-get($colors-md, primary) !default;

$checkbox-md-transition-duration:        280ms !default;
$checkbox-md-transition-easing:          cubic-bezier(.4,0,.2,1) !default;


ion-checkbox {
  position: relative;
  display: inline-block;
}


// Material Design Checkbox Outer Square: Unchecked
// -----------------------------------------

.checkbox-icon {
  position: relative;
  width: $checkbox-md-icon-size;
  height: $checkbox-md-icon-size;
  border-radius: $checkbox-md-icon-border-radius;
  border-width: $checkbox-md-icon-border-width;
  border-style: $checkbox-md-icon-border-style;
  border-color: $checkbox-md-icon-border-color-off;
  background-color: $checkbox-md-icon-background-color-off;

  transition-property: background;
  transition-duration: $checkbox-md-transition-duration;
  transition-timing-function: $checkbox-md-transition-easing;
}


// Material Design Checkbox Outer Square: Checked
// -----------------------------------------

.checkbox-checked {
  background-color: $checkbox-md-icon-background-color-on;
  border-color: $checkbox-md-icon-border-color-on;
}


// Material Design Checkbox Inner Checkmark: Checked
// -----------------------------------------

.checkbox-checked .checkbox-inner {
  position: absolute;
  border-width: $checkbox-md-icon-checkmark-width;
  border-style: $checkbox-md-icon-checkmark-style;
  border-color: $checkbox-md-icon-checkmark-color;
  top: 0;
  left: 4px;
  width: 5px;
  height: 10px;
  border-left: none;
  border-top: none;
  transform: rotate(45deg);
}


// Material Design Checkbox: Disabled
// -----------------------------------------

.checkbox-disabled,
.item-checkbox-disabled ion-label {
  opacity: $checkbox-md-disabled-opacity;
  pointer-events: none;
}


// Material Design Checkbox Within An Item
// -----------------------------------------

.item ion-checkbox {
  position: static;
  display: block;
  margin: $checkbox-md-media-margin;
}

ion-checkbox + .item-inner ion-label {
  margin-left: 0;
}


// Material Design Checkbox Color Mixin
// --------------------------------------------------

@mixin checkbox-theme-md($color-name, $bg-on) {

  ion-checkbox[#{$color-name}] .checkbox-checked {
    background-color: $bg-on;
    border-color: $bg-on;

    .checkbox-inner {
      border-color: color-inverse($bg-on);
    }
  }

}


// Generate Material Design Checkbox Colors
// --------------------------------------------------

@each $color-name, $color-value in $colors-md {
  @include checkbox-theme-md($color-name, $color-value);
}
