/* ========================================
   Games Gallery - CSS
   主题色：紫色系 (#7C3AED)
   重点：移动端优化的瀑布流布局
   ======================================== */

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 紫色主题 */
    --primary: #7C3AED;
    --primary-light: #A78BFA;
    --primary-dark: #6D28D9;
    --accent: #EC4899;
    
    /* 中性色 */
    --bg-main: #F9FAFB;
    --bg-card: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --border: #E5E7EB;
    
    /* 渐变 */
    --gradient-purple: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-overlay: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 60%);
    
    /* 间距 */
    --container-width: 1400px;
    --gap-sm: 12px;
    --gap-md: 16px;
    --gap-lg: 24px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--gap-md);
}

/* ===== Header ===== */
.header {
    background: var(--gradient-purple);
    color: white;
    padding: var(--gap-lg) 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--gap-md);
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.tagline {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Search Box */
.search-container {
    position: relative;
    flex: 0 1 400px;
}

.search-input {
    width: 100%;
    padding: 12px 48px 12px 16px;
    border: none;
    border-radius: 24px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.95);
    transition: background 0.3s;
}

.search-input:focus {
    outline: none;
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.search-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.search-btn:hover {
    background: rgba(124, 58, 237, 0.1);
}

/* ===== Category Navigation ===== */
.category-nav {
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 108px;
    z-index: 90;
}

.category-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: var(--gap-md) 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.category-tab {
    padding: 10px 20px;
    border: none;
    background: var(--bg-main);
    color: var(--text-primary);
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.3s;
}

.category-tab:hover {
    background: var(--primary-light);
    color: white;
}

.category-tab.active {
    background: var(--primary);
    color: white;
}

/* ===== Stats Bar ===== */
.stats-bar {
    padding: var(--gap-lg) 0 var(--gap-md) 0;
}

.stats-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.game-count {
    font-weight: 600;
    color: var(--primary);
}

/* ===== Gallery Grid (Masonry) ===== */
.gallery-grid {
    column-count: 4;
    column-gap: var(--gap-md);
    margin-bottom: var(--gap-lg);
}

.gallery-item {
    break-inside: avoid;
    margin-bottom: var(--gap-md);
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.15);
}

.gallery-thumbnail {
    position: relative;
    overflow: hidden;
    background: #f3f4f6;
}

.gallery-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.5s ease;
}

.gallery-item:hover .gallery-thumbnail img {
    transform: scale(1.08);
}

/* Image Overlay */
.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--gradient-overlay);
    padding: var(--gap-md);
    opacity: 0;
    transition: opacity 0.3s;
}

.gallery-item:hover .image-overlay {
    opacity: 1;
}

.image-overlay h3 {
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

/* Game Info */
.gallery-info {
    padding: var(--gap-md);
}

.gallery-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.category-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--primary-light);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ===== Loading & Complete States ===== */
.loading-status,
.load-complete {
    text-align: center;
    padding: var(--gap-lg);
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.load-complete {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    border-radius: 12px;
    margin: var(--gap-lg) 0;
}

.load-complete p {
    font-size: 1.125rem;
    color: var(--primary);
}

/* ===== Footer ===== */
.footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: var(--gap-lg) 0;
    margin-top: 60px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--gap-md);
}

.footer-links {
    display: flex;
    gap: var(--gap-lg);
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: var(--primary);
}

/* ===== Responsive Design ===== */

/* Tablet: 768px - 1199px */
@media (max-width: 1199px) {
    .gallery-grid {
        column-count: 3;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .search-container {
        flex: 1;
        max-width: 500px;
    }
    
    .category-nav {
        top: 148px;
    }
}

/* Mobile: 480px - 767px */
@media (max-width: 767px) {
    :root {
        --gap-sm: 8px;
        --gap-md: 12px;
        --gap-lg: 16px;
    }
    
    .gallery-grid {
        column-count: 2;
        column-gap: var(--gap-sm);
    }
    
    .gallery-item {
        margin-bottom: var(--gap-sm);
        border-radius: 12px;
    }
    
    .header {
        padding: var(--gap-md) 0;
    }
    
    .logo h1 {
        font-size: 1.5rem;
    }
    
    .tagline {
        font-size: 0.8125rem;
    }
    
    .search-input {
        padding: 10px 44px 10px 14px;
        font-size: 0.9375rem;
    }
    
    .category-tab {
        padding: 8px 16px;
        font-size: 0.875rem;
    }
    
    .gallery-info {
        padding: var(--gap-sm);
    }
    
    .gallery-title {
        font-size: 0.9375rem;
    }
    
    .category-badge {
        font-size: 0.6875rem;
        padding: 3px 8px;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-links {
        flex-direction: column;
        gap: var(--gap-sm);
    }
    
    .category-nav {
        top: 140px;
    }
    
    /* 移动端优化：隐藏悬停效果的overlay */
    .image-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 50%);
        padding: var(--gap-sm);
    }
    
    .image-overlay h3 {
        font-size: 0.875rem;
    }
}

/* Small Mobile: < 480px */
@media (max-width: 479px) {
    .container {
        padding: 0 var(--gap-sm);
    }
    
    .logo h1 {
        font-size: 1.25rem;
    }
    
    .gallery-grid {
        column-gap: 8px;
    }
    
    .gallery-item {
        border-radius: 8px;
    }
    
    .category-tabs {
        gap: 6px;
    }
    
    .category-tab {
        padding: 6px 12px;
        font-size: 0.8125rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .gallery-item:hover {
        transform: none;
    }
    
    .gallery-item:active {
        transform: scale(0.98);
    }
    
    .category-tab:hover {
        background: var(--bg-main);
        color: var(--text-primary);
    }
    
    .category-tab:active,
    .category-tab.active {
        background: var(--primary);
        color: white;
    }
}

/* Landscape mobile optimization */
@media (max-width: 767px) and (orientation: landscape) {
    .header {
        padding: 12px 0;
    }
    
    .logo h1 {
        font-size: 1.25rem;
    }
    
    .tagline {
        display: none;
    }
    
    .category-nav {
        top: 76px;
    }
}
