.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: theme('colors.gray.800');

    &:hover {
        color: theme('colors.gray.900');
    }
}

.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 theme('colors.primary.900');
    }

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

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

            &::before {
                background: theme('colors.blue.700');
                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: theme('colors.gray.800');
        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 theme('colors.gray.400');
    height: 1.25rem;
    width: 1.25rem;
    background: theme('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);
    }
}
