/**
 * Top Games Section Styles
 * Bakersfield eSports - 2025
 * Optimized for accessibility and performance
 */

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible for keyboard navigation */
.game-card:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 4px;
}

.game-card:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 4px;
}

/* Remove outline for mouse users only */
.game-card:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .game-card {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .game-card,
    .game-info,
    .spinner,
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   TOP GAMES SECTION
   ============================================ */

.top-games-section {
    position: relative;
    padding: 4em 0;
    background: linear-gradient(135deg, #030202 0%, #1a0a0f 50%, #030202 100%);
    overflow: hidden;
}

/* Animated gradient background */
.top-games-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg,
        rgba(236, 25, 77, 0.05),
        transparent,
        rgba(236, 25, 77, 0.05)
    );
    background-size: 200% 200%;
    animation: gradient-shift 15s ease infinite;
    z-index: -1;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.top-games-section .container {
    position: relative;
    z-index: 2;
}

/* ============================================
   TOP GAMES HEADER
   ============================================ */

.top-games-header {
    text-align: center;
    margin-bottom: 2.5em;
}

.top-games-header h2 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    color: var(--primary-color);
    margin-bottom: 0.5em;
    text-shadow: 0 0 20px rgba(236, 25, 77, 0.5);
}

.top-games-header p {
    font-size: 1.1rem;
    opacity: 0.8;
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================
   TOP GAMES GRID
   ============================================ */

.top-games-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 columns = 2 rows of 10 */
    gap: 1.5em;
    margin-bottom: 2em;
}

/* Responsive grid */
@media (max-width: 1400px) {
    .top-games-grid {
        grid-template-columns: repeat(5, 1fr); /* Keep 5 columns on large tablets */
    }
}

@media (max-width: 1200px) {
    .top-games-grid {
        grid-template-columns: repeat(4, 1fr); /* 4 columns */
    }
}

@media (max-width: 992px) {
    .top-games-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 columns */
    }
}

@media (max-width: 768px) {
    .top-games-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns */
        gap: 1em;
    }
}

@media (max-width: 480px) {
    .top-games-grid {
        grid-template-columns: repeat(2, 1fr); /* Keep 2 columns on mobile */
        gap: 0.8em;
    }
}

/* ============================================
   GAME CARD
   ============================================ */

.game-card {
    position: relative;
    background: rgba(18, 18, 18, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(236, 25, 77, 0.2);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

.game-card:hover {
    transform: translateY(-8px) scale(1.05);
    border-color: rgba(236, 25, 77, 0.6);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(236, 25, 77, 0.4);
    z-index: 10;
}

/* Game Cover Image */
.game-cover {
    width: 100%;
    aspect-ratio: 2/3; /* Portrait orientation for 600x900 images */
    object-fit: cover;
    display: block;
    background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
}

/* Game Info Overlay */
.game-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1em 0.8em;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.95) 0%,
        rgba(0, 0, 0, 0.85) 50%,
        transparent 100%
    );
    transform: translateY(100%);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-card:hover .game-info {
    transform: translateY(0);
}

.game-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--light-color);
    line-height: 1.3;
    text-align: center;
}

/* Rank Badge */
.game-rank {
    position: absolute;
    top: 0.5em;
    left: 0.5em;
    background: linear-gradient(135deg, var(--primary-color), #ff1744);
    color: white;
    font-size: 0.75rem;
    font-weight: 900;
    padding: 0.3em 0.6em;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(236, 25, 77, 0.5);
    z-index: 5;
}

/* Top 3 special styling */
.game-card[data-rank="1"] .game-rank {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    font-size: 0.85rem;
    padding: 0.4em 0.7em;
}

.game-card[data-rank="2"] .game-rank {
    background: linear-gradient(135deg, #C0C0C0, #A9A9A9);
}

.game-card[data-rank="3"] .game-rank {
    background: linear-gradient(135deg, #CD7F32, #B8860B);
}

/* Glow effect for top 3 */
.game-card[data-rank="1"] {
    border-color: rgba(255, 215, 0, 0.4);
}

.game-card[data-rank="1"]:hover {
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(255, 215, 0, 0.5);
}

/* ============================================
   LOADING STATE
   ============================================ */

.loading-games {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4em 0;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(236, 25, 77, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1em;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-games p {
    font-size: 1.1rem;
    opacity: 0.7;
}

/* ============================================
   ERROR STATE
   ============================================ */

.error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3em;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    border-radius: 12px;
    color: #ff6b6b;
}

/* ============================================
   FOOTER
   ============================================ */

.top-games-footer {
    text-align: center;
    padding-top: 1.5em;
    border-top: 1px solid rgba(236, 25, 77, 0.2);
}

.last-updated {
    font-size: 0.9rem;
    opacity: 0.6;
}

.last-updated span {
    color: var(--primary-color);
    font-weight: 600;
}

/* ============================================
   ANIMATIONS
   ============================================ */

.game-card {
    animation: game-appear 0.5s ease-out forwards;
    opacity: 0;
}

.game-card:nth-child(1) { animation-delay: 0.05s; }
.game-card:nth-child(2) { animation-delay: 0.1s; }
.game-card:nth-child(3) { animation-delay: 0.15s; }
.game-card:nth-child(4) { animation-delay: 0.2s; }
.game-card:nth-child(5) { animation-delay: 0.25s; }
.game-card:nth-child(6) { animation-delay: 0.3s; }
.game-card:nth-child(7) { animation-delay: 0.35s; }
.game-card:nth-child(8) { animation-delay: 0.4s; }
.game-card:nth-child(9) { animation-delay: 0.45s; }
.game-card:nth-child(10) { animation-delay: 0.5s; }

@keyframes game-appear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU acceleration for smooth animations */
.game-card,
.game-info,
.spinner {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Contain paint and layout for better performance */
.game-card {
    contain: layout style paint;
}

/* Optimize image rendering */
.game-cover {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}
