/**
 * 游戏卡片通用样式
 * 用于游戏卡片的统一样式定义
 * version: 1.1.0
 */

/* 游戏卡片网格容器 - 适配不同页面的容器宽度 */
.game-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 始终保持一行三个卡片 */
    grid-auto-rows: auto; /* 自动调整行高 */
    gap: 15px; /* 统一使用15px的间距 */
    width: 100%; /* 占满容器宽度 */
    align-items: start; /* 确保项目从顶部开始对齐 */
    box-sizing: border-box; /* 确保内边距不会增加元素的总宽度 */
    justify-items: center; /* 水平居中网格项目 */
}

/* 为不同页面的容器设置统一的内边距 */
.game-section .game-grid,
.tab-content .game-grid,
.content-area .game-grid {
    padding: 0; /* 移除内边距，由容器控制 */
    margin: 0; /* 移除外边距，由容器控制 */
}

/* 游戏卡片基础样式 */
.game-card {
    position: relative;
    width: 100%; /* 使用百分比宽度，适应网格布局 */
    max-width: 162px; /* 设置最大宽度为162px */
    height: auto; /* 高度自适应 */
    border-radius: 8px;
    overflow: hidden;
    background-color: transparent; /* 使用透明背景 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease; /* 更平滑的过渡 */
    will-change: transform; /* 优化动画性能 */
    box-sizing: border-box; /* 确保内边距和边框不会增加元素的总宽度 */
    display: block; /* 确保元素是块级元素 */
    aspect-ratio: auto; /* 移除固定宽高比，让高度自适应图片 */
    justify-self: center; /* 在网格中居中显示 */
}

.game-card:hover {
    transform: translateY(-5px) scale(1.03); /* 略微增强悬停效果 */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* 游戏图片容器 */
.game-image {
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center; /* 确保内容居中 */
    background-color: transparent; /* 使用透明背景 */
}

/* 游戏图标/缩略图容器 */
.game-icon {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 100%;
    width: 100%;
    padding: 0;
}

/* 缩略图样式 */
.game-thumbnail {
    width: 100% !important;
    height: auto !important; /* 改为auto，让高度根据宽度自适应 */
    object-fit: contain !important; /* 确保图片完整显示 */
    transition: transform 0.3s ease;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    z-index: 5 !important;
}

.game-icon img {
    width: 100% !important;
    height: auto !important; /* 改为auto，让高度根据宽度自适应 */
    object-fit: contain !important; /* 确保图片完整显示 */
    transition: transform 0.3s ease;
    z-index: 5 !important;
}

.game-card:hover .game-icon img,
.game-card:hover .game-thumbnail {
    transform: scale(1.05);
}

/* 游戏提供商标签 */
.game-provider {
    position: absolute;
    top: 5px;
    left: 5px;
    background-color: rgba(0, 0, 0, 0.6);
    color: var(--text-color);
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 3px;
    z-index: 10;
}

/* 游戏名称标签 */
.game-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 5px;
    text-align: center;
    font-size: 12px;
    background-color: rgba(0, 0, 0, 0.7);
    color: var(--text-color);
    z-index: 10;
}

/* 收藏星星按钮 */
.favorite-star {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    z-index: 15;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0.8;
}

.favorite-star:hover {
    transform: scale(1.1);
    opacity: 1;
}

.favorite-star.favorited {
    background-image: url('/assets/img/frontend/common/star.png');
}

.favorite-star.not-favorited {
    background-image: url('/assets/img/frontend/common/star_gray.png');
}

/* 懒加载相关样式 */
img.lazy-load {
    opacity: 1 !important;
    transition: none !important;
}

img.lazy-load[src] {
    opacity: 1 !important;
}

/* 图片加载错误样式 */
img.image-error {
    opacity: 0;
    background-color: transparent;
    border: none;
    object-fit: contain !important;
}

/* 图片加载成功样式 */
img.image-loaded {
    opacity: 1 !important;
}

/* 响应式布局调整 - 保持一行三个卡片，调整间距 */
@media (max-width: 516px) {
    .game-grid {
        grid-template-columns: repeat(3, 1fr); /* 保持一行三个卡片 */
        gap: 15px; /* 保持统一的间距 */
        grid-auto-rows: auto; /* 自动调整行高 */
        justify-items: center; /* 水平居中网格项目 */
    }

    .game-card {
        max-width: 140px; /* 在中等屏幕上减小最大宽度 */
        aspect-ratio: auto; /* 移除固定宽高比，让高度自适应图片 */
        height: auto; /* 高度自适应 */
        justify-self: center; /* 在网格中居中显示 */
    }
}

@media (max-width: 370px) {
    .game-grid {
        grid-template-columns: repeat(3, 1fr); /* 保持一行三个卡片 */
        gap: 15px; /* 保持统一的间距 */
        grid-auto-rows: auto; /* 自动调整行高 */
        justify-items: center; /* 水平居中网格项目 */
    }

    .game-card {
        max-width: 120px; /* 在小屏幕上进一步减小最大宽度 */
        aspect-ratio: auto; /* 移除固定宽高比，让高度自适应图片 */
        height: auto; /* 高度自适应 */
        justify-self: center; /* 在网格中居中显示 */
    }
}

/* 无游戏状态提示 */
.no-games, .no-category-games {
    grid-column: 1 / -1;
    padding: 20px;
    text-align: center;
    color: var(--text-secondary-color);
    background-color: var(--card-bg-color);
    border-radius: 8px;
}
