/**
 * KET Detective - 游戏列表首页样式
 * 基于证据梳理页面的设计风格
 */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;700&display=swap');

/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* iOS PWA 安全区域背景色修复 */
html {
    background-color: #1a2332;
}

body {
    font-family: 'Noto Serif SC', serif;
    background: linear-gradient(135deg, #1a2332 0%, #2c3e50 100%);
    color: #f4f1e8;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ========== Loading Screen ========== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a2332 0%, #2c3e50 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(212, 175, 55, 0.3);
    border-top-color: #d4af37;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* ========== 主容器 ========== */
.home-container {
    width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== 顶部标题栏 ========== */
.header-bar {
    background: linear-gradient(135deg, rgba(26, 35, 50, 0.95) 0%, rgba(44, 62, 80, 0.95) 100%);
    border-bottom: 3px solid #d4af37;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 100;
}

.header-title h1 {
    color: #d4af37;
    font-size: 32px;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.header-subtitle {
    color: #95a5a6;
    font-size: 14px;
    font-style: italic;
}

.header-actions {
    display: flex;
    gap: 15px;
}

.manage-btn,
.login-btn {
    background: linear-gradient(135deg, #d4af37, #b8941f);
    color: #2a1f1a;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.manage-btn:hover,
.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(212, 175, 55, 0.5);
}

/* ========== 用户菜单 ========== */
.user-menu {
    position: relative;
    display: inline-block;
}

.user-menu-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #d4af37, #b8941f);
    color: #2a1f1a;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.user-menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(212, 175, 55, 0.5);
}

.dropdown-arrow {
    font-size: 10px;
    transition: transform 0.3s ease;
}

.user-menu.active .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: rgba(42, 31, 26, 0.98);
    border: 2px solid #d4af37;
    border-radius: 8px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    overflow: hidden;
}

.user-menu.active .user-dropdown {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    padding: 14px 20px;
    color: #f4f1e8;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: rgba(212, 175, 55, 0.2);
    color: #d4af37;
}


/* ========== 游戏网格 ========== */
.games-section {
    flex: 1;
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.section-header {
    margin-bottom: 30px;
}

.section-header h2 {
    color: #d4af37;
    font-size: 24px;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.section-header p {
    color: #95a5a6;
    font-size: 14px;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    padding-bottom: 40px;
}

/* ========== 游戏卡片 ========== */
.game-card {
    background: linear-gradient(135deg, rgba(42, 31, 26, 0.9), rgba(61, 46, 36, 0.9));
    border: 2px solid #d4af37;
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}

.game-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 35px rgba(212, 175, 55, 0.4);
    border-color: #f4f1e8;
}

.card-cover {
    width: 100%;
    height: 200px;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
}

.card-cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.2), rgba(0,0,0,0.6));
}

.badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.badge.official {
    background: linear-gradient(135deg, #d4af37, #b8941f);
    color: #2a1f1a;
}

.badge.published {
    background: rgba(76, 175, 80, 0.9);
    color: #fff;
}

.card-body {
    padding: 20px;
}

.card-body h3 {
    color: #d4af37;
    font-size: 20px;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.description {
    color: #f4f1e8;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 15px;
    opacity: 0.9;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.stats {
    display: flex;
    gap: 15px;
    font-size: 12px;
    color: #95a5a6;
    padding-top: 15px;
    border-top: 1px solid rgba(212, 175, 55, 0.3);
}

.stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 80px 40px;
    color: #95a5a6;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #d4af37;
}

.empty-state p {
    font-size: 16px;
}

/* ========== 响应式设计 ========== */

/* 平板 */
@media screen and (max-width: 1024px) {
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }

    .header-bar {
        padding: 15px 30px;
    }

    .header-title h1 {
        font-size: 28px;
    }

    .games-section {
        padding: 30px 20px;
    }
}

/* 手机 */
@media screen and (max-width: 768px) {
    .header-bar {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 15px 20px;
    }

    .header-actions {
        flex-direction: row;
        width: 100%;
        gap: 10px;
    }

    .manage-btn,
    .login-btn {
        flex: 0 0 auto;
        width: auto;
        padding: 10px 14px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* 学习报告按钮简化 */
    #learningReportBtn {
        padding: 10px 12px;
    }

    /* 用户菜单自适应 */
    .user-menu {
        flex: 1;
        min-width: 0;
    }

    .user-menu-btn {
        width: 100%;
        justify-content: center;
        padding: 10px 14px;
        font-size: 13px;
    }

    .user-menu-btn #userDisplay {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 120px;
    }

    .games-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .games-section {
        padding: 20px 15px;
    }

    .section-header h2 {
        font-size: 20px;
    }

    .card-cover {
        height: 180px;
    }
}

/* 小屏手机 */
@media screen and (max-width: 480px) {
    .header-title h1 {
        font-size: 24px;
    }

    .header-subtitle {
        font-size: 12px;
    }

    .card-cover {
        height: 160px;
    }

    .card-body h3 {
        font-size: 18px;
    }

    .description {
        font-size: 13px;
    }
}

/* ========== 移动端适配 ========== */
@media (max-width: 768px) {
    /* 顶部标题栏适配 */
    .header-bar {
        padding: 15px 20px;
        /* 增加顶部内边距，避开刘海屏并下移内容 */
        padding-top: calc(env(safe-area-inset-top) + 20px);
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .header-title {
        display: none; /* 移动端隐藏标题，节省空间 */
    }

    .header-actions {
        width: 100%;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
    }

    .header-title h1 {
        font-size: 24px;
    }

    /* 游戏网格适配 */
    .games-section {
        padding: 20px;
    }

    .games-grid {
        grid-template-columns: 1fr; /* 强制单列 */
        gap: 20px;
    }

    /* 按钮适配 */
    .manage-btn,
    .login-btn {
        padding: 10px 12px;
        font-size: 13px;
        flex: 0 0 auto;
    }

    .user-menu {
        flex: 1;
        min-width: 0;
        max-width: 160px;
    }

    .user-menu-btn {
        padding: 10px 12px;
        font-size: 13px;
        width: 100%;
    }

    /* 用户菜单下拉框适配 */
    .user-dropdown {
        right: 0;
        left: auto;
        width: 180px;
    }
}
