/* 
 * Navigation Critical CSS
 * Styles critiques pour le header et la navigation
 * Optimisé pour performance et comportement scroll
 */

/* === VARIABLES CSS NAVIGATION === */
:root {
    --nav-height: 80px;
    --nav-height-condensed: 64px;
    --nav-bg-color: rgba(105, 68, 60, 0.98);
    --nav-bg-color-condensed: rgba(105, 68, 60, 1);
    --nav-text-color: #E5C1B0;
    --nav-text-hover: #FFFFFF;
    --nav-text-active: #FFFFFF;
    --nav-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    --nav-shadow-condensed: 0 4px 20px rgba(0, 0, 0, 0.25);
    --nav-transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Dynamic Island Style Variables - Plus opaque */
    --island-border-radius: 50px;
    --island-border-radius-condensed: 25px;
    --island-blur: blur(15px);
    --island-backdrop: rgba(105, 68, 60, 0.95);
}

/* === STYLES DE BASE HEADER === */
.hero-section h1,
.hero-section h1 *,
.hero-section p {
    color: white !important;
}

/* Style de base pour éviter les CLS (Cumulative Layout Shift) */
body {
    font-family: 'Montserrat', sans-serif;
    color: #343a40;
    line-height: 1.6;
    /* Compensation globale pour navigation fixe */
    padding-top: var(--nav-height);
}

/* Ajustements responsive pour le body */
@media (min-width: 640px) {
    body {
        padding-top: calc(var(--nav-height) + 8px); /* +8px pour sm:top-2 */
    }
}

@media (min-width: 768px) {
    body {
        padding-top: calc(var(--nav-height) + 16px); /* +16px pour md:top-4 */
    }
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
}

/* === NAVIGATION PRINCIPALE - DYNAMIC ISLAND STYLE === */
#main-nav {
    height: var(--nav-height);
    transition: var(--nav-transition);
    transform: translateY(0);
    opacity: 1;
    /* Dynamic Island Container */
}

#main-nav .nav-container {
    background: var(--nav-bg-color);
    backdrop-filter: var(--island-blur);
    -webkit-backdrop-filter: var(--island-blur);
    box-shadow: var(--nav-shadow);
    border-radius: var(--island-border-radius);
    transition: var(--nav-transition);
    border: 1px solid rgba(255, 255, 255, 0.15);
    /* Assure une bonne opacité comme le bouton */
    background-color: rgba(105, 68, 60, 0.98);
}

/* État condensé au scroll - Dynamic Island plus petit */
#main-nav.scrolled {
    height: var(--nav-height-condensed);
}

#main-nav.scrolled .nav-container {
    background: var(--nav-bg-color-condensed);
    background-color: rgba(105, 68, 60, 1); /* Complètement opaque au scroll */
    box-shadow: var(--nav-shadow-condensed);
    border-radius: var(--island-border-radius-condensed);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#main-nav.scrolled .header-content {
    height: var(--nav-height-condensed);
}

#main-nav.scrolled .logo-link {
    font-size: 1.25rem; /* Réduction taille logo */
}

/* === PROTECTION CONTRE LES FILTRES === */
nav, 
.nav, 
header,
.logo-link,
.navigation,
nav *,
.nav *,
header *,
.logo-link *,
.navigation * {
    filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    transform: none !important;
    opacity: 1 !important;
}

/* Protection supplémentaire contre les filtres globaux */
body > nav,
body > header,
body > div > nav,
body > div > header {
    filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* Forcer la couleur du nom Marie-Annick REGOND */
.logo-link {
    color: #F5F0E8 !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4) !important;
    font-weight: 600 !important;
    letter-spacing: 0.025em !important;
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

/* Éviter les conflits de positionnement */
nav {
    position: fixed !important;
    z-index: 1000 !important;
}

/* === STYLES LIENS NAVIGATION - DYNAMIC ISLAND === */
.nav-link {
    color: var(--nav-text-color) !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: var(--nav-transition);
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.nav-link:hover::before {
    opacity: 1;
}

.nav-link:hover {
    color: var(--nav-text-hover) !important;
    transform: translateY(-1px);
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.nav-link.active {
    color: var(--nav-text-active) !important;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* === ANIMATION NAVIGATION - DYNAMIC ISLAND === */
#main-nav {
    opacity: 0;
    animation: dynamicIslandAppear 1s cubic-bezier(0.4, 0, 0.2, 1) 0.3s forwards;
}

@keyframes dynamicIslandAppear {
    0% {
        opacity: 0;
        transform: translateY(-40px) scale(0.8);
        filter: blur(8px);
    }
    30% {
        opacity: 0.3;
        transform: translateY(-15px) scale(0.95);
        filter: blur(4px);
    }
    60% {
        opacity: 0.7;
        transform: translateY(-5px) scale(1.05);
        filter: blur(2px);
    }
    80% {
        opacity: 0.9;
        transform: translateY(2px) scale(0.98);
        filter: blur(0px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0px);
    }
}

/* Animation spéciale pour mobile */
@media (max-width: 639px) {\n    #main-nav {\n        animation: mobileHeaderAppear 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.2s forwards;\n    }\n    \n    @keyframes mobileHeaderAppear {\n        0% {\n            opacity: 0;\n            transform: translateY(-100px);\n        }\n        60% {\n            opacity: 0.8;\n            transform: translateY(10px);\n        }\n        100% {\n            opacity: 1;\n            transform: translateY(0);\n        }\n    }\n}

/* Animation de morphing lors du scroll */
#main-nav .nav-container {
    transform-origin: center;
}

#main-nav.scrolled .nav-container {
    animation: islandCondense 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes islandCondense {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.98);
    }
    100% {
        transform: scale(1);
    }
}

/* === MENU MOBILE - Compatible avec Dynamic Island === */
#mobile-menu {
    overflow: hidden;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    height: 0;
    opacity: 0;
    visibility: hidden;
    border-radius: 0 0 20px 20px;
    background: rgba(105, 68, 60, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateY(-20px) scale(0.95);
    transform-origin: top center;
}

/* Sur mobile, pas de border-radius en haut pour le menu */
@media (max-width: 639px) {
    #mobile-menu {
        border-radius: 0 0 20px 20px;
    }
}

#mobile-menu.open {
    height: auto;
    min-height: 280px;
    max-height: 90vh;
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    animation: menuSlideDown 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes menuSlideDown {
    0% {
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }
    50% {
        transform: translateY(5px) scale(1.02);
        opacity: 0.7;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

#mobile-menu-content {
    opacity: 0;
    transform: translateY(-15px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    padding-bottom: 1rem;
}

#mobile-menu.open #mobile-menu-content {
    opacity: 1;
    transform: translateY(0);
    animation: contentFadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

@keyframes contentFadeInUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === RESPONSIVE MOBILE === */
@media (max-width: 639px) {
    :root {
        --nav-height: 70px;
        --nav-height-condensed: 56px;
    }
    
    #main-nav {
        top: 0 !important;
        width: 100% !important;
    }
    
    /* Header rectangulaire sur mobile - prend les coins en haut */
    #main-nav .nav-container {
        border-radius: 0 !important;
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        width: 100%;
    }
    
    /* Quand le menu mobile s'ouvre, arrondir les coins du bas */
    #main-nav .nav-container.menu-open {
        border-bottom-left-radius: 20px !important;
        border-bottom-right-radius: 20px !important;
        animation: headerMorph 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
        box-shadow: 
            0 8px 30px rgba(0, 0, 0, 0.2),
            0 0 0 1px rgba(255, 255, 255, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
    
    /* Transition fluide pour les coins */
    #main-nav .nav-container {
        transition: border-radius 0.5s cubic-bezier(0.4, 0, 0.2, 1), 
                   background 0.3s ease, 
                   box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    @keyframes headerMorph {
        0% {
            border-bottom-left-radius: 0;
            border-bottom-right-radius: 0;
            transform: scale(1);
        }
        50% {
            transform: scale(1.02);
        }
        100% {
            border-bottom-left-radius: 20px;
            border-bottom-right-radius: 20px;
            transform: scale(1);
        }
    }
    
    body {
        padding-top: var(--nav-height);
    }
    
    /* Optimisations spécifiques mobile */
    .logo-link {
        font-size: 1.25rem !important;
        max-width: 180px;
    }
    
    /* S'assurer que le bouton hamburger est bien positionné */
    #mobile-menu-button {
        position: relative !important;
        right: 0 !important;
        top: 0 !important;
        margin-right: 0;
        flex-shrink: 0;
    }
    
    #mobile-menu.open {
        max-height: 85vh;
        overflow-y: auto;
    }
}

@media (min-width: 640px) and (max-width: 767px) {
    #main-nav {
        top: 8px;
        width: 95%;
    }
    
    #main-nav .nav-container {
        border-radius: 20px;
    }
    
    #main-nav.scrolled .nav-container {
        border-radius: 16px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    #main-nav {
        top: 16px;
        width: 95%;
    }
    
    #main-nav .nav-container {
        border-radius: 24px;
    }
    
    #main-nav.scrolled .nav-container {
        border-radius: 20px;
    }
}

@media (min-width: 1024px) {
    #main-nav {
        top: 16px;
        width: 95%;
    }
    
    /* Desktop - Style Dynamic Island complet - TOUJOURS la forme originale */
    #main-nav .nav-container {
        border-radius: var(--island-border-radius) !important;
        background: rgba(105, 68, 60, 0.98) !important;
        background-color: rgba(105, 68, 60, 0.98) !important;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 
            0 8px 30px rgba(0, 0, 0, 0.15),
            0 0 0 1px rgba(255, 255, 255, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.15);
    }
    
    /* Sur desktop, on ignore l'état scrolled - on garde toujours la même forme */
    #main-nav.scrolled .nav-container {
        border-radius: var(--island-border-radius) !important;
        background: rgba(105, 68, 60, 0.98) !important;
        background-color: rgba(105, 68, 60, 0.98) !important;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 
            0 8px 30px rgba(0, 0, 0, 0.15),
            0 0 0 1px rgba(255, 255, 255, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.15);
    }
    
    /* Hauteur fixe sur desktop */
    #main-nav.scrolled {
        height: var(--nav-height) !important;
    }
    
    #main-nav.scrolled .header-content {
        height: var(--nav-height) !important;
    }
}

/* === ANIMATION DES FEUILLES - DYNAMIC ISLAND === */
.leaves-container {
    width: 100%;
    height: 100%;
    position: relative;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    mix-blend-mode: soft-light;
}

.leaves-container img {
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#mobile-menu.open .leaves-container {
    opacity: 0.08;
    transform: scale(1.05);
}

#mobile-menu.open .leaves-container img {
    filter: blur(1px);
}

#main-nav:hover .leaves-container {
    opacity: 0.08;
}

#main-nav.scrolled .leaves-container {
    opacity: 0.3;
}

/* Animation subtile de pulsation quand le menu s'ouvre */
#mobile-menu.open ~ * #main-nav .leaves-container {
    animation: leavesPulse 2s ease-in-out infinite;
}

@keyframes leavesPulse {
    0%, 100% {
        opacity: 0.08;
    }
    50% {
        opacity: 0.12;
    }
}

/* === BOUTONS MOBILE === */
#mobile-menu-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

/* === BOUTONS MOBILE === */
#mobile-menu-button .menu-icon,
#mobile-menu-button .close-icon {
    transition: opacity 0.3s ease-in-out;
}

#mobile-menu-button.open .menu-icon {
    display: none;
}

#mobile-menu-button.open .close-icon {
    display: block;
}

#mobile-menu-button .close-icon {
    display: none;
}

#mobile-menu-button .menu-icon {
    display: block;
}

/* Animation du bouton lui-même */
#mobile-menu-button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#mobile-menu-button.open {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* S'assurer que le bouton reste dans son conteneur */
.lg\:hidden {
    position: relative;
    z-index: 10;
}

/* === ANIMATIONS FADE-IN === */
.animate-fade-in {
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === LIENS MOBILES - Style Dynamic Island === */
.mobile-nav-link {
    color: var(--nav-text-color) !important;
    font-family: 'Montserrat', sans-serif;
    transition: var(--nav-transition);
    font-weight: 500;
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    margin: 0.25rem 0;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateX(-20px);
}

/* Animation échelonnée des liens du menu */
#mobile-menu.open .mobile-nav-link {
    animation: linkSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

#mobile-menu.open .mobile-nav-link:nth-child(1) { animation-delay: 0.1s; }
#mobile-menu.open .mobile-nav-link:nth-child(2) { animation-delay: 0.15s; }
#mobile-menu.open .mobile-nav-link:nth-child(3) { animation-delay: 0.2s; }
#mobile-menu.open .mobile-nav-link:nth-child(4) { animation-delay: 0.25s; }
#mobile-menu.open .mobile-nav-link:nth-child(5) { animation-delay: 0.3s; }
#mobile-menu.open .mobile-nav-link:nth-child(6) { animation-delay: 0.35s; }

@keyframes linkSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.mobile-nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.08);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-nav-link:hover::before {
    opacity: 1;
}

.mobile-nav-link:hover {
    color: var(--nav-text-hover) !important;
    transform: translateX(4px);
}

.mobile-nav-link.active {
    color: var(--nav-text-active) !important;
    background: rgba(255, 255, 255, 0.12);
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* === FIXES POUR LE LOGO === */
.logo-link[data-ignore-active="true"] {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

/* === LAZY LOADING IMAGES === */
.lazy-leaf {
    opacity: 0;
    transition: opacity 0.3s ease;
    transform: translateZ(0); /* Force GPU acceleration */
    image-rendering: auto;
}

.lazy-leaf.loaded {
    opacity: 1;
}

.lazy-leaf[src] {
    opacity: 1;
}

/* === OPTIMISATIONS PERFORMANCE === */
#main-nav,
#main-nav *,
.leaves-container,
.leaves-container * {
    will-change: transform, opacity;
}

/* Performance optimizations for images */
.leaves-container img {
    transform: translateZ(0); /* Force GPU acceleration */
    backface-visibility: hidden;
    image-rendering: optimizeQuality;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}