/* ========== V8.0 2G2核服务器性能优化层 ==========
 * 目标：在低配服务器(2G RAM/2核CPU)上保持流畅体验
 * 策略：减少重绘/回流、GPU加速降级、动画精简、懒加载增强
 * ============================================================ */

/* ====== 1. GPU加速降级（低配设备避免GPU过载；断点：--breakpoint-sm）====== */
@media (max-width: 480px) {
    /* 减少backdrop-filter使用 — GPU密集型 */
    .glassmorphic, .glass-card,
    [style*="backdrop-filter"], [class*="glass"] {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(var(--bg-card-rgb), 0.95) !important;
    }
}

/* ====== 2. 动画精简（仅保留transform+opacity，最高性能）====== */
/* 禁用高开销动画 */
@media (prefers-reduced-motion: reduce), (max-width: 480px) {
    /* splash动画简化 */
    #splashScreen {
        animation: none !important;
        transition: opacity 0.15s ease-out !important;
    }
    .splash-glow { animation: none !important; }
    .splash-arrow-bounce { animation: none !important; }

    /* 卡片光泽动画禁用 */
    .asset-card::after { animation: none !important; }

    /* 官方通知光晕简化 */
    .official-notice { animation: none !important; }
    .official-glow { animation: none !important; }
    .official-pulse { animation: none !important; }
    .badge-pulse { animation: none !important; }

    /* 轮播星星动画简化 */
    .carousel-star { animation: none !important; opacity: 0.6; }

    /* 所有过渡统一为快速 */
    * {
        transition-duration: 0.1s !important;
        animation-duration: 0s !important;
    }
}

/* ====== 3. 图片懒加载占位（减少布局抖动）====== */
img[loading="lazy"] {
    background: linear-gradient(135deg, var(--hex-f0f0f0) 25%, var(--hex-e0e0e0) 50%, var(--hex-f0f0f0) 75%);
    background-size: 400% 100%;
    min-height: 80px;
}
img[loading="lazy"]:not([src]) {
    visibility: hidden;
}

/* ====== 4. 滚动容器优化（启用硬件合成）====== */
.page-content, main, .container {
    contain: layout style paint;
}
.bottom-nav, .tab-bar {
    contain: layout style;
    will-change: transform;
    transform: translateZ(0);
}

/* ====== 5. 字体渲染优化（中文字体抗锯齿）====== */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ====== 6. 阴影轻量化（减少模糊半径）====== */
@media (max-width: 480px) {
    .card, .order-section, .func-list-item, .asset-card {
        box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
    }
    .modal, .popup, .dialog {
        box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
    }
}

/* ====== 7. 首屏关键路径优化 ===== */
/* 确保首屏内容优先渲染 */
.home-top-header, .my-header, .page-content > :first-child {
    content-visibility: auto;
    contain-intrinsic-size: auto 200px;
}

/* ====== 8. 点击反馈优化（替代复杂hover效果）====== */
@media (hover: none) and (pointer: coarse) {
    .nav-item:active, .order-tab:active, .func-list-item:active,
    .asset-card:active, .menu-item:active {
        background: rgba(0, 0, 0, 0.04);
        transform: scale(0.97);
        transition: transform 0.08s ease;
    }
}

/* ====== 9. 内存保护（限制大渐变背景）====== */
@media (max-width: 480px) {
    body {
        background: var(--bg-page);
    }
    /* 复杂渐变替换为纯色（统一使用 variables.css Token） */
    .my-header {
        background: var(--color-primary) !important;
    }
    .home-top-header {
        background: var(--color-primary-dark) !important;
    }
}
