/* ============================================
   Screenshots OPTIMIZADO - Largest Contentful Paint
   ============================================ */

/* ========== SCREENSHOTS SECTION ========== */
.screenshots {
    background: var(--bg);
    padding: 100px 2rem;
}

.screenshots-container {
    max-width: var(--max-width);
    margin: 0 auto;
}

.screenshots-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
    gap: 2.5rem;
    margin-top: 3rem;
}

.screenshot-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-card);
    cursor: pointer;
    /* OPTIMIZACIÓN: Usar transform para animaciones más fluidas */
    will-change: transform;
}

.screenshot-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-xl);
}

.screenshot-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.04), rgba(118, 75, 162, 0.04));
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

[data-theme="dark"] .screenshot-wrapper {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
}

/* OPTIMIZACIÓN CRÍTICA: Imagen con aspect-ratio nativo */
.screenshot-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    filter: brightness(1.02) contrast(1.05) saturate(1.1);
    cursor: pointer;
    background: var(--bg-card);
    /* CRÍTICO: Prevenir layout shift */
    aspect-ratio: 16 / 9;
}

/* Loading placeholder para imágenes */
.screenshot-img[loading="lazy"] {
    background: linear-gradient(
        90deg,
        var(--bg-card) 0%,
        rgba(102, 126, 234, 0.05) 50%,
        var(--bg-card) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

[data-theme="dark"] .screenshot-img {
    filter: brightness(0.98) contrast(1.08) saturate(1.05);
}

.screenshot-card:hover .screenshot-img {
    transform: scale(1.03);
    filter: brightness(1.05) contrast(1.08) saturate(1.12);
}

[data-theme="dark"] .screenshot-card:hover .screenshot-img {
    filter: brightness(1.02) contrast(1.1) saturate(1.08);
}

/* Indicador de zoom - Solo con CSS, sin JavaScript */
.screenshot-wrapper::after {
    content: '🔍 Click para ampliar';
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.screenshot-card:hover .screenshot-wrapper::after {
    opacity: 1;
}

.screenshot-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent 0%, transparent 60%, rgba(0, 0, 0, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

[data-theme="dark"] .screenshot-overlay {
    background: linear-gradient(to bottom, transparent 0%, transparent 60%, rgba(0, 0, 0, 0.3) 100%);
}

.screenshot-card:hover .screenshot-overlay {
    opacity: 1;
}

.screenshot-caption {
    padding: 1.75rem;
    background: var(--bg-card);
    border-top: 3px solid var(--primary);
    transition: border-color 0.3s ease;
}

.screenshot-card:hover .screenshot-caption {
    border-top-color: var(--secondary);
}

.screenshot-caption h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: var(--text);
    font-weight: var(--font-bold);
    transition: color 0.3s ease;
}

.screenshot-card:hover .screenshot-caption h3 {
    color: var(--primary);
}

.screenshot-caption p {
    color: var(--text-light);
    font-size: 0.925rem;
    line-height: 1.6;
}

/* ========== LIGHTBOX OPTIMIZADO ========== */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.96);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    cursor: zoom-in;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(8px);
    padding: 3rem;
    /* OPTIMIZACIÓN: GPU acceleration */
    transform: translateZ(0);
    will-change: opacity;
}

.lightbox.active {
    display: flex;
}

.lightbox-img-container {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* OPTIMIZACIÓN CRÍTICA: Imagen del lightbox con contain */
.lightbox img {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.9);
    animation: zoomIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    cursor: zoom-in;
    /* OPTIMIZACIÓN: Prevenir layout shift */
    aspect-ratio: attr(width) / attr(height);
    /* GPU acceleration */
    transform: translateZ(0);
    will-change: transform;
}

.lightbox img.zoomed {
    transform: scale(2);
    cursor: grab;
    max-width: none;
    max-height: none;
}

.lightbox img.zoomed:active {
    cursor: grabbing;
}

.lightbox-caption {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.8);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    backdrop-filter: blur(10px);
    pointer-events: none;
}

/* ========== BOTÓN DE CERRAR OPTIMIZADO ========== */
.lightbox-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    color: white;
    cursor: pointer;
    z-index: 10001;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    font-size: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    /* OPTIMIZACIÓN */
    will-change: transform;
}

.lightbox-close::before {
    content: '✕';
    display: block;
    font-size: 1.75rem;
    font-weight: 300;
    line-height: 1;
    transition: transform 0.3s ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    transform: translateY(-2px);
}

.lightbox-close:hover::before {
    color: #1e293b;
    transform: scale(1.2) rotate(90deg);
}

.lightbox-close:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.lightbox-close:active::before {
    transform: scale(0.95);
}

.lightbox-close:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Navegación con flechas */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    width: 50px;
    height: 50px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    will-change: transform;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.lightbox-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.lightbox-nav.prev {
    left: 2rem;
}

.lightbox-nav.next {
    right: 2rem;
}

.lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Animaciones optimizadas */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from { 
        transform: scale(0.85); 
        opacity: 0; 
    }
    to { 
        transform: scale(1); 
        opacity: 1; 
    }
}

/* ========== RESPONSIVE OPTIMIZADO ========== */
@media (max-width: 768px) {
    .lightbox {
        padding: 1.5rem;
    }
    
    .lightbox img {
        max-height: 85vh;
    }
    
    .lightbox img.zoomed {
        transform: scale(1.5);
    }
    
    .lightbox-caption {
        bottom: -40px;
        font-size: 0.85rem;
        padding: 0.6rem 1.2rem;
    }
    
    .lightbox-close {
        top: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
    }
    
    .lightbox-close::before {
        font-size: 1.5rem;
    }
    
    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .lightbox-nav.prev {
        left: 1rem;
    }
    
    .lightbox-nav.next {
        right: 1rem;
    }
    
    .screenshot-wrapper::after {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Optimización para motion reducido */
@media (prefers-reduced-motion: reduce) {
    .screenshot-card,
    .screenshot-img,
    .lightbox,
    .lightbox img,
    .lightbox-nav {
        transition: none;
        animation: none;
    }
    
    .screenshot-img[loading="lazy"] {
        animation: none;
    }
}