/* VARIABLES DE COLOR Y FUENTES */
:root {
    --primary: #c2185b; /* Rosa oscuro/Burdeos romántico */
    --secondary: #e91e63;
    --bg-color: #fffafb; /* Blanco cálido */
    --text-color: #333;
    --card-bg: #ffffff;
    --gold: #d4af37;
    
    --font-heading: 'Playfair Display', serif;
    --font-text: 'Poppins', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-text);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

/* UTILIDADES */
.container { max-width: 1000px; margin: 0 auto; padding: 60px 20px; }
.text-center { text-align: center; }
.section-title { font-family: var(--font-heading); font-size: 2.5rem; color: var(--primary); text-align: center; margin-bottom: 40px; }
.hidden { display: none; }

/* BOTONES */
.btn {
    display: inline-block; background: var(--primary); color: white; padding: 12px 28px;
    border: none; border-radius: 30px; font-size: 1rem; cursor: pointer; text-decoration: none;
    transition: all 0.3s ease; font-family: var(--font-text); font-weight: 600;
}
.btn:hover { background: var(--secondary); transform: translateY(-3px); box-shadow: 0 10px 20px rgba(233, 30, 99, 0.2); }
.btn-large { padding: 15px 40px; font-size: 1.2rem; }

/* ANIMACIONES GLOBALES */
.reveal { opacity: 0; transform: translateY(50px); transition: all 0.8s ease-out; }
.reveal.active { opacity: 1; transform: translateY(0); }
.fade-in { animation: fadeIn 1s ease-in-out forwards; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* PANTALLA DE LOGIN */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: linear-gradient(135deg, #fff0f3, #ffd1dc); }
.login-container { background: white; padding: 40px; border-radius: 20px; box-shadow: 0 15px 30px rgba(0,0,0,0.05); text-align: center; max-width: 400px; width: 90%; }
.login-container h1 { font-family: var(--font-heading); color: var(--primary); margin-bottom: 10px; }
.login-container form { display: flex; flex-direction: column; gap: 15px; margin-top: 20px; }
.login-container input { padding: 12px; border: 1px solid #ddd; border-radius: 10px; font-family: var(--font-text); font-size: 1rem; }
.login-container input:focus { outline: none; border-color: var(--primary); }
.error-msg { color: #d32f2f; margin-top: 15px; font-size: 0.9rem; }

/* PORTADA HERO */
.hero { height: 100vh; display: flex; align-items: center; justify-content: center; text-align: center; background: linear-gradient(rgba(255,250,251,0.8), rgba(255,250,251,0.9)), url('https://images.unsplash.com/photo-1518199268815-95a206b4aa26?ixlib=rb-1.2.1&auto=format&fit=crop&w=1500&q=80') center/cover; }
.hero h1 { font-family: var(--font-heading); font-size: 4rem; color: var(--primary); margin-bottom: 10px; }
.hero p { font-size: 1.2rem; color: #555; margin-bottom: 30px; }
.hero .subtitle { font-family: var(--font-heading); font-size: 1.8rem; font-style: italic; color: var(--gold); }

/* GRID DE RECUERDOS */
.memory-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 30px; }
.memory-card { background: var(--card-bg); border-radius: 15px; overflow: hidden; box-shadow: 0 10px 20px rgba(0,0,0,0.05); transition: transform 0.3s ease; text-align: center;}
.memory-card:hover { transform: translateY(-10px); }
.img-placeholder { height: 250px; background-color: #eee; background-size: cover; background-position: center; }
.memory-card h3 { font-family: var(--font-heading); color: var(--primary); padding: 20px 20px 5px; font-size: 1.5rem; }
.memory-card p { padding: 0 20px 20px; font-size: 0.95rem; color: #666; }

/* SECCIÓN PELÍCULA */
.movie-section { background-color: #1a1a1a; color: white; padding: 80px 20px; }
.movie-poster { max-width: 800px; margin: 0 auto; display: flex; background: #000; border: 2px solid #333; border-radius: 10px; overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,0.5); }
.movie-img { flex: 1; min-height: 400px; background-color: #333; background-size: cover; background-position: center; }
.movie-info { flex: 1; padding: 40px; display: flex; flex-direction: column; justify-content: center; }
.movie-info h2 { font-family: var(--font-heading); font-size: 2.5rem; color: var(--gold); margin-bottom: 10px; }
.director { text-transform: uppercase; letter-spacing: 2px; font-size: 0.8rem; margin-bottom: 20px; color: #aaa; }
.synopsis { margin-bottom: 20px; color: #ddd; }
.rating { font-weight: bold; color: var(--gold); }

/* RULETA */
.roulette-container { display: flex; gap: 30px; justify-content: center; flex-wrap: wrap; }
.roulette-box { background: white; padding: 30px; border-radius: 15px; box-shadow: 0 10px 20px rgba(0,0,0,0.05); width: 100%; max-width: 350px; border-top: 5px solid var(--primary); }
.roulette-box h3 { margin-bottom: 20px; font-family: var(--font-heading); color: #333; }
.roulette-result { height: 100px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; font-weight: bold; color: var(--secondary); background: #fff0f3; border-radius: 10px; margin-bottom: 20px; padding: 10px; transition: all 0.1s; text-align: center; }
.animando { animation: vibrar 0.1s infinite; opacity: 0.7; }
@keyframes vibrar { 0% { transform: translate(1px, 1px) rotate(0deg); } 50% { transform: translate(-1px, -1px) rotate(1deg); } 100% { transform: translate(1px, -1px) rotate(-1deg); } }

/* CUADRÍCULA DE SOBRES */
.envelope-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 30px; padding: 10px; }
.envelope { background: #fff; border-radius: 15px; padding: 40px 20px; text-align: center; box-shadow: 0 10px 20px rgba(0,0,0,0.05); cursor: pointer; transition: transform 0.3s ease, box-shadow 0.3s ease; position: relative; }
.envelope-icon { font-size: 4rem; margin-bottom: 15px; }
.envelope.unlocked { border-top: 5px solid var(--primary); }
.envelope.unlocked:hover { transform: translateY(-10px); box-shadow: 0 15px 30px rgba(194, 24, 91, 0.2); }
.click-to-open { display: inline-block; margin-top: 15px; font-size: 0.9rem; color: var(--primary); font-weight: bold; background: #fff0f3; padding: 8px 20px; border-radius: 20px; }
.envelope.locked { background: #fdfdfd; border: 2px dashed #ddd; cursor: not-allowed; opacity: 0.9; box-shadow: none; }
.unlock-time { font-size: 0.95rem; color: #888; display: block; margin-top: 5px; }

/* Animación sacudida */
.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px) rotate(-2deg); }
  75% { transform: translateX(5px) rotate(2deg); }
}

/* =========================================================
   VENTANA EMERGENTE (MODAL) - CENTRADO ABSOLUTO INFALIBLE
   ========================================================= */

/* 1. EL OVERLAY: Capa oscura que ocupa toda la pantalla */
.letter-modal {
    display: none; 
    position: fixed; /* Fijo a la pantalla */
    z-index: 9999; /* Por encima de todo */
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
}

/* 2. EL CONTENIDO: La hoja de papel centrada en el medio exacto */
.letter-modal-content {
    position: fixed; /* La fijamos a la pantalla, no al fondo oscuro */
    top: 50%; /* 50% desde arriba */
    left: 50%; /* 50% desde la izquierda */
    transform: translate(-50%, -50%); /* Truco matemático para centrar su propio eje */
    
    width: 90%;
    max-width: 700px;
    max-height: 85vh; /* Que no sea más alta que la pantalla */
    overflow-y: auto; /* Scroll interno si el texto es muy largo */
    
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    
    /* Importante: usar la nueva animación creada abajo */
    animation: zoomInCenter 0.4s ease-out forwards; 
}

/* 3. NUEVA ANIMACIÓN: Mantiene el centrado mientras hace el zoom */
@keyframes zoomInCenter {
    from { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(0.8); 
    }
    to { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1); 
    }
}

/* 4. BOTÓN DE CERRAR (&times;) */
.close-modal {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #888;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s;
}

.close-modal:hover {
    color: var(--primary);
    transform: scale(1.1);
}

/* Papel de la carta real dentro del modal */
.letter-modal .letter-paper {
    margin: 0;
    width: 100%;
    padding: 60px;
    box-shadow: none;
    border-radius: 12px;
}

/* Responsive para las cartas móviles */
@media (max-width: 768px) {
    .letter-modal .letter-paper {
        padding: 40px 20px;
    }
    .letter-modal .letter-paper::before {
        left: 20px;
    }
}

/* SORPRESA FINAL */
.surprise-box { margin-top: 30px; padding: 40px; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border-radius: 20px; transform: scale(0.9); transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); opacity: 0; }
.surprise-box.show { display: block; transform: scale(1); opacity: 1; }
.surprise-box h3 { font-family: var(--font-heading); font-size: 2rem; margin-bottom: 15px; }
.hearts-explosion { font-size: 2rem; margin-top: 20px; animation: latido 1s infinite; }
@keyframes latido { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }

/* BOTÓN MÚSICA */
.floating-btn { position: fixed; bottom: 20px; right: 20px; background: rgba(255, 255, 255, 0.9); border: 2px solid var(--primary); color: var(--primary); padding: 10px 20px; border-radius: 30px; cursor: pointer; z-index: 1000; font-family: var(--font-text); font-weight: bold; box-shadow: 0 5px 15px rgba(0,0,0,0.1); transition: 0.3s; }
.floating-btn:hover { background: var(--primary); color: white; }

/* RESPONSIVE (MÓVIL) */
@media (max-width: 768px) {
    .hero h1 { font-size: 2.8rem; }
    .hero .subtitle { font-size: 1.3rem; }
    .movie-poster { flex-direction: column; }
    .movie-img { min-height: 250px; }
    .section-title { font-size: 2rem; }
    .letter-paper { padding: 40px 20px; }
    .letter-paper::before { left: 20px; }
}

/* =========================================================
   MODAL DE GALERÍA DE FOTOS (CARRUSEL)
   ========================================================= */
.memory-card {
    cursor: pointer;
}
.click-hint {
    text-align: center; font-size: 0.85rem; color: var(--primary);
    font-weight: bold; margin-top: -10px; padding-bottom: 15px;
}

.gallery-modal {
    display: none; /* JS lo cambia a flex */
    position: fixed; z-index: 10000; /* Por encima de las cartas */
    left: 0; top: 0; width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.9); backdrop-filter: blur(8px);
    align-items: center; justify-content: center; flex-direction: column;
}

.gallery-modal img {
    max-width: 90vw; max-height: 80vh;
    object-fit: contain; /* Evita que la foto se deforme */
    border-radius: 5px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: fadeInGallery 0.3s ease;
}

@keyframes fadeInGallery {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.close-gallery {
    position: absolute; top: 20px; right: 30px;
    color: white; font-size: 40px; cursor: pointer;
    z-index: 10001; transition: 0.3s;
}
.close-gallery:hover { color: var(--primary); transform: scale(1.1); }

.gallery-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15); color: white;
    border: none; font-size: 30px; padding: 15px 20px;
    cursor: pointer; border-radius: 50%; transition: 0.3s; z-index: 10001;
}
.gallery-nav:hover { background: var(--primary); }
.gallery-nav.prev { left: 20px; }
.gallery-nav.next { right: 20px; }

.gallery-counter {
    position: absolute; bottom: 20px; color: white;
    font-size: 1.2rem; background: rgba(0,0,0,0.5);
    padding: 5px 15px; border-radius: 20px;
}

/* Ocultar botones si navegas desde el móvil para no tapar la foto */
@media (max-width: 768px) {
    .gallery-nav { padding: 10px 15px; font-size: 20px; }
    .gallery-nav.prev { left: 5px; }
    .gallery-nav.next { right: 5px; }
}