/* --- HEADER COMPONENT --- */
.site-header {
    background: var(--color-header-bg, var(--color-bg));
    border-bottom: var(--header-border-bottom);
    box-shadow: var(--header-box-shadow);
    min-height: var(--header-min-height, auto);
    position: var(--header-position, sticky);
    top: var(--header-top, 0);
    left: var(--header-left, auto);
    right: var(--header-right, auto);
    transform: var(--header-transform, none);
    width: var(--header-width, 100%);
    max-width: var(--content-max-width, var(--header-max-width, none));
    margin: var(--header-margin, 0);
    border-radius: var(--header-border-radius, 0);
    z-index: 1000;
    padding: var(--header-padding);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.site-header__container {
    width: var(--header-container-width, 100%);
    max-width: var(--header-container-max-width, 1200px);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-wrapper {
    flex-shrink: 0;
}

.logo-wrapper img {
    height: var(--logo-height);
    width: auto;
    display: block;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: var(--spacing-nav-gap, 30px);
    align-items: center;
}

.nav-item {
    font-size: var(--font-size-nav-item, 15px);
    font-weight: var(--nav-item-font-weight, 600);
    padding: var(--nav-item-padding, 0);
    color: var(--color-nav-item, var(--color-text-dark));
    opacity: var(--nav-item-opacity, 1);
    transition: opacity 0.2s;
    white-space: var(--nav-item-white-space, nowrap);
    text-align: var(--nav-item-text-align, left);
    max-width: var(--nav-item-max-width, none);
    line-height: var(--nav-item-line-height, inherit);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-transform: var(--nav-item-text-transform, none);
    letter-spacing: var(--nav-item-letter-spacing, normal);
}

.nav-item:hover {
    color: var(--color-nav-item-hover, var(--color-primary));
    opacity: var(--nav-item-hover-opacity, 0.8);
}

.header-ctas {
    display: flex;
    gap: 15px;
    flex-shrink: 0;
}

.header-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--header-right-gap, 25px);
}

.lang-selector {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    font-size: 14px;
    color: var(--color-nav-item, var(--color-primary));
}

.header-btn {
    padding: var(--header-btn-padding, 10px 22px);
    font-size: var(--header-btn-font-size, 14px);
    font-weight: var(--header-btn-font-weight, 600);
    border-radius: var(--border-radius-button);
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-btn--primary {
    background-color: var(--color-header-btn-primary-bg, var(--color-primary));
    color: var(--color-header-btn-primary-text, var(--color-text-light));
    border: var(--color-header-btn-primary-border, none);
}

.header-btn--accent {
    background-color: var(--color-header-btn-secondary-bg, var(--color-secondary));
    color: var(--color-header-btn-secondary-text, var(--color-text-light));
    border: var(--color-header-btn-secondary-border, none);
}

.header-btn:hover {
    filter: brightness(1.1);
}


/* --- BURGER (mobile menu toggle) --- */
.nav-burger {
    display: none;
    width: var(--burger-size, 58px);
    height: var(--burger-size, 58px);
    flex: 0 0 auto;
    border-radius: 50%;
    border: var(--burger-border, 1.5px solid var(--color-primary, #D6C485));
    background: transparent;
    cursor: pointer;
    padding: 0;
    align-items: center;
    justify-content: center;
    transition: background 0.25s ease;
}

.nav-burger-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--burger-line-gap, 5px);
    width: var(--burger-line-width, 26px);
}

.nav-burger-line {
    display: block;
    width: 100%;
    height: var(--burger-line-thickness, 2px);
    background: var(--burger-line-color, var(--color-primary, #D6C485));
    border-radius: 2px;
    transition: background 0.25s ease;
}

.site-header.menu-open .nav-burger {
    background: var(--burger-open-bg, var(--color-primary, #D6C485));
}

.site-header.menu-open .nav-burger-line {
    background: var(--burger-open-line-color, var(--color-bg, #000000));
}

body.nav-open-lock {
    overflow: hidden;
}

/* Tablet: full-size logo + inline nav is tight, so pull the nav gaps in
   (keeps the logo from being squeezed and the header from overflowing). */
@media (min-width: 769px) and (max-width: 1120px) {
    .site-header {
        --spacing-nav-gap: 24px;
        --font-size-nav-item: 16px;
    }
    .header--nav, nav {
        margin-left: 3%;
    }
}

/* --- RESPONSIVE MOBILE STYLES (max-width: 768px) --- */
@media (max-width: 768px) {
    .site-header {
        padding: var(--header-padding-mobile, 18px 5%);
        min-height: var(--header-min-height-mobile, auto);
        position: relative;
        z-index: 100;
        /* shrink the logo on mobile — the logo img reads var(--logo-height) inline */
        --logo-height: var(--logo-height-mobile, 110px);
    }
    .site-header__container {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0;
    }
    .nav-burger {
        display: flex;
        position: relative;
        z-index: 95;
    }
    .logo-wrapper {
        position: relative;
        z-index: 95;
    }

    /* Nav becomes a full-screen overlay, hidden until the burger is tapped */
    nav#site-nav {
        position: fixed;
        inset: 0;
        background: var(--nav-overlay-bg, var(--color-bg, #000000));
        z-index: 90;
        padding: var(--nav-overlay-padding, 150px 8% 40px);
        transform: translateX(100%);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s;
        overflow-y: auto;
    }
    .site-header.menu-open nav#site-nav {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }

    .nav-menu {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--nav-overlay-item-gap, 40px);
        width: 100%;
    }
    .nav-menu li {
        width: 100%;
    }
    .nav-menu-item {
        justify-content: space-between;
    }
    .nav-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        /* Share the row with the chevron toggle (which sits to the right)
           instead of taking the full width and pushing it onto a new line. */
        flex: 1 1 auto;
        min-width: 0;
        white-space: normal;
        max-width: var(--nav-item-max-width-mobile, none);
        padding: var(--nav-item-padding-mobile, 0);
        line-height: 1.15;
        font-size: var(--nav-item-size-mobile, 32px);
    }
    .nav-menu li:last-child .nav-item {
        border-bottom: var(--nav-overlay-last-border, 1px solid var(--color-primary, #D6C485));
        padding-bottom: 18px;
    }
}

.nav-chevron {
    width: var(--nav-chevron-width, 9px);
    height: var(--nav-chevron-height, 22px);
    margin-left: var(--nav-chevron-gap, 8px);
    display: inline-block;
    vertical-align: middle;
    opacity: var(--nav-chevron-opacity, 0.85);
}

/* --- NAV DROPDOWN --- */
.nav-menu-item {
    position: relative;
    display: flex;
    align-items: center;
}

/* The chevron is a separate control that opens the dropdown. */
.nav-dropdown-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--color-nav-item, var(--color-primary));
    display: inline-flex;
    align-items: center;
}
.nav-dropdown-toggle .nav-chevron {
    transition: transform 0.25s ease;
}
.nav-menu-item.open .nav-dropdown-toggle .nav-chevron {
    transform: rotate(180deg);
    opacity: 1;
}

.nav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1001;
    min-width: var(--nav-dropdown-min-width, 240px);
    max-width: var(--nav-dropdown-max-width, 260px);
    margin: 0;
    padding: var(--nav-dropdown-padding, 12px 0);
    list-style: none;
    background: var(--nav-dropdown-bg, var(--color-bg, #000000));
    border: var(--nav-dropdown-border, 1px solid var(--color-primary, #D6C485));
    display: none;
}
.nav-menu-item.open .nav-dropdown {
    display: block;
}

.nav-dropdown-link {
    display: block;
    padding: 10px 22px;
    color: var(--color-nav-item, var(--color-primary));
    text-decoration: none;
    font-size: var(--nav-dropdown-item-size, 15px);
    /* Wrap long product names inside a narrow menu (matches live) rather than
       letting each name force the dropdown wider on one line. */
    white-space: normal;
    line-height: 1.3;
    opacity: var(--nav-item-opacity, 1);
    transition: opacity 0.2s ease;
}
.nav-dropdown-link:hover {
    opacity: var(--nav-item-hover-opacity, 0.8);
}

/* On the mobile overlay the dropdown expands inline rather than floating. */
@media (max-width: 768px) {
    .nav-dropdown {
        position: static;
        /* Full width on its own line below the label+chevron row; no floating
           box, no left rule (matches live's plain indented list). */
        flex-basis: 100%;
        width: 100%;
        min-width: 0;
        max-width: none;
        border: none;
        margin-left: 0;
        padding: 10px 0 0;
    }
    .nav-dropdown-link {
        font-size: var(--nav-dropdown-item-size-mobile, 20px);
        padding: 8px 0;
    }
    .nav-menu-item {
        flex-wrap: wrap;
    }
}

/* --- SPLIT LAYOUT (nav-left / centered logo / nav-right) ---
   Opt-in: only applies when data.menuItemsLeft/menuItemsRight are passed in,
   so brands using the default single-list data.menuItems are unaffected.

   Grid, not flex: the container's direct children are nav-left, logo-wrapper
   and header-right (nav-burger is display:none on desktop, excluded from
   grid placement same as it would be from flex). A flex `1 1 0`/`space-between`
   split only centers the logo when both sides have equal content width —
   here the right side always carries more (nav + socials + locale), so it
   pulled the "centered" logo visibly off-center. A fixed 1fr/auto/1fr grid
   keeps the middle column's own width centered regardless of how uneven the
   two side columns are. */
.site-header--split .site-header__container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.site-header--split .site-header__nav-left,
.site-header--split .site-header__nav-right {
    display: flex;
}

.site-header--split .site-header__nav-left .nav-menu {
    justify-content: flex-start;
    gap: var(--nav-left-gap, var(--spacing-nav-gap, 30px));
}

.site-header--split .site-header__nav-right .nav-menu {
    justify-content: flex-end;
    gap: var(--nav-right-gap, var(--spacing-nav-gap, 30px));
}

.site-header--split .site-header__nav-right {
    margin-right: var(--nav-right-end-gap, 0);
}

.site-header--split .logo-wrapper {
    justify-self: center;
}

.site-header--split .header-right {
    justify-self: end;
}

.header-socials {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-socials img {
    display: block;
}

.header-locale {
    font-size: 24px;
    line-height: 1;
}

/* Split layout: mobile-only repeats of nav-right's items (see the mobile block). */
.nav-menu-item--mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .site-header--split .site-header__nav-left,
    .site-header--split .site-header__nav-right {
        display: none;
    }
    /* nav-left carries the #site-nav id, so it's the element the fixed-overlay
       rules above (nav#site-nav { position: fixed; ... }) actually reposition —
       but this unconditional display:none was hiding it even after the burger
       opened, leaving an empty, correctly-positioned overlay with nothing in
       it. It has to come back to flex (its own display value outside this
       media query) once open, or the burger visibly does nothing. */
    .site-header--split.menu-open .site-header__nav-left {
        display: flex;
    }
    /* The 1fr/auto/1fr grid above still applies here, and with nav-left
       hidden, auto-placement drops the logo and burger into its first two
       cells — burger glued to the logo instead of at the bar's right edge.
       Pin them to the centre and end cells so the logo stays centred. */
    .site-header--split .site-header__container > .header-right {
        grid-column: 1;
        grid-row: 1;
    }
    .site-header--split .logo-wrapper {
        grid-column: 2;
        grid-row: 1;
        justify-self: center;
    }
    .site-header--split .nav-burger {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
    }
    /* nav-right's links (data.menuItemsRight) and the locale are repeated as
       mobile-only items at the end of nav-left's list (header.html.twig), so
       the overlay is one continuous list; nav-right itself stays hidden. */
    .site-header--split .nav-menu-item--mobile-only {
        display: flex;
    }
    /* header-socials/lang-selector are siblings of nav-right inside
       .header-right (not descendants of it), so hiding nav-right alone
       leaves them stranded next to the burger — the collapsed mobile bar
       is logo + burger only, matching every other nav-right content. */
    .header-right .header-socials,
    .header-right .lang-selector,
    .header-right .header-locale {
        display: none;
    }
}

/* --- BURGER CLOSE ICON (opt-in) --- */
/* Optional close icon (data.burgerCloseIcon): shown instead of the three
   lines while the menu is open. Only a burger rendered with an icon has the
   --close-icon class, so every other burger keeps its lines. */
.nav-burger-close {
    display: none;
    width: var(--burger-close-size, 24px);
    height: var(--burger-close-size, 24px);
}
.nav-burger-close svg {
    display: block;
    width: 100%;
    height: 100%;
}
.site-header.menu-open .nav-burger--close-icon .nav-burger-box {
    display: none;
}
.site-header.menu-open .nav-burger--close-icon .nav-burger-close {
    display: block;
}

/* --- MOBILE DRILL-DOWN OVERLAY (opt-in: data.mobileDrilldown) ---
   One flat list in the overlay; an item with a submenu shows a ▶ instead of
   the chevron, and opening it replaces the list with a "◀ label" row over a
   rule, followed by its links. Every selector needs .site-header--drilldown,
   which only data.mobileDrilldown adds, so other headers are untouched.
   Spacing/type/rules are tokens; the defaults are plain, unstyled values. */
@media (max-width: 768px) {
    /* The overlay covers the header's own bottom border; redraw it on top,
       from the same token, so it stays put wherever the header sits. */
    .site-header--drilldown.menu-open::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        border-top: var(--header-border-bottom, none);
        z-index: 96;
        pointer-events: none;
    }
    .site-header--drilldown nav#site-nav .nav-menu {
        gap: 0;
    }
    .site-header--drilldown nav#site-nav .nav-menu > li {
        margin-bottom: var(--nav-drilldown-item-gap, var(--nav-overlay-item-gap, 40px));
    }
    .site-header--drilldown nav#site-nav .nav-item,
    .site-header--drilldown nav#site-nav .nav-dropdown-link {
        font-size: var(--nav-drilldown-item-size, var(--nav-item-size-mobile, 32px));
        line-height: var(--nav-drilldown-item-line-height, 1.15);
        color: var(--nav-drilldown-item-color, var(--color-nav-item, var(--color-primary)));
    }
    .site-header--drilldown nav#site-nav .nav-menu li:last-child .nav-item {
        border-bottom: none;
        padding-bottom: 0;
    }
    /* The locale row (split layout's mobile-only repeat) closes the list. */
    .site-header--drilldown nav#site-nav .nav-menu > .nav-menu-item--locale {
        margin-top: var(--nav-drilldown-locale-offset, 0);
        padding-bottom: var(--nav-drilldown-rule-gap, 12px);
        border-bottom: var(--nav-drilldown-rule, 1px solid currentColor);
    }
    .site-header--drilldown nav#site-nav .nav-menu-item--locale svg {
        display: block;
    }

    /* ▶ in place of the chevron. content-box: the size is the arrow's own
       box, so any padding the base toggle rule adds for a larger tap target
       grows the hit area instead of eating into (and shifting) the arrow. */
    .site-header--drilldown nav#site-nav .nav-dropdown-toggle {
        box-sizing: content-box;
        width: var(--nav-drilldown-arrow-box, 24px);
        height: var(--nav-drilldown-arrow-box, 24px);
        justify-content: center;
        color: var(--nav-drilldown-item-color, var(--color-nav-item, var(--color-primary)));
    }
    .site-header--drilldown nav#site-nav .nav-dropdown-toggle .nav-chevron {
        display: none;
    }
    .site-header--drilldown nav#site-nav .nav-dropdown-toggle::before,
    .site-header--drilldown nav#site-nav .nav-menu-item.open > .nav-item::before {
        content: '';
        display: block;
        flex: 0 0 auto;
        border-top: calc(var(--nav-drilldown-arrow-height, 14px) / 2) solid transparent;
        border-bottom: calc(var(--nav-drilldown-arrow-height, 14px) / 2) solid transparent;
    }
    .site-header--drilldown nav#site-nav .nav-dropdown-toggle::before {
        border-left: var(--nav-drilldown-arrow-width, 12px) solid currentColor;
    }

    /* Drill-down: the open item takes over the list, its label becomes a
       "◀ label" row over a rule, and the list closes with a rule too. */
    .site-header--drilldown nav#site-nav .nav-menu:has(> .nav-menu-item.open) > li:not(.open) {
        display: none;
    }
    .site-header--drilldown nav#site-nav .nav-menu-item.open .nav-dropdown-toggle {
        display: none;
    }
    .site-header--drilldown nav#site-nav .nav-menu-item.open > .nav-item {
        justify-content: flex-start;
        gap: var(--nav-drilldown-back-gap, 8px);
        padding: 0 0 var(--nav-drilldown-title-rule-gap, 12px);
        border-bottom: var(--nav-drilldown-title-rule, var(--nav-drilldown-rule, 1px solid currentColor));
        font-weight: var(--nav-drilldown-title-weight, 700);
    }
    .site-header--drilldown nav#site-nav .nav-menu-item.open > .nav-item::before {
        margin: var(--nav-drilldown-back-margin, 0);
        border-right: var(--nav-drilldown-arrow-width, 12px) solid currentColor;
    }
    .site-header--drilldown nav#site-nav .nav-dropdown {
        padding: var(--nav-drilldown-submenu-gap, 30px) 0 0;
    }
    .site-header--drilldown nav#site-nav .nav-menu > .nav-menu-item.open {
        padding-bottom: var(--nav-drilldown-end-rule-gap, 20px);
        border-bottom: var(--nav-drilldown-rule, 1px solid currentColor);
    }
    .site-header--drilldown nav#site-nav .nav-dropdown li + li {
        margin-top: var(--nav-drilldown-item-gap, var(--nav-overlay-item-gap, 40px));
    }
    .site-header--drilldown nav#site-nav .nav-dropdown-link {
        padding: 0;
    }
}

/* --- NAV MEGA-MENU (opt-in) ---
   Rendered instead of .nav-dropdown when a dropdown entry carries its own
   items array: a panel of titled columns, as wide as the nav, one grid column
   per group. Every selector below needs .has-megamenu or .nav-megamenu, which
   only the grouped data shape produces — a brand on the flat shape matches
   none of them.

   The panel hangs off the nav rather than off its own list item, so it can be
   wider than the label that opens it. :has() keeps that repositioning on the
   navs that actually carry a mega-menu; every other header keeps the
   positioning it has today. */
@media (min-width: 769px) {
    .site-header nav:has(.nav-menu-item.has-megamenu) {
        position: relative;
    }

    /* Static on purpose: the panel resolves against the nav above, not this item. */
    .nav-menu-item.has-megamenu {
        position: static;
    }

    /* Hover opens it (the panel's top edge meets the item's bottom edge, so there
       is no dead zone to cross); focus-within covers keyboard traversal. */
    .nav-menu-item.has-megamenu:hover .nav-megamenu,
    .nav-menu-item.has-megamenu:focus-within .nav-megamenu {
        display: block;
    }
}

.nav-megamenu {
    display: none;
    position: absolute;
    top: 100%;
    left: var(--nav-megamenu-left, 0);
    right: var(--nav-megamenu-right, 0);
    z-index: 1001;
    padding: var(--nav-megamenu-padding, var(--nav-dropdown-padding, 12px 0));
    background: var(--nav-megamenu-bg, var(--nav-dropdown-bg, var(--color-bg, #000000)));
    border: var(--nav-megamenu-border, none);
    box-shadow: var(--nav-megamenu-shadow, none);
}

/* Same .open contract as the flat dropdown, so the chevron toggle in
   header-menu.js drives this panel too — and drives the mobile accordion. */
.nav-menu-item.open .nav-megamenu {
    display: block;
}

.nav-megamenu__inner {
    width: 100%;
    max-width: var(--nav-megamenu-max-width, var(--content-max-width, 1240px));
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--nav-megamenu-col-min-width, 180px), 1fr));
    gap: var(--nav-megamenu-col-gap, 24px);
    align-items: start;
}

.nav-megamenu__col-title {
    display: block;
    margin-bottom: var(--nav-megamenu-title-margin-bottom, 12px);
    color: var(--nav-megamenu-title-color, var(--color-nav-item, var(--color-primary)));
    font-size: var(--nav-megamenu-title-size, var(--font-size-nav-item, 15px));
    font-weight: var(--nav-megamenu-title-weight, 700);
    text-transform: var(--nav-megamenu-title-transform, none);
    line-height: 1.3;
    text-decoration: none;
}

a.nav-megamenu__col-title:hover {
    color: var(--nav-megamenu-link-hover-color, var(--color-nav-item-hover, inherit));
}

.nav-megamenu__list {
    margin: 0;
    padding: 0;
    list-style: none;
    /* A group with a long link list can be split in place without touching the
       grid above it (matches sites that run one column over two rails). */
    columns: var(--nav-megamenu-list-columns, 1);
}

.nav-megamenu__link {
    display: block;
    padding: var(--nav-megamenu-link-padding, 6px 0);
    color: var(--nav-megamenu-link-color, var(--color-nav-item, var(--color-primary)));
    font-size: var(--nav-megamenu-link-size, var(--nav-dropdown-item-size, 15px));
    line-height: 1.3;
    text-decoration: none;
    /* Wrap long labels inside the column instead of widening it. */
    white-space: normal;
}

.nav-megamenu__link:hover {
    color: var(--nav-megamenu-link-hover-color, var(--color-nav-item-hover, inherit));
}

/* On the mobile overlay the panel is part of the burger menu: no floating box,
   the columns stack under the label whose chevron opened them. */
@media (max-width: 768px) {
    .nav-megamenu {
        position: static;
        flex-basis: 100%;
        width: 100%;
        padding: var(--nav-megamenu-padding-mobile, 10px 0 0);
        background: none;
        border: none;
        box-shadow: none;
    }

    .nav-megamenu__inner {
        display: block;
        max-width: none;
    }

    .nav-megamenu__col + .nav-megamenu__col {
        margin-top: var(--nav-megamenu-col-gap-mobile, 20px);
    }

    .nav-megamenu__list {
        columns: 1;
    }

    .nav-megamenu__link {
        font-size: var(--nav-megamenu-link-size-mobile, var(--nav-dropdown-item-size-mobile, 20px));
        padding: var(--nav-megamenu-link-padding-mobile, 8px 0);
    }
}
