* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Quicksand', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: #26313b;
    position: relative;
    overflow: hidden;
}

/* Fondo acuarela azulito + cálido */
.background {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 10% 0, #f4f2ec 0, transparent 55%),
        radial-gradient(circle at 90% 0, #d9e9f5 0, transparent 55%),
        radial-gradient(circle at 0 100%, #f5e7cf 0, transparent 60%),
        radial-gradient(circle at 100% 100%, #dbeff2 0, transparent 60%);
    z-index: -1;
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    width: 100%;
}

.envelope-area {
    text-align: center;
}

.tap-text {
    margin-top: 18px;
    font-size: 0.9rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #50616f;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* SOBRE */

.envelope {
    width: min(320px, 80vw);
    height: 210px;
    position: relative;
    cursor: pointer;
    perspective: 1200px;
    margin-inline: auto;
}

/* Parte trasera del sobre */
.envelope-back {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #f6f0e4, #d7e4f2);
    box-shadow: 0 18px 40px rgba(40, 80, 120, 0.35);
    z-index: 1;
}

/* Parte frontal */
.envelope-front {
    position: absolute;
    inset: 0;
    z-index: 4;
}

/* Bolsillo frontal */
.envelope-pocket {
    position: absolute;
    inset: 40% 0 0 0;
    background: linear-gradient(135deg, #f0e1c4, #d3e2f1);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

/* Solapa dorada con matiz azul */
.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: linear-gradient(135deg, #f0d6aa, #cfdff0);
    clip-path: polygon(0 0, 50% 75%, 100% 0, 100% 5%, 50% 80%, 0 5%);
    transform-origin: top center;
    transition: transform 1.6s ease-in-out; /* apertura lenta */
    z-index: 5;
}

/* INVITACIÓN COMO IMAGEN */

.invite-card {
    position: absolute;
    left: 50%;
    bottom: 18px;
    /* empieza metida dentro del sobre */
    transform: translate(-50%, 60%) scale(0.9);
    transform-origin: bottom center;
    opacity: 0;

    z-index: 1000; /* siempre por delante del sobre */

    /* sale después de abrirse la solapa (delay 0.9s) */
    transition:
        transform 1.4s cubic-bezier(0.15, 0.65, 0.2, 1.2) 0.9s,
        opacity 1.1s ease 0.9s,
        box-shadow 1.1s ease 0.9s;
}

.invite-image {
    width: min(480px, 90vw);
    display: block;
    border-radius: 18px;
    box-shadow: 0 14px 40px rgba(35, 70, 110, 0.32);
}

/* ESTADOS AL ABRIR */

/* 1) Solapa se abre */
body.opened .envelope-flap {
    transform: rotateX(180deg);
}

/* 2) La invitación sale después (gracias al delay en .invite-card) */
body.opened .invite-card {
    opacity: 1;
    transform: translate(-50%, 30%) scale(1);
    box-shadow: 0 24px 55px rgba(35, 70, 110, 0.35);
}

/* Ocultar texto al abrir */
body.opened .tap-text {
    opacity: 0;
    transform: translateY(10px);
}

/* SELLO EN LA SOLAPA */
/* SELLO EN LA SOLAPA */
.seal {
    position: absolute;
    top: 48%;
    left: 50%;
    transform: translate(-50%, -50%);
    
    width: 64px;
    height: 64px;
    border-radius: 50%;
    
    background: radial-gradient(circle, #e8d6b3 0%, #c8ac7a 60%, #b2955e 100%);
    box-shadow: 
        0 4px 10px rgba(0,0,0,0.25),
        inset 0 2px 4px rgba(255,255,255,0.4),
        inset 0 -3px 4px rgba(0,0,0,0.25);

    font-family: 'Great Vibes', cursive;   /* 👈 Nueva fuente elegante */
    font-size: 1rem;                    /* 👈 Más grande y estética */
    font-weight: 400;
    color: #4a3b25;
    letter-spacing: 1px;

    display: flex;
    justify-content: center;
    align-items: center;

    z-index: 6;
    pointer-events: none;
}

/* Animación del sello */
.seal {
    transition:
        opacity 0.6s ease,
        transform 0.6s ease;
}

/* Cuando se activa: el sello desaparece primero */
body.opened .seal {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.6); 
}


/* RESPONSIVE MÓVIL */

@media (max-width: 520px) {

    .envelope {
        width: 82vw;
        height: 215px;
    }

    .invite-image {
        width: 88vw;
    }

    /* La dejamos centrada y un pelín más pequeña */
    body.opened .invite-card {
        transform: translate(-50%, 25%) scale(0.97);
    }
}
