:host {
  /**
   * @prop --color: Color of the radio
   * @prop --color-checked: Color of the checked radio
   * @prop --border-radius: Border radius of the radio
   * @prop --inner-border-radius: Border radius of the inner checked radio
   */
  --inner-border-radius: 50%;
  display: inline-block;
  position: relative;
  box-sizing: border-box;
  max-width: 100%;
  min-height: inherit;
  user-select: none;
  z-index: 2;
}

:host(:not(.legacy-radio)) {
  cursor: pointer;
}

:host(.radio-disabled) {
  pointer-events: none;
}

.radio-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  contain: layout size style;
}

.radio-icon,
.radio-inner {
  box-sizing: border-box;
}

:host(.legacy-radio) label {
  top: 0;
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  margin-bottom: 0;
  position: absolute;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  outline: none;
  display: flex;
  align-items: center;
  opacity: 0;
}
@supports (inset-inline-start: 0) {
  :host(.legacy-radio) label {
    inset-inline-start: 0;
  }
}
@supports not (inset-inline-start: 0) {
  :host(.legacy-radio) label {
    left: 0;
  }
  :host-context([dir=rtl]):host(.legacy-radio) label, :host-context([dir=rtl]).legacy-radio label {
    left: unset;
    right: unset;
    right: 0;
  }
  @supports selector(:dir(rtl)) {
    :host(.legacy-radio) label:dir(rtl) {
      left: unset;
      right: unset;
      right: 0;
    }
  }
}
:host(.legacy-radio) label::-moz-focus-inner {
  border: 0;
}

input {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  clip: rect(0 0 0 0);
  opacity: 0;
  overflow: hidden;
  -webkit-appearance: none;
  -moz-appearance: none;
}

:host(:focus) {
  outline: none;
}

:host(.in-item:not(.legacy-radio)) {
  width: 100%;
  height: 100%;
}

/**
 * Radio can be slotted
 * in components such as item and
 * toolbar which is why we do not
 * limit the below behavior to just ion-item.
 */
:host([slot=start]:not(.legacy-radio)),
:host([slot=end]:not(.legacy-radio)) {
  width: auto;
}

.radio-wrapper {
  display: flex;
  position: relative;
  flex-grow: 1;
  align-items: center;
  height: inherit;
  min-height: inherit;
  cursor: inherit;
}

.label-text-wrapper {
  /**
   * This ensures that double tapping this text
   * clicks the <label> and focuses the radio
   * when a screen reader is enabled.
   */
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

:host(.in-item:not(.legacy-radio)) .label-text-wrapper {
  margin-top: 10px;
  margin-bottom: 10px;
}

/**
 * If no label text is placed into the slot
 * then the element should be hidden otherwise
 * there will be additional margins added.
 */
.label-text-wrapper-hidden {
  display: none;
}

.native-wrapper {
  display: flex;
  align-items: center;
}

:host(.radio-justify-space-between) .radio-wrapper {
  justify-content: space-between;
}

:host(.radio-justify-start) .radio-wrapper {
  justify-content: start;
}

:host(.radio-justify-end) .radio-wrapper {
  justify-content: end;
}

/**
 * Label is on the left of the radio in LTR and
 * on the right in RTL.
 */
:host(.radio-label-placement-start) .radio-wrapper {
  flex-direction: row;
}

:host(.radio-label-placement-start) .label-text-wrapper {
  /**
   * The margin between the label and
   * the radio should be on the end
   * when the label sits at the start.
   */
  -webkit-margin-start: 0;
  margin-inline-start: 0;
  -webkit-margin-end: 16px;
  margin-inline-end: 16px;
}

/**
 * Label is on the right of the radio in LTR and
 * on the left in RTL.
 */
:host(.radio-label-placement-end) .radio-wrapper {
  flex-direction: row-reverse;
}

/**
 * The margin between the label and
 * the radio should be on the start
 * when the label sits at the end.
 */
:host(.radio-label-placement-end) .label-text-wrapper {
  -webkit-margin-start: 16px;
  margin-inline-start: 16px;
  -webkit-margin-end: 0;
  margin-inline-end: 0;
}

:host(.radio-label-placement-fixed) .label-text-wrapper {
  /**
   * The margin between the label and
   * the radio should be on the end
   * when the label sits at the start.
   */
  -webkit-margin-start: 0;
  margin-inline-start: 0;
  -webkit-margin-end: 16px;
  margin-inline-end: 16px;
}

/**
 * Label is on the left of the radio in LTR and
 * on the right in RTL. Label also has a fixed width.
 */
:host(.radio-label-placement-fixed) .label-text-wrapper {
  flex: 0 0 100px;
  width: 100px;
  min-width: 100px;
}

:host {
  --color: rgb(var(--ion-text-color-rgb, 0, 0, 0), 0.6);
  --color-checked: var(--ion-color-primary, #3880ff);
  --border-width: 2px;
  --border-style: solid;
  --border-radius: 50%;
}

:host(.legacy-radio) {
  width: 20px;
  height: 20px;
}

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

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

.radio-icon {
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  margin-bottom: 0;
  border-radius: var(--border-radius);
  border-width: var(--border-width);
  border-style: var(--border-style);
  border-color: var(--color);
}

.radio-inner {
  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 280ms cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--color-checked);
}

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

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

:host(.legacy-radio.radio-disabled),
:host(.radio-disabled) .label-text-wrapper {
  opacity: 0.38;
}

:host(.radio-disabled) .native-wrapper {
  opacity: 0.63;
}

:host(.ion-focused.legacy-radio) .radio-icon::after {
  top: -12px;
}
@supports (inset-inline-start: 0) {
  :host(.ion-focused.legacy-radio) .radio-icon::after {
    inset-inline-start: -12px;
  }
}
@supports not (inset-inline-start: 0) {
  :host(.ion-focused.legacy-radio) .radio-icon::after {
    left: -12px;
  }
  :host-context([dir=rtl]):host(.ion-focused.legacy-radio) .radio-icon::after, :host-context([dir=rtl]).ion-focused.legacy-radio .radio-icon::after {
    left: unset;
    right: unset;
    right: -12px;
  }
  @supports selector(:dir(rtl)) {
    :host(.ion-focused.legacy-radio) .radio-icon::after:dir(rtl) {
      left: unset;
      right: unset;
      right: -12px;
    }
  }
}

:host(.ion-focused) .radio-icon::after {
  border-radius: var(--inner-border-radius);
  display: block;
  position: absolute;
  width: 36px;
  height: 36px;
  background: var(--ion-color-primary-tint, #4c8dff);
  content: "";
  opacity: 0.2;
}

:host(.in-item.legacy-radio) {
  margin-left: 0;
  margin-right: 0;
  margin-top: 9px;
  margin-bottom: 9px;
  display: block;
  position: static;
}

:host(.in-item.legacy-radio[slot=start]) {
  -webkit-margin-start: 4px;
  margin-inline-start: 4px;
  -webkit-margin-end: 36px;
  margin-inline-end: 36px;
  margin-top: 11px;
  margin-bottom: 10px;
}

.native-wrapper .radio-icon {
  width: 20px;
  height: 20px;
}