/* 
 * 画像最適化用スタイル
 * ファイル: wwwroot/css/image-optimization.css
 * 目的: パフォーマンス向上と表示品質改善
 */

/* ===== 画像の基本最適化 ===== */
.img-fluid {
    height: auto;
    max-width: 100%;
    object-fit: cover;
}

/* レスポンシブ画像対応 */
picture {
    display: block;
    width: 100%;
}

picture img {
    width: 100%;
    height: auto;
    display: block;
}

/* ===== 遅延読み込み対応 ===== */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded,
img[loading="lazy"]:not([loading]) {
    opacity: 1;
}

/* ===== プレースホルダー効果 ===== */
.image-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(#f0f0f0 50%, transparent 50%);
    background-size: 20px 20px;
    animation: placeholder-shimmer 1.5s infinite;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.9rem;
}

@keyframes placeholder-shimmer {
    0% { background-position: 0 0, 0 0; }
    100% { background-position: 20px 20px, 20px 20px; }
}

/* ===== ブラウザ最適化 ===== */
/* WebP対応ブラウザでの最適化 */
@supports (background-image: url('data:image/webp;base64,')) {
    .webp-supported picture source[type="image/webp"] {
        display: block;
    }
}

/* ===== アクセシビリティ改善 ===== */
/* 動きの削減設定時 */
@media (prefers-reduced-motion: reduce) {
    img[loading="lazy"] {
        transition: none;
    }
    
    .image-placeholder {
        animation: none;
        background: #f0f0f0;
    }
}

/* ===== 印刷時の最適化 ===== */
@media print {
    picture {
        break-inside: avoid;
    }
    
    img {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ===== 記事内画像の調整 ===== */
.post-content img,
.post-content picture {
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.post-content figure {
    margin: 2rem 0;
    text-align: center;
}

.post-content figcaption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #6c757d;
    font-style: italic;
}
