$radio-active-background-color: $primary !default;
$radio-size: 1.25em !default;
$radio-colors: $form-colors !default;


.b-radio.radio {
    @extend %unselectable;
    outline: none;
    display: inline-flex;
    align-items: center;

    &:not(.button) {
        margin-right: 0.5em;
        & + .radio:last-child {
            margin-right: 0;
        }
    }

    // reset Bulma
    & + .radio {
        margin-left: 0;
    }

    .check {
        outline: none;
        appearance: none;
        // font-size is changed by user agent to lower size
        font-size: inherit;
        width: $radio-size;
        height: $radio-size;
        flex-shrink: 0;
        border-radius: 50%;
        border: 2px solid $grey;
        transition: background $speed-slow $easing;

        &:checked {
            border-color: $radio-active-background-color;
        }

        &:hover:not(:disabled) {
            border-color: $radio-active-background-color;
        }

        &:focus {
            box-shadow: 0 0 0.5em rgba($grey, 0.8);

            &:checked {
                box-shadow: 0 0 0.5em rgba($radio-active-background-color, 0.8);
            }
        }

        &:before {
            content: "";
            display: flex;
            position: absolute;
            left: $radio-size * 0.5;
            margin-left: calc(-#{$radio-size} * 0.5);
            bottom: 50%;
            margin-bottom: calc(-#{$radio-size} * 0.5);
            width: $radio-size;
            height: $radio-size;
            transition: transform $speed-slow $easing;
            border-radius: 50%;
            transform: scale(0);
            background: $radio-active-background-color;
        }

        &:checked {
            border-color: $radio-active-background-color;

            &:before {
                transform: scale(.5);
            }
        }

        &:focus {
            box-shadow: 0 0 0.5em rgba($grey, 0.8);

            &:checked {
                box-shadow: 0 0 0.5em rgba($radio-active-background-color, 0.8);
            }
        }
    }

    .control-label {
        padding-left: $control-padding-horizontal;
    }

    &.button {
        display: flex;

        &.is-selected {
            z-index: 1;
        }
    }

    &.is-disabled {
        opacity: 0.5;
    }

    &.is-small {
        @include control-small;
    }

    &.is-medium{
        @include control-medium;
    }

    &.is-large {
        @include control-large;
    }

    @each $name, $pair in $radio-colors {
        $color: nth($pair, 1);

        &.is-#{$name} {
            .check:before {
                background: $color;

                &:hover:not(:disabled) {
                    border-color: $color;
                }
            }

            .check:checked {
                border-color: $color;

                &:focus {
                    box-shadow: 0 0 0.5em rgba($color, 0.8);
                }
            }

            .check:hover:not(:disabled) {
                border-color: $color;
            }
        }
    }
}
