
.menu {
    position: relative;
    z-index: 10;
    width: 100%;
    align-self: flex-start;
    text-align: left;

    .dropdown-menu {
        position: absolute !important; // stylelint-disable-line declaration-no-important
    }
}

.menu__link {
    display: inline-block;
    padding: $spacer ($spacer / 2);
    box-shadow: none;
    position: relative;
    line-height: 1;

    &:first-child {
        padding-left: 0;
    }

    @media ($screen-md) {
        &,
        &:first-child {
            padding: ($spacer * 2) $spacer;
        }
    }

    // link line
    &:not(.dropdown-toggle):after {
        content: '';
        position: absolute;
        height: 2px;
        width: 30px;
        background: #fff;
        display: block;
        left: 50%;
        margin-left: -15px;
        bottom: ($spacer / 2);
        // hidden by default
        transform: scale(0);
        transform-origin: center;
        transition: transform .2s ease-out;

        @media ($screen-md) {
            bottom: $spacer * 1.3;
        }
    }

    &:hover,
    &:focus,
    &.active {
        background: transparent;
        // show link line
        &:after { transform: scale(1); }
    }
}

.menu__logo {
    display: inline-block;
    box-shadow: none;
    padding-top: $spacer;

    @media ($screen-md) {
        padding-top: 0;
        vertical-align: middle;
    }

    svg {
        @extend .transition;
        opacity: .8;
        display: inline;

        @media ($screen-md) {
            display: inline-block;
        }
    }

    &:hover,
    &:focus {
        background: transparent;

        svg { opacity: 1; }
    }
}

.menu__hiring {
    @extend .small;
    color: $brand-main-green;
    box-shadow: none;
    padding: $spacer ($spacer / 4);
    display: inline-block;

    @media ($screen-md) {
        margin-left: $spacer;
    }

    &:hover,
    &:focus {
        background: transparent;
        color: $link-hover-bg;

        .icon {
            stroke: $link-hover-bg;
        }
    }

    .icon {
        @extend .transition;
        width: $font-size-sm;
        height: $font-size-sm;
        stroke: $brand-main-green;
        stroke-width: 1.5;
        margin-bottom: -1px;
    }
}

//
// Main menu overlaying a dark background image
// in front page hero or page headers
//
.menu--main {
    background: rgba($brand-main-blue-dark, .35);
    backdrop-filter: saturate(150%) blur(10px);
    border-bottom: 1px solid rgba($brand-main-gray, .5);
    padding-top: ($spacer / 2);
    padding-bottom: ($spacer / 2);

    .grid__col--2 {
        display: flex;
        justify-content: space-between;

        @media ($screen-md) {
            display: block;
            white-space: nowrap;
        }
    }

    .menu__logo {
        margin-bottom: ($spacer / 2);

        @media ($screen-md) {
            margin-bottom: 0;
        }
    }

    .menu__link {
        color: #fff;
        opacity: .9;

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

    @media ($screen-md) {
        padding-top: 0;
        padding-bottom: 0;
        text-align: right;
    }
}

.menu-overflow {
    // yummy scrolling
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-left: -$gutter-space / 2;
    margin-right: -$gutter-space / 2;
    padding-left: $gutter-space / 2;
    padding-right: $gutter-space / 2;
    text-align: center;

    &::-webkit-scrollbar { display: none; }

    @media ($screen-md) {
        margin: 0;
        padding: 0;
        white-space: normal;
        overflow: visible;
        text-align: right;
    }
}

//
// Footer Menu
//
.menu--footer {
    .grid__col {
        &:nth-child(2) {
            margin-top: $spacer;

            @media ($screen-sm) {
                margin-top: 0;
            }
        }
    }

    .menu__logo {
        margin-top: ($spacer / 3);
        margin-bottom: 0;

        svg {
            @media ($screen-sm) {
                margin: 0;
            }
        }
    }

    .menu__link {
        @extend .small;
        padding: ($spacer / 2) ($spacer / 4);
        color: $text-color;

        @media ($screen-sm) {
            display: block;
            text-align: left;
            padding: ($spacer / 2);
        }

        // hide link line
        &:after { display: none; }

        &:hover,
        &:focus,
        &.active { color: $brand-primary; }
    }
}

.footer__copyright {
    border-top: 1px solid $brand-main-gray;
    text-align: center;
    display: block;
    margin-top: ($spacer * 2);
    padding-top: ($spacer * 2);

    @media ($screen-md) {
        padding-bottom: $spacer * 2;
        text-align: left;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .menu__link {
        display: inline-block;
        text-transform: none;

        @media ($screen-md) {
            padding: 0 $spacer;
        }

        &:first-child { margin-left: ($spacer / 2); }
        &:last-child { padding-right: 0; }
    }

    &,
    small,
    .menu__link {
        @extend .mini;
        color: $gray-light;
    }
}

//
// ERDF logo
//
.erdf {
    display: block;
    margin-top: $spacer * 2;
    margin-bottom: $spacer;
    box-shadow: none;
    text-align: center;

    @media ($screen-md) {
        margin: 0;
    }

    &:hover,
    &:focus {
        background: none;

        .logo-erdf {
            fill: $brand-main-green;
        }
    }
}

.logo-erdf {
    @extend .transition;
    fill: $gray-light;
    width: 122px;
    height: 30px;
    display: inline-block;
}

//
// On-page sub menu
//
.menu--sub {
    @include transition;
    transform: translate3d(0, 0, 0);
    background: lighten($gray, 30%);

    .menu__link {
        color: $gray-dark;
        margin-left: $spacer;
        margin-right: $spacer;

        &:after {
            display: none;
        }

        &.active {
            color: darken($gray-dark, 10%);
        }
    }

    .menu-overflow {
        text-align: center;
    }

    .icon {
        width: 1rem;
        height: 1rem;
        vertical-align: baseline;
        margin-right: $spacer / 6;
        margin-bottom: -2px;
        stroke-width: 4px; // that's weird
        color: $gray;
        stroke: $gray-dark;
    }

    .number {
        text-align: center;
        display: inline-block;
        width: 1rem;
        height: 1rem;
        border-radius: 50%;
        font-size: $font-size-xs;
        vertical-align: .1rem;
        background: $gray;
        color: $gray-light;
        font-weight: $font-weight-bold;
        line-height: 1rem;
        margin-right: .2rem;
        margin-left: -1.2rem;
    }
}

.menu--sub.sticky {
    background: rgba(lighten($gray, 30%), .85);
    backdrop-filter: saturate(200%) blur(10px);
    box-shadow: 0 2px 6px rgba($gray-dark, .4);

    // fake less padding and smaller menu bar
    // for performant and smoooth transition
    transform: translate3d(0, -2rem, 0);

    .menu__link {
        @media ($screen-sm) {
            transform: scale(.85) translate3d(0, .6rem, 0);
            transform-origin: bottom;
        }

        &.active {
            color: $headings-color;

            .number {
                background: $headings-color;
                color: $gray;
            }
        }
    }
}

//
// Sticky sub menu
//
body {
    position: relative;
}

.sticky {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 2;

    @supports (position: sticky) {
        position: sticky;
    }
}
