/* gallery-lightbox.css */
/* ギャラリーライトボックス用CSS */

.purimall-gallery-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-in-out;
    /* 複数枚スワイプ時にブラウザの横スクロール・戻るジェスチャに取られにくくする */
    touch-action: pan-y pinch-zoom;
}

.purimall-gallery-lightbox-modal {
    position: relative;
    /* 画像が画面いっぱいになりすぎないように上限を調整 */
    max-width: min(90vw, 900px);
    max-height: 90vh;
    text-align: center;
    animation: zoomIn 0.3s ease-in-out;
}

.purimall-gallery-lightbox-image {
    /* モーダル内での画像サイズを適切に収める */
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.purimall-gallery-lightbox-stage {
    max-width: 100%;
    max-height: 90vh;
}

.purimall-gallery-lightbox-video {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background: #000;
}

.purimall-gallery-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 34px;
    font-weight: 400;
    line-height: 1;
    text-indent: 0;
    letter-spacing: normal;
    text-decoration: none;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    z-index: 100000;
}

.purimall-gallery-lightbox-prev {
    left: 12px;
}

.purimall-gallery-lightbox-next {
    right: 12px;
}

/*
 * ボタン円自体は .purimall-gallery-lightbox-nav の
 * position:absolute + top:50% + transform:translateY(-50%) で上下中央に配置済み。
 * ここではその配置に触れず、記号（‹ ›）のグリフだけを視覚的に上下中央へ補正する。
 * ‹ › は左右反転しただけの同一グリフのため、補正量は左右で共通でよい。
 * このセレクタは .purimall-gallery-lightbox-nav 配下限定で、
 * 他のボタン/スライダーには影響しない。
 */
.purimall-gallery-lightbox-nav-glyph {
    display: inline-block;
    /* 継承フォント（和文フォントスタック等）によるグリフの上下ズレを避けるため、
       ラテン文字の記号として一般的な字形を持つフォントを明示指定する */
    font-family:
        Arial,
        Helvetica,
        "Segoe UI",
        -apple-system,
        BlinkMacSystemFont,
        sans-serif;
    line-height: 1;
    /* フォントのグリフ位置による見た目の浮き上がりを補正（円の視覚的中心に合わせる） */
    transform: translateY(-7%);
}

.purimall-gallery-lightbox-close {
    position: absolute;
    /* top: -40px; */
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    z-index: 100000;
}

.purimall-gallery-lightbox-modal,
.purimall-gallery-lightbox-image {
    -webkit-user-select: none;
    user-select: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/*
 * 公開ギャラリーの列レイアウト。
 * purimall_render_gallery_with_videos()（inc/posts/media-uploader.php、動画混在ギャラリー時に
 * WordPress標準の [gallery] ショートコード出力を置き換える）は、
 * <div class="gallery gallery-columns-N"><dl class="gallery-item">...</dl></div> という
 * 標準ギャラリーと同じclass構造のHTMLを出力するが、WordPress Core標準ギャラリー
 * （gallery_shortcode()）が自動的にページへ埋め込む列幅指定インラインstyleを再現していない。
 * dl.gallery-itemはブロック要素のため、幅指定が無ければ常に100%幅＝1列表示になる。
 * ここでCSS Gridを使い、gallery-columns-Nクラスから列数を復元する（個別gallery IDへの
 * 動的style生成はしない）。画像のみのギャラリー（Core標準gallery_shortode()にフォールバック
 * する場合）にもこのclass構造は共通なので、同じCSSがそのまま適用される。
 */
.talent-post-content .gallery {
    display: grid;
    gap: 8px;
    margin: 0 0 1em;
}

.talent-post-content .gallery-columns-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}
.talent-post-content .gallery-columns-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.talent-post-content .gallery-columns-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.talent-post-content .gallery-columns-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.talent-post-content .gallery-columns-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}
.talent-post-content .gallery-columns-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}
.talent-post-content .gallery-columns-7 {
    grid-template-columns: repeat(7, minmax(0, 1fr));
}
.talent-post-content .gallery-columns-8 {
    grid-template-columns: repeat(8, minmax(0, 1fr));
}
.talent-post-content .gallery-columns-9 {
    grid-template-columns: repeat(9, minmax(0, 1fr));
}

.talent-post-content .gallery .gallery-item {
    width: auto;
    max-width: none;
    margin: 0;
    /* dl > dt/dd のUA既定marginを打ち消す（既定のdd左インデントがグリッド内で見切れの原因になるため） */
}

.talent-post-content .gallery .gallery-item dt,
.talent-post-content .gallery .gallery-item dd {
    margin: 0;
}

.talent-post-content .gallery .gallery-item img,
.talent-post-content .gallery .gallery-item video {
    max-width: 100%;
    height: auto;
}

.talent-post-content .gallery .gallery-item .post-video {
    /* assets/css/post-video-download.css の本文用余白（margin: 10px 0）はギャラリー内では不要 */
    margin: 0;
}

/*
 * ギャラリー内動画は元のアスペクト比のまま、セル幅いっぱいに表示する
 * （object-fit:cover等によるクロップはしない。video要素・ソースファイルにも一切触れない）。
 * 画像アイテム（.gallery-item img）は対象外で、既存の挙動をそのまま維持する。
 */
.talent-post-content .gallery .gallery-item-video video {
    display: block;
    width: 100%;
    height: auto;
}

/*
 * モバイルではギャラリーの基本列数を3列に統一する。
 * gallery-columns-1〜9 のどの指定であっても（画像のみ／動画混在いずれの経路でも）
 * このメディアクエリ内では画像アイテムを一律3列にする。個別の `.gallery-columns-N`
 * セレクタ一覧では元の列数指定との組み合わせやページ側の想定外CSSに左右されうるため、
 * `.gallery` 自体を対象にした単一ルール＋`!important` で確実に3列を強制する。
 * desktop/tablet側（このメディアクエリの外）の `.gallery-columns-N` は変更しない。
 *
 * 動画は従来どおり .gallery-item-video で全トラックをspanさせるため、
 * 画像の列数を3列へ増やしても1行全幅表示と元アスペクト比を維持する。
 */
@media (max-width: 768px) {
    .talent-post-content .gallery {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    /*
     * 動画は横長など縦横比が様々で、画像用の3列グリッドに押し込むと窮屈・不揃いになる。
     * 動画セルだけは常にグリッドの全トラックをspanさせ、1行全幅（1列相当）で表示する。
     * grid-column: 1 / -1 は列数によらず機能するため、gallery-columns-N の値には依存しない。
     * 画像アイテムの列配置（上の3列ルール）には触れない。
     */
    .talent-post-content .gallery .gallery-item-video {
        grid-column: 1 / -1 !important;
    }
}

/* モバイル対応 */
@media (max-width: 768px) {
    .purimall-gallery-lightbox-modal {
        /* スマホでは少し広めだが、フルスクリーンになりすぎない程度に調整 */
        max-width: 96% !important;
        max-height: 90vh !important;
    }

    .purimall-gallery-lightbox-close {
        /* top: -35px !important; */
        font-size: 25px !important;
    }

    .purimall-gallery-lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 26px;
    }
}
