/// ----------------------------------------------------------------------------------------
/// Header Styles
/// ----------------------------------------------------------------------------------------
/// @author - Modop
/// @description - The styling for the global header
////

/////
/// ----------------------------------------------------------------------------------------
/// @imports - Global imports
/// ----------------------------------------------------------------------------------------
////
@import '../sass/_variables';
@import '../sass/_mixins';
@import '../sass/_functions';

/////
/// ----------------------------------------------------------------------------------------
/// @description - All viewport widths up to infinity
/// ----------------------------------------------------------------------------------------
////
@media (min-width: $mobile) {
    header {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        z-index: 8;
    }

    .hpp-navbar {
        align-items: center;
        display: flex;
        background-color: $white;
        box-shadow: rem-calc(0 2 10) $shadow-color;
        justify-content: flex-end;
        min-height: rem-calc(52);
        padding-right: rem-calc(20);
        position: relative;

        .navbar-menu {
            background: $darkblue;
            overflow: scroll;
        }

        #burger-options {
            padding-top: rem-calc(50);
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;

            &.is-active {
                animation: slide-in-from-right 1s 1;
                z-index: 11;
            }
        }

        .navbar-burger {
            border: none;
            background: transparent;
            outline: none;
            padding: 0;
            width: rem-calc(20);
            z-index: 13;

            span {
                background: $lightblue;
                height: rem-calc(2);
                left: 0;
                width: rem-calc(20);
            }
        }

        .navbar-end {
            display: flex;
            flex-direction: column;
        }

        .menu-item {
            font-size: rem-calc(14);
            font-family: $styleguide-titles-font-family;
            color: $white;
            display: inline-block;
            position: relative;
            user-select: none;
            outline: none;
            border: none;
            cursor: pointer;
            width: 100%;

            .menu {
                text-align: left;
                position: relative;
                width: 100%;
                height: 100%;
                display: block;
                padding: rem-calc(10 0 10 24);
                color: $white;
                outline: none;
                border: none;
                user-select: none;
                font-size: rem-calc(14);

                &.hasSubmenu {
                    height: inherit;

                    &::after {
                        content: '';
                        border: solid $white;
                        border-width: rem-calc(0 2 2 0);
                        display: inline-block;
                        padding: rem-calc(5);
                        transform: rotate(-45deg);
                        position: absolute;
                        right: rem-calc(24);
                        top: rem-calc(14);
                        transition-duration: 150ms;
                        transition-timing-function: ease-in;
                    }
                }
            }

            .submenu {
                display: block;
                position: relative;
                text-transform: uppercase;
                width: 100%;

                .subcontainer {
                    position: relative;
                    background: $darkblue;
                    top: 0;
                    z-index: 2;
                    width: 100%;
                    box-shadow: none;
                    text-align: left;
                }

                .submenu-text {
                    position: relative;
                    width: 100%;
                    display: block;
                    padding: rem-calc(10 0 10 48);
                    text-align: left;
                    letter-spacing: 0;
                    color: $white;
                    outline: none;
                    border: none;
                    user-select: none;

                    &:hover {
                        background: $lightblue;
                        color: $white;

                        .menu-text {
                            color: $white;
                        }
                    }

                    &:first-child {
                        margin-top: 0;
                    }

                    &:last-child {
                        margin-bottom: 0;
                    }
                }
            }

            &.menu-open .menu.hasSubmenu::after {
                transform: rotate(45deg);
            }
        }

        .menu-mobile-only {
            display: block;
        }
    }
}
/// End of Mobile Up

/////
/// ----------------------------------------------------------------------------------------
/// @description - Tablet (768px) viewport widths up to infinity
/// ----------------------------------------------------------------------------------------
////
@media (min-width: $tablet) {
    .hpp-navbar {
        #burger-options.is-active {
            z-index: 12;
        }

        .navbar-end {
            position: relative;
        }

        // Setting up underscore navigation on nav items. This animation only applies to
        // the header on desktop resolutions. Here we don't apply hove because this are 
        // tablet resolution media query
        @for $i from 1 through $menuItemsLoop {
            .menu-item:nth-child(#{$i}).active ~ .menu-item:last-child:after {
                left: (-100% * $menuItemsLoop) + (($i) * 100) + $menuGap;
            }
        }


    }
}
/// End of Tablet Up

/////
/// ----------------------------------------------------------------------------------------
/// @description - Desktop (1024px) viewport widths up to infinity
/// ----------------------------------------------------------------------------------------
////
@media (min-width: $desktop) {
    .hpp-navbar {
        padding-right: 0;

        .navbar-menu {
            background: none;
            overflow: visible;
            padding-top: 0;

            &.is-active {
                animation: none;
            }
        }

        #burger-options {
            padding-top: 0;
            position: relative;
            top: initial;
            left: initial;
            width: initial;
            height: initial;
            animation: none;

            &.is-active {
                animation: none;
                max-width: 100%;
                left: initial;
                float: initial;
                right: initial;
                z-index: initial;
            }
        }

        .navbar-end {
            align-items: center;
            display: flex;
            flex-direction: row;
            min-height: rem-calc(52);
        }

        .nav-content {
            display: -ms-inline-flexbox;
            display: flex;
            height: 100%;
        }

        .menu-item {
            font-size: rem-calc(14);
            font-family: $styleguide-titles-font-family;
            color: $darkblue;
            display: block;
            text-align: center;
            min-width: rem-calc(96);
            transition-duration: 1s;

            &:last-child {
                background: $lightblue;

                &:hover,
                &.active {
                    &::after {
                        background: $white;
                        left: $menuGap !important;
                    }

                    .menu .menu-text {
                        color: $darkblue;
                    }
                }

                &::after {
                    content: '';
                    left: $menuGap;
                    height: rem-calc(3);
                    bottom: rem-calc(12);
                    background: $lightblue;
                    display: block;
                    position: absolute;
                    pointer-events: none;
                    transition: all ease-in-out .4s;
                    width: rem-calc(48);
                }

                .menu {
                    background: $lightblue;

                    .menu-text {
                        color: $white;
                    }
                }
            }

            &.active {
                background: $white;

                .menu.hasSubmenu::after {
                    display: none;
                }

                .submenu .menu-text {
                    font-size: rem-calc(14);
                    color: $darkblue;
                }
            }

            .menu {
                align-items: center;
                border: none;
                color: $darkblue;
                display: flex;
                height: 100%;
                justify-content: center;
                padding: 0;
                outline: none;
                text-align: center;
                user-select: none;
                width: 100%;

                &.light {
                    color: $lightblue;
                }

                &.hasSubmenu {
                    height: 100%;

                    &::after {
                        display: none;
                    }
                }

                &:hover {
                    color: $white;

                    .menu-text {
                        color: $lightblue;
                    }
                }
            }

            .submenu {
                position: absolute;
                display: block;
                text-transform: uppercase;
                top: 0;
                left: rem-calc(-16);
                overflow: visible;

                .subcontainer {
                    position: absolute;
                    background: $white;
                    top: rem-calc(52);
                    z-index: 2;
                    width: auto;
                    animation: fade-in .2s 1;
                    box-shadow: rem-calc(0 4 6) $shadow-color;
                }

                .submenu-text {
                    position: relative;
                    width: 100%;
                    height: 100%;
                    display: block;
                    padding: rem-calc(16 32);
                    text-align: left;
                    letter-spacing: 0;
                    color: $darkblue;
                    outline: none;
                    border: none;
                    user-select: none;
                    white-space: nowrap;

                    .menu-text {
                        color: $darkblue;
                    }

                    &:hover {
                        background: $lightblue;
                        color: $white;

                        .menu-text {
                            color: $white;
                        }
                    }

                    &:first-child {
                        margin-top: 0;
                    }

                    &:last-child {
                        margin-bottom: 0;
                    }
                }
            }

            &:nth-child(6) .submenu {
                left: auto;
                right: 0rem;
            }
        }
        .menu-mobile-only {
            display: none;
        }

        // This add the same animation as in the previous media query but on hover 
        // We add it here since this is a desktop resolution so we are sure code will
        // without creating false hover situations
        @for $i from 1 through $menuItemsLoop {
            .menu-item:nth-child(#{$i}):hover ~ .menu-item:last-child:after {
                left: (-100% * $menuItemsLoop) + (($i) * 100) + $menuGap;
            }
        }

    
    }
}
/// End of Desktop Up

/////
/// ----------------------------------------------------------------------------------------
/// @description - Full-HD (1366px) viewport widths up to infinity
/// ----------------------------------------------------------------------------------------
////
@media (min-width: $fullhd) {
    .hpp-navbar {
        .menu-item {
            min-width: rem-calc(120);

            &:last-child::after {
                transform: translateX(rem-calc(6));
            }

            .submenu {
                left: rem-calc(-4);
            }

            &:nth-child(6) .submenu {
                left: auto;
                right: 0rem;
            }
        }
    }
}
/// End Full-HD Up
