/* --- Estilos Base (Escritorio) --- */
body {
    margin: 0;
    padding: 0;
    /* Fondo Rojo Navideño */
    background: radial-gradient(circle at top, #b71c1c 0%, #5d080e 100%);
    overflow-x: hidden; /* Evitamos scroll horizontal */
    min-height: 100vh; /* Usamos min-height para que crezca si es necesario en móvil */
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

/* --- Título --- */
.title {
    text-align: center;
    margin-bottom: 25px;
    margin-top: 40px; /* Espacio extra para que no pegue con las luces */
    font-weight: 800;
    font-size: 1.5rem;
    text-shadow: 0 4px 6px rgba(0,0,0,0.3);
    letter-spacing: 1px;
    z-index: 150;
    position: relative;
    color: #fff;
    padding: 0 10px;
}

/* --- LUCES REALISTAS --- */
.lightrope {
    position: absolute;
    top: -5px;
    width: 100%;
    display: flex;
    justify-content: space-around;
    padding: 0;
    margin: 0;
    z-index: 200;
    pointer-events: none;
    list-style: none;
    border-top: 3px solid #333;
    white-space: nowrap; /* Asegura que no salten de línea */
    overflow: hidden; /* Corta si sobran */
}

.lightrope li {
    position: relative;
    width: 18px;
    height: 30px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    margin: 0;
    flex-shrink: 0; /* Evita que las bombillas se aplasten */
    animation-iteration-count: infinite;
    animation-fill-mode: both;
    animation-name: glow;
    animation-duration: 2s;
}

.lightrope li::before {
    content: "";
    position: absolute;
    background: #222;
    width: 12px;
    height: 7px;
    top: -5px;
    left: 3px;
    border-radius: 2px;
}

/* Colores de bombillas */
.lightrope li:nth-child(4n+1) { background: #00ffea; box-shadow: 0px 5px 20px 5px rgba(0, 255, 234, 0.5); animation-duration: 1.5s; }
.lightrope li:nth-child(4n+2) { background: #50ff34; box-shadow: 0px 5px 20px 5px rgba(80, 255, 52, 0.5); animation-duration: 1.8s; animation-delay: 0.2s; }
.lightrope li:nth-child(4n+3) { background: #ffeb3b; box-shadow: 0px 5px 20px 5px rgba(255, 235, 59, 0.5); animation-duration: 1.2s; animation-delay: 0.4s; }
.lightrope li:nth-child(4n+4) { background: #ffffff; box-shadow: 0px 5px 20px 5px rgba(255, 255, 255, 0.6); animation-duration: 2.2s; animation-delay: 0.1s; }

@keyframes glow {
    0%, 100% { opacity: 1; filter: brightness(1.3); }
    50% { opacity: 0.5; filter: brightness(0.7); box-shadow: 0px 2px 5px rgba(255,255,255,0.1); }
}

/* --- Canvas Nieve --- */
#snowCanvas {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100;
}

/* --- GRID CALENDARIO --- */
.main-container {
    z-index: 150;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px; /* Para que no se estire infinito en pantallas gigantes */
}

.advent-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 Columnas en PC */
    gap: 20px;
    padding: 20px;
    justify-items: center; /* Centrar las cajas en sus celdas */
}

.gift-box {
    width: 130px;
    height: 130px;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
}

.gift-door, .gift-content {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 12px;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    backface-visibility: hidden;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

/* PUERTA */
.gift-door {
    background-color: #ffffff;
    color: #b71c1c;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: 800;
    z-index: 2;
    transform-origin: left;
    border: 3px solid #fff;
}

.gift-door::after {
    content: ''; position: absolute; top: 10px; right: 10px; width: 10px; height: 10px;
    border-radius: 50%; background: #b71c1c; opacity: 0.2;
}

.gift-box:hover .gift-door {
    background-color: #f0f0f0;
    transform: rotateY(-10deg);
}

/* --- CONTENIDO --- */
.gift-content {
    background-color: #ffebee; 
    color: #333;
    transform: rotateY(0deg);
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Alineado arriba para textos largos */
    align-items: center;
    text-align: center;
    padding: 10px;
    box-sizing: border-box;
    border: 2px dashed #b71c1c;
    
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #b71c1c #ffebee;
}


.gift-content::-webkit-scrollbar { width: 6px; }
.gift-content::-webkit-scrollbar-thumb { background-color: #b71c1c; border-radius: 10px; }
.gift-content::-webkit-scrollbar-track { background: transparent; }

.gift-content img {
    width: 50px; 
    height: 50px; 
    object-fit: contain; 
    margin-bottom: 5px;
    flex-shrink: 0; 
}

.gift-content p {
    margin: auto 0;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    color: #b71c1c;
    width: 100%;
    word-wrap: break-word;
}

.long-text {
    font-size: 0.8rem !important; 
    text-align: left; 
    font-weight: 400 !important; 
    color: #555 !important;
}

.gift-box.opened .gift-door {
    transform: rotateY(-120deg);
    box-shadow: -5px 0 10px rgba(0,0,0,0.1);
}

/* =========================================
   MEDIA QUERIES (RESPONSIVE CELULAR)
   ========================================= */

@media (max-width: 768px) {
    /* TABLETS Y CELULARES GRANDES */
    .advent-grid {
        grid-template-columns: repeat(2, 1fr); /* Cambiamos a 2 columnas */
        gap: 15px;
    }
    
    .title {
        font-size: 2rem; /* Título un poco más pequeño */
        margin-top: 60px; /* Más espacio arriba para las luces */
    }

    body {
        align-items: flex-start; /* Permitimos scroll vertical si no cabe */
        padding-top: 20px;
        height: auto; /* Altura automática para scroll */
        overflow-y: auto; /* Habilitar scroll en el cuerpo */
    }
}

@media (max-width: 480px) {
    /* CELULARES PEQUEÑOS (iPhone, Android estándar) */
    .title {
        font-size: 1.8rem;
    }

    .advent-grid {
        grid-template-columns: repeat(2, 1fr); /* Mantenemos 2 columnas */
        gap: 10px;
        padding: 10px;
    }

    .gift-box {
        /* Hacemos las cajas un poco más pequeñas para que quepan bien */
        width: 135px; 
        height: 135px;
    }

    /* Ajustamos las luces para que no se vean gigantes */
    .lightrope li {
        width: 14px;
        height: 24px;
        margin: 0 2px; /* Las juntamos un poquito */
    }
    
    /* Importante: para que el calendario no se pegue a los bordes */
    .main-container {
        padding-bottom: 50px;
    }
}