/* grid-menu.css - CSS Asíncrono para el Grid de Juegos OPTIMIZADO V6 (ENFOQUE EN MINIMIZAR REPAINT/REFLOW) */

.modal-content {
    background-color: var(--color-bg-modal); 
    color: var(--color-text-light);
    width: 100%; 
    height: 100%; 
    transition: none;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center; 
    min-height: 96px; 
    position: relative;
    z-index: 1; 
    overflow: hidden; 
    flex-shrink: 0; 
    border-bottom: 3px solid var(--color-accent); 
}

.modal-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-bg-darkest); 
    background-image: var(--bg-url); 
    background-size: cover;
    background-position: center;
    opacity: 0.7; 
    filter: blur(5px) brightness(0.5); 
    z-index: -1; 
    /* ✅ MANTENER: Anima propiedades costosas (filter, opacity). */
    transform: translateZ(0); /* ❌ OPTIMIZACIÓN: Simplificado translate3d(0, 0, 0) a translateZ(0) */
    will-change: filter, opacity; /* ❌ OPTIMIZACIÓN: Se elimina 'transform' de will-change (la animación es estática) */
}

#modal-image {
    height: 80px; 
    width: auto;
    object-fit: contain;
    z-index: 2; 
    max-width: calc(100% - 200px); 
    /* ❌ OPTIMIZACIÓN: Se elimina will-change innecesario */
}

/* Base compartida para botones de cierre (agrupación) */
.modal-close, .game-details-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    z-index: 2;
}

.modal-close {
    color: var(--color-text-light);
    font-size: 30px; 
    position: absolute; 
    top: 50%; 
    left: 20px; 
    line-height: 1;
    display: flex;
    align-items: center;
    /* ✅ MANTENER: Usa translateY. */
    transform: translateY(-50%) translateZ(0); /* ❌ OPTIMIZACIÓN: Simplificado translate3d(0, 0, 0) a translateZ(0) */
    will-change: transform; /* Se añade will-change para el hover de la imagen (aunque el padre no se mueve) */
}

.modal-close img {
    width: 60px; 
    height: 60px;
    transition: filter 0.2s ease-out; 
    will-change: filter; 
}

.modal-close:hover img {
    filter: drop-shadow(0 0 10px var(--color-accent)) drop-shadow(0 0 20px var(--color-accent-hover)); 
    cursor: pointer;
}

.modal-body {
    padding: 20px; 
    flex-grow: 1;
    overflow-y: auto;
    background-color: var(--color-bg-modal); 
}

/* ESTILOS PARA EL GRID DE CONTENIDO (BASE) */
.content-grid-container {
    padding: 2vh 1vw; 
    max-width: 1920px; 
    margin: 0 auto; 
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-columns), 1fr); 
    gap: 1.5vw; 
    padding: 0;
    margin: 0;
    list-style: none;
}

.content-grid:has(> .grid-item:only-child) {
    justify-content: center; 
}

.content-grid:has(> .grid-item:only-child) > .grid-item {
    max-width: 300px; 
}


/* --- Media Queries (Sin Cambios Estructurales) --- */

@media (max-width: 1920px) {
     .content-grid { --grid-columns: 7; }
}
@media (max-width: 1600px) {
    .content-grid { --grid-columns: 6; }
}
@media (max-width: 1440px) {
     .content-grid { --grid-columns: 5; }
}
@media (max-width: 1280px) {
     .content-grid { --grid-columns: 4; }
}
@media (max-width: 900px) {
    .content-grid {
        --grid-columns: 3;
        gap: 1.2vw;
    }
}
@media (max-width: 600px) {
    .content-grid {
        --grid-columns: 2;
        gap: var(--mobile-padding); 
    }
    .content-grid-container {
        padding: var(--mobile-padding); 
    }
}

.grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background-color: var(--color-bg-darkest); 
    border-radius: 8px;
    overflow: hidden; 
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    will-change: transform, box-shadow; 
    transition: transform 0.2s ease, box-shadow 0.2s ease; 
    cursor: pointer;
    align-self: start; 
    /* ✅ MANTENER: Se acelera para la animación de hover. */
    transform: translateZ(0); /* ❌ OPTIMIZACIÓN: Simplificado translate3d(0, 0, 0) a translateZ(0) */
}

.grid-item:hover,
.grid-item.selected { 
    transform: translateY(-5px) translateZ(0); /* ❌ OPTIMIZACIÓN: Simplificado, y añadido translateZ(0) para mantener la capa */
    box-shadow: 0 0 15px var(--color-accent); 
}

/* Adaptabilidad de la imagen */
.grid-item-image {
    width: 100%;
    height: auto; 
    object-fit: contain; 
    display: block;
    aspect-ratio: 16 / 9; 
    transition: aspect-ratio 0.3s ease; 
}

/* Estilo para el estado de carga (loading.svg) */
.grid-item-image.is-loading {
    object-fit: contain; 
    padding: 10%; 
    aspect-ratio: 16 / 9; 
}


.grid-item-title {
    color: var(--color-text-light); 
    font-size: 0.9em;
    font-weight: bold;
    padding: 10px 5px;
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    width: 100%;
}

#modal-title {
    display: none; 
}

/* ----------------------------------------------------- */
/* *** MODIFICACIÓN: Ajustes de tamaño en Encabezado Móvil (max-width: 768px) *** */
/* ----------------------------------------------------- */
@media (max-width: 768px) {
    /* Icono del Sistema (Centrado) */
    #modal-image {
        height: 60px; 
        max-width: calc(100% - 100px); 
        width: auto; 
        transform: translateZ(0); /* ✅ REFUERZO: Se añade para asegurar su propia capa */
    }
    
    /* Botón de Cierre (Ícono Atrás) */
    .modal-close {
        left: 10px; 
    }
    
    .modal-close img {
        width: 40px; 
        height: 40px;
    }
}