/* ============================================
   CSS OPTIMIZADO PARA MÓVIL - SISTEMA DE TORNEOS
   Elimina efectos GPU-intensivos, mantiene diseño
============================================ */

/* Hero Card - Sistema de Torneos */
.hero-card {
    background: linear-gradient(135deg, #17a2b8 0%, #001c3a 60%);
    border: 3px solid #00ffe7;
    box-shadow: 0 0 12px rgba(0, 255, 231, 0.4);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    /* Optimización móvil */
    contain: layout style paint;
}

.hero-icon-container {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.25);
    /* backdrop-filter eliminado para móvil */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.hero-icon {
    font-size: 1.6rem;
}

.hero-title {
    text-shadow: 1px 2px 6px rgba(0, 0, 0, 0.25);
    letter-spacing: -0.3px;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-weight: 700;
}

.hero-subtitle {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    font-size: 1rem;
    font-weight: 400;
    opacity: 0.92;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.5;
}

.hero-divider {
    width: 70px;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.6) 50%, transparent 100%);
}

/* Torneos Activos Card */
.torneos-card {
    background: #ffffff;
    border: 1px solid rgba(30, 58, 95, 0.25);
    border-radius: 18px;
    overflow: hidden;
    /* backdrop-filter eliminado */
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.torneos-header {
    background: #b8b8b8;
    color: #001c3a !important;
    border: 0;
    border-bottom: 2px solid #00ffe7;
    box-shadow: 0 2px 10px rgba(0, 255, 231, 0.3);
}

.torneos-header-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 30% 20%, rgba(45, 90, 160, 0.25) 0%, transparent 50%);
    /* backdrop-filter eliminado */
}

.torneos-header-title {
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
    font-weight: 700;
}

.torneos-body {
    background: #f5f5f5;
}

/* Tournament Cards */
.tournament-card {
    background: #f0f0f0;
    /* backdrop-filter eliminado */
    border: 1px solid rgba(0, 110, 255, 0.9);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.07);
    /* Optimizaciones críticas */
    contain: content;
    will-change: transform;
}

/* Hover solo en desktop (no móvil) */
@media (hover: hover) and (pointer: fine) {
    .tournament-card:hover {
        transform: translateY(-6px) scale(1.02);
        box-shadow: 0 18px 35px rgba(30, 58, 95, 0.2);
        background: #ffffff;
        border-color: rgba(45, 90, 160, 0.5);
    }
}

.tournament-card-header {
    position: relative;
    overflow: hidden;
    padding: 0;
    height: 180px;
    background-image: linear-gradient(180deg, rgba(0, 28, 58, 0.15) 0%, rgba(0, 28, 58, 0.75) 80%),
        var(--cover-image, linear-gradient(135deg, #17a2b8 0%, #001c3a 60%));
    background-size: cover;
    background-position: center;
    border-bottom: 0;
    box-shadow: inset 0 -3px 0 rgba(0, 255, 231, 0.65);
    transition: background-image 0.45s ease, filter 0.3s ease;
}

.tournament-card-header.cover-fade {
    animation: coverFade 0.55s ease;
}

.tournament-cover-content {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.25rem 1.5rem 1.5rem;
    color: #ffffff;
    background: radial-gradient(circle at 20% 25%, rgba(255, 255, 255, 0.08) 0%, transparent 45%);
    text-align: left;
}

.tournament-crown-badge {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.18);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    /* backdrop-filter eliminado */
}

.tournament-crown-icon {
    color: #fbbf24;
    font-size: 0.9rem;
}

.tournament-logo-bridge {
    position: relative;
    z-index: 2;
    margin-top: -50px;
    margin-bottom: 10px;
}

.tournament-logo-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: #ffffff;
    border-radius: 50%;
    border: 1px solid rgba(30, 58, 95, 0.12);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.08);
    width: 92px;
    height: 92px;
}

.tournament-logo {
    padding: 0.1rem;
    max-height: 80px;
    max-width: 80px;
    width: 70px;
    height: 70px;
    object-fit: contain;
    /* filter optimizado */
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
    /* Optimización imágenes */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.tournament-card-body {
    padding-top: 1.5rem;
}

.tournament-title {
    color: #001c3a;
    text-shadow: none;
    font-size: 1.1rem;
    font-weight: 700;
}

.tournament-description {
    line-height: 1.5;
    font-size: 0.88rem;
    color: #2d3748;
}

.tournament-dates {
    background: rgba(30, 58, 95, 0.08);
    border: 1px solid rgba(45, 90, 160, 0.15);
    border-radius: 8px;
}

.tournament-dates-icon {
    color: #1e3a5f;
}

.tournament-dates-text {
    color: #0c2340;
    font-weight: 500;
}

.tournament-format-badge {
    background: linear-gradient(45deg, #0c2340, #1e3a5f);
    color: white;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 12px;
}

.tournament-view-btn {
    background: linear-gradient(135deg, #17a2b8, #001c3a);
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(12, 35, 64, 0.3);
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
    font-weight: 600;
}

.tournament-view-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 5px 18px rgba(12, 35, 64, 0.4);
}

/* Alert Info */
.alert-torneos {
    background: rgba(30, 58, 95, 0.08);
    border: 1px solid rgba(45, 90, 160, 0.25);
    color: #1e3a5f;
    border-radius: 10px;
}

/* ============================================
   OPTIMIZACIONES CRÍTICAS PARA MÓVIL
============================================ */

/* Hint shown on mobile to indicate horizontal swipe */
.torneos-swipe-hint {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    color: rgba(0, 0, 0, 0.6);
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.torneos-swipe-hint .swipe-arrows {
    display: inline-block;
    font-size: 1rem;
    color: rgba(0, 0, 0, 0.55);
    transform: translateX(0);
    animation: swipeHint 1.5s ease-in-out infinite;
    will-change: transform;
}

@keyframes swipeHint {
    0% { transform: translateX(-4px); opacity: 0.7; }
    50% { transform: translateX(4px); opacity: 1; }
    100% { transform: translateX(-4px); opacity: 0.7; }
}

@keyframes coverFade {
    0% { opacity: 0.2; filter: saturate(0.7); }
    100% { opacity: 1; filter: saturate(1); }
}

/* ============================================
   MÓVIL: Optimizaciones específicas para < 768px
============================================ */

@media (max-width: 768px) {
    /* Desactiva efectos costosos en móvil */
    * {
        /* Reduce o elimina animaciones costosas */
        animation-duration: 0.02ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.02ms !important;
    }
    
    /* Hero optimizado para móvil */
    .hero-card {
        padding: 0rem;
        border-width: 2px;
        border-radius: 16px;
        box-shadow: 0 0 8px rgba(0, 255, 231, 0.3);
        margin: 0rem;
    }
    
    .hero-title {
        width: auto !important;
        font-size: 1.4rem !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
        padding: 0rem;
        margin: 0;
    }
    
    .hero-subtitle {
        font-size: 0.95rem;
        padding: 0 0rem;
    }
    
    .hero-icon-container {
        width: 48px;
        height: 48px;
    }
    
    .hero-icon {
        font-size: 1.4rem;
    }
    
    /* Torneos card optimizado */
    .torneos-card {
        border-radius: 16px;
        margin: 0rem;
        height: auto !important;
        min-height: 40px !important;
        padding: 0 !important;
    }
    #swipeHint {
        margin-bottom: 0rem;
        margin-top: 0rem;
        padding: 0rem !important;
    }
    
    .torneos-header {
        padding: 0.75rem 1rem;
    }
    
    .torneos-header-title {
        font-size: 1.1rem;
    }
    .torneos-body {
        padding: 0.5rem !important;
        margin-left: 0.8rem !important;
        height: auto !important;
        min-height: 30px !important;
    }
    /* Scroll horizontal optimizado para móvil */
    .torneos-body > .row {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 0.75rem;
        padding: orem;
        margin-bottom: 0rem;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        /* Optimizaciones críticas */
        -webkit-overflow-scrolling: auto;
        scrollbar-width: none; /* Firefox */
        contain: content;
    }
    
    .torneos-body > .row::-webkit-scrollbar {
        display: none; /* Chrome, Safari */
    }
    
    .torneos-body > .row > .col-lg-4,
    .torneos-body > .row > .col-md-6 {
        flex: 0 0 88%;
        max-width: 88%;
        scroll-snap-align: start;
        /* Content-visibility para scroll fluido */
        content-visibility: auto;
        contain-intrinsic-size: 360px;
        margin-bottom: 0;
    }
    
    /* Tournament cards móvil */
    .torneos-body .tournament-card {
        height: auto;
        min-height: 180px;
        /* Desactiva transformaciones costosas */
        transform: none !important;
        /* Sombra más simple */
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
        border-radius: 14px;
        /* Mejora renderizado */
        opacity: 1;
        transition: opacity 0.2s ease;
    }
    
    /* Asegura que las cards sean visibles */
    .tournament-card {
        opacity: 1 !important;
    }
    
    .tournament-card-header {
        height: 150px;
    }

    .tournament-cover-content {
        padding: 1rem 1.25rem 1.25rem;
    }

    .tournament-logo-bridge {
        margin-top: -42px;
    }
    
    .tournament-logo-chip {
        padding: 5px;
        width: 68px;
        height: 68px;
    }
    
    .tournament-title {
        font-size: 1rem;
    }
    
    .tournament-logo {
        max-height: 48px;
        max-width: 48px;
        width: 48px;
        height: 48px;
    }
    
    .tournament-description {
        font-size: 0.82rem;
        line-height: 1.4;
    }
    
    .tournament-view-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
    
    /* Elimina TODOS los backdrop-filter en móvil */
    .torneos-card,
    .tournament-card,
    .hero-icon-container,
    .torneos-header-gradient,
    .tournament-crown-badge {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    /* Muestra hint de swipe */
    .torneos-swipe-hint {
        display: flex;
        padding: 0.5rem 0;
    }
}

/* ============================================
   MÓVIL PEQUEÑO: Optimizaciones adicionales < 480px
============================================ */

@media (max-width: 480px) {
    .hero-card {
        border-radius: 14px;
        margin: 0.25rem;
    }
    
    .hero-title {
        font-size: 1.2rem;
    }
    
    .hero-subtitle {
        font-size: 0.88rem;
    }
    
    .torneos-body > .row {
        gap: 0.5rem;
        padding: 0.75rem 0.5rem 1.25rem 0.5rem;
    }
    
    .torneos-body > .row > .col-lg-4,
    .torneos-body > .row > .col-md-6 {
        flex: 0 0 92%;
        max-width: 92%;
        contain-intrinsic-size: 340px;
    }
    
    .torneos-body .tournament-card {
        min-height: 150px;
        margin: 0;
    }
    
    .tournament-card-header {
        height: 130px;
    }

    .tournament-cover-content {
        padding: 0.85rem 1rem 1rem;
    }

    .tournament-logo-bridge {
        margin-top: -35px;
    }
    
    .tournament-logo-chip {
        padding: 4px;
        width: 58px;
        height: 58px;
    }
    
    .tournament-title {
        font-size: 0.95rem;
    }
    
    .tournament-logo {
        padding: 0.2rem;
        max-height: 50px;
        max-width: 50px;
        width: 50px;
        height: 50px;
    }
}

/* ============================================
   PREVENCIÓN DE FLASH BLANCO AL SCROLLEAR
============================================ */

/* Fondo constante para prevenir flash blanco */
html, body {
    background-color: #f0f2f5 !important;
    min-height: 100vh;
}

/* Skeleton loading optimizado */
.skeleton-card {
    background: linear-gradient(90deg, 
        #f0f0f0 0%, 
        #e8e8e8 50%, 
        #f0f0f0 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 14px;
    min-height: 380px;
    content-visibility: auto;
    contain-intrinsic-size: 380px;
}

@keyframes skeleton-loading {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Clase para ocultar mientras carga */
.loading {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loaded {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   MEJORAS DE RENDIMIENTO GENERAL
============================================ */

/* Aplica contain a elementos grandes */
.hero-card,
.torneos-card,
.tournament-card {
    contain: layout style paint;
}

/* Optimiza transformaciones */
.tournament-card,
.tournament-view-btn {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Mejora renderizado de texto */
.hero-title,
.torneos-header-title,
.tournament-title {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   FIX PARA SAFARI/IOS
============================================ */

@supports (-webkit-touch-callout: none) {
    /* Fix para iOS */
    .hero-card,
    .torneos-card,
    .tournament-card {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    .torneos-body > .row {
        -webkit-overflow-scrolling: auto;
    }
}

/* ============================================
   ESTILOS DE FALLBACK PARA JS DESHABILITADO
============================================ */

.no-js .tournament-card {
    opacity: 1 !important;
    transform: none !important;
}

.no-js .torneos-body > .row {
    flex-wrap: wrap !important;
    overflow-x: visible !important;
}

.no-js .torneos-body > .row > .col-lg-4,
.no-js .torneos-body > .row > .col-md-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
}

/* Características destacadas en una fila */
#heroFeatures {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 1rem;
}

#heroFeatures .col-auto {
    flex: 0 0 auto;
    min-width: fit-content;
}

@media (max-width: 576px) {
    #heroFeatures {
        gap: 0.5rem;
    }
    
    #heroFeatures .col-auto {
        flex: 0 1 auto;
    }
    
    #heroFeatures .d-flex {
        font-size: 0.85rem;
    }
    
    #heroFeatures i {
        font-size: 1rem !important;
    }
    
    #heroFeatures .me-4 {
        margin-right: 0.5rem !important;
    }
}