/* Playleria Mobile Optimizations CSS */

/* Desktop/Large Screen Optimizations */
@media (min-width: 1024px) {
    /* Compact Hero Section for Desktop */
    .hero-section-compact {
        padding: 3rem 0 !important;
    }
    
    .hero-title {
        font-size: 3.5rem !important;
        margin-bottom: 1rem !important;
    }
    
    .hero-subtitle {
        font-size: 1.125rem !important;
        margin-bottom: 1.5rem !important;
        max-width: 42rem !important;
    }
    
    /* Compact Search Box */
    .search-container-compact {
        max-width: 36rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .search-input-compact {
        padding: 0.75rem 1.5rem !important;
        font-size: 1rem !important;
    }
    
    .search-button-compact {
        padding: 0.75rem 2rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Compact category grid */
    .category-grid-compact {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1.5rem !important;
    }
    
    /* Reduce section padding */
    .section-compact {
        padding: 3rem 0 !important;
    }
}

/* Base Mobile Styles */
@media (max-width: 768px) {
    /* Typography Optimizations */
    .hero-title {
        font-size: 2.5rem !important;
        line-height: 1.1;
        margin-bottom: 1.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem !important;
        line-height: 1.4;
        margin-bottom: 2rem;
    }
    
    .section-title {
        font-size: 1.75rem !important;
        margin-bottom: 1rem;
    }
    
    .section-subtitle {
        font-size: 0.95rem !important;
        line-height: 1.4;
    }
    
    /* Form Input Optimizations */
    .search-input {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 1rem !important;
    }
    
    .search-button {
        padding: 1rem 1.5rem !important;
        font-size: 0.9rem;
    }
    
    /* Game Cards Mobile Optimization */
    .game-card {
        margin-bottom: 1.5rem;
    }
    
    .game-card-image {
        height: 180px !important;
    }
    
    .game-card-content {
        padding: 1rem !important;
    }
    
    .game-card-title {
        font-size: 1.1rem !important;
        margin-bottom: 0.5rem;
    }
    
    .game-card-description {
        font-size: 0.85rem !important;
        line-height: 1.4;
        margin-bottom: 0.75rem;
    }
    
    /* Category Cards Mobile */
    .category-card {
        padding: 1.25rem !important;
        margin-bottom: 1rem;
    }
    
    .category-icon {
        width: 3rem !important;
        height: 3rem !important;
        margin-bottom: 1rem;
        font-size: 1.5rem !important;
    }
    
    .category-title {
        font-size: 1.1rem !important;
        margin-bottom: 0.75rem;
    }
    
    .category-description {
        font-size: 0.9rem !important;
        line-height: 1.4;
        margin-bottom: 1rem;
    }
    
    /* Navigation Mobile */
    .mobile-nav-item {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        border-bottom: 1px solid #E5E7EB;
    }
    
    .mobile-nav-item:last-child {
        border-bottom: none;
    }
    
    /* Game Container Mobile */
    .game-container {
        padding: 1rem !important;
        margin: 0 0.5rem;
        border-radius: 15px;
    }
    
    .game-iframe {
        height: 300px !important;
        border-radius: 10px;
    }
    
    /* Game Controls Mobile */
    .game-controls-mobile {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
        max-width: 200px;
        margin: 1rem auto;
    }
    
    .control-btn {
        width: 50px !important;
        height: 50px !important;
        font-size: 1rem;
        border-radius: 8px;
    }
    
    /* Touch-friendly buttons */
    .touch-button {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        touch-action: manipulation;
    }
    
    .btn-small-mobile {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        min-height: 38px;
    }
    
    /* Statistics Mobile */
    .game-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem;
        text-align: center;
    }
    
    .stats-number {
        font-size: 2rem !important;
    }
    
    .stats-label {
        font-size: 0.9rem;
    }
    
    /* Footer Mobile */
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem;
        text-align: center;
    }
    
    .footer-column {
        margin-bottom: 1.5rem;
    }
    
    .footer-links {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
    }
    
    /* Breadcrumb Mobile */
    .breadcrumb-mobile {
        font-size: 0.8rem;
        padding: 0.75rem 1rem;
    }
    
    .breadcrumb-mobile .breadcrumb-item {
        margin-right: 0.5rem;
    }
    
    /* Search Mobile */
    .search-suggestions-mobile {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border-radius: 0 0 1rem 1rem;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        z-index: 50;
    }
    
    /* Game Filter Mobile */
    .filter-buttons-mobile {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1rem;
        justify-content: center;
    }
    
    .filter-button-mobile {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
        border-radius: 20px;
        white-space: nowrap;
    }
}

/* Extra Small Mobile Screens */
@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
    }
    
    .container-padding {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .category-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .games-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .search-flex {
        flex-direction: column !important;
        gap: 0.5rem;
    }
    
    .search-input {
        border-radius: 0.75rem !important;
    }
    
    .search-button {
        border-radius: 0.75rem !important;
        width: 100%;
    }
    
    .game-iframe {
        height: 250px !important;
    }
    
    .control-btn {
        width: 45px !important;
        height: 45px !important;
        font-size: 0.9rem;
    }
    
    .mobile-nav-item {
        padding: 1rem;
        font-size: 1.1rem;
    }
    
    .section-padding-small {
        padding: 2rem 1rem;
    }
    
    .game-card-grid-single {
        grid-template-columns: 1fr !important;
    }
}

/* Landscape Mobile Optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .game-iframe {
        height: 350px !important;
    }
    
    .hero-section-landscape {
        padding: 2rem 0;
    }
    
    .mobile-landscape-compact {
        padding: 1rem 0;
    }
}

/* Touch and Animation Improvements */
* {
    -webkit-tap-highlight-color: transparent;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 图片优化 */
img {
    max-width: 100%;
    height: auto;
}

.game-image {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* 移动端触摸优化 */
.game-card {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    cursor: pointer;
}

.game-card:active {
    transform: scale(0.98);
}

/* 响应式网格 */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    #games-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    #featured-games {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    .category-tag {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    /* 简化卡片设计 */
    .game-card .p-3 {
        padding: 0.5rem;
    }
    
    .game-card h3 {
        font-size: 0.75rem;
        line-height: 1.2;
    }
}

@media (max-width: 480px) {
    /* 超小屏幕优化 */
    .text-5xl {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }
    
    .text-xl {
        font-size: 1rem !important;
    }
    
    .py-16 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    /* 搜索框优化 */
    #main-search {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 0.75rem 1rem;
    }
    
    /* 按钮优化 */
    button, .btn-primary {
        min-height: 44px; /* iOS推荐触摸目标大小 */
        min-width: 44px;
    }
}

/* 减少动画以提升性能 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .bg-gray-50 {
        background-color: #1f2937;
    }
    
    .text-gray-900 {
        color: #f9fafb;
    }
    
    .text-gray-600 {
        color: #d1d5db;
    }
}

/* 加载状态 */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* 文本截断工具类 */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 无障碍优化 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 焦点状态 */
button:focus,
input:focus,
select:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* PWA 支持 */
@supports (display: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* iOS specific optimizations */
@supports (-webkit-touch-callout: none) {
    .ios-safe-input {
        font-size: 16px !important; /* Prevents zoom */
    }
    
    .ios-smooth-scroll {
        -webkit-overflow-scrolling: touch;
    }
}

/* Android specific optimizations */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .android-input-fix {
        background-color: transparent;
    }
}

/* High DPI screens optimization */
@media (-webkit-min-device-pixel-ratio: 2) {
    .high-dpi-text {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Mobile Menu Improvements */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-slide {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.mobile-menu-slide.active {
    transform: translateX(0);
}

/* Performance optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

.reduce-motion {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Game Thumbnail Styles */
.game-thumbnail {
    transition: transform 0.3s ease, filter 0.3s ease;
    object-fit: cover;
}

.game-thumbnail:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* Game card hover effects */
.bg-white:hover .game-thumbnail {
    transform: scale(1.03);
}

/* Lazy loading optimization */
.game-thumbnail[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-thumbnail[loading="lazy"].loaded {
    opacity: 1;
}

/* Mobile optimizations for thumbnails */
@media (max-width: 768px) {
    .game-thumbnail:hover {
        transform: none; /* Disable hover effects on mobile */
        filter: none;
    }
    
    .bg-white:hover .game-thumbnail {
        transform: none;
    }
} 