/* === Efecto de materialización del mago === */
.mago {
    position: absolute; /* antes, absolute */
    bottom: 12vh;
    left: 50%;
    transform: translateX(-50%);
    width: 40vh; /* Ajusta según el tamaño de tu imagen */
    z-index: 1; /* Debajo de las cortinas (z-index: 2) pero encima del escenario (z-index: 1) */
    opacity: 0; /* Inicialmente invisible */
    filter: blur(15px) brightness(1.5); /* Efecto de desenfoque y brillo inicial */
    transition: opacity 3s ease-in-out, filter 3s ease-in-out;
}

.mago img {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(20px -10px 10px rgba(0, 0, 0, 0.8))
            drop-shadow(30px -20px 20px rgba(0, 0, 0, 0.4));
}

/* Clase que se añadirá al abrir las cortinas */
.mago.materializado {
    opacity: 1;
    filter: blur(0) brightness(1);
}

.mago::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    left: var(--bola-x, '50%');
    top: var(--bola-y, '50%');
    transform: translate(-50%, -50%); /* Centra exactamente en las coordenadas */
    width: 80px;
    height: 80px;
    background: radial-gradient(
        circle,
        white 0%,
        #fffacd 10%,
        gold 30%,
        rgba(255, 215, 0, 0.7) 50%,
        transparent 70%
    );
    opacity: 0;
    animation: brillo-bola 2s infinite ease-in-out;
    filter: blur(15px); /* Reduce el blur para mayor precisión */
}

@keyframes brillo-bola {
    0%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}

/* --- Cuando las cortinas están abiertas --- */
.mago.materializado {
    z-index: 3; /* Encima de las cortinas abiertas */
}

/* Solo activa la zona-bola cuando las cortinas estén abiertas */
.mago.materializado .zona-bola {
    pointer-events: auto;
    display: block;
}

/* Crea una capa clickable del tamaño del brillo */
.zona-bola {
    position: absolute;
    width: 40px; /* Mayor que el brillo para mejor UX */
    height: 40px;
    left: var(--bola-x, '50%');
    top: var(--bola-y, '50%');
    transform: translate(-50%, -50%);
    cursor: url('../imgs/clic-bola.png'), pointer;
    z-index: 9999;
    pointer-events: none;
    display: none;
}

/* === Destello con difuminado al aparecer el mago === */
.destello {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400%;
    height: 400%;
    background: radial-gradient(
        circle, 
        rgba(255, 255, 255, 0.9) 0%, 
        rgba(255, 215, 0, 0.7) 40%, 
        rgba(255, 100, 0, 0) 70%
    );
    transform: translate(-50%, -50%) scale(0.5);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    filter: blur(15px);
    transition: 
        opacity 1.5s ease-out,
        transform 1.5s ease-out,
        filter 1.5s ease-out;
}

.destello.activo {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1.3);
    filter: blur(25px);
}

.destello.desvaneciendo {
    opacity: 0;
    filter: blur(40px);
    transform: translate(-50%, -50%) scale(1.8);
}

/* === Partículas === */
.particulas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 11; /* Encima del destello */
}

.particula {
    position: absolute;
    width: 8px;
    height: 8px;
    background: gold;
    border-radius: 50%;
    filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.8));
    opacity: 0;
    animation: 
        volar 2s ease-out forwards, 
        brillo 1.5s ease-in-out infinite;
}

@keyframes volar {
    0% { 
        transform: translate(0, 0) scale(0.3); 
        opacity: 1; 
    }
    100% { 
        transform: translate(var(--tx), var(--ty)) scale(1); 
        opacity: 0; 
    }
}

@keyframes brillo {
    0%, 100% { box-shadow: 0 0 10px gold; }
    50% { box-shadow: 0 0 20px orange; }
}
