.tb-switch-wrapper {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
}

.tb-switch {
    position: relative;
    display: inline-block;
}

.tb-switch__label {
    cursor: pointer;
    color: config('colors.grey-darker');

    &:hover {
        color: config('colors.grey-darkest');
    }
}

.tb-switch__label--before {
    padding-right: $spacing-2;
}

.tb-switch__label--after {
    padding-left: $spacing-2;
}

.tb-switch__input {
    cursor: pointer;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    display: inline-block;
    height: 1.125rem;
    width: 2rem;
    opacity: 0;

    &:focus ~ .tb-switch__background .tb-switch__knob {
        outline: 1px dotted config('colors.primary-darkest');
    }

    &:checked {
        ~ .tb-switch__background::before {
            background: config('colors.positive-light');
        }

        ~ .tb-switch__background .tb-switch__knob {
            transition: transform 90ms cubic-bezier(.4, 0, .2, 1);
            transform: translateX(.875rem);

            &::before {
                background: config('colors.blue-dark');
                opacity: .15;
            }
        }
    }
}

.tb-switch__background {
    cursor: pointer;
    user-select: none;
    position: relative;
    display: block;
    height: 1.125rem;
    width: 2rem;
    background: transparent;
    border-radius: .75rem;
    outline: none;

    &::before {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        display: block;
        background: config('colors.grey-darker');
        border-radius: .75rem;
        transition: background 90ms cubic-bezier(.4, 0, .2, 1);
    }
}

.tb-switch__knob {
    position: absolute;
    top: -.08em;
    left: 0;
    z-index: 1;
    display: block;
    border: 1px solid config('colors.grey-light');
    height: 1.25rem;
    width: 1.25rem;
    background: config('colors.white');
    border-radius: .625rem;
    box-shadow: 0 0 .5rem rgba(155, 155, 155, .16);
    transition: transform 90ms cubic-bezier(.4, 0, .2, 1);
    transform: translateX(0);

    &::before {
        content: '';
        position: absolute;
        top: -.875rem;
        left: -.875rem;
        height: 3rem;
        width: 3rem;
        background: transparent;
        border-radius: 1.5rem;
        opacity: .2;
        transition: transform 90ms cubic-bezier(.4, 0, .2, 1);
        transform: scale(0);
    }
}
