/* ===== ESCENA 16: LA CARTA MÁGICA (FINAL VERDADERO) ===== */

#escena-16 {
    background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1200px;
}

#escena16-particulas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Polvo de estrellas */
.particula-magica {
    position: absolute;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 10px #fff, 0 0 20px #ffb6c1;
    opacity: 0;
    pointer-events: none;
}

/* Contenedor del sobre con animación de flotación */
#sobre-wrapper {
    position: relative;
    width: 300px;
    height: 200px;
    z-index: 10;
    animation: flotarSobre 4s ease-in-out infinite alternate;
    cursor: pointer;
    transition: transform 1s ease;
}

@keyframes flotarSobre {
    0% { transform: translateY(0px) rotate(0deg); }
    100% { transform: translateY(-15px) rotate(2deg); }
}

.sobre-container {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

/* Partes del sobre */
.sobre-back, .sobre-front-left, .sobre-front-right, .sobre-front-bottom, .sobre-solapa {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}

.sobre-back {
    background-color: #eaddc5; /* Marfil elegante */
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 1;
}

/* Bolsillos frontales del sobre con CSS clip-path para formas triangulares */
.sobre-front-left {
    background-color: #dfcdad;
    clip-path: polygon(0 0, 50% 50%, 0 100%);
    z-index: 3;
}

.sobre-front-right {
    background-color: #d6c098;
    clip-path: polygon(100% 0, 50% 50%, 100% 100%);
    z-index: 3;
}

.sobre-front-bottom {
    background-color: #ceb585;
    clip-path: polygon(0 100%, 50% 50%, 100% 100%);
    z-index: 4;
}

/* Solapa superior */
.sobre-solapa {
    background-color: #c4a771;
    clip-path: polygon(0 0, 100% 0, 50% 60%);
    z-index: 5;
    transform-origin: top;
    transition: transform 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sobre-solapa.abierta {
    transform: rotateX(180deg);
    z-index: 2; /* Pasa detrás de la carta al abrirse */
}

/* Sello de cera */
.sello-cera {
    position: absolute;
    left: 50%;
    top: 55%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: #8e733f; /* Dorado oscuro elegante */
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4), inset 0 2px 5px rgba(255,255,255,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: #fffde7;
    transition: opacity 0.5s ease;
}

.sobre-solapa.abierta .sello-cera {
    opacity: 0;
}

/* La Carta Física */
.carta-fisica {
    position: absolute;
    bottom: 5px; 
    left: 2%;
    width: 96%;
    height: 95%;
    background: #fffbf0; /* Textura crema suave */
    background-image: 
        radial-gradient(circle, transparent 20%, rgba(200, 150, 100, 0.05) 100%),
        linear-gradient(to right, rgba(255,255,255,0.8), transparent 5%, transparent 95%, rgba(255,255,255,0.8));
    border-radius: 4px;
    z-index: 2; /* Entre el back y el front */
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    transition: all 2s cubic-bezier(0.25, 1, 0.5, 1);
    transform-origin: center bottom;
    display: flex;
    flex-direction: column;
}

.carta-decoracion {
    position: absolute;
    top: 6px; left: 6px; right: 6px; bottom: 6px;
    border: 1px solid rgba(200, 150, 120, 0.3);
    border-radius: 2px;
    pointer-events: none;
}
.carta-decoracion::before {
    content: '';
    position: absolute;
    top: 2px; left: 2px; right: 2px; bottom: 2px;
    border: 1px dashed rgba(200, 150, 120, 0.4);
}

.carta-contenido {
    padding: 25px 20px;
    color: #4a2040;
    font-family: 'Georgia', serif;
    font-size: 14px;
    line-height: 1.6;
    opacity: 0;
    transition: opacity 1.5s ease 1s;
    z-index: 2;
    overflow-y: auto;
    flex: 1;
}

/* Estilar el scrollbar para que encaje con la carta */
.carta-contenido::-webkit-scrollbar {
    width: 6px;
}
.carta-contenido::-webkit-scrollbar-track {
    background: rgba(200, 150, 120, 0.1);
    border-radius: 4px;
}
.carta-contenido::-webkit-scrollbar-thumb {
    background: rgba(200, 150, 120, 0.4);
    border-radius: 4px;
}
.carta-contenido::-webkit-scrollbar-thumb:hover {
    background: rgba(200, 150, 120, 0.7);
}

/* Estado de la carta abierta */
.sobre-container.abierto .carta-fisica {
    /* Aumentamos el ancho a los lados (420px comparado con el sobre de 300px) */
    width: 440px;
    left: -70px; /* (300 - 440) / 2 = -70 para centrar */
    
    transform: translateY(140px) scale(1.3);
    z-index: 6; /* Pasa al frente del sobre */
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), 0 0 40px rgba(255,182,193,0.6);
}

.sobre-container.abierto .carta-contenido {
    opacity: 1;
}

/* Partículas al abrir */
.chispa-sobre {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 10px #ffb6c1, 0 0 20px #ff69b4;
    pointer-events: none;
    z-index: 7;
}
