/* 性能优化样式文件 */

/* 错误提示动画 */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 图片懒加载优化 */
.vehicle-image {
    transition: opacity 0.3s ease;
}

.vehicle-image[loading="lazy"] {
    opacity: 0.7;
}

.vehicle-image[loading="lazy"]:not([src=""]) {
    opacity: 1;
}

/* 加载状态优化 */
.loading-overlay {
    position: relative;
}

.loading-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* 性能优化：减少重绘 */
.vehicle-card {
    will-change: transform;
}

.vehicle-card:hover {
    transform: translateY(-2px);
    transition: transform 0.2s ease;
}

/* 字体优化 - 添加fallback策略 */
@font-face {
    font-family: 'SystemFont';
    font-style: normal;
    font-weight: 400;
    font-display: swap; /* 字体交换策略 - 立即显示fallback，然后交换 */
    src: local('-apple-system'), local('BlinkMacSystemFont'), local('Segoe UI'), local('PingFang SC'), local('Hiragino Sans GB'), local('Microsoft YaHei');
}

@font-face {
    font-family: 'SystemFont';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: local('-apple-system'), local('BlinkMacSystemFont'), local('Segoe UI'), local('PingFang SC'), local('Hiragino Sans GB'), local('Microsoft YaHei');
}

body {
    font-family: 'SystemFont', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-display: swap;
    font-synthesis: none; /* 禁用字体合成 */
    text-rendering: optimizeSpeed; /* 优化渲染速度 */
}

/* 字体加载优化 */
.font-loading {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.font-loaded {
    font-family: 'SystemFont', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

/* 关键文本的字体优化 */
.vehicle-title, .brand-name, .hero-title {
    font-display: swap;
    font-synthesis: none;
}

/* 关键CSS - 首屏渲染优化 */
.hero-section {
    contain: layout style paint; /* CSS Containment */
}

.banner-slide {
    contain: layout style paint;
}

.vehicle-card {
    contain: layout style;
}

/* 图片优化 */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* 减少重排重绘 */
.vehicle-grid {
    contain: layout;
}

.brand-items {
    contain: layout;
}

/* 预加载关键资源 */
.preload-critical {
    font-display: swap;
}

/* 优化滚动性能 */
.vehicle-grid {
    transform: translateZ(0); /* 启用硬件加速 */
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
}

/* 减少动画对性能的影响 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高DPI屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .vehicle-image {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* 打印样式优化 */
@media print {
    .vehicle-card {
        break-inside: avoid;
    }
    
    .banner-section {
        display: none;
    }
}
