/* Police manuscrite */
@font-face {
    font-family: 'Photograph Signature';
    src: url('/Photograph Signature.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none !important; /* Supprimer les contours par défaut */
    border: none; /* Supprimer les bordures par défaut */
    -webkit-tap-highlight-color: transparent;
    -webkit-focus-ring-color: transparent;
}

*:focus {
    outline: none !important; /* Supprimer les contours au focus */
}

*:focus-visible {
    outline: none !important; /* Supprimer les contours focus-visible */
}

*:active {
    outline: none !important;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Georgia', 'Times New Roman', serif;
    background: #2a1f0f;
    color: #3d2e1a;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Augmenter la résolution globale */
    image-rendering: -webkit-optimize-contrast;
    text-rendering: optimizeLegibility;
    outline: none; /* Supprimer les contours par défaut */
}

/* Overlay de chargement - fond beige qui cache tout au début */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f5f0e8; /* Couleur beige de la feuille centrale */
    z-index: 10000; /* Très élevé pour passer au-dessus de tout */
    pointer-events: none; /* Ne pas bloquer les interactions */
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Supprimer tous les contours par défaut du navigateur */
a, button, input, select, textarea, div, span, img, p, h1, h2, h3, h4, h5, h6, nav, ul, li {
    outline: none !important;
    -webkit-tap-highlight-color: transparent; /* Supprimer le highlight sur mobile */
    -webkit-focus-ring-color: transparent;
    border: none !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

a:focus, button:focus, input:focus, select:focus, textarea:focus,
div:focus, span:focus, img:focus, p:focus, h1:focus, h2:focus, h3:focus, h4:focus, h5:focus, h6:focus,
nav:focus, ul:focus, li:focus {
    outline: none !important;
    -webkit-focus-ring-color: transparent;
    border: none !important;
    box-shadow: none !important;
}

a:active, button:active, img:active, p:active, nav:active, ul:active, li:active {
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
    border: none !important;
    box-shadow: none !important;
}

a:visited, a:link {
    outline: none !important;
    border: none !important;
}

/* Supprimer les contours spécifiques pour les images */
img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

/* Container principal */
.bunker-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
    perspective: 2000px;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    outline: none !important;
    border: none !important;
    -webkit-tap-highlight-color: transparent;
    -webkit-focus-ring-color: transparent;
}

.bunker-container.dragging {
    cursor: grabbing;
}

/* Nouveau bouton menu mobile (caché sur desktop) */
.mobile-menu-btn {
    display: none !important; /* Caché par défaut sur desktop */
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    height: auto;
    background: none; /* Pas de fond */
    border: none; /* Pas de bordure */
    cursor: pointer;
    z-index: 1500; /* En dessous des modals (2000) mais au-dessus des autres éléments */
    outline: none;
    touch-action: manipulation;
    pointer-events: auto !important;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    box-shadow: none; /* Pas d'ombre */
    align-items: center;
    justify-content: center;
    padding: 10px;
    -webkit-tap-highlight-color: transparent;
    opacity: 0; /* Caché au départ */
    visibility: hidden; /* Caché au départ */
}

.mobile-menu-btn:hover {
    transform: translateX(-50%) scale(1.1);
}

.mobile-menu-btn:hover .menu-icon {
    color: #a68a6f; /* Légèrement plus clair au survol */
}

.mobile-menu-btn:active {
    transform: translateX(-50%) scale(0.95);
}

.menu-icon {
    font-size: 32px; /* Agrandi */
    color: #8b7355;
    line-height: 1;
    display: block;
    font-weight: normal;
    letter-spacing: 0;
}

/* Ancien bouton menu - garder pour compatibilité */
.menu-toggle {
    display: none;
}

/* Overlay sombre pour le menu mobile */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1500;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none !important; /* Ne pas bloquer les clics quand inactif */
}

.menu-overlay.active {
    opacity: 1;
    pointer-events: auto !important; /* Activer les clics seulement quand actif */
}

/* Menu discret */
.menu {
    position: fixed;
    top: 50%;
    right: 30px;
    transform: translateY(-50%);
    z-index: 1000;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    outline: none !important;
    border: none !important;
    -webkit-tap-highlight-color: transparent;
    -webkit-focus-ring-color: transparent;
    /* Ne pas bloquer les clics sur les enveloppes */
    pointer-events: auto;
}

/* Sur mobile, le menu est caché par défaut */
@media (max-width: 768px) {
    .menu:not(.mobile-open) {
        /* Menu complètement caché */
        display: none !important;
        pointer-events: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        z-index: -1 !important;
    }
}

.menu:hover {
    opacity: 1;
}

.menu ul {
    list-style: none;
    display: flex;
    gap: 20px;
    flex-direction: column;
    align-items: flex-end;
}

.menu li {
    list-style: none;
}

.menu a {
    color: #8b7355;
    text-decoration: none;
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 300;
    transition: color 0.3s ease;
    cursor: pointer;
    text-align: right;
    display: block;
}

.menu a:hover {
    color: #b89d7a;
}

/* Supprimer spécifiquement les contours du menu */
.menu,
.menu *,
.menu *:hover,
.menu *:focus,
.menu *:active,
.menu *:visited,
.menu *:focus-visible {
    outline: 0 !important;
    outline: none !important;
    outline-offset: 0 !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-focus-ring-color: transparent !important;
    box-shadow: none !important;
    border: none !important;
    /* Firefox spécifique */
    -moz-outline: none !important;
    -moz-outline-radius: 0 !important;
    -moz-outline-offset: 0 !important;
    /* Empêcher la sélection */
    -moz-user-select: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Règle supplémentaire pour Firefox */
@-moz-document url-prefix() {
    .menu,
    .menu *,
    .logo-image {
        outline: 0 !important;
        outline: none !important;
        -moz-outline: none !important;
        -moz-outline-radius: 0 !important;
        -moz-outline-offset: 0 !important;
    }
}

/* Scène cartographique */
.map-scene {
    width: 320%;
    height: 310%;
    position: absolute;
    top: -105%;
    left: -110%;
    transform-style: preserve-3d;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Permet aux éléments de dépasser */
    overflow: visible;
}

/* Grille 3×3 */
.map-grid {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    position: relative;
    overflow: visible;
    /* Pas d'espace entre les zones */
    gap: 0;
    /* Légèrement agrandir pour masquer les bords */
    transform: scale(1.01);
    transform-origin: center center;
}

/* Zones de la carte */
.map-zone {
    position: relative;
    overflow: hidden;
    background: #3d2e1a;
    border: 1px solid rgba(139, 115, 85, 0.1);
    transform-style: preserve-3d;
    transition: opacity 0.3s ease;
    /* Marge négative plus importante pour masquer les bords et aligner parfaitement les layers */
    margin: -5px;
}

/* Zone centrale : overflow visible pour les enveloppes et le triangle */
.map-zone.zone-center {
    overflow: visible !important; /* FORCER pour que le triangle soit visible */
}

.map-zone.loading {
    opacity: 0.3;
}

.map-zone.loaded {
    opacity: 1;
}

/* Zone centrale active au départ */
.map-zone.zone-center {
    z-index: 10;
}

.map-zone.zone-center .central-paper {
    z-index: 12;
}

/* Contenu des zones */
.zone-content {
    width: 102%;
    height: 102%;
    position: relative;
    transform-style: preserve-3d;
    /* Légèrement décaler pour centrer l'agrandissement */
    left: -1%;
    top: -1%;
    overflow: visible !important; /* Permettre au triangle de dépasser */
}

/* Zone centrale : contenu peut dépasser */
.map-zone.zone-center .zone-content {
    overflow: visible;
}

/* Fond de table (bois) */
.table-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at center, #4a3723 0%, #2a1f0f 100%),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(139, 115, 85, 0.03) 2px,
            rgba(139, 115, 85, 0.03) 4px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(139, 115, 85, 0.02) 2px,
            rgba(139, 115, 85, 0.02) 4px
        );
    background-size: 100% 100%, 20px 20px, 20px 20px;
    z-index: -1;
    transform: translateZ(-100px) scale(1.1);
    filter: blur(0.5px);
    opacity: 0.9;
}

/* Feuille centrale */
.central-paper {
    width: 80%;
    height: 80%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateZ(20px);
    background: 
        linear-gradient(135deg, #f5f0e8 0%, #e8ddd4 100%),
        repeating-linear-gradient(
            transparent,
            transparent 2px,
            rgba(139, 115, 85, 0.05) 2px,
            rgba(139, 115, 85, 0.05) 4px
        );
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.3),
        inset 0 0 100px rgba(139, 115, 85, 0.1),
        inset 0 0 200px rgba(139, 115, 85, 0.05);
    border-radius: 2px;
    padding: 20px 40px 40px 40px; /* Réduit le padding-top pour permettre le bouton en haut */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid rgba(139, 115, 85, 0.2);
    overflow: visible !important; /* Permettre au triangle de dépasser */
    z-index: 12; /* En dessous des enveloppes */
}

.central-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            transparent,
            transparent 2px,
            rgba(139, 115, 85, 0.05) 2px,
            rgba(139, 115, 85, 0.05) 4px
        );
    pointer-events: none;
}

.paper-content {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Centrer verticalement le contenu */
    align-items: center;
    padding-top: 50px; /* Espace pour le bouton de connexion en haut */
}

.logo-image {
    max-width: 300px;
    width: 100%;
    height: auto;
    margin: 0 auto 20px auto;
    display: block;
    flex-shrink: 0; /* Empêcher le logo de rétrécir */
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
    outline: none !important;
    outline: 0 !important;
    outline-offset: 0 !important;
    border: none !important;
    -webkit-tap-highlight-color: transparent;
    -webkit-focus-ring-color: transparent;
    -webkit-user-drag: none;
    user-drag: none;
    /* Firefox spécifique */
    -moz-outline: none !important;
    -moz-outline-radius: 0 !important;
    /* Empêcher la sélection */
    -moz-user-select: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: auto;
    /* Supprimer tous les contours et bordures */
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    /* Supprimer les contours de sélection */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Logo cliquable */
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    touch-action: manipulation;
    /* Logo invisible au départ, apparaîtra via l'animation JavaScript */
    opacity: 0;
}

.logo-image:focus,
.logo-image:active,
.logo-image:hover,
.logo-image:visited,
.logo-image:link {
    outline: none !important;
    outline: 0 !important;
    outline-offset: 0 !important;
    border: none !important;
    -moz-outline: none !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
}


/* Supprimer les contours du conteneur du logo */
.paper-content,
.central-paper {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

.paper-content:focus,
.central-paper:focus {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* Menu utilisateur / Bouton connexion */
.paper-content {
    position: relative; /* Pour positionner le menu utilisateur */
}

.user-menu-container {
    position: absolute;
    top: 5px; /* Positionné en haut de la feuille */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    text-align: center;
    width: 100%;
}

.login-button {
    color: #8b7355;
    text-decoration: none;
    font-size: 1.3rem;
    letter-spacing: 1px;
    font-weight: normal;
    background: none;
    border: none;
    cursor: pointer;
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.3s ease;
    font-family: 'Photograph Signature', cursive;
    font-style: normal;
    text-transform: none;
    display: inline-block;
}

.login-button:hover {
    color: #2a1f0f;
}

.user-menu {
    position: relative;
    display: inline-block;
}

.user-menu-toggle {
    background: none;
    border: none;
    color: #8b7355;
    font-size: 1.3rem;
    letter-spacing: 1px;
    font-weight: normal;
    cursor: pointer;
    padding: 0;
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.3s ease;
    font-family: 'Photograph Signature', cursive;
    font-style: normal;
    text-transform: none;
}

.user-menu-toggle:hover {
    color: #2a1f0f;
}

.user-name {
    display: inline-block;
}

.user-menu-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    margin-top: 10px;
    background: #f5f0e8;
    border: 2px solid #8b7355;
    border-radius: 4px;
    min-width: 250px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 1001;
}

.user-menu:hover .user-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.user-menu-item {
    display: block;
    padding: 12px 20px;
    color: #2a1f0f;
    text-decoration: none;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(139, 115, 85, 0.2);
    transition: background 0.2s ease;
}

.user-menu-item:last-child {
    border-bottom: none;
}

.user-menu-item:hover {
    background: rgba(139, 115, 85, 0.1);
    color: #8b7355;
}

.welcome-text {
    font-size: 1.3rem;
    color: #2a1f0f;
    letter-spacing: 2px;
    font-weight: 300;
    line-height: 1.6;
    text-align: center;
    margin-top: 20px;
    min-height: 1.6em; /* Éviter le saut de hauteur pendant l'animation */
    outline: none !important;
    border: none !important;
    -webkit-tap-highlight-color: transparent;
    -webkit-focus-ring-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.welcome-text.typing::after {
    content: '|';
    color: #8b7355;
    animation: blink 1s infinite;
    outline: none !important;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Enveloppes */
.envelope {
    position: absolute;
    width: 200px;
    height: 150px;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.3s ease, opacity 0.4s ease;
    z-index: 2000 !important; /* Très élevé pour passer au-dessus du menu (1000) et du menu-toggle (2000) */
    pointer-events: auto !important; /* Forcer les événements tactiles */
    /* S'assurer que les enveloppes ne sont pas coupées */
    will-change: transform;
    outline: none !important; /* Supprimer les contours */
    border: none; /* Supprimer les bordures par défaut */
    touch-action: manipulation; /* Améliorer la réactivité tactile */
    overflow: visible !important; /* Permettre au triangle de dépasser */
}

/* S'assurer que les enveloppes passent au-dessus du menu-toggle */
.envelope-top-right,
.envelope-bottom-right {
    z-index: 2001 !important; /* Au-dessus du menu-toggle (1500) */
    pointer-events: auto !important; /* Forcer les événements tactiles */
}

.envelope-top-left {
    /* Position au coin haut-gauche de la zone, bien au-delà de la feuille */
    top: 5%;
    left: 5%;
    transform: rotate(-15deg) translateZ(30px);
    z-index: 15;
}

.envelope-top-right {
    /* Position au coin haut-droite de la zone, bien au-delà de la feuille */
    top: 5%;
    right: 5%;
    transform: rotate(15deg) translateZ(30px);
    z-index: 15;
}

.envelope-bottom-left {
    /* Position au coin bas-gauche de la zone, bien au-delà de la feuille */
    bottom: 5%;
    left: 5%;
    transform: rotate(15deg) translateZ(30px);
    z-index: 15;
}

.envelope-bottom-right {
    /* Position au coin bas-droite de la zone, bien au-delà de la feuille */
    bottom: 5%;
    right: 5%;
    transform: rotate(-15deg) translateZ(30px);
    z-index: 15;
}

.envelope-top-left:hover {
    transform: rotate(-15deg) translateZ(35px) scale(1.05);
}

.envelope-top-right:hover {
    transform: rotate(15deg) translateZ(35px) scale(1.05);
}

.envelope-bottom-left:hover {
    transform: rotate(15deg) translateZ(35px) scale(1.05);
}

.envelope-bottom-right:hover {
    transform: rotate(-15deg) translateZ(35px) scale(1.05);
}

.envelope-top-left.opening {
    transform: rotate(-15deg) translateZ(30px) scale(1.05);
}

.envelope-top-right.opening {
    transform: rotate(15deg) translateZ(30px) scale(1.05);
}

.envelope-bottom-left.opening {
    transform: rotate(15deg) translateZ(30px) scale(1.05);
}

.envelope-bottom-right.opening {
    transform: rotate(-15deg) translateZ(30px) scale(1.05);
}

.envelope.opening .envelope-flap {
    transform: rotateX(-180deg);
    transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1 !important;
    /* Rotation pure autour de la base (top center) - pas de translation, la base reste fixe */
}

/* Lettre apparaît et sort par le haut lors de l'ouverture - z-index le plus haut */
.envelope.opening .letter {
    opacity: 1;
    visibility: visible;
    z-index: 10 !important;
    position: relative;
    transform-style: preserve-3d;
}

@keyframes letterOpen {
    0% {
        transform: translate(-50%, -50%) translateZ(2px) scale(1);
        opacity: 0;
    }
    40% {
        transform: translate(-50%, -50%) translateY(-80px) translateZ(400px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) translateY(-20px) translateX(15px) rotateZ(5deg) translateZ(400px) scale(1.3);
        opacity: 1;
    }
}

/* Animation pour enveloppe penchée à gauche (top-left, bottom-right) - rotation vers la droite (opposé) */
.envelope-top-left.opening .letter,
.envelope-bottom-right.opening .letter {
    animation: letterOpenRight 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Animation pour enveloppe penchée à droite (top-right, bottom-left) - rotation vers la gauche (opposé) */
.envelope-top-right.opening .letter,
.envelope-bottom-left.opening .letter {
    animation: letterOpenLeft 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes letterOpenLeft {
    0% {
        transform: translate(-50%, -50%) translateZ(2px) scale(1);
        opacity: 0;
    }
    40% {
        transform: translate(-50%, -50%) translateY(-80px) translateZ(400px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) translateY(-20px) translateX(-15px) rotateZ(-5deg) translateZ(400px) scale(1.3);
        opacity: 1;
    }
}

@keyframes letterOpenRight {
    0% {
        transform: translate(-50%, -50%) translateZ(2px) scale(1);
        opacity: 0;
    }
    40% {
        transform: translate(-50%, -50%) translateY(-80px) translateZ(400px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) translateY(-20px) translateX(15px) rotateZ(5deg) translateZ(400px) scale(1.3);
        opacity: 1;
    }
}

/* Lettre retourne dans l'enveloppe lors de la fermeture - chemin inverse */
.envelope.closing .letter {
    animation: letterClose 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    z-index: 10 !important;
}

@keyframes letterClose {
    0% {
        transform: translate(-50%, -50%) translateY(-20px) translateX(15px) rotateZ(5deg) translateZ(400px) scale(1.3);
        opacity: 1;
    }
    40% {
        transform: translate(-50%, -50%) translateY(-80px) translateZ(400px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) translateZ(2px) scale(1);
        opacity: 0;
    }
}

/* Animation de fermeture pour enveloppe penchée à gauche - rotation vers la droite (opposé) */
.envelope-top-left.closing .letter,
.envelope-bottom-right.closing .letter {
    animation: letterCloseRight 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Animation de fermeture pour enveloppe penchée à droite - rotation vers la gauche (opposé) */
.envelope-top-right.closing .letter,
.envelope-bottom-left.closing .letter {
    animation: letterCloseLeft 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes letterCloseLeft {
    0% {
        transform: translate(-50%, -50%) translateY(-20px) translateX(-15px) rotateZ(-5deg) translateZ(400px) scale(1.3);
        opacity: 1;
    }
    40% {
        transform: translate(-50%, -50%) translateY(-80px) translateZ(400px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) translateZ(2px) scale(1);
        opacity: 0;
    }
}

@keyframes letterCloseRight {
    0% {
        transform: translate(-50%, -50%) translateY(-20px) translateX(15px) rotateZ(5deg) translateZ(400px) scale(1.3);
        opacity: 1;
    }
    40% {
        transform: translate(-50%, -50%) translateY(-80px) translateZ(400px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) translateZ(2px) scale(1);
        opacity: 0;
    }
}

/* Corps de l'enveloppe - z-index le plus bas */
.envelope-body {
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(135deg, #f5f0e8 0%, #e8ddd4 100%);
    border: 2px solid rgba(139, 115, 85, 0.6); /* Réduit de 3px à 2px et opacité réduite */
    border-radius: 4px;
    position: relative;
    box-shadow: 
        0 5px 20px rgba(0, 0, 0, 0.2),
        inset 0 0 20px rgba(139, 115, 85, 0.1),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
    transform-style: preserve-3d;
    z-index: 1;
    overflow: visible !important; /* Permettre au triangle de dépasser */
}

/* Rabat de l'enveloppe - Forme triangulaire - z-index au milieu */
.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60%;
    /* Forme triangulaire avec la base en haut (arête la plus grande = axe de rotation) */
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    background: linear-gradient(135deg, #e8ddd4 0%, #d4c4b0 100%);
    /* L'axe de rotation est sur la base (en haut) - la base reste fixe */
    transform-origin: top center;
    transform: rotateX(0deg);
    transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 
        0 -5px 15px rgba(0, 0, 0, 0.15),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    z-index: 2;
    /* z-index au-dessus du body (1) mais en dessous de la lettre (3) */
    overflow: visible !important;
    pointer-events: none;
    /* S'assurer que le triangle n'est jamais coupé */
    will-change: transform;
    backface-visibility: visible;
}

/* Bordure supérieure (base du triangle - axe de rotation) - réduite */
.envelope-flap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px; /* Réduit de 4px à 2px */
    background: rgba(139, 115, 85, 0.7); /* Opacité réduite */
    z-index: 4;
    box-shadow: 0 1px 2px rgba(139, 115, 85, 0.5); /* Ombre réduite */
}

/* Bordures latérales du triangle - réduites */
.flap-border-left {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    border-left: 2px solid rgba(139, 115, 85, 0.7); /* Réduit de 4px à 2px et opacité réduite */
    clip-path: polygon(0 0, 100% 0, 0 100%);
    z-index: 4;
    pointer-events: none;
    box-shadow: -1px 0 2px rgba(139, 115, 85, 0.5); /* Ombre réduite */
}

.flap-border-right {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    border-right: 2px solid rgba(139, 115, 85, 0.7); /* Réduit de 4px à 2px et opacité réduite */
    clip-path: polygon(100% 0, 100% 0, 50% 100%);
    z-index: 4;
    pointer-events: none;
    box-shadow: 1px 0 2px rgba(139, 115, 85, 0.5); /* Ombre réduite */
}

/* Face avant de l'enveloppe - cache la lettre au départ */
.envelope-front-face {
    position: absolute;
    bottom: 0; /* Centré en bas de l'enveloppe */
    left: 50%; /* Centrer horizontalement */
    transform: translateX(-50%) translateZ(1px); /* Centrer et positionner en 3D */
    width: 90%; /* Largeur adaptée au contenu */
    height: auto; /* Hauteur adaptée au contenu du texte */
    min-height: 60px; /* Hauteur minimale pour le texte */
    border: none;
    border-radius: 4px 4px 0 0; /* Arrondi en haut */
    transform-style: preserve-3d;
    transition: opacity 0.4s ease 0.4s, transform 0.4s ease 0.4s;
    pointer-events: none;
    display: flex;
    align-items: center; /* Centrer verticalement le texte */
    justify-content: center; /* Centrer horizontalement le texte */
    padding: 15px 20px; /* Espacement interne pour le texte */
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 15px;
}

/* Label sur la face avant de l'enveloppe */
.envelope-label {
    color: #8b7355;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-align: center;
    padding: 0 10px;
    line-height: 1.3;
    transform: translateZ(2px);
    font-family: 'Georgia', 'Times New Roman', serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Face avant disparaît quand l'enveloppe s'ouvre */
.envelope.opening .envelope-front-face {
    opacity: 0;
    transform: translateX(-50%) translateZ(-10px) scale(0.95); /* Maintenir le centrage */
}

/* Face avant réapparaît quand l'enveloppe se ferme */
.envelope.closing .envelope-front-face {
    opacity: 1;
    transform: translateX(-50%) translateZ(2px); /* Maintenir le centrage */
    transition: opacity 0.4s ease 0.2s, transform 0.4s ease 0.2s;
}

/* Rabat se referme lors de la fermeture */
.envelope.closing .envelope-flap {
    transform: rotateX(0deg);
    transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.2s;
}

/* Lettre - cachée au départ, apparaît lors de l'ouverture - z-index le plus haut */
.letter {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateZ(2px);
    width: 85%;
    height: 70%;
    background: #ffffff;
    border: 1px solid #d4c4b0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    z-index: 3;
    /* z-index le plus haut : au-dessus du body (1) et du flap (2) */
    overflow: visible !important; /* Retirer le cache */
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Contenu de la lettre */
.letter-content {
    width: 100%;
    height: 100%;
    overflow: hidden; /* Cacher la barre de défilement dans la feuille blanche de l'animation */
    overflow-y: hidden;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    box-sizing: border-box;
}

.letter-title {
    font-size: 0.4rem;
    font-weight: 600;
    color: #2a1f0f;
    margin-bottom: 3px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-align: center;
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.1;
}

.letter-text {
    font-size: 0.32rem;
    color: #3d2e1a;
    line-height: 1.15;
    text-align: justify;
    margin: 0;
    font-family: 'Georgia', 'Times New Roman', serif;
    flex: 1;
}

.letter::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    height: 2px;
    background: #8b7355;
    opacity: 0.3;
}

/* Overlay pour le contenu des enveloppes */
.envelope-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(42, 31, 15, 0.95);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden !important; /* Désactiver le scroll sur l'overlay */
}

.envelope-overlay.active {
    display: flex;
    opacity: 1;
}

/* Désactiver le scroll du body quand l'overlay est ouvert */
.envelope-overlay.active ~ *,
body:has(.envelope-overlay.active) {
    overflow: hidden !important;
}

.overlay-content {
    width: 80%;
    max-width: 900px;
    background: #f5f0e8;
    padding: 60px;
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    transform: scale(0.9);
    transition: transform 0.4s ease;
    max-height: 90vh;
    overflow-y: auto; /* Réactiver le scroll dans le modal final */
    overflow-x: hidden;
    pointer-events: auto;
    touch-action: manipulation;
}

.overlay-body {
    overflow: visible; /* Permettre le scroll dans le modal final */
    max-height: 100%;
}

.envelope-overlay.active .overlay-content {
    transform: scale(1);
}

.close-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #8b7355;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
    outline: none !important; /* Supprimer les contours */
    z-index: 2010; /* Au-dessus de l'overlay (2000) et du menu (1600) */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    pointer-events: auto;
}

.close-overlay:hover {
    color: #2a1f0f;
}

.overlay-body {
    color: #2a1f0f;
    line-height: 1.8;
    font-size: 1.1rem;
}

.overlay-body #map {
    width: 100%;
    height: 400px;
    margin-top: 30px;
    border: 2px solid #8b7355;
    border-radius: 4px;
    overflow: hidden;
}

.overlay-body #map iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Effets de parallax */
.map-zone[data-zone="center"] .zone-content {
    transform: translateZ(0px);
}

.map-zone[data-zone="top-left"] .zone-content,
.map-zone[data-zone="top-right"] .zone-content,
.map-zone[data-zone="bottom-left"] .zone-content,
.map-zone[data-zone="bottom-right"] .zone-content {
    transform: translateZ(-20px);
}

/* Responsive */
@media (max-width: 768px) {
    .logo-image {
        max-width: 200px;
    }
    
    .welcome-text {
        font-size: 1rem;
        letter-spacing: 1px;
    }
    
    .envelope {
        width: 150px;
        height: 110px;
        pointer-events: auto !important; /* Forcer les événements tactiles sur mobile */
        touch-action: manipulation; /* Améliorer la réactivité tactile */
        -webkit-tap-highlight-color: transparent;
    }
    
    .envelope-top-left {
        top: 3%;
        left: 3%;
        transform: rotate(-15deg) translateZ(30px);
    }
    
    .envelope-top-right {
        top: 3%;
        right: 3%;
        transform: rotate(15deg) translateZ(30px);
    }
    
    .envelope-bottom-left {
        bottom: 3%;
        left: 3%;
        transform: rotate(15deg) translateZ(30px);
    }
    
    .envelope-bottom-right {
        bottom: 3%;
        right: 3%;
        transform: rotate(-15deg) translateZ(30px);
    }
    
    /* Nouveau bouton menu visible sur mobile */
    .mobile-menu-btn {
        display: flex !important; /* Flex pour centrer le symbole */
        position: fixed !important;
        bottom: 80px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 1500 !important; /* En dessous des modals (2000) mais au-dessus des autres éléments */
        pointer-events: auto !important; /* Forcer les événements tactiles */
        touch-action: manipulation !important;
        /* opacity et visibility seront gérés par JavaScript après l'animation */
    }
    
    /* Overlay visible sur mobile mais ne bloque pas les clics quand inactif */
    .menu-overlay {
        display: block;
        z-index: 1500; /* Au-dessus du menu-toggle mais en dessous du menu ouvert */
        pointer-events: none !important; /* Ne pas bloquer les clics quand inactif */
    }
    
    .menu-overlay.active {
        pointer-events: auto !important; /* Activer seulement quand actif */
        z-index: 1550 !important; /* Au-dessus du menu-toggle (1500) mais en dessous du menu ouvert (1600) */
    }
    
    /* Menu caché par défaut sur mobile - complètement retiré du flux */
    /* Cette règle est déjà gérée par la règle générale au-dessus */
    
    /* Menu ouvert sur mobile - centré au milieu */
    .menu.mobile-open {
        display: block !important;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        opacity: 1;
        pointer-events: auto !important; /* Activer les clics quand ouvert */
        visibility: visible !important;
        z-index: 1600 !important; /* Au-dessus de l'overlay (1500) mais en dessous de l'envelope-overlay (2000) */
        /* Style du menu ouvert */
        background: rgba(245, 234, 216, 0.98);
        padding: 40px 60px;
        border-radius: 8px;
        border: 2px solid #8b7355;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    }
    
    .menu ul {
        gap: 20px;
        align-items: center; /* Centrer les éléments */
    }
    
    .menu a {
        font-size: 20px; /* Agrandi pour mobile */
        letter-spacing: 3px;
        text-align: center; /* Centrer le texte */
        padding: 10px 0;
    }
    
    .envelope-label {
        font-size: 0.9rem; /* Réduit pour mobile */
        letter-spacing: 1px;
    }
    
    /* Réduire la taille des titres dans les modals sur mobile */
    .overlay-body h2 {
        font-size: 1.4rem !important; /* Réduit de 2rem à 1.4rem sur mobile */
        letter-spacing: 2px !important;
        margin-bottom: 15px !important;
    }
    
    .overlay-body h3 {
        font-size: 1.1rem !important; /* Réduit pour mobile */
        margin-bottom: 8px !important;
    }
    
    .overlay-content {
        padding: 40px 30px !important; /* Réduire le padding sur mobile */
    }
}
