/* =========================================
   1. STYLES DE BASE ET MENU
========================================= */
body {
    background-color: #ffa5ec;
    font-family: "Comic Sans MS", "Comic Sans", cursive;
    margin: 0;
    border: 0;
}

.menu {
    text-align: center;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    font-size: x-large;
    background-color: #ff3d99;
    align-items: center;
}

.menu a {
    color: white;
    font-size: clamp(0.5em, 2vw, 2em);
    text-decoration: none;
}

.menu p {
    color: red;
    font-size: clamp(0.5em, 2vw, 2em);
    padding: 0 2em;
}

/* =========================================
   2. PAGE 1 : L'ENVELOPPE ANIMÉE
========================================= */
.centre-ecran {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60vh;
    position: relative;
    z-index: 10;
}

#ma-lettre {
    width: 40vw;
    max-width: 400px;
    min-width: 150px;
    cursor: pointer;
    user-select: none;
    transition: transform 0.3s ease;
}

#ma-lettre:hover {
    transform: scale(1.15);
}

#message-avertissement {
    display: none;
    color: #ff3366;
    font-size: clamp(0.5em, 2vw, 2em);
    font-weight: bold;
    margin-top: 0px;
    text-align: center;
}

/* =========================================
   3. ANIMATION : LES CŒURS EN FOND
========================================= */
#coeurs-fond {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

header {
    position: relative;
    z-index: 10;
}

.coeur {
    position: absolute;
    bottom: -50px;
    color: #ff3366;
    animation: envol linear forwards;
}

@keyframes envol {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-110vh) scale(1.5);
        opacity: 0;
    }
}

/* =========================================
   4. PAGE 2 : LA BOÎTE MYSTÈRE
========================================= */
.cache {
    display: none !important;
}

#mystere-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    cursor: pointer;
    z-index: 20;
    user-select: none;
}

#texte-mystere {
    font-size: 60px;
    font-weight: bold;
    color: #b83b5e;
    display: inline-block;
    animation: trembler 0.1s infinite alternate;
}

@keyframes trembler {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }

    33% {
        transform: translate(-5px, -8px) rotate(-10deg) scale(1.1);
    }

    66% {
        transform: translate(5px, 8px) rotate(10deg) scale(0.9);
    }

    100% {
        transform: translate(-5px, 5px) rotate(-5deg) scale(1.05);
    }
}

/* =========================================
   5. PAGE 2 : LA LETTRE ET LE TEXTE
========================================= */
.lettre-conteneur {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5vw;
    position: relative;
    z-index: 10;
}

.feuille-papier {
    background-color: #fffdf7;
    width: 100%;
    max-width: 850px;
    height: auto;
    min-height: 60vh;
    /* Les marges s'adaptent pour ne pas toucher les photos */
    padding: clamp(30px, 5vw, 80px) clamp(20px, 8vw, 100px);
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), inset 0 0 40px rgba(0, 0, 0, 0.02);
    position: relative;
    box-sizing: border-box;
}

.texte-lettre {
    position: relative;
    z-index: 5;
}

.texte-lettre h2 {
    color: #b83b5e;
    margin-top: 0;
    font-size: clamp(22px, 4vw, 32px);
}

.texte-lettre p {
    font-size: clamp(14px, 2vw, 18px);
    line-height: 1.8;
    color: #444;
}

.signature {
    text-align: right;
    font-weight: bold;
    margin-top: clamp(20px, 5vw, 40px);
    color: #b83b5e;
}

/* =========================================
   6. PAGE 2 : LES 4 PHOTOS POLAROID
========================================= */
.photo-epinglee {
    background: #ffffff;
    padding: 8px 8px 16px 8px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    border-radius: 2px;
    position: absolute;

    /* La taille s'adapte en pourcentage de l'écran */
    width: 18vw;
    max-width: 160px;
    /* Sur grand écran, bloque à 160px */
    min-width: 100px;
    /* Sur petit écran, bloque à 100px */

    text-align: center;
    user-select: none;
    transition: transform 0.2s ease, z-index 0.2s ease;
    box-sizing: border-box;
    /* Empêche le cadre blanc de déborder */
}

.photo-epinglee:hover {
    transform: scale(1.08) rotate(0deg) !important;
    z-index: 20;
}

.photo-epinglee img {
    width: 100%;
    /* Force l'image à rester parfaitement carrée peu importe sa taille */
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.photo-epinglee .legende {
    font-size: clamp(10px, 1.5vw, 13px);
    /* Le texte s'adapte aussi */
    margin: 8px 0 0 0;
    color: #555;
}

.punaise {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 20px;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

/* Placement aux 4 coins */
.photo-haut-gauche {
    top: -20px;
    left: -30px;
    transform: rotate(-5deg);
}

.photo-haut-droite {
    top: -20px;
    right: -30px;
    transform: rotate(8deg);
}

.photo-bas-gauche {
    bottom: -20px;
    left: -30px;
    transform: rotate(-6deg);
}

.photo-bas-droite {
    bottom: -20px;
    right: -30px;
    transform: rotate(4deg);
}

/* =========================================
   7. ADAPTATION POUR LES TÉLÉPHONES
========================================= */
@media (max-width: 800px) {
    .feuille-papier {
        /* On garde de grandes marges pour que le texte ne glisse pas sous les photos */
        padding: 60px 75px;
        min-height: 80vh;
    }

    .photo-epinglee {
        /* On annule l'empilement, on force la position absolue */
        position: absolute !important;
        margin: 0;

        /* On réduit la taille des Polaroid pour les petits écrans */
        width: 24vw;
        min-width: 70px;
        max-width: 120px;
        padding: 4px 4px 12px 4px;
        /* Cadre blanc plus fin */
    }

    .photo-epinglee .legende {
        font-size: 9px;
        margin-top: 4px;
    }

    .punaise {
        display: block !important;
        /* On garde les punaises */
        font-size: 14px;
        top: -10px;
    }

    /* On les replace aux 4 coins, très légèrement rentrées vers l'intérieur */
    .photo-haut-gauche {
        top: -10px;
        left: -10px;
        transform: rotate(-5deg);
        order: unset;
    }

    .photo-haut-droite {
        top: -10px;
        right: -10px;
        transform: rotate(8deg);
        order: unset;
    }

    .photo-bas-gauche {
        bottom: -10px;
        left: -10px;
        transform: rotate(-6deg);
        order: unset;
    }

    .photo-bas-droite {
        bottom: -10px;
        right: -10px;
        transform: rotate(4deg);
        order: unset;
    }
}