/* ============================================================
   HEADER.CSS
   ============================================================ */

header {
    position: sticky;
    top: var(--space-md);
    z-index: 100;

    max-width: var(--wrap-max-wide);
    width: calc(100% - 2 * var(--space-md));
    margin-top: var(--space-md);
    margin-inline: auto;

    background-color: var(--color-primary);
    border-radius: var(--radius-md);
    overflow: visible;

    transition: background-color 0.4s ease, border-radius 0.1s ease 0.25s;
}


/* ------------------------------------------------------------
   Main row
   ------------------------------------------------------------ */

.header-main {
    display: flex;
    align-items: center;
    height: 64px;
    padding-inline: var(--space-xl);
    position: relative;
}

/* Logo — anchors left, natural width so hover zone is text only */
.logo {
    font-family: var(--font-heading);
    font-weight: bold;
    font-size: var(--text-lg);
    color: #ffffff;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.logo:hover {
    color: #ffffff;
    opacity: 0.75;
}

/* Centre nav — absolutely centred so logo can be natural width */
.nav-center {
    display: flex;
    gap: var(--space-xl);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* Right nav — pushed to the far right */
.nav-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-xl);
    margin-left: auto;
}

/* Shared nav link styles */
.nav-center a,
.nav-right a {
    font-family: var(--font-body);
    font-weight: normal;
    font-size: var(--text-base);
    color: #ffffff;
    text-decoration: none;
    text-transform: lowercase;
    letter-spacing: 0.03em;
    opacity: 0.85;
    transition: opacity 0.2s ease, font-weight 0s 0.1s;
}

.nav-center a:hover,
.nav-right a:hover,
.nav-center a.active,
.nav-right a.active {
    font-family: var(--font-heading);
    font-weight: bold;
    opacity: 1;
}

/* Hidden bold copy of the text — pre-reserves the wider space so bold never shifts layout */
.nav-center a::after,
.nav-right a::after {
    content: attr(data-text);
    font-family: var(--font-heading);
    font-weight: bold;
    display: block;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
}


/* ------------------------------------------------------------
   About dropdown trigger
   ------------------------------------------------------------ */

.dropdown {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    cursor: pointer;
}

.chevron {
    width: 13px;
    height: 13px;
    color: #ffffff;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

/* Rotate chevron when expanded */
header:has(.dropdown:hover) .chevron,
header:has(.header-expanded:hover) .chevron {
    transform: rotate(180deg);
}

/* Keep "about" bold and full opacity while the expanded panel is open */
header:has(.header-expanded:hover) .dropdown a {
    font-family: var(--font-heading);
    font-weight: bold;
    opacity: 1;
}

/* Square off bottom corners when panel is open — snap immediately on open, delay on close */
header:has(.dropdown:hover),
header:has(.header-expanded:hover) {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    transition: border-radius 0s;
}


/* ------------------------------------------------------------
   Expanded panel — full-width, reveals below the main row
   ------------------------------------------------------------ */

.header-expanded {
    /* Float over page content — does not affect document flow */
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;

    background-color: var(--color-primary);
    border-radius: 0 0 var(--radius-md) var(--radius-md);

    /* Hidden by default */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, background-color 0.4s ease;
}

/* Inner div carries the padding so it doesn't leak through the overflow clip */
.header-expanded-inner {
    display: flex;
    gap: var(--space-xl);
    padding-inline: var(--space-xl);
    padding-top: var(--space-md);
    padding-bottom: var(--space-xl);
}

.dropdown-col {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.dropdown-headline {
    font-family: var(--font-heading);
    font-weight: bold;
    font-size: var(--text-base);
    color: #ffffff;
    text-transform: lowercase;
    letter-spacing: 0.03em;
    margin-bottom: var(--space-xs);
}

.header-expanded a {
    font-family: var(--font-body);
    font-weight: normal;
    font-size: var(--text-base);
    color: #ffffff;
    text-decoration: none;
    text-transform: lowercase;
    letter-spacing: 0.03em;
    transition: color 0.2s ease, font-weight 0s 0.1s;
}

.header-expanded a:hover {
    font-family: var(--font-heading);
    font-weight: bold;
    color: #ffffff;
}

/* Expand when hovering the trigger or the panel itself */
header:has(.dropdown:hover) .header-expanded,
header:has(.header-expanded:hover) .header-expanded {
    max-height: 220px;
}


/* ------------------------------------------------------------
   Hamburger button (hidden on desktop)
   ------------------------------------------------------------ */

.nav-hamburger {
    display: none;
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: var(--space-xs);
    margin-left: auto;
    flex-shrink: 0;
    line-height: 0;
}

.mobile-nav-col {
    display: none;
}


/* ------------------------------------------------------------
   Disable hover dropdown on touch devices
   ------------------------------------------------------------ */

@media (hover: none) {
    header:has(.dropdown:hover) .header-expanded,
    header:has(.header-expanded:hover) .header-expanded {
        max-height: 0;
    }
    header:has(.dropdown:hover),
    header:has(.header-expanded:hover) {
        border-radius: var(--radius-md);
        transition: border-radius 0.1s ease 0.25s;
    }
}


/* ------------------------------------------------------------
   Header colour flip when footer is in view (mobile)
   ------------------------------------------------------------ */

header.header-light {
    background-color: #3A8359;
}

header.header-light .header-expanded {
    background-color: #3A8359;
}


/* ------------------------------------------------------------
   Mobile: show hamburger, hide desktop nav
   ------------------------------------------------------------ */

@media (max-width: 767px) {
    .header-main {
        padding-inline: var(--space-lg);
    }

    .header-expanded-inner {
        padding-inline: var(--space-lg);
    }

    .nav-center,
    .nav-right {
        display: none;
    }

    .nav-hamburger {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    header.mobile-open {
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        transition: border-radius 0s;
    }

    header.mobile-open .header-expanded,
    header.mobile-open:has(.dropdown:hover) .header-expanded,
    header.mobile-open:has(.header-expanded:hover) .header-expanded {
        max-height: 600px;
    }

    .header-expanded-inner {
        display: flex;
        flex-direction: column;
        gap: var(--space-lg);
        padding-inline: var(--space-lg);
        padding-bottom: var(--space-lg);
    }

    .mobile-nav-col {
        display: flex;
        order: -1;
    }
}
