/*
 * Rivera — Header
 *
 * Four blocks live here, each usable on its own:
 *   .header        — the dark navy band: logo, tagline, languages, burger
 *   .lang-switcher — flag circles with a country label
 *   .main-nav      — the maroon bar with the main menu (desktop)
 *   .mobile-nav    — the same menu stacked, opened by the burger (<1024)
 *
 * The design was drawn for a ~1720px container; the project settled on 1380,
 * so the header is the design scaled to that width and then trimmed: the logo
 * and tagline are deliberately smaller than a straight 0.8 scale, and the menu
 * bar is a single line of text instead of the design's two.
 *
 * Outer geometry belongs to the parent, so .lang-switcher, .main-nav and
 * .mobile-nav carry no margins of their own.
 */

/* ── Header ─────────────────────────────────────────────────────────────── */
.header {
    /* Transparent: the glow behind the logo is the page's own ground (.site in
     * main.css), so it runs on under the menu without a seam. */
    background-color: transparent;
}

/* A block normally leaves outer positioning to its parent. This is the
 * exception: sticking to the viewport is a property of the header itself,
 * toggled from the Customizer, and no parent block owns that decision. */
.header--sticky {
    position:         sticky;
    top:              0;
    z-index:          var(--z-sticky);
    /* A header that stays on screen needs a ground of its own, or the page
     * would scroll visibly underneath it. */
    background-color: var(--header-bg);
}

.header__top {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             30px;
    padding:         28px 0;
}

/* ── Brand: logo + tagline ──────────────────────────────────────────────── */
.header__brand {
    display:         flex;
    align-items:     center;
    justify-content: flex-start;
    gap:             26px;
    flex:            1 1 auto;
    min-width:       0;
}

/* The logo is dropped in by the client, so constrain it here rather than
 * trusting whatever dimensions the uploaded file happens to have. */
.header__logo {
    display:         inline-flex;
    align-items:     center;
    flex:            0 1 auto;
    min-width:       0;
    text-decoration: none;
}

.header__logo-img {
    display:    block;
    width:      auto;
    height:     auto;
    max-width:  100%;
    max-height: 136px;
}

.header__logo--text {
    color:          var(--color-secondary);
    overflow-wrap:  anywhere;
    font-size:      24px;
    font-weight:    700;
    letter-spacing: 1px;
    text-transform: var(--tt-heading);
}

.header__tagline {
    display:        flex;
    flex-direction: column;
    gap:            6px;
    margin:         0;
    color:          var(--color-orange);
    font-size:      17px;
    font-weight:    700;
    line-height:    1.2;
    letter-spacing: 0.5px;
    text-transform: var(--tt-heading);
}

/* Two lines, and only two — each is its own span in a column flex, so the pair
 * is structural. No white-space: nowrap here on purpose: it does not create the
 * break (the markup already does), it only stops a long line from ever
 * shrinking, which pushed the tagline over the language switcher. */
.header__tagline-line {
    display: block;
}

/* ── Language switcher ──────────────────────────────────────────────────── */
.lang-switcher {
    line-height: 1;
}

.header__lang-switcher {
    flex: 0 0 auto;
}

.lang-switcher__list {
    display:    flex;
    gap:        4px;
    margin:     0;
    padding:    0;
    list-style: none;
}

.lang-switcher__link {
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    gap:             4px;
    text-decoration: none;
    color:           var(--color-secondary);
}

/* A round flag needs a square source; WPML ships 18x12 rectangles, so the
 * image is scaled to fill and cropped by the circle rather than squashed. */
.lang-switcher__flag {
    display:       block;
    width:         30px;
    height:        30px;
    border-radius: 50%;
    object-fit:    cover;
    border:        1px solid var(--color-secondary);
    transition:    transform var(--transition);
}

.lang-switcher__label {
    font-size:      var(--fs-label-sm);
    font-weight:    700;
    letter-spacing: 0.5px;
    line-height:    1;
    color:          var(--color-sky);
    transition:     color var(--transition);
}

.lang-switcher__link:hover .lang-switcher__flag,
.lang-switcher__link:focus-visible .lang-switcher__flag {
    transform: scale(1.12);
}

.lang-switcher__link:hover .lang-switcher__label,
.lang-switcher__link:focus-visible .lang-switcher__label {
    color: var(--color-orange);
}

.lang-switcher__item--current .lang-switcher__flag {
    border-color: var(--color-orange);
}

.lang-switcher__item--current .lang-switcher__label {
    color: var(--color-orange);
}

/* ── Burger ─────────────────────────────────────────────────────────────── */
/* Hidden on desktop, where the maroon bar carries the menu.
 *
 * 40x40 with an 18px icon inside. That is below the 44px tap target the
 * platform guidelines ask for, but it is the only control in its corner with
 * nothing to mis-tap into, and the design wants it compact. The cross state
 * shifts each outer bar by 6px — half the 2px bar plus the 4px gap — so the
 * three lines meet exactly in the middle. */
.header__burger {
    display:         none;
    flex-direction:  column;
    justify-content: center;
    gap:             4px;
    width:           40px;
    height:          40px;
    padding:         11px;
    border:          0;
    border-radius:   var(--radius);
    background:      var(--color-maroon);
    cursor:          pointer;
    transition:      background-color var(--transition);
}

.header__burger:hover,
.header__burger:focus-visible {
    background: var(--color-maroon-hi);
}

.header__burger-bar {
    display:    block;
    height:     2px;
    background: var(--color-secondary);
    transition: transform var(--transition), opacity var(--transition);
}

.header__burger--active .header__burger-bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.header__burger--active .header__burger-bar:nth-child(2) {
    opacity: 0;
}

.header__burger--active .header__burger-bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ── Main navigation (desktop) ──────────────────────────────────────────── */
/* Full-width row that carries no look of its own — the maroon bar is .main-nav
 * inside the container, so it lines up with the rest of the content. */
.header__bottom {
    width: 100%;
}

.main-nav {
    background-color: var(--header-nav-bg);
}

/* Nine items, two lines each, as the design draws them: the labels are split
 * in inc/nav.php and each line is a block, so the break is always the same
 * whatever the width. Sizes are the design's (a 1918px bar) scaled to this
 * 1340px container, ×0.7 (84px end insets → 47px, less the link's own 12px);
 * the type is 16px throughout, by the client's call, and the bar 94px tall.
 *
 * At 16px the nine labels need about 700px, so the row has room to spare at
 * every width the bar is shown (from 1024px up). */
.main-nav__list {
    display:         flex;
    align-items:     stretch;
    justify-content: space-between;
    flex-wrap:       nowrap;
    margin:          0;
    padding:         0 35px;
    list-style:      none;
}

.main-nav__item {
    position: relative;
    flex:     0 0 auto;
}

.main-nav__link {
    display:         flex;
    flex-direction:  column;
    justify-content: center;
    height:          100%;
    min-height:      94px;
    padding:         18px 12px;
    color:           var(--color-secondary);
    font-size:       16px;
    font-weight:     700;
    line-height:     1.25;
    text-decoration: none;
    white-space:     nowrap;
    transition:      background-color var(--transition), color var(--transition);
}

.main-nav__line {
    display: block;
}

.main-nav__link:hover,
.main-nav__link:focus-visible {
    background-color: var(--color-maroon-hi);
}

.main-nav__item--current .main-nav__link {
    color: var(--color-orange);
}

/* Submenus: in the DOM at load, hidden with CSS. Crawlers do not click, so
 * building them on hover would make the links invisible to search. */
.main-nav__submenu {
    position:         absolute;
    top:              100%;
    left:             0;
    z-index:          var(--z-dropdown);
    min-width:        220px;
    margin:           0;
    padding:          6px 0;
    list-style:       none;
    background-color: var(--color-maroon);
    box-shadow:       var(--shadow);
    opacity:          0;
    visibility:       hidden;
    transform:        translateY(8px);
    transition:       opacity var(--transition), transform var(--transition), visibility var(--transition);
}

.main-nav__item:hover .main-nav__submenu,
.main-nav__item:focus-within .main-nav__submenu {
    opacity:    1;
    visibility: visible;
    transform:  translateY(0);
}

.main-nav__sublink {
    display:         block;
    padding:         10px 18px;
    color:           var(--color-secondary);
    font-size:       14px;
    text-decoration: none;
    transition:      background-color var(--transition);
}

.main-nav__sublink:hover,
.main-nav__sublink:focus-visible {
    background-color: var(--color-maroon-hi);
}

/* ── Burger panel ───────────────────────────────────────────────────────── */
/* Everything the burger opens: on tablets just the menu, on phones the tagline
 * and the language switcher as well. Removed outright above the tablet
 * breakpoint, so a stale open class can never reveal it on a desktop, and the
 * duplicated links and flags stay out of the accessibility tree while their
 * header-row copies are the live ones. It turns into an animated grid inside
 * the media query. */
.header__panel {
    display: none;
}

.header__tagline--panel,
.header__lang-switcher--panel {
    display: none;
}

.mobile-nav__list {
    margin:     0;
    padding:    0;
    list-style: none;
}

/* Every row carries its own rule; the first one doubles as the panel's top
 * edge, which saves an adjacent-sibling selector coupling the item to its
 * neighbour. */
.mobile-nav__item {
    border-top: 1px solid var(--color-border);
}

.mobile-nav__link {
    display:         block;
    padding:         16px 0;
    color:           var(--color-secondary);
    font-size:       18px;
    font-weight:     700;
    line-height:     1.3;
    text-decoration: none;
    transition:      color var(--transition);
}

.mobile-nav__link:hover,
.mobile-nav__link:focus-visible {
    color: var(--color-orange);
}

.mobile-nav__item--current .mobile-nav__link {
    color: var(--color-orange);
}

/* Second level sits open in the flow: there is no hover on touch, and a
 * tap-to-expand would hide the links from crawlers that do not click. */
.mobile-nav__submenu {
    margin:     0;
    padding:    0 0 8px 16px;
    list-style: none;
}

.mobile-nav__sublink {
    display:         block;
    padding:         12px 0;
    color:           var(--color-sky);
    font-size:       16px;
    text-decoration: none;
    transition:      color var(--transition);
}

.mobile-nav__sublink:hover,
.mobile-nav__sublink:focus-visible {
    color: var(--color-secondary);
}

/* ── Narrow desktop ─────────────────────────────────────────────────────── */
/* Below a 1440px window the container stops being 1380; the header and the
 * menu bar step down in two stages. */
@media (max-width: 1439px) {
    .header__top {
        padding: 22px 0;
    }

    .header__logo-img {
        max-height: 116px;
    }

    .header__logo--text {
        font-size: 21px;
    }

    .header__tagline {
        gap:       4px;
        font-size: 15px;
    }

    .main-nav__list {
        padding: 0 16px;
    }

    .main-nav__link {
        min-height: 94px;
        padding:    18px 10px;
    }
}

/* Under a 1280px window the container is down to 1232px and less; the two-line
 * labels and the 16px type stay, only the insets step down. */
@media (max-width: 1279px) {
    .main-nav__list {
        padding: 0 6px;
    }

    .main-nav__link {
        min-height: 84px;
        padding:    14px 8px;
    }
}

/* ── Tablet ─────────────────────────────────────────────────────────────── */
/* Nine items at desktop size need ~1700px. Below that the bar is dropped and
 * the burger takes over — a squeezed bar would wrap into four cramped rows. */
@media (max-width: 1023px) {
    .header__top {
        gap:     20px;
        padding: 18px 0;
    }

    .header__brand {
        gap: 20px;
    }

    .header__logo-img {
        max-height: 104px;
    }

    .header__logo--text {
        font-size: 19px;
    }

    .header__tagline {
        gap:       4px;
        font-size: 14px;
    }

    .header__lang-switcher {
        align-self: center;
    }

    .lang-switcher__flag {
        width:  26px;
        height: 26px;
    }

    .header__burger {
        display: flex;
        order:   3;
    }

    .header__bottom {
        display: none;
    }

    /* An overlay over the page, from under the header row down to the bottom
     * edge. The offset comes from js/main.js, which measures the row — it
     * changes with the breakpoint and with whatever logo the client uploads,
     * so hard-coding it would break the first time either changes.
     *
     * It unrolls downwards on its height rather than sliding in on a
     * transform: the panel sits flush under the header row, so a translate
     * would have to travel over that row unless something clipped it. Growing
     * from zero starts it exactly at the row's edge and needs no stacking
     * order games. Both ends are definite lengths, so the value interpolates.
     *
     * dvh, not vh: on phones vh counts the address bar that is not there. */
    .header__panel {
        display:             block;
        position:            fixed;
        top:                 var(--header-panel-top, 80px);
        left:                0;
        right:               0;
        z-index:             var(--z-modal);
        height:              0;
        overflow-y:          auto;
        overscroll-behavior: contain;
        background-color:    var(--header-bg);
        visibility:          hidden;
        transition:          height var(--transition-slow),
                             visibility var(--transition-slow);
    }

    .header__panel--open {
        height:     calc(100vh - var(--header-panel-top, 80px));
        height:     calc(100dvh - var(--header-panel-top, 80px));
        visibility: visible;
    }

    .header__panel-inner {
        padding-top:    8px;
        padding-bottom: 32px;
    }
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
/* The top row keeps the logo and the burger, and nothing else: the tagline and
 * nine flags have no room beside a 44px logo, so both move into the panel the
 * burger opens. */
@media (max-width: 767px) {
    .header__top {
        align-items: center;
        gap:         12px;
        padding:     14px 0;
    }

    .header__logo-img {
        max-height: 88px;
    }

    .header__logo--text {
        font-size: 16px;
    }

    .header__tagline--top,
    .header__lang-switcher--top {
        display: none;
    }

    .header__tagline {
        gap:       2px;
        font-size: 15px;
    }

    .header__tagline--panel {
        display: flex;
        padding: 16px 0 14px;
    }

    .header__lang-switcher--panel {
        display:        block;
        padding-bottom: 16px;
    }

    .lang-switcher__list {
        flex-wrap: wrap;
        gap:       8px;
    }

    .mobile-nav__link {
        padding:   14px 0;
        font-size: 17px;
    }

    .mobile-nav__sublink {
        padding: 11px 0;
    }
}

/* Opening is decoration; for anyone who asked the system for less motion the
 * panel just appears. Kept at the top level — a media query nested inside
 * another one is valid CSS, but not worth the parser risk for one declaration. */
@media (prefers-reduced-motion: reduce) {
    .header__panel {
        transition: none;
    }
}

/* Page scroll while the overlay is open. Set on <body> from js/main.js. */
.no-scroll {
    overflow: hidden;
}
