/**
 * JPMS Crypto Exchange - Performance Optimization CSS
 * 性能优化样式 - 关键CSS、懒加载动画、资源优? * @author AI Assistant
 * @created 2026-02-20
 */

/* ========================================
   关键CSS内联（Critical CSS?   这些样式应该内联到HTML?head>?   ======================================== */

/* 防止FOUC（Flash of Unstyled Content?*/
html {
    visibility: visible;
    opacity: 1;
}

/* 字体显示优化 - 使用swap策略 */
@font-face {
    font-family: 'Inter';
    font-display: swap;
    src: local('Inter'), local('Inter-Regular');
}

/* ========================================
   图片懒加载样?   ======================================== */

/* 懒加载图片占?*/
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[data-src].loading {
    opacity: 0.5;
    background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

img[data-src].loaded {
    opacity: 1;
}

img[data-src].error {
    opacity: 1;
    filter: grayscale(100%);
}

/* 背景图片懒加?*/
[data-bg-src] {
    background-color: #1a1a1a;
    transition: background-image 0.3s ease;
}

[data-bg-src].bg-loading {
    background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

[data-bg-src].bg-loaded {
    animation: none;
}

/* 骨架屏动?*/
@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   内容可见性优化（Content Visibility?   ======================================== */

/* 对屏幕外的内容使用content-visibility */
.JPMS-features,
.JPMS-faq,
.JPMS-testimonials,
.JPMS-footer {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}

/* ========================================
   will-change优化
   ======================================== */

/* 只对即将动画的元素使用will-change */
.JPMS-navbar {
    will-change: transform, background-color;
}

.JPMS-hero-visual {
    will-change: transform;
}

/* 动画完成后移除will-change */
.animation-complete {
    will-change: auto;
}

/* ========================================
   减少重绘和重?   ======================================== */

/* 使用transform代替top/left */
.JPMS-coin-icon,
.JPMS-feature-icon,
.JPMS-stat-icon {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* 避免布局抖动 */
.JPMS-market-table {
    table-layout: fixed;
}

/* ========================================
   打印优化
   ======================================== */

@media print {
    .JPMS-navbar,
    .JPMS-mobile-nav,
    .JPMS-footer,
    .JPMS-hero-visual {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* ========================================
   减少动画（用户偏好）
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .JPMS-hero-visual {
        animation: none !important;
    }
}

/* ========================================
   资源提示样式
   ======================================== */

/* 预加载指示器 */
.resource-loading {
    position: relative;
    overflow: hidden;
}

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

@keyframes shimmer {
    100% {
        left: 100%;
    }
}

/* ========================================
   响应式图片优?   ======================================== */

/* 确保图片不会溢出容器 */
img {
    max-width: 100%;
    height: auto;
}

/* 高DPI屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .JPMS-coin-icon {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* ========================================
   字体加载优化
   ======================================== */

/* 系统字体回退?*/
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
}

/* 等宽字体 */
.JPMS-price,
.JPMS-stat-value,
.JPMS-hero-stat-value {
    font-family: 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
}

/* ========================================
   缓存提示
   ======================================== */

/* 对缓存的资源添加视觉提示（调试用?*/
[data-cached="true"] {
    /* 仅用于调试，生产环境可移?*/
}
