/**
 * Header
 * ----------------------------------------------------------------------------
 */

// Variables.
$header-link-color: $color-gray-85;
$header-link-color--hover: $color-black;
$header-link-spacing: $spacing--large;
$header-padding: $spacing--xsmall $spacing;
$header-background: rgba($color-white, 0.9);

.header {
    position: fixed;
    z-index: z-index(header);
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    box-shadow: $shadow;
    background-color: $header-background;
    border-bottom: 1px solid transparent;
    transition:
        background $transition,
        border $transition,
        box-shadow $transition;

    .admin-bar & {
        top: $wp-admin-bar-mobile;

        @include breakpoint($wp-admin-bar-breakpoint) {
            top: $wp-admin-bar-desktop;
        }
    }

    @include breakpoint(medium down) {
        min-height: rem-calc(60);
    }

    @include breakpoint(large) {
        padding: $spacing--xsmall 15px;
    }
}

.header__inner {
    width: 100%;
}

.header__column {
    padding: 0;
}

.header__column--menu {
    text-align: center;
    position: relative;
    .header__navigation {
        @include breakpoint(large) {
            position: absolute;
            width: 100%;
            top: 50%;
            transform: translateY(-50%);
        }
    }
}

.header__column--cart {
    position: relative;
    .header__items {
        top: 5px;
        position: relative;
    }
}

.header__items {
    display: flex;
    align-items: center;
}

.header__menu {
    margin: 0;
    list-style: none;

    li {
        display: inline-block;
    }
}

.header__menu a,
.header__link {
    position: relative;
    display: block;
    font-size: rem-calc(16);
    font-weight: 700;
    margin-left: $header-link-spacing;
    color: $color-gray-85;
    transition: all $transition;

    &::after {
        pointer-events: none;
        content: '';
        display: block;
        width: 100%;
        height: 6px;
        bottom: -17px;
        opacity: 0;
        position: absolute;
        background: $color-black;
        transition: all $transition;
    }

    svg {
        height: 24px;
        top: 4px;
        position: relative;
    }

    &:hover, &:focus {
        opacity: .7;
        &::after {
            opacity: 1;
        }
    }

    &:hover:focus,
    &:hover:active,
    &:active {
        opacity: .45;
    }

    &.is-active {
        position: relative;
        color: $color-gray-25;
        &::after {
            opacity: 1;
        }
    }
}

.header__menu {
    li {
        &.current-menu-item {
            a {
                position: relative;
                &::after {
                    opacity: 1;
                }
            }
        }
    }
}


/**
 * Sub menu
 */
.header__menu li {
    position: relative;

    ul {
        display: none;

        position: absolute;
        left: 0;
        top: 100%;
        background: rgba($color-white, 0.95);
        border-top: 1px solid $color-gray-10;
        min-width: 170%;

        li {
            width: 100%;
            display: block;

            a {
                margin: 0;
                padding: 0;
                display: block;
                word-break: keep-all;
                padding: .6em .9em;
                white-space: nowrap;

                &:hover {
                    background-color: $color-gray-5;
                }


                &::after {
                    display: none;
                }
            }
        }
    }

    &:hover ul {
        display: block;
    }
}

/**
 * Transparent header.
 */

.header--transparent {
    &:not(.header--scrolling) {
        background-color: transparent;
        box-shadow: none;
        border-bottom: 1px solid $color-gray-75;
    }
}

/**
 * Mobile header.
 */

.header__cart-content-count {
    position: absolute;
    right: $spacing--small;
    top: 50%;
    transform: translateY(-50%);
    .counter {
        .header__link {
            display: block;
            &.is-updated {
                animation-name: cart-updated;
                animation-timing-function: ease;
                animation-duration: .5s;
                animation-fill-mode: forwards;
            }
        }
        .header__link-content--bag {
            display: block;
        }
        .header__link-content--counter {
            display: none;
        }
        .header__link--counter {
            color: $color-white;
            background-color: $color-gray-75;
            border-radius: 100px;
            padding: $spacing--xsmall;
            padding: 0;
            width: 30px;
            height: 30px;
            line-height: 30px;
            display: block;
            text-align: center;
            position: relative;
            top: 3px;
            &::after {
                bottom: -14px;
            }

            .header__link-content--bag {
                display: none;
            }
            .header__link-content--counter {
                display: block;
            }
        }
    }
    @include breakpoint(large) {
        position: relative;
        right: auto;
        top: auto;
        transform: none;
        height: 36px;
    }
}

.header__navigation-mobile-trigger {
    position: absolute;
    left: $spacing--small;
    top: 50%;
    transform: rotate(0deg) translateY(-50%);
    bottom: 0;
    height: rem-calc(20);
    width: rem-calc(30);
    font-size: 0;
    margin: 0;
    padding: 0;
    outline: none !important;
    transition: .5s ease-in-out;
    cursor: pointer;

    span {
        position: absolute;
        display: block;
        width: rem-calc(30);
        height: 2px;
        background-color: #111;
        opacity: 1;
        transform: rotate(0deg);
        transition: .25s ease-in-out;
        left: 0;

        &:nth-child(1){
            top: 0px;
        }
        &:nth-child(2),
        &:nth-child(3) {
            top: 9px;
        }
        &:nth-child(4) {
            top: 18px;
        }
    }

    &.open {
        span {
            &:nth-child(1){
                top: 9px;
                width: 0;
                left: 50%;
            }
            &:nth-child(2){
                transform: rotate(45deg);
            }
            &:nth-child(3){
                transform: rotate(-45deg);
            }
            &:nth-child(4){
                top: 9px;
                width: 0;
                left: 50%;
            }
        }
    }
}

.header__navigation-mobile {
    text-align: left;
    position: absolute;
    left: 0;
    right: 0;
    top: 30px;
    display: none;

    &::after {
        content: '';
        position: absolute;
        top:0;
        bottom: 0;
        left:0;
        right: 0;
        display: block;
        height: 100%;
        width: 100%;
        z-index: 1;
        background-color: rgba($color-white, 0.9);
        backdrop-filter: blur(10px);
    }

    ul {
        list-style-type: none;
        padding: 0;
        margin: 0;
        position: relative;
        z-index: 11;

        &.header__mobile-menu {
            padding: $spacing--large $spacing--small;
            border-top: 1px solid $color-gray-85;
        }

        li {

            a {
                position: relative;
                font-size: rem-calc(16);
                font-weight: 500;
                line-height: 1.2;
                display: block;
                padding: $spacing--xsmall 0;
                color: $color-gray-85;
                transition: all $transition;

                &::before {
                    display: none;
                    position: absolute;
                    content: '';
                    width: 3px;
                    height: 100%;
                    background: $color-black;
                    top: 0;
                    left: -16px;
                }

                &:hover, &:focus {
                    opacity: .7;
                }

                &:hover:focus,
                &:hover:active,
                &:active {
                    opacity: .45;
                }
            }

            &.current-menu-item {
                & > a {
                    color: $color-gray-25;
                    &::before {
                        display: block;
                    }
                }
            }
            &.current-menu-parent {
                & > a {
                    &::before {
                        display: block;
                    }
                }
                .sub-menu {
                    .current-menu-item a::before {
                        display: none;
                    }
                }
            }

            .sub-menu {
                padding: 0;
                margin: 0;

                li {
                    padding-left: $spacing--large;
                    width: 100%;
                    display: block;
                }
            }
        }
    }

}

