/***********************
 ! 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"));

    &:insensitive { -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"));

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

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

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

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

        &:insensitive { -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")); }

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

        &:inconsistent {
            -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")); }

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

@include exports("checkradio") {
    * {
        -GtkCheckButton-indicator-size: 16;
        -GtkCheckMenuItem-indicator-size: 16;
    }

    .radio { @include toggle("radio"); }

    .check { @include toggle("checkbox"); }

    //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) {
            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") {
    GtkSwitch {
        padding: 0;
        border-radius: $roundness;
        font: bold condensed;
        outline-offset: -4px;

        &.slider {
            @include linear-gradient(shade($bg_color, 1.2));

            border: 1px solid rgba(0, 0, 0, .2);
            box-shadow: 0 1px 2px -1px alpha($dark_shadow, .12);

            &:insensitive {
                border-color: rgba(0, 0, 0, .1);
                background-color: shade($bg_color, .9);
                box-shadow: none;
            }
        }

        &.trough {
            @include linear-gradient(shade($bg_color, .95), to top);

            border: 1px solid border_normal($bg_color);
            color: $fg_color;
            box-shadow: inset 1px 0 alpha($dark_shadow, .07),
                        inset 0 1px alpha($dark_shadow, .08),
                        inset -1px 0 alpha($dark_shadow, .07),
                        inset 0 -1px alpha($dark_shadow, .05);

            &:active {
                @include linear-gradient($selected_bg_color, to top);

                border-color: shade($selected_bg_color, .9);
                color: $selected_fg_color;
            }

            &:insensitive {
                @include linear-gradient(shade($bg_color, .9), to top);

                border-color: border_insensitive($bg_color);
                color: mix($fg_color, $bg_color, .5);
            }
        }
    }
}
