/* ==========================================================================
   Header - Caen Couverture
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
    --header-height: 80px;
    --color-primary: #405262;
    --color-red: #F4333E;
    --color-white: #ffffff;
    --font-primary: 'Montserrat', sans-serif;
}

/* Header principal */
.site-header,
.site-header.site-header,
header.site-header,
header#masthead {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    height: var(--header-height) !important;
    background-color: var(--color-white) !important;
    z-index: 100000 !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    transition: box-shadow 0.3s ease;
}

/* Header fixed par défaut sur toutes les pages SAUF la homepage */
body:not(.home) .site-header,
body:not(.home) header#masthead {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

/* Compenser la hauteur du header fixed sur les pages (sauf homepage) */
body:not(.home) {
    padding-top: var(--header-height) !important;
}

/* Header fixed au scroll avec animation (homepage uniquement) */
.site-header.is-fixed,
header#masthead.is-fixed {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
    animation: slideDown 0.2s ease-out forwards;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

.header-container,
.site-header .header-container,
header .header-container {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 8vw !important;
    box-sizing: border-box !important;
}

/* Logo */
.header-logo {
    flex-shrink: 0;
}

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

.header-logo img {
    height: 30px;
    width: auto;
    max-width: none;
}

/* Navigation centrale */
.header-nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 3rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-menu li {
    margin: 0;
}

.nav-menu a {
    font-family: var(--font-primary);
    font-size: 16px;
    font-weight: 500;
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.nav-menu a:hover {
    color: var(--color-red);
}

/* Lien actif */
.nav-menu .current-menu-item a,
.nav-menu .current_page_item a,
.nav-menu .current-menu-ancestor a {
    color: var(--color-red);
}

/* ==========================================================================
   Mega Menu - Couverture
   ========================================================================== */

.menu-item-has-megamenu {
    position: static;
}

.menu-item-has-megamenu > a {
    position: relative;
}

/* Icône chevron indicateur de sous-menu */
.menu-item-has-megamenu > a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.menu-item-has-megamenu > a::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23405262' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    vertical-align: middle;
    margin-top: 1px;
}

.menu-item-has-megamenu:hover > a::after {
    transform: rotate(180deg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23F4333E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.menu-item-has-megamenu:hover > a,
.menu-item-has-megamenu.is-current > a {
    color: var(--color-red);
}

.menu-item-has-megamenu.is-current > a::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23F4333E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* La nav-menu devient le conteneur de référence */
.nav-menu {
    position: relative;
}

/* Container du mega menu - prend la largeur de la nav + débordement */
.megamenu {
    position: absolute;
    top: calc(100% + 35px);
    left: -30px;
    right: -30px;
    transform: translateY(-10px);
    background: var(--color-white);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    z-index: 9997;
    border-radius: 12px;
}

/* Zone invisible de transition - apparaît seulement au hover de Couverture */
.megamenu::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    height: 35px;
    background: transparent;
}

.menu-item-has-megamenu:hover .megamenu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.megamenu-inner {
    display: flex;
    padding: 0;
    gap: 0;
}

/* Partie gauche - Navigation */
.megamenu-left {
    flex: 0 0 auto;
    background-color: #F1F4F6;
    border-radius: 12px 0 0 12px;
    padding: 1.5rem 0 1.5rem 1.5rem;
}

.megamenu-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.megamenu-nav-item {
    margin: 0;
}

.megamenu-nav-item a {
    display: block;
    padding: 1rem 4rem 1rem 1.5rem;
    font-family: var(--font-primary);
    font-size: 15px;
    font-weight: 500;
    color: var(--color-primary);
    text-decoration: none;
    border-radius: 4px 0 0 4px;
    transition: background-color 0.2s ease;
}

.megamenu-nav-item.is-active a {
    background-color: #ffffff;
    color: var(--color-red);
}

/* Partie droite - Contenu dynamique */
.megamenu-right {
    flex: 1;
    min-width: 0;
    position: relative;
    padding: 2rem;
}

.megamenu-content {
    position: absolute;
    top: 2rem;
    left: 2rem;
    right: 2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.megamenu-content:first-child {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
}

.megamenu-content.is-active {
    opacity: 1;
    pointer-events: auto;
}

.megamenu-image {
    width: 100%;
    height: 240px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.megamenu-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.megamenu-text {
    min-height: 100px;
}

.megamenu-text h3 {
    font-family: var(--font-primary);
    font-size: 18px;
    font-weight: 600;
    color: var(--color-primary);
    margin: 0 0 0.5rem 0;
}

.megamenu-text p {
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 400;
    color: #6b7a8a;
    line-height: 1.6;
    margin: 0;
}

/* Bouton CTA */
.header-cta {
    flex-shrink: 0;
}

.btn-contact {
    display: inline-block;
    padding: 0.75rem 1.25rem;
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-red);
    background-color: var(--color-white);
    border: 1px solid var(--color-red);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-contact:hover {
    background-color: var(--color-red);
    color: var(--color-white) !important;
}

/* Bouton CTA mobile (caché en desktop) */
.header-cta-mobile {
    display: none;
}

/* Menu burger (cache en desktop) */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 10001;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    outline: none;
}

.menu-toggle:focus,
.menu-toggle:focus-visible,
.menu-toggle:active,
.menu-toggle:hover {
    outline: none;
    box-shadow: none;
    background: none;
    -webkit-tap-highlight-color: transparent;
}

.hamburger {
    display: block;
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23405262' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='3' y1='12' x2='21' y2='12'%3E%3C/line%3E%3Cline x1='3' y1='6' x2='21' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='18' x2='21' y2='18'%3E%3C/line%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.2s ease;
}

/* Animation burger ouvert - icône X */
.menu-toggle.is-active .hamburger {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23405262' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E");
}

/* Plus besoin de compenser car header n'est plus fixed */
body {
    padding-top: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Entre 1250px et 1399px - première réduction */
@media (max-width: 1399px) and (min-width: 1250px) {
    .header-container {
        padding: 0 4vw !important;
    }

    .nav-menu {
        gap: 1.5rem;
    }

    .nav-menu > li > a {
        font-size: 14px;
    }

    .btn-contact {
        padding: 0.65rem 1rem;
        font-size: 13px;
    }
}

/* Entre 1100px et 1249px - deuxième réduction */
@media (max-width: 1249px) and (min-width: 1101px) {
    .header-container {
        padding: 0 3vw !important;
    }

    .nav-menu {
        gap: 1rem;
    }

    .nav-menu > li > a {
        font-size: 13px;
    }

    .btn-contact {
        padding: 0.6rem 0.9rem;
        font-size: 12px;
    }

    .menu-item-has-megamenu > a::after {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 1100px) {
    .menu-toggle {
        display: block !important;
    }

    .header-nav {
        display: none !important;
        position: fixed !important;
        top: var(--header-height) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        height: calc(100vh - var(--header-height)) !important;
        width: 100% !important;
        background-color: var(--color-white) !important;
        padding: 2rem 8vw;
        overflow-y: auto;
        z-index: 99999 !important;
    }

    .header-nav.is-active {
        display: flex !important;
        flex-direction: column;
        justify-content: flex-start;
    }

    .nav-menu {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        width: 100%;
    }

    .nav-menu li {
        width: 100%;
        border-bottom: 1px solid #e0e0e0;
    }

    .nav-menu li:last-child {
        border-bottom: none;
    }

    .nav-menu a {
        display: block;
        padding: 1.25rem 0;
        font-size: 18px;
    }

    .header-cta {
        display: none !important;
    }

    .header-cta-mobile {
        display: block;
        width: 100%;
        margin-top: 2rem;
    }

    .header-cta-mobile .btn-contact {
        display: block;
        width: 100%;
        text-align: center;
        padding: 1rem 1.5rem;
        font-size: 16px;
    }

    /* Bloquer le scroll du body quand menu ouvert */
    body.menu-open {
        overflow: hidden;
    }

    /* Mega Menu - Mobile */
    .menu-item-has-megamenu > a::after {
        transform: rotate(0deg);
        transition: transform 0.2s ease;
        margin-top: -2px;
    }

    .menu-item-has-megamenu.is-open > a::after {
        transform: rotate(180deg);
    }

    .megamenu {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border-top: none;
        display: none;
        background: transparent;
        border-radius: 0;
        margin-top: 0;
        pointer-events: auto;
    }

    .megamenu::before {
        display: none;
    }

    .menu-item-has-megamenu:hover .megamenu {
        opacity: 1;
        visibility: visible;
        transform: none;
    }

    .menu-item-has-megamenu.is-open .megamenu {
        display: block;
    }

    .megamenu-inner {
        flex-direction: column;
        padding: 0;
        gap: 0;
    }

    .megamenu-left {
        flex: none;
        background: transparent;
        border-radius: 0;
        padding: 0;
        margin: 0;
    }

    .megamenu-nav {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .megamenu-nav-item a {
        padding: 1rem 1.5rem !important;
        font-size: 16px !important;
        border-radius: 0 !important;
        background: transparent !important;
        color: var(--color-primary) !important;
    }

    .megamenu-nav-item a:hover,
    .megamenu-nav-item a:focus,
    .megamenu-nav-item.is-active a {
        background: transparent !important;
        color: var(--color-primary) !important;
    }

    /* Cacher la partie droite (images et descriptions) sur mobile */
    .megamenu-right {
        display: none;
    }

    /* Pas de classe is-active sur mobile */
    .megamenu-nav-item.is-active a {
        background: transparent !important;
        color: var(--color-primary) !important;
    }
}

@media (max-width: 480px) {
    .header-logo img {
        height: 25px;
    }

    .header-container {
        padding: 0 5vw !important;
    }

    .header-nav {
        padding: 2rem 5vw;
    }

    .nav-menu a {
        font-size: 16px;
        padding: 1rem 0;
    }
}
