@use "sass:math";

$toggle-width: 162;
$toggle-height: 72;

$toggle-floater-width: 80;
$toggle-floater-height: 64;
$toggle-floater-margin: 4;
$toggle-checked-left-offset: $toggle-width - $toggle-floater-margin - $toggle-floater-width;

.toggle {
    @extend %nav-all;
    @include trans-colors-opa;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    position: relative;
    width: space($toggle-width);
    height: space($toggle-height);
    background: $color-transparent;
    border-radius: space(math.div($toggle-height, 2));
    cursor: pointer;
    opacity: 0.9;

    &:hover, &:focus-visible, &:focus {
        background-color: $color-secondary-a30;
        opacity: 1;
    }

    &:active {
        background-color: $color-secondary-a5;
        opacity: 1;
    }

    .toggle__border {
        @include inner-border-block($color-secondary-l);
        border-radius: space(math.div($toggle-height, 2));
    }

    .toggle__floater {
        position: absolute;
        width: space($toggle-floater-width);
        height: space($toggle-floater-height);
        top: 50%;
        left: space($toggle-floater-margin);
        transform: translateY(-50%);
        border-radius: space(math.div($toggle-floater-height, 2));
        background: $color-secondary-d;
    }
    
    &--checked {
        .toggle__floater {
            left: space($toggle-checked-left-offset);
        }

        .toggle__icon {
            &.toggle__icon--left {
                color: $color-secondary-l;
                opacity: 0.9;
            }
            &.toggle__icon--right {
                color: $color-text;
                opacity: 1.0;
            }
        }
    }
}

.toggle__icons {
    display: flex;
    position: absolute;
    height: space(56);
    top: 50%;
    transform: translateY(-50%);
    right: space(16);
    left: space(16);
    align-items: center;
    justify-content: space-between;
}

.toggle__icon {
    @extend %prompt-font-lg;
    @include trans-colors;
    display: flex;
    align-items: center;
    justify-content: center;
    width: space(56);
    height: space(56);
    color: $color-text;

    &--right {
        opacity: 1;
        color: $color-secondary-l;
    }
}
