﻿@charset "UTF-8";
/* エリア確保 */
.insta-widget-container {
  position: relative; /* スピナーを中央に絶対配置するため */
  overflow:hidden;
  width:100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

/* 読み込み後は行数と隙間に合わせて高さを決める（旧HTMLにも対応）。 */
.insta-widget-container:has(> .insta-grid),
.insta-widget-container:has(> .insta-error),
.insta-widget-container:has(> .insta-empty) {
    aspect-ratio: auto;
}

/* ===================================================
   🌀 初回読み込み中のスピナー（SpinKit風）
   =================================================== */
.insta-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px; /* 中央配置 */
    background-color: #333;
    border-radius: 100%;
    animation: insta-spinner-scaleout 1.0s infinite ease-in-out;
}

@keyframes insta-spinner-scaleout {
    0% {
        transform: scale(0);
    }
    100% {
        transform: scale(1.0);
        opacity: 0;
    }
}

/* 画像1枚ごとの読み込み中スピナー（少し小さめ、img読み込み完了で消える） */
.insta-item-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    background-color: #999;
    border-radius: 100%;
    z-index: 1; /* imgより手前、キャプション(z-index:4)より奥 */
    animation: insta-spinner-scaleout 1.0s infinite ease-in-out;
}

/* インスタウィジェット全体のグリッド配置 */
.insta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)); /* 3列 */
/* gap: clamp(12px, 4.68px + 1.7vw, 20px); 標準 */
    gap: 4.5px; /* 画像同士のすき間 */
}

/* 各投稿アイテムの箱 */
.insta-item {
    display: block;
    aspect-ratio: 1 / 1; /* 必ず正方形を維持 */
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background-color: #f0f0f0;
}

/* 縮小画像 */
.insta-figure {
    margin: 0;
    height: 100%;
}

.insta-item picture,
.insta-item img {
    display: block;
}

.insta-item picture {
    height: 100%;
}

.insta-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, filter 0.3s ease;
    color: transparent;
}

/* 更新アニメーション */
.insta-widget-container {
    transition: opacity 0.3s ease;
}
.insta-widget-container.insta-fade-out {
    opacity: 0;
}

/* ===================================================
   🎥 動画（VIDEO）の場合の再生マーク（Base64完全互換版）
   =================================================== */
.insta-item.is-video::after {
    content: "";
    position: absolute;
    top: 5%;
    right: 5%;
    width: 11%;
    height: 11%;
    min-width: 16px;  /* 画面が小さくても視認できる最低サイズ */
    min-height: 16px;
    max-width: 25px;  /* 画面が大きくなりすぎても肥大化しない上限 */
    max-height: 25px;
    z-index: 2;
    transition: opacity 0.2s ease;
    
    /* Base64コードに変換 */
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0iI2ZmZmZmZiI+PHBhdGggZD0iTTEyIDJDNi40OCAyIDIgNi40OCAyIDEyczQuNDggMTAgMTAgMTAgMTAtNC40OCAxMC0xMFMxNy41MiAyIDEyIDJ6bS0yIDE0LjV2LTlsNiA0LjUtNiA0LjV6Ii8+PC9zdmc+");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    
    /* 白い写真の上でもクッキリ見せるためのドロップシャドウ */
    filter: drop-shadow(0px 1px 3px rgba(0, 0, 0, 0.4));
}


/* ===================================================
   💬 キャプションのマスク層（スマホ・PC共通の基本設定）
   =================================================== */
.insta-caption {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    color: #ffffff;
    padding: 23px;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    
    /* 視覚的に隠しても、読み上げには本文を残す。 */
    display: flex;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 4;
}

/* 📝 テキスト自体のスタイル */
.caption-text {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.9;
    letter-spacing: 0.03em;
    word-break: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}


/* ===================================================
   💻 PC（マウスホバーができる端末）だけの限定演出
   =================================================== */
@media (hover: hover) and (pointer: fine) {
    /* マウスが乗ったらふわっと出す */
    .insta-item:hover .insta-caption {
        opacity: 1;
    }
    
    /* マウスが乗ったら画像を少し大きくする */
    .insta-item:hover img {
        transform: scale(1.03);
        filter: blur(0.5px) saturate(60%);
    }
    
    /* マウスが乗ったら動画マークを薄くする */
    .insta-item:hover.is-video::after {
        opacity: 0.66;
    }
    /* 干渉対策 */
    .insta-item:hover {
        opacity: unset;
    }

}

/* キーボード対応はポインターの種類に依存させない。 */
.insta-item:focus-visible .insta-caption {
    opacity: 1;
}

.insta-item:focus-visible {
    outline: 3px solid #fff;
    outline-offset: -3px;
    opacity: 1;
}

.insta-item:focus-visible::before {
    content: "";
    position: absolute;
    inset: 0;
    border: 3px solid #fff;
    box-shadow: inset 0 0 0 3px #111;
    z-index: 5;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .insta-spinner,
    .insta-item-spinner {
        animation: none;
    }

    .insta-widget-container,
    .insta-item img,
    .insta-caption,
    .insta-item.is-video::after {
        transition: none;
    }

    .insta-item:hover img {
        transform: none;
    }
}

/* エラー・空文字のスタイル */
.insta-error, .insta-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 0;
    color: #888888;
    font-size: 14px;
}
