/* ===========================
   Video Loading Optimization
   動画読み込み最適化スタイル
   =========================== */

/* 1. 動画コンテナの最適化 */
.hero-video-container,
#instantLoadingScreen video {
    /* GPUアクセラレーションを有効化 */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    perspective: 1000;
    -webkit-perspective: 1000;
    
    /* レンダリング最適化 */
    will-change: transform;
    contain: layout style paint;
}

/* 2. 動画要素の最適化 */
video {
    /* ハードウェアアクセラレーション */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    
    /* スムーズな再生 */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    
    /* メモリ使用量の最適化 */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* 3. プレースホルダーアニメーション */
.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        #1a1a2e 0%,
        #16213e 50%,
        #0f3460 100%
    );
    animation: placeholderShimmer 2s ease-in-out infinite;
    z-index: -1;
}

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

/* 4. 動画読み込み中のスケルトンスクリーン */
.video-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(
            90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0) 100%
        );
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s ease-in-out infinite;
}

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

/* 5. 低品質プレビュー画像 */
.video-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(20px);
    transform: scale(1.1);
    transition: opacity 0.3s ease-out;
}

.video-loaded .video-preview {
    opacity: 0;
}

/* 6. パフォーマンス最適化クラス */
.optimize-video {
    /* コンポジットレイヤーの作成 */
    opacity: 0.99;
    
    /* ペイント最適化 */
    contain: paint;
    
    /* レイアウト計算の削減 */
    contain-intrinsic-size: 1920px 1080px;
}

/* 7. モバイル最適化 */
@media (max-width: 768px) {
    video {
        /* モバイルでの再生最適化 */
        -webkit-playsinline: true;
        playsinline: true;
        
        /* タッチ遅延の削除 */
        touch-action: manipulation;
    }
    
    /* 低解像度デバイス向け */
    @media (max-resolution: 1dppx) {
        video {
            image-rendering: pixelated;
        }
    }
}

/* 8. ネットワーク状態インジケーター */
.network-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    display: none;
    z-index: 9999;
}

.network-indicator.slow {
    display: block;
    background: rgba(255, 152, 0, 0.9);
}

.network-indicator.offline {
    display: block;
    background: rgba(244, 67, 54, 0.9);
}

/* 9. 動画バッファリングインジケーター */
.video-buffering {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    display: none;
}

.video-buffering::after {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: buffering 0.8s linear infinite;
}

video.buffering ~ .video-buffering {
    display: block;
}

@keyframes buffering {
    to {
        transform: rotate(360deg);
    }
}

/* 10. プリロードアニメーション */
.preload-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    transition: width 0.3s ease;
    z-index: 10;
}

/* 11. エラー時のフォールバック */
video.error {
    display: none;
}

video.error ~ .video-fallback {
    display: block;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text x="50" y="50" text-anchor="middle" dy=".3em" fill="white" font-family="sans-serif" font-size="16">動画を読み込み中...</text></svg>') center no-repeat;
    background-color: #1a1a2e;
}