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

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

:host {
  --color: #{$radio-md-color-off};
  --color-checked: #{ion-color(primary, base)};
  --border-width: #{$radio-md-icon-border-width};
  --border-style: #{$radio-md-icon-border-style};
  --border-radius: #{$radio-md-icon-border-radius};

  width: $radio-md-icon-width;
  height: $radio-md-icon-height;
}

:host(.ion-color) .radio-inner {
  background: current-color(base);
}

:host(.ion-color.radio-checked) .radio-icon {
  border-color: current-color(base);
}

// Material Design Radio Outer Circle: Unchecked
// -----------------------------------------

.radio-icon {
  @include margin(0);
  @include border-radius(var(--border-radius));

  border-width: var(--border-width);
  border-style: var(--border-style);
  border-color: var(--color);
}


// Material Design Radio Inner Circle: Unchecked
// -----------------------------------------

.radio-inner {
  @include border-radius(var(--inner-border-radius));

  width: calc(50% + var(--border-width));
  height: calc(50% + var(--border-width));

  transform: scale3d(0, 0, 0);

  transition: transform $radio-md-transition-duration $radio-md-transition-easing;

  background: var(--color-checked);
}


// Material Design Radio Outer Circle: Checked
// -----------------------------------------

:host(.radio-checked) .radio-icon {
  border-color: var(--color-checked);
}


// Material Design Radio Inner Circle: Checked
// -----------------------------------------

:host(.radio-checked) .radio-inner {
  transform: scale3d(1, 1, 1);
}


// Material Design Radio: Disabled
// -----------------------------------------

// .item-md.item-radio-disabled ion-label {
:host(.radio-disabled) {
  opacity: $radio-md-disabled-opacity;
}


// Material Design Radio: Keyboard Focus
// -----------------------------------------

:host(.ion-focused) .radio-icon::after {
  @include border-radius(var(--inner-border-radius));
  @include position(-12px, null, null, -12px);

  display: block;
  position: absolute;

  width: 36px;
  height: 36px;

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

  content: "";
  opacity: .2;
}


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

:host(.in-item) {
  @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);

  display: block;
  position: static;
}

:host(.in-item[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);
}
