/* ==========================================================================
   HEADER + MAIN MENU
   Desktop: 830px container, centered on the page. Logo and menu are
   left-aligned inside it (menu below the logo).
   Mobile (<= 889px): logo left, toggle button right, menu opens below.
   ========================================================================== */

/* sticky (not fixed): sits below the WP admin bar at any screen width.
   no paint containment here, because the mobile menu overlays the page below the header. */
.header {
    contain: layout style;
    position: sticky;
    top: var(--admin-bar-height);
    z-index: 5;
    height: var(--header-height);
    background: var(--color-white);
    box-shadow: 0 0 .5rem 0 rgba(29, 29, 29, .2);
}

.header-bar,
.header-nav {
    max-width: 830px;
    margin: 0 auto;
}

.header-logo {
    display: block;
    width: 29rem;
    margin: 3.5rem 0 3rem;
}

/* checkbox is visually hidden, but stays keyboard-focusable */
.header-check {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.header-toggle {
    display: none;
    cursor: pointer;
}

.header-check:focus-visible ~ .header-bar .header-toggle {
    outline: 2px solid var(--color-blue);
    outline-offset: .4rem;
}

.header-toggle img {
    display: block;
    width: 3.4rem;
    height: 2.4rem;
}

.header-menu {
    display: flex;
    gap: 4rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.header-menu a {
    display: inline-block;
    font-size: 2rem;
    color: var(--color-blue);
    border-bottom: 2px solid transparent;
}

.header-menu a:hover,
.header-menu a:focus {
    border-bottom-color: var(--color-blue);
}

.header-menu .current-menu-item > a,
.header-menu .current-menu-parent > a {
    font-weight: 700;
    color: var(--color-red);
    border-bottom-color: var(--color-red);
}

/* overrides --header-height of style.css, so this file must be loaded after it. */
@media (max-width: 889px) {

    :root {
        --header-height: 7rem;
    }

    .header-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: var(--header-height);
        margin: 0 1.5rem;
    }

    .header-logo {
        width: 22rem;
        margin: 0;
    }

    .header-toggle {
        display: block;
    }

    /* slide down: animate the row height from 0fr to 1fr */
    .header-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        display: grid;
        grid-template-rows: 0fr;
        max-width: none;
        background: var(--color-white);
        box-shadow: 0 .5rem .5rem 0 rgba(29, 29, 29, .2);
        visibility: hidden;
        transition: grid-template-rows .4s ease-out, visibility 0s .4s;
    }

    .header-check:checked ~ .header-nav {
        grid-template-rows: 1fr;
        visibility: visible;
        transition-delay: 0s;
    }

    .header-menu {
        display: block;
        min-height: 0;
        padding: 0;
        overflow: hidden;
    }

    .header-menu li:first-child {
        padding-top: .5rem;
    }

    .header-menu li:last-child {
        padding-bottom: .5rem;
    }

    /* link spans the full row; the underline moves to the text span */
    .header-menu a {
        display: block;
        padding: 1rem 1.5rem;
        border-bottom: 0;
    }

    .header-menu-text {
        display: inline-block;
        border-bottom: 2px solid transparent;
    }

    .header-menu a:hover .header-menu-text,
    .header-menu a:focus .header-menu-text {
        border-bottom-color: var(--color-blue);
    }

    .header-menu .current-menu-item > a .header-menu-text,
    .header-menu .current-menu-parent > a .header-menu-text {
        border-bottom-color: var(--color-red);
    }
}

@media (min-width: 640px) and (max-width: 889px) {

    .header-bar {
        margin: 0 3rem;
    }
}

/* without menu: logo height (svg viewBox 187x27) + its vertical margins */
@media (min-width: 890px) {

    :root:has(.header--no-menu) {
        --header-height: calc(29rem * 27 / 187 + 6.5rem);
    }
}


/* ==========================================================================
   HEADER IMAGE
   Default banner, overridable via the featured image of a page/post.
   ========================================================================== */

.header-image {
    position: relative;
    contain: content;
    height: 25rem;
}

.header-image picture {
    display: block;
    height: 100%;
}

.header-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* ai labeling icon of the header image: bottom right corner.
   on wide screens it aligns with the right edge of the 830px content area. */
.header-image .header-image-ai-label {
    position: absolute;
    right: max(1.2rem, calc((100% - 830px) / 2));
    bottom: 1.2rem;
    width: 11rem;
    height: auto;
}
