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

// ==========================================================================
// Burger Menu Component (menu ouvert)
// Two-column desktop layout: nav groups + portrait photo + contact block.
// Figma references:
// - Global overlay: node-id=92-109
// - Main links:     node-id=92-156
// - Secondary links: node-id=92-160
// - Contact block:  node-id=92-166
// Note: Burger toggle button (MENU / X) lives in _header.scss — the header
// stays fixed above this overlay (z-index) so it doubles as the menu's
// own top bar, matching the Figma frame.
// ==========================================================================

.burger-menu {
    position: fixed;
    inset: 0;
    z-index: 20;
    background-color: $color-neutral;
    opacity: 0;
    visibility: hidden;
    overflow-y: auto;
    transition: opacity 0.4s ease, visibility 0.4s ease;

    body.menu-open & {
        opacity: 1;
        visibility: visible;
    }
}

// Subtle mountain silhouette watermark, same mask technique used behind the
// Actualité/Expertise heroes — kept very light here since it's decorative.
.burger-menu__mountain-bg {
    @include fixed-mountain-bg('../../images/actualite-mountain-mask-v2.svg', $color-light, 55vh);
    opacity: 0.6;
}

.burger-menu__backdrop {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.burger-menu__content {
    position: relative;
    z-index: 2;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: var(--header-height-css);
}

// --------------------------------------------------------------------------
// Nav layout: nav links | photo | contact
// --------------------------------------------------------------------------

.burger-menu__nav {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: $spacing-xl;
    width: 100%;
    max-width: $breakpoint-wrapper;
    margin: 0 auto;
    padding: $spacing-lg;
    height: calc(100vh - #{$header-height-lg});
    overflow-y: auto;

    @media (min-width: $breakpoint-lg) {
        flex-direction: row;
        align-items: stretch;
        gap: $spacing-lg;
    }

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

.burger-menu__nav-col {
    display: flex;
    flex-direction: column;
    gap: $spacing-lg;
    width: 100%;

    @media (min-width: $breakpoint-lg) {
        flex: 1 1 0;
        max-width: 620px;
    }
}

// --------------------------------------------------------------------------
// Main links (large, prominent)
// --------------------------------------------------------------------------

.burger-menu__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.burger-menu__list--main {
    gap: $spacing-md;

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

.burger-menu__list--secondary {
    gap: $spacing-sm;
    padding-top: $spacing-lg;
    border-top: 1px solid $color-primary-lighter;
}

.burger-menu__item {
    opacity: 0;
    transform: translateY(16px);

    body.menu-open & {
        animation: burgerMenuItemIn 0.5s ease forwards;

        @for $i from 1 through 10 {
            &:nth-child(#{$i}) {
                animation-delay: #{0.05 + ($i * 0.05)}s;
            }
        }
    }
}

@keyframes burgerMenuItemIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.burger-menu__link {
    position: relative;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: $color-primary-dark;
    transition: color 0.3s ease, padding-left 0.3s ease;

    // Hover/active tick mark growing to the left of the link (Figma's
    // collapsed vertical line, hidden until interaction).
    &::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 1px;
        background-color: currentColor;
        transform: scaleY(0);
        transform-origin: center;
        transition: transform 0.3s ease;
    }

    &:hover,
    &:focus-visible {
        color: $color-primary;
        padding-left: $spacing-md;

        &::before {
            transform: scaleY(1);
        }
    }
}

.burger-menu__link--main {
    font-family: $font-family-serif;
    font-size: clamp(32px, 4.5vw, 48px);
    line-height: 1.5;
    padding-left: $spacing-sm;
}

.burger-menu__link--secondary {
    font-family: $font-family-serif;
    font-size: clamp(18px, 2vw, 24px);
    line-height: 1.5;
    padding-left: $spacing-sm;
}

.burger-menu__admin-link {
    align-self: flex-start;
    margin-top: $spacing-sm;
    font-family: $font-family-sans;
    font-size: $font-size-sm;
    color: $color-primary-lighter;
    text-decoration: none;
    padding: $spacing-xs $spacing-sm;
    border: 1px solid $color-primary-lighter;
    border-radius: $radius-sm;
    transition: all 0.3s ease;

    &:hover {
        background-color: $color-primary-lighter;
        color: $color-primary-dark;
    }
}

// --------------------------------------------------------------------------
// Portrait photo (admin-configurable, see MenuConfigService)
// --------------------------------------------------------------------------

.burger-menu__photo {
    display: none;
    flex-shrink: 0;
    overflow: hidden;

    @media (min-width: $breakpoint-lg) {
        display: block;
        width: 220px;
        aspect-ratio: 293 / 566;
    }

    @media (min-width: $breakpoint-xl) {
        width: 260px;
    }
}

.burger-menu__photo-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

// --------------------------------------------------------------------------
// Contact block
// --------------------------------------------------------------------------

.burger-menu__contact {
    display: flex;
    flex-direction: column;
    gap: $spacing-md;
    width: 100%;

    @media (min-width: $breakpoint-lg) {
        flex: 0 0 40%;
        max-width: 40%;
        padding-left: $spacing-lg;
        border-left: 1px solid $color-primary-lighter;
        justify-content: flex-end;
    }
}

.burger-menu__contact-photo {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow: hidden;

    // Admin edit mode, no image configured yet in /admin/settings/menu.
    &.is-empty-image {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 160px;
        background: $color-neutral;
        border: 2px dashed $color-primary;
        border-radius: $radius-sm;

        .burger-menu__contact-photo-image {
            display: none;
        }
    }
}

.burger-menu__contact-photo-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    object-position: top;
}

.burger-menu__contact-info {
    display: flex;
    flex-direction: column;
    gap: $spacing-xs;
}

.burger-menu__contact-title {
    font-family: $font-family-serif;
    font-size: 28px;
    line-height: 1.6;
    color: $color-primary-dark;
    margin: 0;

    @media (min-width: $breakpoint-md) {
        font-size: 36px;
    }
}

.burger-menu__contact-address {
    font-family: $font-family-sans;
    font-size: $font-size-base;
    line-height: $line-height-base;
    color: $color-primary-dark;
    margin: 0;
}

.burger-menu__contact-actions {
    display: flex;
    align-items: center;
    gap: $spacing-sm;
}

.burger-menu__contact-cta {
    flex: 0 0 auto;
    justify-content: center;
}

.burger-menu__lang {
    flex-shrink: 0;

    @media (min-width: $breakpoint-md) {
        display: none;
    }
}

.burger-menu__audio {
    flex-shrink: 0;
    --padding-y: 12px;
    --padding-x: 12px;

    @media (min-width: $breakpoint-md) {
        display: none;
    }
}

.burger-menu__audio-icon {
    width: 18px;
    height: 18px;
    // `.link-btn svg` paints currentColor, which would fill the ring
    fill: none;
    opacity: 0.6;
    transition: opacity 0.3s ease;

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

.burger-menu__social {
    flex-shrink: 0;
    --padding-y: 12px;
    --padding-x: 12px;
}

// --------------------------------------------------------------------------
// Body scroll lock when menu is open
// --------------------------------------------------------------------------

body.menu-open {
    overflow: hidden;
}
