@use '../base/variables' as *;
@use '../base/mixins' as *;

// ==========================================================================
// Site Header Component
// Fixed header with logo, burger menu, language switcher, and actions
// ==========================================================================

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background-color: transparent;
    border-bottom: 1px solid transparent;
    transition: background-color 0.3s ease, border-color 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    justify-content: center;
    display: flex;
    height: var(--header-height-css);
    padding: 0 $spacing-lg;
    transform: translateY(0);

    &.site-header--hidden {
        transform: translateY(-100%);
    }

    // Hidden while the home "préhome" intro screen is in view (see assets/home.ts,
    // IntersectionObserver toggling this class on body).
    body.prehome-active & {
        opacity: 0;
        pointer-events: none;
    }

    &::before {
        content: "";
        position: absolute;
        bottom: -1px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - (#{$spacing-lg} * 2));
        height: 1px;
        background-color: $color-primary-dark;
        transition: opacity 0.3s ease, width 0.3s ease;

        @include above-wrapper-breakpoint {
            width: $breakpoint-wrapper;
        }
    }

    &.site-header--scrolled {
        background-color: $color-neutral;

        &::before {
            width: 100%;
        }
    }

    // Menu open: header doubles as the burger-menu's own top bar (Figma
    // node-id=92-109), so force it solid regardless of scroll state.
    body.menu-open & {
        background-color: $color-neutral;

        &::before {
            width: 100%;
        }
    }

    @include above-wrapper-breakpoint {
        padding: 0;
    }
}

.site-header__container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    justify-content: space-between;
    max-width: $breakpoint-wrapper;
    margin: 0 auto;
    position: relative;
    width: 100%;
}

// --------------------------------------------------------------------------
// Left: Burger Menu
// --------------------------------------------------------------------------

.site-header__left {
    flex: 0 0 auto;
}

.burger-menu__toggle {
    display: flex;
    align-items: center;
    gap: $spacing-sm;
    background: transparent;
    border: none;
    padding: $spacing-xs;
    cursor: pointer;
    transition: transform 0.3s ease;

    &:hover {
        transform: scale(1.05);
    }

    &:focus-visible {
        outline: 2px solid $color-primary;
        outline-offset: 4px;
    }
}

.burger-menu__icon {
    display: block;
    position: relative;
    width: 24px;
    height: 2px;
    background-color: $color-primary-dark;
    transition: background-color 0.3s ease;

    &::before,
    &::after {
        content: '';
        position: absolute;
        left: 0;
        width: 100%;
        height: 2px;
        background-color: $color-primary-dark;
        transition: transform 0.3s ease, top 0.3s ease;
    }

    &::before {
        top: -6px;
    }

    &::after {
        top: 6px;
    }

    // When menu is open, transform to cross
    body.menu-open & {
        background-color: transparent;

        &::before {
            top: 0;
            transform: rotate(45deg);
        }

        &::after {
            top: 0;
            transform: rotate(-45deg);
        }
    }
}

.burger-menu__label {
    font-family: $font-family-sans;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.05em;
    color: $color-primary-dark;
    text-transform: uppercase;

    @media (max-width: #{$breakpoint-sm - 1px}) {
        display: none;
    }
}

// --------------------------------------------------------------------------
// Center: Logo
// --------------------------------------------------------------------------

.site-header__center {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
}

.site-header__logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: opacity 0.3s ease;

    &:hover {
        opacity: 0.8;
    }
}

.site-header__logo-image {
    height: 40px;
    width: auto;

    @media (min-width: $breakpoint-md) {
        height: 50px;
    }
}

// --------------------------------------------------------------------------
// Right: Actions
// --------------------------------------------------------------------------

.site-header__right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: $spacing-sm;
    justify-content: end;

    @media (min-width: $breakpoint-md) {
        gap: $spacing-md;
    }
}

// Language switcher
.site-header__lang {
    position: relative;

    // Moved into the burger menu on mobile
    @media (max-width: #{$breakpoint-md - 1px}) {
        display: none;
    }
}

.site-header__lang-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    padding: $spacing-xs $spacing-sm;
    cursor: pointer;
    font-family: $font-family-sans;
    font-size: 14px;
    font-weight: 400;
    color: $color-primary-dark;
    transition: color 0.3s ease;

    &:hover {
        color: $color-primary;
    }

    .icon {
        transition: transform 0.3s ease;
    }

    &:hover .icon {
        transform: translateY(2px);
    }
}

.site-header__lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: $spacing-xs;
    background: $color-light;
    border: 1px solid color-mix(in srgb, $color-primary 20%, transparent);
    border-radius: $radius-sm;
    padding: $spacing-xs;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.site-header__lang:hover .site-header__lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.site-header__lang-option {
    display: block;
    padding: $spacing-xs $spacing-sm;
    font-family: $font-family-sans;
    font-size: 14px;
    color: $color-primary-dark;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.3s ease, color 0.3s ease;

    &:hover {
        background-color: $color-neutral;
        color: $color-primary;
    }
}

// Icon buttons
.site-header__icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: $color-primary-dark;
    transition: color 0.3s ease, transform 0.3s ease;
    padding: 0;

    &:hover {
        color: $color-primary;
        transform: scale(1.1);
    }

    &:focus-visible {
        outline: 2px solid $color-primary;
        outline-offset: 2px;
    }

    @media (max-width: #{$breakpoint-md - 1px}) {
        width: 32px;
        height: 32px;

        .icon {
            --icon-size: 18px;
        }
    }
}

// Contact button (visuals from shared .btn--lined component, see components/_button.scss)
.site-header__cta {
    @media (max-width: #{$breakpoint-xl}) {
        display: none;
    }
}

// Audio button specific styling
.site-header__audio-btn {
    // The icon already carries its own ring, so the button stays borderless
    // and matches the icon box exactly.
    width: 36px;
    height: 36px;

    @media (max-width: #{$breakpoint-md - 1px}) {
        display: none;
    }
}

.site-header__audio-icon {
    // Bars and ring both paint with currentColor (see components/_audio-icon).
    color: $color-primary;
    opacity: 0.6;
    transition: color 0.3s ease, opacity 0.3s ease;

    .site-header__audio-btn:hover & {
        opacity: 1;
    }
}

.site-header__audio-btn--active .site-header__audio-icon {
    color: $color-primary-dark;
    opacity: 1;
}

// --------------------------------------------------------------------------
// Body padding for fixed header
// --------------------------------------------------------------------------

body {
    padding-top: var(--header-height-css);

    &.no-padding-top, &.zero-padding-top {
        padding-top: 0;
    }
}
