/* --- ESTILOS GENERALES --- */
body {
    background-color: #fce4ec;
    font-family: 'Montserrat', sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    min-height: 100vh;
}

h1 {
    color: #d81b60;
    font-family: 'Dancing Script', cursive;
    text-align: center;
    margin-top: 20px;
    z-index: 10;
    position: relative;
}

/* --- EL SOBRE --- */
.envelope-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 50px;
    height: 300px;
    position: relative;
    z-index: 50; /* Muy alto para que el sobre tape todo al abrirse */
}

.envelope-container {
    position: relative;
    cursor: pointer;
    transition: transform 0.5s;
}

/* Cuando se abre, hacemos que el contenedor del sobre desaparezca visualmente 
   para dejar paso a la carta gigante */
.envelope-container.open .envelope {
    background-color: transparent; 
}
.envelope-container.open .pocket,
.envelope-container.open .flap {
    opacity: 0; /* Desaparecen el sobre rojo */
    transition: opacity 0.5s;
}

.envelope {
    position: relative;
    width: 300px;
    height: 200px;
    background-color: #d32f2f;
    border-radius: 5px;
}

.flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-top: 110px solid #e53935;
    transform-origin: top;
    transition: transform 0.4s ease-in-out;
    z-index: 5;
}

.pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 150px solid #c62828;
    border-right: 150px solid #b71c1c;
    border-top: 100px solid transparent;
    z-index: 4;
    border-radius: 0 0 5px 5px;
}

/* --- LA CARTA (MODO GIGANTE) --- */
.letter {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) scale(0.5); /* Empieza pequeña dentro del sobre */
    width: 260px;
    height: 180px;
    background-color: white;
    padding: 20px;
    box-sizing: border-box;
    transition: all 0.8s ease-in-out;
    z-index: 3;
    border-radius: 5px;
    opacity: 0; /* Oculta al principio */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ESTADO ABIERTO: La carta se hace gigante en el centro */
.envelope-container.open .letter {
    position: fixed; /* Se fija a la pantalla */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 90%; /* Ocupa el 90% del ancho */
    max-width: 600px; /* Pero no más de 600px */
    height: auto;
    max-height: 80vh; /* Máximo 80% de la altura de la pantalla */
    z-index: 1000; /* Por encima de todo */
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    opacity: 1;
    overflow-y: auto; /* Scroll si el texto es muy largo */
}

.letter-content h2 {
    font-family: 'Dancing Script', cursive;
    color: #d32f2f;
    margin-top: 0;
}

.letter-content p {
    font-family: 'Montserrat', sans-serif;
    line-height: 1.6;
    color: #333;
}

.close-btn {
    background-color: #d32f2f;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    margin-top: 20px;
    font-family: 'Montserrat', sans-serif;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.close-btn:hover {
    background-color: #b71c1c;
}

/* --- GALERÍA DISPERSA (FOTOS GRANDES) --- */
.scattered-gallery {
    position: relative;
    width: 100%;
    min-height: 800px; /* Más espacio vertical */
    padding-bottom: 50px;
}

.card-container {
    width: 300px; /* AUMENTADO: Antes era 200px */
    height: 400px; /* AUMENTADO: Antes era 260px */
    perspective: 1000px;
    cursor: pointer;
    position: absolute; 
    transition: transform 0.3s ease, z-index 0s;
}

.card-container:hover {
    z-index: 20 !important;
    transform: scale(1.05) rotate(0deg) !important;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.card-container.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    box-shadow: 3px 3px 15px rgba(0,0,0,0.2);
    background-color: white;
    padding: 15px; /* Marco blanco más ancho */
    box-sizing: border-box;
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.card-back {
    background-color: #f8bbd0;
    color: #880e4f;
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: 'Dancing Script', cursive;
    font-size: 1.5rem; /* Letra de atrás más grande */
}

/* --- RESPONSIVE (MÓVIL) --- */
@media (max-width: 768px) {
    .scattered-gallery {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 40px;
        position: static;
    }

    .card-container {
        position: static !important;
        transform: rotate(0deg) !important;
        margin-bottom: 20px;
        width: 90%; /* En móvil que ocupe casi todo el ancho */
        max-width: 300px;
        height: 400px;
    }
}
/* El corazón que cae */
.heart-fall {
    position: fixed;
    top: -10px;
    font-size: 20px;
    color: #e91e63;
    animation: fall linear forwards;
    z-index: 0; /* Detrás de todo */
    opacity: 0.8;
}

@keyframes fall {
    to {
        transform: translateY(105vh); /* Cae hasta el final de la pantalla */
    }
}
/* --- GALERÍA TIPO PINTEREST --- */
.memory-wall {
    padding: 40px 20px;
    text-align: center;
    background-color: #fff0f5; /* Fondo ligeramente diferente para separar secciones */
    margin-top: 50px;
}

.memory-wall h2 {
    color: #880e4f;
    font-family: 'Dancing Script', cursive;
    font-size: 2.5rem;
    margin-bottom: 30px;
}

/* El Grid Mágico */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Se ajusta solo */
    gap: 15px;
    max-width: 1000px;
    margin: 0 auto;
}

.gallery-item {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    cursor: pointer;
    position: relative;
}

.gallery-item:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Para que no se deformen */
    display: block;
    border-radius: 10px;
}

/* --- BOTÓN DE SUBIR FOTO --- */
input[type="file"] {
    display: none; /* Ocultamos el input feo por defecto */
}

.custom-file-upload {
    display: inline-block;
    padding: 10px 20px;
    cursor: pointer;
    background-color: #d81b60;
    color: white;
    border-radius: 25px;
    font-family: 'Montserrat', sans-serif;
    font-weight: bold;
    margin-bottom: 30px;
    transition: background 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.custom-file-upload:hover {
    background-color: #ad1457;
}

/* Animación para fotos nuevas */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.new-photo {
    animation: fadeIn 0.5s ease forwards;
}
/* --- ESTILOS DEL LIGHTBOX (VISOR DE FOTOS) --- */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9); /* Fondo negro al 90% */
    display: flex; /* Usamos flex para centrar */
    justify-content: center;
    align-items: center;
    z-index: 3000; /* Por encima del chat y todo lo demás */
    opacity: 0;
    pointer-events: none; /* No se puede clicar si está invisible */
    transition: opacity 0.3s ease;
}

/* Clase para mostrarlo */
.lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox img {
    max-width: 90%; /* Que no se salga de la pantalla en ancho */
    max-height: 90%; /* Que no se salga en alto */
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

/* Efecto zoom al abrir */
.lightbox.active img {
    transform: scale(1);
}

.close-btn-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    font-weight: bold;
    z-index: 3001;
}

.close-btn-lightbox:hover {
    color: #d81b60;
}