@import "./radio";
@import "./radio.md.vars";

// Material Design Radio
// --------------------------------------------------

// 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;

  contain: layout size style;
}


// 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: Keyboard Focus
// -----------------------------------------

.radio-key .radio-icon::after {
  @include border-radius(50%);
  @include position(-12px, null, null, -12px);

  position: absolute;

  display: block;

  width: 36px;
  height: 36px;

  background: $radio-md-background-color-focused;

  content: "";

  opacity: .2;
}


// Material Design Radio Within An Item
// -----------------------------------------

.item-md .radio-md {
  @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);

  position: static;
  display: block;

  &[slot="start"] {
    @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: ion-color($colors-md, $color-name, base, md);

  .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-value in $colors-md {
  @include radio-theme-md($color-name);
}
