.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background-color: rgba(var(--color-bg-rgb), 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(200, 200, 200, 0.25);
    transition:
        background 400ms var(--easing-gentle),
        color 400ms var(--easing-gentle),
        border-color 400ms var(--easing-gentle);
}

.header-logo {
    display: inline-flex;
    align-items: center;
}

.header-logo svg {
    display: block;
}

/* Override the SVG's inline fill="black" so the logo follows the text color.
   Fill transitions independently of the parent header — SVG paths don't
   inherit the parent's transition. */
.header-logo svg path {
    fill: var(--color-text, black);
    transition: fill 400ms var(--easing-gentle);
}

/* The hamburger / chevron icons ship with stroke="black" inline; route them
   through currentColor so they pick up --color-text. */
.header-toggle svg path {
    stroke: var(--color-text, black);
    transition: stroke 400ms var(--easing-gentle);
}

.header-menu-link a,
.header-languages-link a {
    text-decoration: none;
}

.header-languages-link.active {
    opacity: 1;
}

.header-languages-name {
    display: none;
}


/* Toggle button (mobile only by default) */
.header-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 32px;
    height: 32px;
    position: relative;
}

.header-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.header-toggle-icon svg {
    display: block;
    width: 32px;
    height: 32px;
}

.header-toggle-icon--close {
    display: none;
}

.header.is-open .header-toggle-icon--open {
    display: none;
}

.header.is-open .header-toggle-icon--close {
    display: inline-flex;
}


/* Mobile collapsed: hide menu + languages */

.header-menu,
.header-languages {
    display: none;
}


/* Mobile open: full-screen overlay */

.header.is-open {
    position: fixed;
    inset: 0;
    background: var(--color-bg, white);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 0;
    color: inherit;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "logo  toggle"
        "menu  menu"
        "lang  lang";
    align-items: start;
    row-gap: 3rem;
    padding: 0.5rem 1rem;
    animation: fade-in 250ms var(--easing-gentle);
}

.header.is-open .header-logo {
    grid-area: logo;
    align-self: center;
}

.header.is-open .header-toggle {
    grid-area: toggle;
    align-self: center;
    justify-self: end;
}

.header.is-open .header-menu {
    grid-area: menu;
    display: flex;
    flex-direction: column;
    gap: 0.25em;
    align-self: start;
    padding-top: 2rem;
}

.header.is-open .header-menu-link {
    font-size: var(--text-h1);
    line-height: 1.1;
}

.header.is-open .header-languages {
    grid-area: lang;
    display: flex;
    gap: 1.5rem;
    align-self: end;
    padding-bottom: 1rem;
    font-size: var(--text-smaller);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.header.is-open .header-languages-code {
    display: none;
}

.header.is-open .header-languages-name {
    display: inline;
}

.header.is-open .header-languages-link {
    opacity: 0.5;
    transition: opacity 300ms var(--easing-gentle);
}

.header.is-open .header-languages-link:focus-visible,
.header.is-open .header-languages-link:hover {
    opacity: 1;
}

/* Inside the open overlay, ensure icons are dark even when a transparent-white variant is set */
.header.is-open svg,
.header.is-open svg * {
    fill: var(--color-text, black);
    stroke: currentColor;
}


/* Desktop: centered menu in a 1fr | auto | 1fr grid */

@media screen and (min-width: 48rem) {
    .header {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        column-gap: 2rem;
    }

    .header-logo {
        justify-self: start;
    }

    .header-menu {
        display: flex;
        gap: 1.5rem;
        justify-self: center;
        font-size: var(--text-smaller);
    }

    .header-menu-link {
        text-transform: uppercase;
        letter-spacing: 0.1em;
    }

    .header-languages {
        display: flex;
        gap: 1rem;
        justify-self: end;
        font-size: var(--text-smaller);
    }

    .header-languages-link {
        opacity: 0.5;
        transition: opacity 300ms var(--easing-gentle);
    }

    .header-languages-link:focus-visible,
    .header-languages-link:hover {
        opacity: 1;
    }

    .header-toggle {
        display: none;
    }
}


/* Header: Variants */

.header--bg-white {
    background: linear-gradient(rgba(var(--color-bg-rgb), 1) 0%,
            rgba(var(--color-bg-rgb), 0.85) 17%,
            rgba(var(--color-bg-rgb), 0.65) 33%,
            rgba(var(--color-bg-rgb), 0.42) 50%,
            rgba(var(--color-bg-rgb), 0.22) 67%,
            rgba(var(--color-bg-rgb), 0.08) 83%,
            rgba(var(--color-bg-rgb), 0) 100%);
}

.header--bg-transparent {
    background-color: transparent;
}

.header--bg-transparent-white {
    color: var(--color-bg, white);
    backdrop-filter: unset;
    -webkit-backdrop-filter: unset;
    border: 0;
    background: linear-gradient(rgba(0, 0, 0, 0.50) 0%,
            rgba(0, 0, 0, 0.43) 17%,
            rgba(0, 0, 0, 0.33) 33%,
            rgba(0, 0, 0, 0.22) 50%,
            rgba(0, 0, 0, 0.12) 67%,
            rgba(0, 0, 0, 0.04) 83%,
            rgba(0, 0, 0, 0) 100%);
    padding-bottom: 4rem;
}

.header--bg-transparent-white svg,
.header--bg-transparent-white svg * {
    fill: var(--color-bg, white);
}

/* Beat the more-specific `.header-logo svg path` rule defined above. */
.header--bg-transparent-white .header-logo svg path {
    fill: var(--color-bg, white);
}

.header--bg-transparent-white .header-toggle svg path {
    stroke: var(--color-bg, white);
}
