/**
 * Header Section Block Styles
 *
 * Floating header: transparent outer wrapper with a white "pill" nav bar that
 * holds a logo (left), a menu and a button (right). Positioned absolutely so it
 * floats over the Banner Section below it.
 *
 * Reference design: child-theme-sections-screenshots/header-with-banner-section.png (top part)
 *
 * @package ACF Child Theme
 */

:root {
    --color-grey: #f3f3f3;
    --color-navy: #0d1e3b;
    --color-teal: #17abc1;
    --color-text: #252525;
    --color-blue: #004e95;
    --color-white: #ffffff;
    --font-primary: 'Montserrat', sans-serif;
}

/* Floating, transparent header wrapper
   ========================================================================== */
.header-section {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    width: 100%;
    padding-top: 40px;
    background: transparent;
    font-family: var(--font-primary), 'Montserrat', sans-serif;
    transition: padding-top 0.35s ease;
}

/* Compact state once the page is scrolled (toggled by JS). */
.header-section.is-scrolled {
    padding-top: 14px;
}

.header-section__container {
    max-width: var(--theme-normal-container-max-width, 1290px);
    width: var(--theme-container-width, 100%);
    margin: 0 auto;
    padding: 0 20px;
}

/* White pill nav bar
   ========================================================================== */
.header-section__nav {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    /* Reduced vertical padding compensates for the larger logo so the overall
       header height stays the same (~88px). */
    padding: 4px 32px;
    background-color: var(--color-white, #ffffff);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(13, 30, 59, 0.12);
    transition: padding 0.35s ease, box-shadow 0.35s ease;
}

.header-section.is-scrolled .header-section__nav {
    padding: 5px 32px;
    box-shadow: 0 6px 18px rgba(13, 30, 59, 0.18);
}

/* Logo
   ========================================================================== */
.header-section__logo {
    flex: 0 0 auto;
    line-height: 0;
}

.header-section__logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.header-section__logo-link img {
    display: block;
    height: 68px;
    width: auto;
    transition: height 0.35s ease;
}

.header-section.is-scrolled .header-section__logo-link img {
    height: 54px;
}

.header-section__logo-text {
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    color: var(--color-navy, #0d1e3b);
    letter-spacing: 0.02em;
}

/* Right-hand cluster: menu + button
   ========================================================================== */
.header-section__collapse {
    display: flex;
    align-items: center;
    gap: 32px;
}

.header-section__menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 28px;
}

.header-section__menu li {
    margin: 0;
}

.header-section__menu a {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-navy, #0d1e3b);
    text-decoration: none;
    transition: color 0.3s ease;
}

.header-section__menu a:hover,
.header-section__menu a:focus-visible,
.header-section__menu .current-menu-item > a,
.header-section__menu .current_page_item > a {
    color: var(--color-teal, #17abc1);
    outline: none;
}

/* Sub-menus (dropdowns)
   ========================================================================== */
.header-section__menu > li {
    position: relative;
}

/* Caret indicator on items that have children. */
.header-section__menu .menu-item-has-children > a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.header-section__menu .menu-item-has-children > a::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.3s ease;
}

.header-section__menu > li.menu-item-has-children:hover > a::after,
.header-section__menu > li.menu-item-has-children:focus-within > a::after {
    transform: translateY(1px) rotate(-135deg);
}

.header-section__menu .sub-menu {
    list-style: none;
    margin: 0;
    /* Sits flush under the parent; top padding keeps the hover bridge intact. */
    padding: 14px 0 8px;
    position: absolute;
    top: 100%;
    left: -14px;
    min-width: 220px;
    background-color: var(--color-white, #ffffff);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(13, 30, 59, 0.16);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    z-index: 20;
}

.header-section__menu > li:hover > .sub-menu,
.header-section__menu > li:focus-within > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.header-section__menu .sub-menu li {
    margin: 0;
}

.header-section__menu .sub-menu a {
    display: block;
    padding: 10px 22px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--color-navy, #0d1e3b);
    white-space: nowrap;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.header-section__menu .sub-menu a:hover,
.header-section__menu .sub-menu a:focus-visible {
    color: var(--color-teal, #17abc1);
    background-color: var(--color-grey, #f3f3f3);
}

/* Button (brand gradient)
   ========================================================================== */
.header-section__button {
    display: inline-block;
    padding: 13px 30px;
    font-family: var(--font-primary), 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
    color: var(--color-white, #ffffff);
    background: linear-gradient(to right, var(--color-teal, #17abc1), var(--color-blue, #004e95));
    border: none;
    border-radius: 10px;
    text-decoration: none;
    text-align: center;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.header-section__button:hover,
.header-section__button:focus-visible {
    color: var(--color-white, #ffffff);
    background: var(--color-navy, #0d1e3b);
    outline: none;
}

/* Hamburger toggle (hidden on desktop)
   ========================================================================== */
.header-section__toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    padding: 9px;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.header-section__toggle-bar {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--color-navy, #0d1e3b);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Toggle -> X animation when open */
.header-section__nav.is-open .header-section__toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.header-section__nav.is-open .header-section__toggle-bar:nth-child(2) {
    opacity: 0;
}

.header-section__nav.is-open .header-section__toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Responsive - Tablet (tighten spacing)
   ========================================================================== */
@media (min-width: 769px) and (max-width: 1023px) {
    .header-section__collapse {
        gap: 22px;
    }

    .header-section__menu {
        gap: 20px;
    }

    .header-section__menu a {
        font-size: 14px;
    }

    .header-section__button {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* Responsive - Mobile (hamburger + dropdown)
   ========================================================================== */
@media (max-width: 768px) {

    .header-section__container {
        width: 100%;
    }

    .header-section {
        padding-top: 16px;
    }

    .header-section__nav {
        flex-wrap: wrap;
        padding: 8px 14px;
    }

    .header-section__logo-link img {
        height: 40px;
    }
    
    .header-section.is-scrolled .header-section__logo-link img {
        height: 34px;
    }

    .header-section__toggle {
        display: flex;
    }

    .header-section__collapse {
        /* Collapsed by default; expands when the toggle adds .is-open. */
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 18px;
        width: 100%;
        margin-top: 14px;
        padding-top: 16px;
        border-top: 1px solid rgba(13, 30, 59, 0.1);
    }

    .header-section__nav.is-open .header-section__collapse {
        display: flex;
    }

    .header-section__menu {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        width: 100%;
    }

    .header-section__menu a {
        font-size: 16px;
    }

    .header-section__menu > li {
        width: 100%;
    }

    /* Sub-menus stack inline (indented) on mobile instead of floating. */
    .header-section__menu .menu-item-has-children > a {
        display: flex;
        width: 100%;
    }

    .header-section__menu .menu-item-has-children > a::after {
        margin-left: auto;
    }

    .header-section__menu .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        min-width: 0;
        margin: 10px 0 0;
        padding: 0 0 0 16px;
        background-color: transparent;
        border-radius: 0;
        box-shadow: none;
        border-left: 1px solid rgba(13, 30, 59, 0.12);
    }

    .header-section__menu .sub-menu a {
        padding: 8px 0;
        white-space: normal;
    }

    .header-section__menu .sub-menu a:hover,
    .header-section__menu .sub-menu a:focus-visible {
        background-color: transparent;
    }

    .header-section__button {
        align-self: flex-start;
    }
}

/* Respect users who prefer reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .header-section,
    .header-section__nav,
    .header-section__logo-link img {
        transition: none;
    }
}
