﻿
header {
    flex: 0 0 auto; /* Header should not grow or shrink */

    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    background-attachment: scroll; /*image is fixed, but content is scrollable*/

    position: sticky;
    top: 0;
    z-index: 1020;
    overflow-x: clip; /* iOS Safari: contain transformed mobile-nav items so they don't expand the layout viewport */
}

.header-wrapper {
    display: grid;
    padding: var(--large-gap) var(--pill-gap);
    will-change: padding;
    transition: padding ease-in-out 0.3s;
}

.header-row {
    grid-row: 1;
    grid-column: 1;
    display: flex;
    flex-direction: row;
    justify-content: start;
    align-items: center;
    gap: var(--pill-gap);
    height: var(--pill-h);
}

    .header-row:nth-child(1) {
        position: relative;
        z-index: 1; /* paint above row 2 so tooltips arent clipped behind it */
    }

    .header-row:nth-child(2) {
        margin-top: calc(var(--pill-h) + var(--pill-gap));
        transition: margin-top ease 0.3s;
    }

.header-pill-wrapper > .header-pill {
    position: relative;
}

    /* Tooltip */
    .header-pill-wrapper > .header-pill::after {
        content: attr(aria-label);
        position: absolute;
        top: calc(100% + 6px);
        left: 50%;
        transform: translateX(-50%);
        background-color: var(--gray-bg);
        padding: 2px var(--pill-gap);
        border-radius: calc(var(--pill-h) / 2);
        white-space: nowrap;
        font-size: 1.4rem;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s ease;
    }

    .header-pill-wrapper > .header-pill:hover::after {
        opacity: 1;
    }

.header-pill-wrapper{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: var(--pill-gap);
}

.header-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--gray-bg);
    height: var(--pill-h);
    min-width: var(--pill-h);
    border-radius: calc(var(--pill-h) / 2);
    gap: var(--pill-gap);
    /* <button> pills don't inherit the site font/color by default (the UA gives
       them a smaller system font + buttontext color), so their text looked
       different from the <a> pills next to them. Force inheritance so button and
       anchor pills render identically -- keep new pills consistent for free. */
    font: inherit;
    color: inherit;
}

.header-pill--grow {
    flex-grow: 2;
    justify-content: start;
    padding: 0 calc(var(--pill-gap) * 2);
}

    .header-pill--grow > h1 {
        margin-bottom: 0;
        margin-right: 200px;
        transition: margin-right ease 0.5s;
        max-width: 55vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: normal;
    } 

    .header-pill--grow > .header-a {
        margin-right: var(--medium-gap);
    }

    .header-pill--grow > .header-a:last-child {
        margin-right: 0;
    }

.header-logo {
    height: calc(var(--pill-h) - var(--pill-gap));
    aspect-ratio: 1;
    /* Logos are stored as squares and displayed as circles */
    border-radius: 50%;
    object-fit: cover;
}

.header-icon {
    width: calc(var(--pill-h) / 2.3);
    height: calc(var(--pill-h) / 2.3);
}

.header-a {
    display: flex;
    align-items: center;
    gap: var(--pill-gap);
    position: relative;
}

    /* Tooltip */
    .header-wrapper--minimized .header-a::after {
        content: attr(aria-label);
        position: absolute;
        top: calc(100% + 6px);
        left: 50%;
        transform: translateX(-50%);
        background-color: var(--gray-bg);
        padding: 2px var(--pill-gap);
        border-radius: calc(var(--pill-h) / 2);
        white-space: nowrap;
        font-size: 1.4rem;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s ease;
        z-index: 1050;
    }

    /* :has() limits hover to the icon only, avoiding the invisible-but-present span */
    .header-wrapper--minimized .header-a:has(.header-icon:hover)::after {
        opacity: 1;
    }

    .header-a > span {
        max-width: 16ch;
        opacity: 1;
        will-change: max-width;
        transition: max-width ease 0.1s;
    }

/* Maximized/Minimized Overwrites */

.header-wrapper--minimized {
    padding: calc(var(--pill-gap) * 2) var(--pill-gap);
}

.header-wrapper--maximized > .header-row {
    width: 100%;
}

.header-wrapper--minimized > .header-row {
    width: auto;
}

    .header-wrapper--minimized > .header-row:nth-child(1) {
        margin-left: 0;
        margin-right: auto;
    }

    .header-wrapper--minimized > .header-row:nth-child(2) {
        margin-top: 0px;
        margin-left: auto;
        margin-right: 0;
    }

.header-wrapper--minimized .header-a {
    gap: 0;
}


.header-wrapper--minimized .header-a > span {
    max-width: 0;
    opacity: 0;
    transition: max-width ease 0.5s;
}

.header-wrapper--minimized .header-pill--grow > h1 {
    margin-right: 0;
}

/* Prevent stutter from scroll anchoring during animation */
html.is-animating {
    overflow-anchor: none;
}

/* ------------------------------------------------------------ */
/*                  Accesibility                                */

@media (prefers-reduced-motion: reduce) {
    .header-wrapper, .header-row, .header-pill--grow > h1, .header-a > span,
    .header-a::after, .header-pill-wrapper > .header-pill::after,
    .nav-mobile > .header-pill, .nav-mobile-backdrop {
        transition: none !important;
    }

    .nav-mobile > .header-pill {
        transform: none !important;
        filter: none !important;
    }
}

/* ------------------------------------------------------------ */
/*                  Mobile                                      */

.header-menu-btn {
    display: none;
    padding: 0;
    z-index: 1000;
}

.nav-mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .35); 
    opacity: 0;
    pointer-events: none;
    transition: opacity 2s ease;
    z-index: 999; /* below nav panel that will be 1000 */
}

.nav-mobile-backdrop--open {
    opacity: 1;
    pointer-events: auto;
}

.nav-mobile {
    display: flex;
    flex-direction: column;
    align-items: end;
    padding-top: var(--pill-gap);
    gap: var(--pill-gap);
    /* position the mobile nav */
    position: absolute;
    right: var(--pill-gap);
    top: calc(var(--pill-gap) * 2 + var(--pill-h));
    z-index: 1000;
    /*opacity: 0;*/
    pointer-events: none;
    transition: opacity .8s ease;
}

    .nav-mobile > .header-pill {
        padding: 0 var(--medium-gap);
        /* Slide-in animation */
        opacity: 0;
        transform: translateX(100%);
        filter: blur(6px);
        transition: opacity 0.25s ease, transform 0.25s ease, filter 0.25s ease;
        transition-delay: calc(var(--i, 0) * 0.06s);
        /* Promote to own compositor layer in Safari to avoid blur/transform jank */
        will-change: transform, opacity, filter;
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }

.nav-mobile--open {
    pointer-events: auto;
}

    .nav-mobile--open > .header-pill {
        opacity: 1;
        transform: translateX(0);
        filter: blur(0);
    }

@media (max-width: 850px) {
    .header-wrapper {
        padding: calc(var(--pill-gap) * 2) var(--pill-gap);
    }

    .header-row:nth-child(2) {
        display: none;
    }

    .header-row:nth-child(1) {
        width: 100% !important;
    }

        .header-row:nth-child(1) > .header-pill-wrapper {
            display: none;
        }

    .header-pill--grow > h1 {
        margin-right: 0;
    }

    .header-menu-btn {
        display: flex;
    }
}


/* Keep old header styles to prevent breaking something else */
    .mk-icon {
    width: calc(var(--pill-h) / 2.3);
    height: calc(var(--pill-h) / 2.3);
}



/* -------- ----------- -------- */
/* -------- Mobile Menu -------- */

/*.mk-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .35);*/ /* slate-ish */
    /*opacity: 0;
    pointer-events: none;
    transition: opacity 2s ease;
    z-index: 999;*/ /* below the header/nav panel that will be 1000 */
/*}*/

/* Base visibility */
/*.mk-menu-toggle {
    display: none;
}

.nav-desktop {
    display: flex;
}

.nav-mobile {
    display: none;
}*/

/* Stack the nav vertically when open, and hide it by default on small screens */
/*@media (max-width: 850px) {
    .mk-header-grid {
        padding: var(--medium-gap) 0;
    }*/
    /* show hamburger */
    /*.mk-menu-toggle {
        display: inline-flex;
    }*/
    /* hide desktop nav */
    /*.nav-desktop {
        display: none;
    }*/
    /* allow JS to show it */
    /*.nav-mobile {
        display: block;
    }*/
    /* hide icons */
    /*.mk-icons {
        display: none;
    }

    .mk-header-a {
        height: var(--pill-h);
    }*/

    /* Drawer panel */
    /*#mkMobileNav[hidden] {
        display: none !important;
    }

    #mkMobileNav {
        position: absolute;*/
        /*left: 0;*/
        /*right: 0;
        top: 80%;*/ /* almost under header */
        /*z-index: 1000;
        padding: calc(var(--pill-gap, 8px));
        opacity: 0;
        pointer-events: none;
        transition: opacity .8s ease;
    }*/

        /* Vertical list */
        /*#mkMobileNav .mk-nav-list {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        #mkMobileNav .mk-pill {
            justify-content: flex-end;
            transition: transform .2s ease, opacity .2s ease;
        }

        #mkMobileNav .mk-header-a p {
            max-width: 100%;
        }*/

    /* Open state via .is-menu-open on header */
    /*.is-menu-open #mkMobileNav {
        opacity: 1;
        pointer-events: auto;
        display: flex;
        flex-direction: column;
        gap: var(--pill-gap);
        align-items:end;
    }*/

    /* Backdrop show state */
    /*.is-menu-open .mk-backdrop {
        opacity: 1;
        pointer-events: auto;
    }*/

    /* Backdrop show state */
    /*.is-menu-open .mk-menu-toggle {
        z-index: 1000;
    }

    
}*/

/* Optional: small transition when the menu opens */
/*.mk-header .mk-header-row[aria-label="Navigation"] {
    transition: transform .2s ease, opacity .2s ease;
}

.mk-header.is-menu-open .mk-header-row[aria-label="Navigation"] {
    transform: translateY(0);
    opacity: 1;
}*/
