/***********************
 ! Check and Radio items
************************/

$suffix: if($variant == "dark", "-dark", "");

@mixin toggle($type) {
    background-image: none;

    -gtk-icon-source: -gtk-scaled(url("../assets/#{$type}-unchecked#{$suffix}.png"),
                                  url("../assets/#{$type}-unchecked#{$suffix}@2.png"));

    &:disabled { -gtk-icon-source: -gtk-scaled(url("../assets/#{$type}-unchecked-insensitive#{$suffix}.png"),
                                               url("../assets/#{$type}-unchecked-insensitive#{$suffix}@2.png")); }

    &:checked, &:active {
        -gtk-icon-source: -gtk-scaled(url("../assets/#{$type}-checked#{$suffix}.png"),
                                      url("../assets/#{$type}-checked#{$suffix}@2.png"));

        &:disabled { -gtk-icon-source: -gtk-scaled(url("../assets/#{$type}-checked-insensitive#{$suffix}.png"),
                                                   url("../assets/#{$type}-checked-insensitive#{$suffix}@2.png")); }
    }

    &:indeterminate {
        -gtk-icon-source: -gtk-scaled(url("../assets/#{$type}-mixed#{$suffix}.png"),
                                      url("../assets/#{$type}-mixed#{$suffix}@2.png"));

        &:disabled { -gtk-icon-source: -gtk-scaled(url("../assets/#{$type}-mixed-insensitive#{$suffix}.png"),
                                                   url("../assets/#{$type}-mixed-insensitive#{$suffix}@2.png")); }
    }

    menuitem &, modelbutton & {
        -gtk-icon-source: -gtk-scaled(url("../assets/menuitem-#{$type}-checked-insensitive.png"),
                                      url("../assets/menuitem-#{$type}-checked-insensitive@2.png"));

        &:disabled { -gtk-icon-source: none; }

        &:checked, &:active {
            -gtk-icon-source: -gtk-scaled(url("../assets/menuitem-#{$type}-checked.png"),
                                          url("../assets/menuitem-#{$type}-checked@2.png"));

            &:hover { -gtk-icon-source: -gtk-scaled(url("../assets/menuitem-#{$type}-checked-hover.png"),
                                                    url("../assets/menuitem-#{$type}-checked-hover@2.png")); }

            &:disabled { -gtk-icon-source: -gtk-scaled(url("../assets/menuitem-#{$type}-checked-insensitive.png"),
                                                       url("../assets/menuitem-#{$type}-checked-insensitive@2.png")); }
        }

        &:indeterminate {
            -gtk-icon-source: -gtk-scaled(url("../assets/menuitem-#{$type}-mixed.png"),
                                          url("../assets/menuitem-#{$type}-mixed@2.png"));

            &:hover { -gtk-icon-source: -gtk-scaled(url("../assets/menuitem-#{$type}-mixed-hover.png"),
                                                    url("../assets/menuitem-#{$type}-mixed-hover@2.png")); }

            &:disabled { -gtk-icon-source: -gtk-scaled(url("../assets/menuitem-#{$type}-mixed-insensitive.png"),
                                                       url("../assets/menuitem-#{$type}-mixed-insensitive@2.png")); }
        }
    }
}

@include exports("checkradio") {
    radio {
        @include toggle("radio");
        min-width: 16px;
        min-height: 16px;
        margin-right: $spacing;
    }

    check {
        @include toggle("checkbox");
        min-width: 16px;
        min-height: 16px;
        margin-right: $spacing;
    }

    radio:dir(rtl), check:dir(rtl) {
        margin-right: 0;
        margin-left: $spacing;
    }

    //selection-mode
    @each $s,$as in ('', '-unchecked'),
                  (':hover', '-unchecked'),
                  (':active', '-checked'),
                  (':backdrop', '-unchecked'),
                  (':checked', '-checked'),
                  (':checked:hover', '-checked'),
                  (':checked:active', '-checked'),
                  (':backdrop:checked', '-checked') {
        .view.content-view.check#{$s}:not(list) {
            -gtk-icon-shadow: none;
            -gtk-icon-source: -gtk-scaled(url("../assets/grid-selection#{$as}#{$suffix}.png"),
                                          url("../assets/grid-selection#{$as}#{$suffix}@2.png"));
            background-color: transparent;
        }
    }
}


/********
 ! Switch
*********/

@include exports("switch") {
    switch {
        min-height: 16px;
        padding: $spacing - 2px;
        border-radius: $roundness;
        border: none;
        outline: none;
        transition: background-color .3s linear;

        background-color: $switch_bg_color;
        color: $switch_fg_color;
        box-shadow: inset 1px -1px 0 alpha($dark_shadow, .06), inset -1px 1px 0 alpha($dark_shadow, .06);

        slider {
            min-height: 18px;
    	    min-width: 26px;
	    padding: 0 2px;

            background-color: $switch_slider_bg_color;
            transition: all 0.3s ease-in;
            box-shadow: 0 1px 2px 0 alpha($dark_shadow, .07), 1px 0 2px 0 alpha($dark_shadow, .07);
            border-radius: $roundness;
        }

        &:checked {
            background-color: $selected_bg_color;
            background-image: none;
            border-color: $selected_bg_color;
            color: $base_color;

            slider {
                background-color: $white;
                box-shadow: 0 1px 3px 0 alpha($dark_shadow, .1);
            }
        }

        &:disabled {
            background-color: $switch_disabled_bg_color;
            background-image: none;
            border-color: $switch_disabled_border_color;
            color: $switch_disabled_fg_color;
            box-shadow: none;

            slider {
                background-color: $switch_disabled_slider_bg_color;
            }
        }

        list row:selected & {
            background-color: $switch_disabled_slider_bg_color;
            color: $switch_disabled_bg_color;

            slider {
                background-color: mix($switch_disabled_bg_color, $base_color, .4);
            }

            &:checked {
                color: $selected_bg_color;
                background-color: $switch_slider_bg_color;

                slider {
                    background-color: $selected_bg_color;
                }
            }
        }
    }
}
