@import "button";


/**********
 ! Notebook
***********/

@include exports("notebook") {
    notebook {
        &.frame {
            border-color: border_normal($base_color);

            &.top {
                border-width: 1px 1px 0;
            }

            &.right {
                border-width: 1px 1px 1px 0;
            }

            &.bottom {
                border-width: 0 1px 1px;
            }

            &.left {
                border-width: 1px 0 1px 1px;
            }
        }

        > header {
            padding: 0;
            margin: 0;
            border-width: 1px;
            border-radius: 0;
            border-color: $borders_color;
            background-image: none;
            background-clip: border-box;
            background-color: shade($base_color, .9);
            color: $text_color;

            tabs { margin: -1px; }

            &.top {
                border-bottom-style: solid;

                tabs {
                    margin-top: 0;
                    margin-left: 0;
                    margin-right: 0;
                }
            }

            &.right {
                border-left-style: solid;

                tabs {
                    margin-right: 0;
                    margin-top: 0;
                    margin-bottom: 0;
                }
            }

            &.bottom {
                border-top-style: solid;

                tabs {
                    margin-bottom: 0;
                    margin-left: 0;
                    margin-right: 0;
                }
            }

            &.left {
                border-right-style: solid;

                tabs {
                    margin-left: 0;
                    margin-top: 0;
                    margin-bottom: 0;
                }
            }

            &.top > tabs > arrow {
                @extend %notebook_vert_arrows;

                border-top-style: none;
            }

            &.bottom > tabs > arrow {
                @extend %notebook_vert_arrows;

                border-bottom-style: none;
            }

            @at-root %notebook_vert_arrows {
                margin-left: 0;
                margin-right: 0;
                padding-left: 4px;
                padding-right: 4px;

                &.down { -gtk-icon-source: -gtk-icontheme('pan-start-symbolic'); }

                &.up { -gtk-icon-source: -gtk-icontheme('pan-end-symbolic'); }
            }

            &.left > tabs > arrow {
                @extend %notebook_horz_arrows;

                border-left-style: none;
            }

            &.right > tabs > arrow {
                @extend %notebook_horz_arrows;

                border-right-style: none;
            }

            @at-root %notebook_horz_arrows {
                margin-top: 0;
                margin-bottom: 0;
                padding-top: 4px;
                padding-bottom: 4px;

                &.down { -gtk-icon-source: -gtk-icontheme('pan-up-symbolic'); }

                &.up { -gtk-icon-source: -gtk-icontheme('pan-down-symbolic'); }
            }

            > tabs > arrow {
                @extend %close_button;

                min-height: 16px;
                min-width: 16px;

                &:hover:not(:active):not(:backdrop) {
                    background-clip: padding-box;
                    background-image: none;
                    background-color: transparentize($white, .7);
                    border-color: transparent;
                    box-shadow: none;
                }

                &:disabled { @extend %undecorated_button; }
            }

            tab {
                padding: ($spacing + 1) 0 0; // top | left/right | bottom
                border-style: solid;
                border-width: 1px;         // for reorderable tabs
                border-color: transparent; //
                background-image: none;
                box-shadow: none;
                outline: none;

                button, button:hover {
                    padding: $spacing - 4;
                    margin-left: 15px;
                    min-height: 18px;
                    min-width: 18px;
                    opacity: 0;
                    transition: opacity .3s ease-in;
                }

                > box, > label {
                    padding: 0 ($spacing * 3) ($spacing + 1); // top | left/right | bottom
                    border-width: 2px;
                    border-style: solid;
                    border-color: transparent;
                    transition: border-color .3s ease-out;
                }

                &:hover {
                    background-color: shade($base_color, .93);
                    border-color: transparent;
                    outline: none;

                    button, button:hover {
                        opacity: 1;
                    }
                }

                &:checked {
                    background-color: mix($bg_color, $base_color, .4);
                    border-bottom-color: transparent;
                    outline: none;

                    label {
                        color: $selected_bg_color;
                    }

                    &:hover {
                        background-color: mix($bg_color, $base_color, .6);
                    }
                }

                label {
                    color: mix($text_color, $base_color, .3);
                }

                /* close button styling */
                button {
                    @extend %close_button;
                }
            }

            &.top tab,
            &.bottom tab {
                &:hover {
                    &:not(:first-child):not(:last-child):not(:only-child) {
                        box-shadow: 1px 0 1px shade($base_color, .85), -1px 0 1px shade($base_color, .85);
                    }

                    &:last-child:not(:only-child) {
                        box-shadow: -1px 0 1px shade($base_color, .85);
                    }

                    &:first-child:not(:only-child) {
                        box-shadow: 1px 0 1px shade($base_color, .85);
                    }
                }

                &:checked {
                    &:not(:first-child):not(:last-child):not(:only-child) {
                        box-shadow: 1px 0 1px shade($base_color, .8), -1px 0 1px shade($base_color, .8);
                    }

                    &:last-child:not(:only-child) {
                        box-shadow: -1px 0 1px shade($base_color, .8);
                    }

                    &:first-child:not(:only-child) {
                        box-shadow: 1px 0 1px shade($base_color, .8);
                    }
                }
            }

            &.right tab,
            &.left tab {
                &:hover {
                    &:not(:first-child):not(:last-child):not(:only-child) {
                        box-shadow: 0 1px 1px shade($base_color, .85), 0 -1px 1px shade($base_color, .85);
                    }

                    &:last-child:not(:only-child) {
                        box-shadow: 0 -1px 1px shade($base_color, .85);
                    }

                    &:first-child:not(:only-child) {
                        box-shadow: 0 1px 1px shade($base_color, .85);
                    }
                }

                &:checked {
                    &:not(:first-child):not(:last-child):not(:only-child) {
                        box-shadow: 0 1px 1px shade($base_color, .8), 0 -1px 1px shade($base_color, .8);
                    }

                    &:last-child:not(:only-child) {
                        box-shadow: 0 -1px 1px shade($base_color, .8);
                    }

                    &:first-child:not(:only-child) {
                        box-shadow: 0 1px 1px shade($base_color, .8);
                    }
                }
            }

            &.top tab {
                padding: ($spacing + 1) 0 0; // top | left/right | bottom
                border-style: solid;
                border-color: $borders_color;
                border-width: 0;
                border-bottom-width: 1px;
                transition: border-bottom-color .3s ease-out;

                > box, > label {
                    padding: 0 ($spacing * 3) ($spacing + 1); // top | left/right | bottom
                }

                &:hover {
                    outline: none;
                }

                &:checked {
                    border-bottom-color: $selected_bg_color;
                    outline: none;

                    > box, > label {
                        border-bottom-color: $selected_bg_color;
                    }

                    label {
                        margin-bottom: 0;
                        color: $selected_bg_color;
                    }

                    &:hover {
                        background-color: mix($bg_color, $base_color, .6);
                    }
                }
            }

            &.right tab {
                padding: 0 ($spacing + 1) 0 0; // top | right | bottom | left
                border-style: solid;
                border-color: $borders_color;
                border-width: 0;
                border-left-width: 1px;
                transition: border-left-color .3s ease-out;

                > box, > label {
                    padding: ($spacing + 1) ($spacing * 3); // top | right | bottom | left
                }

                &:hover {
                    outline: none;
                }

                &:checked {
                    border-left-color: $selected_bg_color;
                    outline: none;

                    > box, > label {
                        border-left-color: $selected_bg_color;
                    }

                    label {
                        margin-left: 0;
                        color: $selected_bg_color;
                    }

                    &:hover {
                        background-color: mix($bg_color, $base_color, .6);
                    }
                }
            }

            &.bottom tab {
                padding: 0 0 ($spacing + 1); // top | left/right | bottom
                border-style: solid;
                border-color: $borders_color;
                border-width: 0;
                border-top-width: 1px;
                transition: border-top-color .3s ease-out;

                > box, > label {
                    padding: ($spacing + 1) ($spacing * 3) 0;  // top/bottom | left/right
                }

                &:hover {
                    outline: none;
                }

                &:checked {
                    border-top-color: $selected_bg_color;
                    outline: none;

                    > box, > label {
                        border-top-color: $selected_bg_color;
                    }

                    label {
                        margin-top: 0;
                        color: $selected_bg_color;
                    }

                    &:hover {
                        background-color: mix($bg_color, $base_color, .6);
                    }
                }
            }

            &.left tab {
                padding: 0 0 0 ($spacing + 1); // top | right | bottom | left
                border-style: solid;
                border-color: $borders_color;
                border-width: 0;
                border-right-width: 1px;
                transition: border-right-color .3s ease-out;

                > box, > label {
                    padding: ($spacing + 1) ($spacing * 3); // top/bottom | left/right
                }

                &:hover {
                    outline: none;
                }

                &:checked {
                    border-right-color: $selected_bg_color;
                    outline: none;

                    > box, > label {
                        border-right-color: $selected_bg_color;
                    }

                    label {
                        margin-right: 0;
                        color: $selected_bg_color;
                    }

                    &:hover {
                        background-color: mix($bg_color, $base_color, .6);
                    }
                }
            }
        }

        > stack:not(:only-child) {
            background-color: $base_color;

            &:backdrop { background-color: $backdrop_base_color; }
        }
    }
}