﻿@mixin checkout__radio-expand(
    $name-space:                              null,
    $margin-bottom:                           null,
    $list-padding:                            null,
    $item-gutter:                             null,
    $item-padding:                            null,
    $item-background-color:                   null,
    $input-width:                             null,
    $input-height:                            null,
    $input-background-color:                  null,
    $input-border:                            null,
    $input-checked-background-color:          null,
    $input-disabled-border:                   null,
    $input-disabled-checked-background-color: null,
    $image-width:                             null,
    $image-margin-right:                      null,
    $image-background-color:                  null,
    $text-small-spacing:                      null,
    $text-large-spacing:                      null,
    $text-right-border:                       null,
    $text-heading-color:                      null,
    $text-heading-margin-bottom:              null,
    $price-width:                             null,
    $price-top:                               null,
    $price-right:                             null,
    $details-heading-color:                   null,
    $details-heading-margin:                  null,
    $details-heading-border-bottom:           null,
    $details-text-color:                      null,
    $details-link-color:                      null
) {
    .#{$name-space}radio-expand {
        @include checkout__reset;
        margin: 0 0 $margin-bottom;

        &__list {
            margin: 0;
            padding: $list-padding;

            @include checkout__media-small {
                padding-left: $list-padding + $input-width;
            }
        }

        &__item {
            @include checkout__clearfix;
            margin: 0;
            padding: $item-padding;
            list-style: none;
            background-color: $item-background-color;
        }

        &__item:not(:last-child) {
            margin-bottom: $item-gutter;
        }

        &__label {
            @include checkout__clearfix;
            width: 100%;
            display: block;
            position: relative;
            cursor: pointer;
        }

        &__input {
            float: left;
            width: $input-width;
            height: $input-height;
            border-radius: 50%;
            -webkit-appearance: none;
            background-color: $input-background-color;
            border: $input-border;
            position: absolute;
            left: -($input-width / 2);
            top: 50%;
            transform: translateY(-50%);
            cursor: pointer;

            &:checked {
                &:after {
                    content: " ";
                    background-color: $input-checked-background-color;
                    position: absolute;
                    height: ($input-height / 2);
                    width: ($input-width / 2);
                    border-radius: 50%;
                    top: 50%;
                    left: 50%;
                    transform: translateX(-50%) translateY(-50%);
                }

                ~ .radio-expand__text {
                    border-right: $text-right-border;

                    .radio-expand__details {
                        display: block;
                        animation: show 0.15s ease-out;

                        @keyframes show {
                            0% {
                                opacity: 0;
                            }

                            100% {
                                opacity: 1;
                            }
                        }
                    }
                }
            }

            &:checked:disabled {
                cursor: default;

                &:after {
                    content: " ";
                    background-color: $input-disabled-checked-background-color;
                    position: absolute;
                    height: ($input-height / 2);
                    width: ($input-width / 2);
                    border-radius: 50%;
                    top: 50%;
                    left: 50%;
                    transform: translateX(-50%) translateY(-50%);
                }
            }

            &:disabled {
                cursor: default;
                border: $input-disabled-border;
            }

            &:focus {
                outline: none;
            }
        }

        &__image {
            float: left;
            width: $image-width;
            background-color: $image-background-color;
            margin: $text-large-spacing 0 0 ($input-width + 5px);

            @include checkout__media-small {
                width: $image-width / 2;
            }
        }

        &__text {
            @include checkout__clearfix;
            display: block;
            width: 100%;
            padding: $text-large-spacing $text-small-spacing $text-large-spacing ($image-width + $input-width + $image-margin-right + 5px);

            @include checkout__media-small {
                padding: ($image-width / 2 + $text-large-spacing + 5px) $text-small-spacing $text-large-spacing ($input-width + 5px);
            }
        }

        &__heading {
            color: $text-heading-color;
            margin: 0 ($price-width + 5px) $text-heading-margin-bottom 0;

            @include checkout__media-small {
                margin: 0 0 $text-heading-margin-bottom 0;
            }
        }

        &__description {
            margin: 0;
        }

        &__price {
            position: absolute;
            top: $price-top;
            right: $price-right;
            width: $price-width;
            text-align: right;
        }

        &__details {
            display: none;

            &__heading {
                color: $details-heading-color;
                margin: $details-heading-margin;
                padding-bottom: 5px;
                border-bottom: $details-heading-border-bottom;
            }

            &__text {
                color: $details-text-color;
            }

            &__link {
                color: $details-link-color;
                font-weight: 600;
            }
        }

        @content;
    }
}