.radio-container {
  display: inline-block;
  position: relative;
  padding-inline-start: 22px;
  margin-inline-end: 10px;
  max-width: 80ch;
  word-wrap: break-word;
}

/* Focus event occurs on the root element */
:host(:focus) {
  input[type='radio'] + label {
    &::before {
      border: 1px solid transparent;
      box-shadow: 0 0 0 2px rgb(44, 92, 197);
      border-color: darken($app-icon-color, 10%);
    }
  }

  input[type='radio'][disabled] + label {
    &::before {
      box-shadow: none;
      border: 1px solid #dadfe3;
    }
  }
}

/* Hover event occurs on the root element */
:host(:hover) {
  input[type='radio'] + label {
    &::before {
      box-shadow: 0 0 0 5px rgb(235, 239, 243);
      border-color: darken($app-icon-color, 10%);
    }
  }

  input[type='radio'][disabled] + label {
    cursor: not-allowed;

    &::before {
      box-shadow: none;
      border: 1px solid #dadfe3;
    }
  }
}

#description {
  font-size: 12px;
  color: #475867;
  letter-spacing: 0;
  line-height: 20px;
  position: relative;
  font-weight: 400;
}

input[type='radio'] {
  display: none;

  & + label {
    user-select: none;
    cursor: pointer;
    margin-block-end: 4px;
    vertical-align: middle;
    font-size: 14px;
    line-height: 20px;
    font-weight: 400;
    color: $color-elephant-900;

    .with-description {
      font-weight: 600;
    }

    &::before,
    &::after {
      content: '';
      display: block;
      position: absolute;
      inset-block-start: 0;
      box-sizing: border-box;
    }
    @media screen and (prefers-reduced-motion: reduce) {
      &::before {
        transition: none;
      }
    }

    &::before {
      inset-inline-start: 0;
      border: 1px solid $app-border-primary;
      border-radius: 50px;
      inset-block-start: 4px;
      width: 14px;
      height: 14px;
      background: $app-action-icon-bg;
      transition: all 0.3s ease;
    }

    &.error {
      @media screen and (prefers-reduced-motion: reduce) {
        &::before {
          transition: none;
        }
      }
      &::before {
        inset-inline-start: 0;
        border: 1px solid $app-error;
        border-radius: 50px;
        inset-block-start: 4px;
        width: 14px;
        height: 14px;
        background: $app-action-icon-bg;
        transition: all 0.3s ease;
      }
    }
    @media screen and (prefers-reduced-motion: reduce) {
      &::after {
        transition: none;
      }
    }

    &::after {
      inset-inline-start: 3px;
      border-radius: 100%;
      width: 8px;
      height: 8px;
      opacity: 0;
      transition: opacity 0.2s ease-in-out;
      box-sizing: border-box;
    }
  }

  &:checked + label {
    &::before {
      background: $app-action-icon-bg;
      border-color: $app-primary;
      box-shadow: none;
    }

    &::after {
      border-radius: 50%;
      background-color: $app-primary;
      opacity: 1;
      inset-block-start: 7px;
    }
  }

  &:checked:focus + label {
    &::before {
      border-color: lighten($app-primary, 5%);
      box-shadow: 0 0 4px 1px rgba($app-primary, 0.6);
    }

    &::after {
      background-color: lighten($app-primary, 5%);
    }
  }

  &[disabled] {
    & + label {
      color: #92a2b1;

      .label-field {
        color: #92a2b1;
      }

      &::before {
        border-color: $disabled-color;
        background-color: $ticket-tag-background;
      }

      &::after {
        border-color: $ticket-tag-background;
        background-color: $disabled-color;
      }
    }

    &:checked + label {
      color: #92a2b1;
    }
  }
}

:host(.fw-radio-group__radio) {
  margin-block-end: 8px;
}

:host(.fw-radio-group__radio--last) {
  margin-block-end: 0px;
}
