@import "../../themes/ionic.globals.md";

// Material Design Radio
// --------------------------------------------------

/// @prop - Color of the checked radio
$radio-md-color-on:                  color($colors-md, primary) !default;

/// @prop - Color of the unchecked radio
$radio-md-color-off:                 darken($list-md-border-color, 40%) !default;

/// @prop - Width of the radio icon
$radio-md-icon-width:                16px !default;

/// @prop - Height of the radio icon
$radio-md-icon-height:               16px !default;

/// @prop - Border width of the radio icon
$radio-md-icon-border-width:         2px !default;

/// @prop - Border style of the radio icon
$radio-md-icon-border-style:         solid !default;

/// @prop - Border radius of the radio icon
$radio-md-icon-border-radius:        50% !default;

/// @prop - Transition duration of the radio
$radio-md-transition-duration:       280ms !default;

/// @prop - Transition easing of the radio
$radio-md-transition-easing:         cubic-bezier(.4, 0, .2, 1) !default;

/// @prop - Opacity of the disabled radio
$radio-md-disabled-opacity:          .3 !default;

// deprecated
$radio-md-item-left-margin:          null !default;

/// @prop - Margin top of the item-start in a radio
$radio-md-item-start-margin-top:     11px !default;

/// @prop - Margin end of the item-start in a radio
$radio-md-item-start-margin-end:     36px !default;

/// @prop - Margin bottom of the item-start in a radio
$radio-md-item-start-margin-bottom:  10px !default;

/// @prop - Margin start of the item-start in a radio
$radio-md-item-start-margin-start:   4px !default;

// deprecated
$radio-md-item-right-margin:         null !default;

/// @prop - Margin top of the item-end in a radio
$radio-md-item-end-margin-top:       $item-md-padding-media-top !default;

/// @prop - Margin end of the item-end in a radio
$radio-md-item-end-margin-end:       10px !default;

/// @prop - Margin bottom of the item-end in a radio
$radio-md-item-end-margin-bottom:    $item-md-padding-media-bottom !default;

/// @prop - Margin start of the item-end in a radio
$radio-md-item-end-margin-start:     0 !default;


.radio-md {
  position: relative;
  display: inline-block;
}


// Material Design Radio Outer Circle: Unchecked
// -----------------------------------------

.radio-md .radio-icon {
  @include position(0, null, null, 0);
  @include margin(0);
  @include border-radius($radio-md-icon-border-radius);

  position: relative;
  display: block;

  width: $radio-md-icon-width;
  height: $radio-md-icon-height;

  border-width: $radio-md-icon-border-width;
  border-style: $radio-md-icon-border-style;
  border-color: $radio-md-color-off;
}


// Material Design Radio Inner Circle: Unchecked
// -----------------------------------------

.radio-md .radio-inner {
  @include position($radio-md-icon-border-width, null, null, $radio-md-icon-border-width);
  @include border-radius(50%);

  position: absolute;

  width: $radio-md-icon-width - $radio-md-icon-border-width * 4;
  height: $radio-md-icon-height - $radio-md-icon-border-width * 4;

  background-color: $radio-md-color-on;
  transform: scale3d(0, 0, 0);
  transition: transform $radio-md-transition-duration $radio-md-transition-easing;
}


// Material Design Radio Outer Circle: Checked
// -----------------------------------------

.radio-md .radio-checked {
  border-color: $radio-md-color-on;
}


// Material Design Radio Inner Circle: Checked
// -----------------------------------------

.radio-md .radio-checked .radio-inner {
  transform: scale3d(1, 1, 1);
}


// Material Design Radio: Disabled
// -----------------------------------------

.radio-md.radio-disabled,
.item-md.item-radio-disabled ion-label {
  opacity: $radio-md-disabled-opacity;

  pointer-events: none;
}


// Material Design Radio Within An Item
// -----------------------------------------

.item-md .radio-md {
  position: static;
  display: block;

  @include deprecated-variable(margin, $radio-md-item-right-margin) {
    @include margin($radio-md-item-end-margin-top, $radio-md-item-end-margin-end, $radio-md-item-end-margin-bottom, $radio-md-item-end-margin-start);
  }

  &[item-left], // deprecated
  &[item-start] {
    @include deprecated-variable(margin, $radio-md-item-left-margin) {
      @include margin($radio-md-item-start-margin-top, $radio-md-item-start-margin-end, $radio-md-item-start-margin-bottom, $radio-md-item-start-margin-start);
    }
  }
}

.item-radio.item-md ion-label {
  @include margin-horizontal(0, null);
}


// Material Design Radio Item Label: Checked
// -----------------------------------------

.item-radio-checked.item-md ion-label {
  color: $radio-md-color-on;
}


// Material Design Radio Color Mixin
// --------------------------------------------------

@mixin radio-theme-md($color-name, $color-base, $color-contrast) {

  .item-radio-md-#{$color-name}.item-radio-checked ion-label {
    color: $color-base;
  }

  .radio-md-#{$color-name} .radio-checked {
    border-color: $color-base;
  }

  .radio-md-#{$color-name} .radio-inner {
    background-color: $color-base;
  }

}


// Generate Material Design Radio Colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-md) {
  @include radio-theme-md($color-name, $color-base, $color-contrast);
}
