/* ==========================================
   VARIABLES GLOBALES & RESET (Romance Pastel)
   ========================================== */
:root {
    --bg-dark: #ffb3c6;
    --bg-light: #ffe6ea;
    --envelope-color: #ffffff;
    --envelope-dark: #f2eef0;
    --wax-color: #d81b60;
    --wax-accent: #ff4081;
    --paper-color: #fff9fa;
    --ink-color: #4a154b;
    --wpp-color: #25D366; /* Verde WhatsApp */
    --font-hand: 'Dancing Script', cursive;
    --font-royal: 'Cinzel', serif;
    --font-modern: 'Poppins', sans-serif;
}

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

body {
    background: radial-gradient(circle at center, var(--bg-light) 0%, var(--bg-dark) 100%);
    min-height: 100vh;
    overflow: hidden;
    font-family: var(--font-modern);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- SISTEMA DE PÉTALOS --- */
#petals-container {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; /* Para que no bloqueen los clics */
    z-index: 1;
}

.petal {
    position: absolute;
    background: radial-gradient(circle, #ffb3c6 0%, #d81b60 100%);
    border-radius: 15px 0 15px 0;
    opacity: 0.7;
    animation: fall linear forwards;
    box-shadow: 0 2px 5px rgba(216, 27, 96, 0.3);
}

@keyframes fall {
    0% { transform: translateY(-10vh) rotate(0deg) scale(0.5); opacity: 0; }
    10% { opacity: 0.8; }
    100% { transform: translateY(110vh) rotate(360deg) scale(1); opacity: 0; }
}

/* --- INTERFAZ PRINCIPAL --- */
.container { position: relative; z-index: 10; perspective: 1200px; }

.instruction {
    position: absolute; top: -50px; width: 100%; text-align: center;
    color: #d81b60; font-size: 1rem; font-weight: 600;
    letter-spacing: 1.5px; text-transform: uppercase;
    animation: instructionPulse 2s infinite; z-index: 20;
}

.envelope-wrapper {
    position: relative; width: 340px; height: 240px;
    transition: transform 1.2s ease, opacity 1s ease; margin-top: 40px;
}

.envelope-body {
    position: absolute; bottom: 0; width: 100%; height: 100%;
    background: var(--envelope-dark); border-radius: 10px; z-index: 3;
    box-shadow: 0 20px 50px rgba(216, 27, 96, 0.25);
    clip-path: polygon(0 0, 50% 50%, 100% 0, 100% 100%, 0 100%);
}

.envelope-body::before {
    content: ''; position: absolute; width: 100%; height: 100%;
    background: var(--envelope-color);
    clip-path: polygon(0 100%, 50% 50%, 100% 100%);
}

.envelope-flap {
    position: absolute; top: 0; left: 0; width: 100%; height: 140px;
    background: var(--envelope-color); clip-path: polygon(0 0, 100% 0, 50% 100%);
    transform-origin: top; transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5; box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.wax-seal {
    position: absolute; top: 110px; left: 50%;
    transform: translateX(-50%); width: 65px; height: 65px;
    background: radial-gradient(circle, var(--wax-accent), var(--wax-color));
    border-radius: 50%; z-index: 6; cursor: pointer;
    box-shadow: 0 6px 15px rgba(216, 27, 96, 0.4);
    display: flex; justify-content: center; align-items: center;
    color: #ffffff; font-family: var(--font-hand); font-size: 1.5rem;
    transition: all 0.3s ease; animation: sealPulse 2s infinite;
}

.wax-seal:hover { transform: translateX(-50%) scale(1.1); box-shadow: 0 0 20px var(--wax-accent); }

/* --- LA CARTA Y CONTENIDO --- */
.letter {
    position: absolute; top: 15px; left: 5%; width: 90%; height: 440px;
    background: var(--paper-color); border-radius: 10px; z-index: 2;
    transition: transform 1.8s cubic-bezier(0.175, 0.885, 0.32, 1.275), z-index 1s;
    box-shadow: inset 0 0 30px rgba(216, 27, 96, 0.05);
    padding: 35px 20px 20px 20px; display: flex; flex-direction: column;
}

.parchment-title {
    font-family: var(--font-royal); color: var(--wax-color);
    font-size: 1.6rem; margin-bottom: 20px; text-align: center;
}

.handwriting {
    font-family: var(--font-hand); color: var(--ink-color);
    font-size: 1.5rem; line-height: 1.5; min-height: 160px;
}

.cursor { border-right: 2px solid var(--ink-color); animation: blinkCursor 0.7s infinite; }

/* --- FOOTER DE LA CARTA (CONTADOR + WHATSAPP) --- */
.letter-footer {
    margin-top: auto; text-align: center;
    border-top: 1px dashed rgba(216, 27, 96, 0.3); padding-top: 15px;
    display: flex; flex-direction: column; gap: 8px;
}

.pd-text { font-size: 0.7rem; color: #888; text-transform: uppercase; letter-spacing: 1px; }
.love-counter { font-size: 1rem; color: var(--wax-color); font-weight: bold; }

.whatsapp-btn {
    background: var(--wpp-color); color: white; text-decoration: none;
    font-size: 0.9rem; font-weight: 600; padding: 12px 20px;
    border-radius: 50px; margin-top: 10px;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: wppPulse 2s infinite;
}

.whatsapp-btn:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(37, 211, 102, 0.6); }

/* --- MARCA DE AGUA MANYA CODE --- */
.watermark {
    position: fixed; bottom: 15px; width: 100%; text-align: center;
    font-size: 0.75rem; color: rgba(216, 27, 96, 0.6); z-index: 5;
    letter-spacing: 1px;
}

.watermark strong { font-weight: 600; color: #d81b60; }

/* --- GESTOR DE ESTADOS (AL ABRIR) --- */
.open .envelope-flap { transform: rotateX(180deg); z-index: 1; }
.open .wax-seal { opacity: 0; transform: translateX(-50%) scale(0); pointer-events: none; }
.open .instruction { animation: none; opacity: 0; visibility: hidden; transition: opacity 0.5s ease, visibility 0.5s; }
.open .letter { transform: translateY(-230px); z-index: 10; }
.open .envelope-wrapper { transform: translateY(150px); }

/* --- ANIMACIONES --- */
@keyframes sealPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 64, 129, 0.6); transform: translateX(-50%) scale(1); }
    70% { box-shadow: 0 0 0 15px rgba(255, 64, 129, 0); transform: translateX(-50%) scale(1.05); }
    100% { box-shadow: 0 0 0 0 rgba(255, 64, 129, 0); transform: translateX(-50%) scale(1); }
}

@keyframes wppPulse {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.6); }
    70% { box-shadow: 0 0 0 10px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

@keyframes instructionPulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }
@keyframes blinkCursor { from, to { border-color: transparent; } 50% { border-color: var(--ink-color); } }

.hidden { opacity: 0; transition: opacity 1s ease; pointer-events: none; display: none; }
.show { opacity: 1; pointer-events: auto; display: flex; }