/* ===========================================
   Game Index - 遊戲中心首頁樣式
   =========================================== */

/* CSS Variables - 深色模式（預設） */
:root {
    --gaming-primary: #7c3aed;
    --gaming-primary-hover: #6d28d9;
    --gaming-secondary: #10b981;
    --gaming-accent: #f59e0b;
    --gaming-danger: #ef4444;
    --gaming-bg: #0f0f23;
    --gaming-surface: #1a1a2e;
    --gaming-surface-hover: #252542;
    --gaming-border: #2d2d4a;
    --gaming-text: #e2e8f0;
    --gaming-text-muted: #94a3b8;
    --gaming-gradient: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
    --gaming-glow: 0 0 20px rgba(124, 58, 237, 0.3);
    --gaming-card-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --gaming-overlay: rgba(0, 0, 0, 0.6);
}

/* 淺色模式變數 */
:root[data-theme="light"] {
    --gaming-bg: #f8fafc;
    --gaming-surface: #ffffff;
    --gaming-surface-hover: #f1f5f9;
    --gaming-border: #e2e8f0;
    --gaming-text: #1e293b;
    --gaming-text-muted: #64748b;
    --gaming-glow: 0 0 20px rgba(124, 58, 237, 0.15);
    --gaming-card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --gaming-overlay: rgba(0, 0, 0, 0.4);
}

/* 跟隨系統 - 淺色 */
@media (prefers-color-scheme: light) {
    :root[data-theme="system"] {
        --gaming-bg: #f8fafc;
        --gaming-surface: #ffffff;
        --gaming-surface-hover: #f1f5f9;
        --gaming-border: #e2e8f0;
        --gaming-text: #1e293b;
        --gaming-text-muted: #64748b;
        --gaming-glow: 0 0 20px rgba(124, 58, 237, 0.15);
        --gaming-card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        --gaming-overlay: rgba(0, 0, 0, 0.4);
    }
}

/* ==================== Accessibility ==================== */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus 樣式 */
:focus-visible {
    outline: 2px solid var(--gaming-primary);
    outline-offset: 2px;
}

/* Container */
.gaming-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

/* ==================== Hero Section ==================== */
.gaming-hero {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 3rem;
    padding: 4rem 0;
    min-height: 400px;
}

.hero-content {
    max-width: 600px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gaming-gradient);
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hero-badge i {
    font-size: 1rem;
}

.gaming-hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin: 0 0 1rem;
    background: linear-gradient(135deg, #fff 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--gaming-text-muted);
    margin: 0 0 2rem;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.hero-visual {
    position: relative;
    width: 300px;
    height: 300px;
}

.floating-cards {
    position: relative;
    width: 100%;
    height: 100%;
}

.game-card-mini {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100px;
    height: 100px;
    background: var(--gaming-surface);
    border: 1px solid var(--gaming-border);
    border-radius: 1rem;
    color: var(--gaming-text);
    font-size: 0.75rem;
    font-weight: 600;
    animation: float 3s ease-in-out infinite;
    box-shadow: var(--gaming-glow);
}

.game-card-mini i {
    font-size: 1.5rem;
    color: var(--gaming-primary);
}

.game-card-mini[data-delay="0"] { top: 0; left: 50%; transform: translateX(-50%); animation-delay: 0s; }
.game-card-mini[data-delay="1"] { top: 50%; right: 0; transform: translateY(-50%); animation-delay: 0.5s; }
.game-card-mini[data-delay="2"] { bottom: 0; left: 50%; transform: translateX(-50%); animation-delay: 1s; }
.game-card-mini[data-delay="3"] { top: 50%; left: 0; transform: translateY(-50%); animation-delay: 1.5s; }

@keyframes float {
    0%, 100% { transform: translateY(0) translateX(-50%); }
    50% { transform: translateY(-10px) translateX(-50%); }
}

.game-card-mini[data-delay="1"],
.game-card-mini[data-delay="3"] {
    animation-name: float-horizontal;
}

@keyframes float-horizontal {
    0%, 100% { transform: translateY(-50%); }
    50% { transform: translateY(calc(-50% - 10px)); }
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn.primary {
    background: var(--gaming-gradient);
    color: white;
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--gaming-glow);
}

.btn.ghost {
    background: transparent;
    color: var(--gaming-text);
    border: 1px solid var(--gaming-border);
}

.btn.ghost:hover {
    background: var(--gaming-surface);
    border-color: var(--gaming-primary);
}

.btn.large {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn.small {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

/* ==================== Search Section ==================== */
.search-section {
    padding: 2rem 0;
}

.search-wrapper {
    max-width: 700px;
    margin: 0 auto;
}

.search-input-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem 0.5rem 1.25rem;
    background: var(--gaming-surface);
    border: 2px solid var(--gaming-border);
    border-radius: 3rem;
    transition: border-color 0.2s ease;
}

.search-input-group:focus-within {
    border-color: var(--gaming-primary);
}

.search-input-group i {
    color: var(--gaming-text-muted);
    font-size: 1.125rem;
}

.search-input-group input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--gaming-text);
    font-size: 1rem;
    outline: none;
}

.search-input-group input::placeholder {
    color: var(--gaming-text-muted);
}

.search-input-group .btn {
    border-radius: 2rem;
}

.search-results {
    margin-top: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--gaming-surface);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-result-item:hover {
    background: var(--gaming-surface-hover);
    transform: translateX(5px);
}

.search-result-item img {
    width: 60px;
    height: 40px;
    object-fit: cover;
    border-radius: 0.25rem;
}

.search-result-item .game-info {
    flex: 1;
}

.search-result-item .game-name {
    font-weight: 600;
    color: var(--gaming-text);
    margin: 0;
}

.search-result-item .game-meta {
    font-size: 0.75rem;
    color: var(--gaming-text-muted);
    margin: 0.25rem 0 0;
}

/* ==================== Stats Section ==================== */
.stats-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    padding: 2rem 0;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem;
    background: var(--gaming-surface);
    border: 1px solid var(--gaming-border);
    border-radius: 1rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--gaming-primary);
    box-shadow: var(--gaming-glow);
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--gaming-gradient);
    border-radius: 0.75rem;
    font-size: 1.5rem;
    color: white;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gaming-text);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gaming-text-muted);
}

/* ==================== Section Styles ==================== */
.section {
    padding: 2rem 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title i {
    font-size: 1.25rem;
    color: var(--gaming-primary);
}

.section-title h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--gaming-text);
}

.section-desc {
    font-size: 0.875rem;
    color: var(--gaming-text-muted);
    margin: 0.25rem 0 0;
}

/* ==================== Games Grid ==================== */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 0.5rem 0;
    overflow: visible;
}

.game-card {
    position: relative;
    background: var(--gaming-surface);
    border: 1px solid var(--gaming-border);
    border-radius: 1rem;
    overflow: visible;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1;
}

.game-card:hover {
    transform: translateY(-5px);
    border-color: var(--gaming-primary);
    box-shadow: var(--gaming-glow);
    z-index: 10;
}

.game-card .card-image {
    position: relative;
    height: 160px;
    overflow: hidden;
    border-radius: 1rem 1rem 0 0;
}

.game-card .card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    background: var(--gaming-surface-hover);
}

.game-card:hover .card-image img {
    transform: scale(1.05);
}

.game-card .card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 50%);
}

.game-card .lfg-count {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--gaming-primary);
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.game-card .card-body {
    padding: 1rem;
}

.game-card .card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gaming-text);
    margin: 0 0 0.5rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.game-card .card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.game-card .genre-tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--gaming-surface-hover);
    border-radius: 0.25rem;
    font-size: 0.6875rem;
    color: var(--gaming-text-muted);
}

.game-card .card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--gaming-border);
}

.game-card .rating {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--gaming-accent);
}

.game-card .action-btn {
    padding: 0.5rem 0.75rem;
    background: var(--gaming-gradient);
    border: none;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.game-card .action-btn:hover {
    transform: scale(1.05);
}

/* ==================== LFG List ==================== */
.lfg-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.lfg-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--gaming-surface);
    border: 1px solid var(--gaming-border);
    border-radius: 0.75rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.lfg-item:hover {
    border-color: var(--gaming-primary);
    background: var(--gaming-surface-hover);
}

.lfg-item .game-thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 0.5rem;
}

.lfg-item .lfg-info {
    flex: 1;
}

.lfg-item .lfg-title {
    font-weight: 600;
    color: var(--gaming-text);
    margin: 0 0 0.25rem;
}

.lfg-item .lfg-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--gaming-text-muted);
}

.lfg-item .lfg-meta span {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.lfg-item .host-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lfg-item .host-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.lfg-item .slots-badge {
    padding: 0.375rem 0.75rem;
    background: var(--gaming-secondary);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.lfg-item .slots-badge.full {
    background: var(--gaming-accent);
}

/* ==================== Carousel ==================== */
.games-carousel {
    position: relative;
    padding: 0 3rem;
}

.carousel-track {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0.5rem 0;
}

.carousel-track::-webkit-scrollbar {
    display: none;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: var(--gaming-surface);
    border: 1px solid var(--gaming-border);
    border-radius: 50%;
    color: var(--gaming-text);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.carousel-btn:hover {
    background: var(--gaming-primary);
    border-color: var(--gaming-primary);
}

.carousel-btn.prev {
    left: 0;
}

.carousel-btn.next {
    right: 0;
}

.carousel-game-card {
    flex: 0 0 220px;
    background: var(--gaming-surface);
    border: 1px solid var(--gaming-border);
    border-radius: 0.75rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.carousel-game-card:hover {
    transform: translateY(-5px);
    border-color: var(--gaming-primary);
}

.carousel-game-card img {
    width: 100%;
    height: 130px;
    object-fit: cover;
}

.carousel-game-card .card-content {
    padding: 0.75rem;
}

.carousel-game-card .card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gaming-text);
    margin: 0 0 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.carousel-game-card .card-rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--gaming-accent);
}

/* ==================== Guide Section ==================== */
.guide-section {
    background: var(--gaming-surface);
    border: 1px solid var(--gaming-border);
    border-radius: 1rem;
    padding: 2rem;
}

.guide-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
}

.guide-step {
    text-align: center;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--gaming-gradient);
    border-radius: 50%;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    margin-bottom: 1rem;
}

.step-content h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gaming-text);
    margin: 0 0 0.5rem;
}

.step-content p {
    font-size: 0.875rem;
    color: var(--gaming-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ==================== Loading State ==================== */
.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem;
    color: var(--gaming-text-muted);
}

.loading-placeholder i {
    font-size: 2rem;
    color: var(--gaming-primary);
}

/* ==================== Modal ==================== */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    background: var(--gaming-surface);
    border: 1px solid var(--gaming-border);
    border-radius: 1rem;
    overflow: auto;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: var(--gaming-surface-hover);
    border: 1px solid var(--gaming-border);
    border-radius: 50%;
    color: var(--gaming-text);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: var(--gaming-danger);
    border-color: var(--gaming-danger);
}

.modal-body {
    padding: 2rem;
}

/* ==================== Responsive ==================== */
@media (max-width: 1024px) {
    .gaming-hero {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .hero-visual {
        display: none;
    }
    
    .hero-actions {
        justify-content: center;
    }
    
    .guide-steps {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .gaming-hero h1 {
        font-size: 2.5rem;
    }
    
    .stats-section {
        grid-template-columns: 1fr;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
    }
    
    .guide-steps {
        grid-template-columns: 1fr;
    }
    
    .games-carousel {
        padding: 0;
    }
    
    .carousel-btn {
        display: none;
    }
}

@media (max-width: 480px) {
    .gaming-container {
        padding: 0 1rem 2rem;
    }
    
    .gaming-hero {
        padding: 2rem 0;
    }
    
    .gaming-hero h1 {
        font-size: 2rem;
    }
    
    .hero-actions {
        flex-direction: column;
    }
    
    .btn.large {
        width: 100%;
    }
    
    .lfg-item {
        flex-direction: column;
        text-align: center;
    }
    
    .lfg-item .lfg-meta {
        justify-content: center;
    }
}

/* ==================== Light Mode Adjustments ==================== */
:root[data-theme="light"] .gaming-container,
:root[data-theme="light"] .gaming-hero,
:root[data-theme="light"] .section {
    background: transparent;
}

/* 淺色模式下 H1 標題使用深色漸層 */
:root[data-theme="light"] .gaming-hero h1 {
    background: linear-gradient(135deg, #1e293b 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 淺色模式下浮動卡片調整 */
:root[data-theme="light"] .game-card-mini {
    background: var(--gaming-surface);
    border-color: var(--gaming-border);
    box-shadow: var(--gaming-card-shadow);
}

:root[data-theme="light"] .game-card,
:root[data-theme="light"] .stat-card,
:root[data-theme="light"] .search-result-item,
:root[data-theme="light"] .lfg-item,
:root[data-theme="light"] .guide-step {
    box-shadow: var(--gaming-card-shadow);
}

:root[data-theme="light"] .game-card:hover,
:root[data-theme="light"] .carousel-card:hover {
    box-shadow: 0 8px 30px rgba(124, 58, 237, 0.15);
}

:root[data-theme="light"] .modal-content {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

:root[data-theme="light"] .btn.ghost {
    border-color: var(--gaming-border);
    color: var(--gaming-text);
}

:root[data-theme="light"] .btn.ghost:hover {
    background: var(--gaming-surface-hover);
    border-color: var(--gaming-primary);
}

:root[data-theme="light"] .search-input-group input {
    background: var(--gaming-surface);
    border: 1px solid var(--gaming-border);
}

:root[data-theme="light"] .search-input-group input:focus {
    border-color: var(--gaming-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

/* 跟隨系統淺色模式 */
@media (prefers-color-scheme: light) {
    :root[data-theme="system"] .gaming-container,
    :root[data-theme="system"] .gaming-hero,
    :root[data-theme="system"] .section {
        background: transparent;
    }

    /* 系統淺色模式下 H1 標題使用深色漸層 */
    :root[data-theme="system"] .gaming-hero h1 {
        background: linear-gradient(135deg, #1e293b 0%, #7c3aed 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    /* 系統淺色模式下浮動卡片調整 */
    :root[data-theme="system"] .game-card-mini {
        background: var(--gaming-surface);
        border-color: var(--gaming-border);
        box-shadow: var(--gaming-card-shadow);
    }

    :root[data-theme="system"] .game-card,
    :root[data-theme="system"] .stat-card,
    :root[data-theme="system"] .search-result-item,
    :root[data-theme="system"] .lfg-item,
    :root[data-theme="system"] .guide-step {
        box-shadow: var(--gaming-card-shadow);
    }

    :root[data-theme="system"] .game-card:hover,
    :root[data-theme="system"] .carousel-card:hover {
        box-shadow: 0 8px 30px rgba(124, 58, 237, 0.15);
    }

    :root[data-theme="system"] .modal-content {
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    }

    :root[data-theme="system"] .btn.ghost {
        border-color: var(--gaming-border);
        color: var(--gaming-text);
    }

    :root[data-theme="system"] .btn.ghost:hover {
        background: var(--gaming-surface-hover);
        border-color: var(--gaming-primary);
    }

    :root[data-theme="system"] .search-input-group input {
        background: var(--gaming-surface);
        border: 1px solid var(--gaming-border);
    }

    :root[data-theme="system"] .search-input-group input:focus {
        border-color: var(--gaming-primary);
        box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
    }
}
