/*!-----------------[性能优化样式]--------------*/

/* 关键渲染路径优化 */
.critical-above-fold {
    /* 首屏关键内容优先级最高 */
    will-change: transform;
    contain: layout style paint;
}

/* 图片懒加载样式 */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s;
}

.lazy-image.loaded {
    opacity: 1;
}

.lazy-image.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* 视频优化 */
.video-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
    background: #000;
    border-radius: 8px;
}

.video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.3s;
}

.video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.video-play-button:hover {
    background: rgba(255, 255, 255, 1);
    transform: translate(-50%, -50%) scale(1.1);
}

.video-play-button::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 20px solid #333;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    margin-left: 4px;
}

/* 性能优化辅助类 */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.will-change-transform {
    will-change: transform;
}

.will-change-scroll {
    will-change: scroll-position;
}

/* 减少重排重绘 */
.no-reflow {
    contain: layout;
}

.no-repaint {
    contain: paint;
}

/* 预加载资源提示 */
.preload-hint::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    pointer-events: none;
}

/* 骨架屏样式 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: 4px;
}

.skeleton-text:last-child {
    width: 80%;
    margin-bottom: 0;
}

.skeleton-image {
    width: 100%;
    height: 200px;
    border-radius: 8px;
}

/* 响应式图片优化 */
.responsive-image {
    max-width: 100%;
    height: auto;
    display: block;
}

/* WebP支持检测 */
.webp .image-webp {
    background-image: url('image.webp');
}

.no-webp .image-webp {
    background-image: url('image.jpg');
}

/* 字体加载优化 */
@font-face {
    font-family: 'OptimizedFont';
    src: url('../fonts/font.woff2') format('woff2'),
         url('../fonts/font.woff') format('woff');
    font-display: swap; /* 字体交换策略 */
}

/* 打印样式优化 */
@media print {
    .no-print {
        display: none !important;
    }
    
    .video-container,
    .lazy-image.loading {
        display: none !important;
    }
    
    .print-optimize {
        break-inside: avoid;
        orphans: 3;
        widows: 3;
    }
}

/* 减少动画消耗 */
@media (prefers-reduced-motion: reduce) {
    .lazy-image,
    .video-play-button,
    .skeleton {
        animation: none !important;
        transition: none !important;
    }
}