#nav-trigger {
    position: absolute;
    top: 0;
}

#header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 76px;
    font-size: 14px;
    font-weight: 600;
    background-color: white;
    transition: all 300ms ease-in-out;
    z-index: 14;

    @at-root .page--article & {
        background-color: $blue-xl;
        border-bottom: 1px solid $blue-xl-border;
    }
    .inner {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
    }

    .btn {
        display: block;
        background-color: $grey-xl;
        color: $black;
        height: 48px;
        line-height: 48px;
        padding: 0 40px;
        border-radius: 10px;
        text-align: center;
        cursor: pointer;
        transition: all 160ms linear;

        & > * {
            cursor: pointer;
        }
        &#signup-btn {
            background-color: $blue;
            color: white;
        }
    }
    button:not(:disabled),
    button:not(:disabled) * {
        cursor: pointer;
    }
    #login-link {
        color: $black;
    }
}
#header-logo {
    width: 140px;

    svg {
        vertical-align: middle;
    }
}
#header-content {
    flex: 1;
    margin-left: 160px;
}
#sidebar-toggle,
#menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    margin-right: -5px;
    position: relative;
    cursor: pointer;

    .bar {
        position: absolute;
        left: 4px;
        right: 4px;
        height: 4px;
        width: 34px;
        border-radius: 4px;
        background-color: $black;
        transition: all 300ms linear;
        pointer-events: none;
        overflow: hidden;

        &:nth-child(1) {
            top: 11px;
        }
        &:nth-child(2) {
            top: 20px;
        }
        &:nth-child(3) {
            top: 29px;
        }
    }
    &.open .bar {
        &:nth-child(1) {
            top: 21px;
            transform: rotate(45deg);
        }
        &:nth-child(2) {
            top: 20px;
            width: 0;
        }
        &:nth-child(3) {
            top: 21px;
            transform: rotate(-45deg);
        }
    }
}
#header-menu-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;

    @media (max-width: 1000px) {
        flex: none;
    }

    @media (min-width: 561px) {
        #login-link,
        .label {
            position: relative;
            display: inline-block;
            height: 48px;
            line-height: 48px;
            padding-right: 24px;
            color: $black;
            cursor: pointer;

            &:hover {
                color: $blue;
            }
        }
    }
}
@media (max-width: 1000px) {
    #header-content {
        position: absolute;
        left: 0;
        right: 0;
        background-color: white;
        margin: 0;
        padding: 10px 50px;
        box-shadow: 0 0 30px transparentize($black-l, 0.9);
        display: grid;
        grid-template-columns: 50px 1fr;
    }
    #sidebar-toggle {
        display: block;
    }
}
@media (max-width: 480px) {
    #header-content {
        padding: 10px 25px;
    }
}
@media (min-width: 561px) {
    #signup-btn {
        background-color: $blue;
        color: white;

        &:hover {
            background-color: $blue-hover;
        }
    }
    #header-auth-visitor,
    #header-auth-user {
        position: absolute;
        top: 0;
        right: 0;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        transform: translateY(-100px);
        opacity: 0;

        &.transition-in {
            transform: translateY(0);
            transition: transform 0ms linear 0ms;
            animation: fadeIn 500ms forwards 300ms;
        }
        &.transition-out {
            transform: translateY(-100px);
            animation: fadeOut 500ms forwards;
            transition: transform 0ms linear 500ms;
        }
    }
    #header-auth-user {
        color: white;
        cursor: pointer;

        .label {
            cursor: pointer;
            transition: all 300ms linear;
        }

        &:hover .label {
            color: $yellow;
        }
        &.transition-in ~ #header-auth-logout {
            display: block;
        }
    }
    #header-user-avatar {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border-radius: 100%;
        overflow: hidden;
        border: 2px solid transparentize(white, 0.9);
        cursor: pointer;

        img {
            cursor: pointer;
        }
        @at-root #header-authentication.loading & {
            cursor: default;
            filter: grayscale(50);
            opacity: 0.8;
        }
    }
    #header-auth-loading {
        position: absolute;
        left: 0;
        right: 0;
        height: 100%;
        animation: fadeIn 400ms forwards;

        &.transition-out {
            animation: authTransitionOut 300ms forwards;
        }

        .grey-line {
            position: absolute;
            height: 10px;
            background-color: $grey-l;
            left: 0;
            top: 16px;
            right: 100%;
            animation: authLoading 2s infinite linear;
        }
    }
    #header-auth-logout {
        display: none;
        position: absolute;
        right: 0;
        top: 100%;
        background: #f4f4f4;
        padding: 16px 20px;
        border-radius: 4px;
        font-size: 12px;
        width: 100px;
        line-height: 13px;
        cursor: pointer;
        opacity: 0;
        transform: translateY(10px);
        transition: color 300ms linear;

        &:hover {
            color: $blue;
        }
        @at-root #header-authentication.loading & {
            display: none;
        }
    }
    #header-authentication {
        width: 240px;
        height: 48px;
        position: relative;
        overflow: hidden;

        &:hover {
            overflow: visible;

            #header-auth-logout {
                animation: fadeIn 300ms forwards, moveUp 600ms forwards;
            }
        }
    }
}
@media (max-width: 560px) {
    #menu-toggle {
        display: block;
    }
    #header-menu-wrap {
        display: block;
        pointer-events: none;
        opacity: 0;
        position: fixed;
        background: #fff;
        top: 0;
        left: 0;
        right: 0;
        flex: none;
        box-shadow: 0 0 20px transparentize($black, 0.7);
        overflow: auto;
        z-index: 3;

        &.open {
            opacity: 1;
            pointer-events: initial;
        }
    }
    #header-authentication {
        margin-top: 20px;

        &.loading {
            #header-auth-user,
            #header-auth-logout {
                background-color: $grey-l;
                color: $grey-m;
                cursor: default;
                pointer-events: none;

                img {
                    filter: grayscale(50);
                }
            }
        }
    }
    #header-auth-visitor,
    #header-auth-user,
    #header-auth-logout,
    #header-auth-loading {
        display: none;
    }

    @mixin resposiveNavBtn() {
        height: 60px;
        line-height: 60px;
        margin: 10px 50px;
        border-radius: 6px;
        text-align: center;
        transition: all 300ms ease-in-out;

        @media (max-width: 420px) {
            margin: 10px;
        }
    }
    #header-auth-visitor {
        &.transition-in {
            display: block;
        }
        &.transition-out {
            display: none;
        }
    }
    #login-link {
        background-color: $grey-xl;
        display: block;
        @include resposiveNavBtn();

        &:hover,
        &:focus {
            background-color: $grey-l;
        }
    }
    #signup-btn {
        background-color: $blue;
        color: white;
        display: block;
        @include resposiveNavBtn();

        &:hover,
        &:focus {
            background-color: $blue-hover;
        }
    }
    #header-auth-user {
        background-color: $blue;
        color: white;
        @include resposiveNavBtn();

        .label {
            display: inline-block;
            vertical-align: middle;
        }
        &:hover,
        &:focus {
            background-color: $blue-hover;
        }
        &.transition-in {
            display: block;

            & ~ #header-auth-logout {
                display: block;
            }
        }
        &.transition-out {
            display: none;
        }
    }
    #header-auth-logout {
        background-color: $grey-xl;
        color: $black;
        @include resposiveNavBtn();

        &:hover,
        &:focus {
            background-color: $grey-l;
            color: $red;
        }
    }
    #header-user-avatar {
        display: inline-block;
        vertical-align: middle;
        height: 40px;
        width: 40px;
        border-radius: 100%;
        overflow: hidden;
        border: 2px solid transparentize(white, 0.9);
        cursor: pointer;

        img {
            vertical-align: top;
        }
    }
}
