/* ==========================================================================
   Header - Main header
   ========================================================================== */

/* General
   ========================================================================== */
.sg-header {
    position: fixed;
    z-index: 1000;

    display: block;
    width: 100%;
    padding: 0 20px;
    margin: 0 0 50px;

    background: $white;
    box-shadow: 0 2px 5px 0 rgba(0, 0, 0, .12), 0 2px 10px 0 rgba(0, 0, 0, .08);

    border-bottom: 1px solid $grey;

    font-family: $primary-font;

    @media (min-width: $screen-md-min) {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;

        display: flex;
        flex-direction: column;
        width: 360px;
        height: 100%;
        padding: 0;
        margin: 0;
        overflow-y: auto;
    }
}


/* Brand
   ========================================================================== */
.sg-header__brand {
    position: relative;
    z-index: 1;

    display: inline-block;
    width: 180px;
    margin-top: 8px;

    text-decoration: none;

    a {
        display: inline-block;
        padding: 10px 0;

        span {
            display: none;
        }

        &:hover {
            text-decoration: none;
        }
    }

    @media (min-width: $screen-md-min) {
        display: block;
        width: 100%;

        a {
            display: block;
            padding: 20px 50px;

            text-align: left;
        }
    }
}

.sg-header__brand__logo {
    display: inline-block;
    width: 100%;
}

/* Navigation
   ========================================================================== */
.sg-header__nav {
    max-height: 0;
    overflow: auto;

    transition: max-height .3s ease;

    &.mobile-nav-open {
        max-height: 500px; // big enough

        border-top: 1px solid $grey--light;
    }

    @media (min-width: $screen-md-min) {
        max-height: none;

        border-top: none;
    }
}

/* Mobile toggle button
   ========================================================================== */
.sg-header__nav__btn {
    float: right;
    margin: 10px 0 0;
    padding: 1.25em 1em;

    box-shadow: none;
    border: none;
    appearance: none;
    background: none;

    font-size: 12px;
    line-height: 1;
    color: $grey;

    transition: color .3s ease;

    &:focus, &:active {
        color: $grey;
        outline: none;
    }

    &:hover {
        color: $white;
    }

    @media (min-width: $screen-md-min) {
        display: none;
    }
}

/* Hamburger
   ========================================================================== */
.sg-header__nav__btn__icon {
    position: relative;

    width: 28px;
    height: 20px;
    padding: 0;
    margin: 0;
    transform: rotate(0deg);

    box-shadow: none;

    line-height: 1;

    transition: .5s ease-in-out;
    cursor: pointer;

    span {
        position: absolute;

        display: block;
        height: 2px;
        width: 50%;

        background: $black;

        opacity: 1;
        transform: rotate(0deg);
        transition: .25s ease-in-out;

        &:nth-child(even) {
            left: 50%;

            border-radius: 0 2px 2px 0;
        }

        &:nth-child(odd) {
            left: 0;

            border-radius: 2px 0 0 2px;
        }

        &:nth-child(1),
        &:nth-child(2) {
            top: 0;
        }

        &:nth-child(3),
        &:nth-child(4) {
            top: 8px;
        }

        &:nth-child(5),
        &:nth-child(6) {
            top: 16px;
        }
    }

    .mobile-nav-open & {

        span {

            &:nth-child(1),
            &:nth-child(6) {
                transform: rotate(45deg);
            }

            &:nth-child(2),
            &:nth-child(5) {
                transform: rotate(-45deg);
            }

            &:nth-child(1) {
                left: 3px;
                top: 6px;
            }

            &:nth-child(2) {
                left: calc(50% - 3px);
                top: 6px;
            }

            &:nth-child(3) {
                left: -50%;

                opacity: 0;
            }

            &:nth-child(4) {
                left: 100%;

                opacity: 0;
            }

            &:nth-child(5) {
                top: 14px;
                left: 3px;
            }

            &:nth-child(6) {
                top: 14px;
                left: calc(50% - 3px);
            }
        }
    }
}


/* Navigation
   ========================================================================== */
.sg-header__nav__list {
    margin: 0 0 20px;

    text-align: right;

    ul, & {
        padding: 0;
        list-style: none;
    }

    @media (max-width: $screen-sm-max) {
        ul {
            display: none;
        }
    }
}

.sg-header__nav__list__item {
    display: block;
    margin: 20px 0 0;

    text-align: left;

    a {
        display: block;
        padding: 5px 10px;

        color: $black;
        font-size: 16px;
        font-weight: bold;
        text-decoration: none;

        transition: color .3s ease, border .3s ease;

        &:hover {
            border-color: $grey;

            color: $black;
            text-decoration: none;
        }
    }

    &.active {
        border-bottom: 0;

        > ul {
            display: block;

            border-top: 1px solid $grey;
        }

        > a {
            margin-bottom: -1px;

            border-color: $primary-color;

            color: $primary-color--dark;
        }
    }

    ul {

        li {
            position: relative;

            &.children {
                > a:before {
                    display: block;
                }
            }

            a {
                position: relative;

                padding: 6px 24px;

                border-bottom: 1px solid $grey;

                font-weight: normal;
                font-size: 14px;

                &:before {
                    content: ' ';

                    position: absolute;
                    top: 0;
                    bottom: 0;
                    left: -5px;

                    width: 5px;

                    background: $grey--dark;

                    transition: transform .25s ease;
                }

                &:hover {

                    &:before {
                        transform: translate3d(5px, 0, 0);
                    }
                }
            }

            &.active {

                > a {
                    font-weight: bold;

                    &:before {
                        transform: translate3d(5px, 0, 0);
                    }
                }

                ul {
                    display: block;
                }
            }

            ul {
                display: none;

                background: $grey--light;

                li {

                    a {
                        padding: 6px 24px 6px 36px;

                        &:hover {

                            &:before {
                                display: block;
                            }
                        }
                    }
                }
            }
        }
    }
}
