/* 精选游戏页面专用样式 - 完整修复版 */

/* 重置所有glass元素 - 清除Tailwind干扰 */
.glass, 
.glass-heavy,
div.glass,
header.glass,
nav.glass {
    /* 清除所有Tailwind CSS变量 */
    --tw-backdrop-blur: none !important;
    --tw-backdrop-brightness: none !important;
    --tw-backdrop-contrast: none !important;
    --tw-backdrop-grayscale: none !important;
    --tw-backdrop-hue-rotate: none !important;
    --tw-backdrop-invert: none !important;
    --tw-backdrop-opacity: none !important;
    --tw-backdrop-saturate: none !important;
    --tw-backdrop-sepia: none !important;
}

.safe-top { 
    padding-top: env(safe-area-inset-top); 
}

.safe-bottom { 
    padding-bottom: env(safe-area-inset-bottom); 
}

/* 毛玻璃效果 - 主要样式 */
.glass {
    background: rgba(255, 255, 255, 0.02) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    /* 确保创建新的层叠上下文 */
    position: relative;
    isolation: isolate;
}

.glass-heavy {
    background: rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(40px) !important;
    -webkit-backdrop-filter: blur(40px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    position: relative;
    isolation: isolate;
}

/* 流光边框效果 */
.flow-border {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.flow-border::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
    transform: rotate(0deg);
    animation: flow 3s linear infinite;
}

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

/* 标签样式 */
.tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s;
}

.tag.active,
.category-filter-btn.active {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

/* 触摸反馈 */
.tap-feedback {
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.tap-feedback:active {
    transform: scale(0.98);
    opacity: 0.8;
}

/* 隐藏滚动条 */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* 噪点纹理 */
.noise {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.015;
    z-index: 1;
    pointer-events: none;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIj48ZmlsdGVyIGlkPSJhIj48ZmVUdXJidWxlbmNlIGJhc2VGcmVxdWVuY3k9Ii45IiBudW1PY3RhdmVzPSI0IiBzZWVkPSIyIi8+PC9maWx0ZXI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsdGVyPSJ1cmwoI2EpIiBvcGFjaXR5PSIxIi8+PC9zdmc+');
}

/* 游戏卡片 */
.game-card {
    position: relative;
    cursor: pointer;
    will-change: transform;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    display: block;
    opacity: 1;
    transform: scale(1);
}

@media (hover: hover) and (pointer: fine) {
    .game-card:hover {
        transform: translateY(-8px) scale(1.02);
        box-shadow: 0 25px 50px rgba(0,0,0,0.4);
    }
    
    .game-card:hover .game-cover {
        transform: scale(1.1);
    }
}

@media (hover: none) and (pointer: coarse) {
    .game-card:active {
        transform: scale(0.95);
        opacity: 0.9;
    }
}

.game-cover {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    object-fit: cover;
}

/* 游戏卡片毛玻璃效果 */
.game-card.glass {
    background: rgba(255, 255, 255, 0.03) !important;
    backdrop-filter: blur(25px) !important;
    -webkit-backdrop-filter: blur(25px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* 游戏卡片筛选状态 */
.game-card.hidden {
    display: none;
}

.game-card.filtering {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

.game-card.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* 背景过渡层 */
.background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    z-index: -1;
    opacity: 0;
    transform: scale(1.1);
    transition: all 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
}

.background-layer.show {
    z-index: 9999;
    opacity: 1;
    transform: scale(1);
}

.background-layer.fade-out {
    opacity: 0;
    transform: scale(1.05);
    filter: blur(5px);
    transition: all 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@media (max-width: 768px) {
    .background-layer {
        background-attachment: scroll;
    }
}

/* 背景遮罩滑动效果 */
.background-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, 
        rgba(0,0,0,0.7) 0%, 
        rgba(0,0,0,0.5) 30%, 
        rgba(0,0,0,0.3) 50%, 
        rgba(0,0,0,0.5) 70%, 
        rgba(0,0,0,0.7) 100%);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    transform: translateX(-100%);
    transition: transform 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
}

.background-mask.slide-in {
    transform: translateX(0%);
}

.background-mask.slide-out {
    transform: translateX(100%);
    opacity: 0;
    transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55), 
                opacity 0.8s ease;
}

/* 详情页面 */
.game-detail-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.game-detail-page.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.game-detail-page.fade-out {
    opacity: 0;
    transform: scale(0.95);
    filter: blur(2px);
    transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* 详情页面毛玻璃效果 */
.game-detail-page .glass {
    background: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(30px) !important;
    -webkit-backdrop-filter: blur(30px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* 主内容区域过渡 */
.main-content {
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.main-content.fade-out {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    filter: blur(1px);
}

.main-content.fade-in {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
}

/* 动画元素 */
.slide-from-top {
    transform: translateY(-100vh);
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-from-bottom {
    transform: translateY(100vh);
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-from-left {
    transform: translateX(-100vw);
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-from-right {
    transform: translateX(100vw);
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-from-top.animate-in,
.slide-from-bottom.animate-in,
.slide-from-left.animate-in,
.slide-from-right.animate-in {
    transform: translate(0, 0);
    opacity: 1;
}

/* 封面占位样式 */
.cover-placeholder {
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 12px;
}

/* 波浪过渡效果 */
.wave-mask {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(0,0,0,0.8) 20%, 
        rgba(0,0,0,0.9) 50%, 
        rgba(0,0,0,0.8) 80%, 
        transparent 100%);
    transform: skewX(-15deg);
    transition: left 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
}

.wave-mask.sweep {
    left: 100%;
}

.wave-mask.reverse-sweep {
    left: -100%;
    opacity: 0;
    transition: left 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55), 
                opacity 0.8s ease;
}

/* 飞行封面优化 */
.flying-cover {
    position: fixed;
    z-index: 10001;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    will-change: transform, width, height, top, left;
    pointer-events: none;
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 游戏卡片恢复动画 */
.card-restore {
    transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.card-restore.slide-up {
    animation: cardSlideUp 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes cardSlideUp {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
        filter: blur(2px);
    }
    60% {
        opacity: 0.8;
        transform: translateY(-5px) scale(1.02);
        filter: blur(0);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* 反向动画 - 更平滑的消失 */
.slide-out-top {
    animation: slideOutTopSmooth 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.slide-out-bottom {
    animation: slideOutBottomSmooth 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.slide-out-left {
    animation: slideOutLeftSmooth 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.slide-out-right {
    animation: slideOutRightSmooth 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes slideOutTopSmooth {
    0% {
        transform: translateY(0);
        opacity: 1;
        filter: blur(0);
    }
    50% {
        opacity: 0.5;
        filter: blur(1px);
    }
    100% {
        transform: translateY(-100vh);
        opacity: 0;
        filter: blur(3px);
    }
}

@keyframes slideOutBottomSmooth {
    0% {
        transform: translateY(0);
        opacity: 1;
        filter: blur(0);
    }
    50% {
        opacity: 0.5;
        filter: blur(1px);
    }
    100% {
        transform: translateY(100vh);
        opacity: 0;
        filter: blur(3px);
    }
}

@keyframes slideOutLeftSmooth {
    0% {
        transform: translateX(0);
        opacity: 1;
        filter: blur(0);
    }
    50% {
        opacity: 0.5;
        filter: blur(1px);
    }
    100% {
        transform: translateX(-100vw);
        opacity: 0;
        filter: blur(3px);
    }
}

@keyframes slideOutRightSmooth {
    0% {
        transform: translateX(0);
        opacity: 1;
        filter: blur(0);
    }
    50% {
        opacity: 0.5;
        filter: blur(1px);
    }
    100% {
        transform: translateX(100vw);
        opacity: 0;
        filter: blur(3px);
    }
}

/* 弹性效果 */
@keyframes elasticScale {
    0% { transform: scale(1); }
    20% { transform: scale(1.05); }
    40% { transform: scale(0.95); }
    60% { transform: scale(1.02); }
    80% { transform: scale(0.98); }
    100% { transform: scale(1); }
}

/* 加载动画补充 */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .game-detail-page {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .mobile-cover-center {
        max-width: 280px;
        margin: 0 auto;
    }
    
    .mobile-button {
        min-height: 48px;
        font-size: 16px;
    }
    
    .mobile-text {
        font-size: 14px;
        line-height: 1.6;
    }
    
    .mobile-spacing {
        gap: 12px;
    }
    
    .mobile-padding {
        padding: 16px;
    }
}

/* 防止双击缩放 */
* {
    touch-action: manipulation;
}

/* 滚动优化 */
.smooth-scroll {
    scroll-behavior: smooth;
    scrollbar-width: none;
}

.smooth-scroll::-webkit-scrollbar {
    display: none;
}