/* 1. 全体のレイアウト：ナビ2段分(約125px)コンテンツを下げる */



/* ギャラリービューの基本 */
#gallery-view {
    display: none;
    width: 100%;
    margin-top: 3vh;
    background: transparent;
    min-height: 100vh;
    position: relative;
    z-index: 10;
}

/* 2. ナビゲーションの透明化（背景は後のプレートに任せる） */


/* 上段ナビの重なり順 */
body[data-vod] #navbar {
    z-index: 10000 !important;
    /* 最前面 */
}

/* 3. 下段ナビの設定と「合体すりガラスプレート」 */
.vod-platform-nav {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 10px 2.5%;
    position: fixed;
    top: 68px;
    /* メインナビのすぐ下 */
    left: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 10050 !important;
    /* 文字をプレートより上にするため高い値を設定 */
}


body.search-mode #navbar,
body.search-mode .vod-platform-nav {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}


.platform-tab {
    text-decoration: none !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
    transition: color 0.2s ease, background 0.3s ease, border 0.3s ease, box-shadow 0.3s ease !important;
    border: 1px solid transparent !important;

    /* ズレ防止のレイアウト */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    padding: 11px 16px !important;
    background: transparent !important;
    cursor: pointer;
}

/* ホバー時（アクティブではない時） */
.platform-tab:hover:not(.active) {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.1) !important;
    /* うっすら白く光る */
    backdrop-filter: blur(5px) !important;
    -webkit-backdrop-filter: blur(5px) !important;
}

/* 選択中（アクティブ）のデザイン */
.platform-tab.active {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.08) !important;
    /* わずかな白 */

    /* 二重ガラスの濁りを防ぐためのリセット */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;

    /* 光の反射（白線）と内側のハイライト・立体感 */
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;

    cursor: default !important;
    /* 選択中は指マークを外す */
    pointer-events: none !important;
    /* 選択中はクリック反応を消す */
}

/* 5. 以降（ジャンル・グリッド）は変更なし */
.vod-genre-nav {
    display: flex;
    gap: 12px;
    padding: 20px 40px;
    overflow-x: auto;
    scrollbar-width: none;
}

.vod-genre-nav::-webkit-scrollbar {
    display: none;
}

.genre-tab {
    background: #222;
    color: white;
    border: 1px solid #444;
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s;
    font-size: 0.95rem;
}

.genre-tab.active {
    background: white;
    color: black;
    font-weight: bold;
}

.vod-genre-nav {
    display: flex;
    gap: 12px;
    padding: 20px var(--side-padding, 2.5%);
    /* 40pxから2.5%に変更 */
    overflow-x: auto;
    scrollbar-width: none;
}

.vod-grid {
    display: grid;
    /* ★解決策：1fr を minmax(0, 1fr) に変えることで巨大化を物理的に防ぐ */
    grid-template-columns: repeat(var(--display-cards, 6), minmax(0, 1fr));
    gap: var(--card-gap, 10px);
    row-gap: 30px !important;
    padding: 0 var(--side-padding, 2.5%);
    margin-top: 20px;
    padding-bottom: 80px;
}

@media (min-aspect-ratio: 2/1) {
    .vod-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* （おまけ）ノートPCやタブレットなど、画面が狭い場合への配慮 */
@media (max-width: 1440px) {
    .vod-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1024px) {
    .vod-grid {
        grid-template-columns: repeat(3, 1fr);
        padding: 0 20px;
    }
}

@media (max-width: 768px) {
    .vod-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

.gallery-item {
    cursor: pointer;
}

.vod-grid .gallery-item {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    /* ホーム側の transform などの競合を防ぐ */
    display: block;
}

.vod-grid .gallery-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    border-radius: 8px;
    /* 読み込み時のガタつきを防ぐ */
    display: block;
}

body.poster-mode .vod-grid .gallery-item img {
    aspect-ratio: 2 / 3 !important;
}

/* VODのサムネモード（横長） */
body:not(.poster-mode) .vod-grid .gallery-item img {
    aspect-ratio: 16 / 9 !important;
}

body.poster-mode .vod-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    row-gap: 20px !important;
}

/* 2. ウルトラワイド設定（21:9 / 2:1以上）: 1列 8作品 */
@media (min-width: 1921px) and (min-aspect-ratio: 2/1) {
    body.poster-mode .vod-grid {
        grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
    }
}

.vod-grid .gallery-item {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    /* これで中身による膨張を防ぐ */
    margin: 0 !important;
    display: block;
    cursor: pointer;
}

.vod-grid .gallery-item img {
    width: 100% !important;
    height: auto !important;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    transition: aspect-ratio 0.3s ease;
    /* 切り替えを滑らかに */
}

/* 3. 巨大化バグを物理的に抑え込み、グリッドの幅に強制的に合わせる */
body.poster-mode .vod-grid .gallery-item {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
}

/* サムネイルモード（横長）は今まで通り 6枚（または任意の設定）を維持 */
body:not(.poster-mode) .vod-grid {
    grid-template-columns: repeat(var(--display-cards, 6), 1fr) !important;
}

body:not(.poster-mode) .vod-grid .movie-card-wrapper,
body:not(.poster-mode) .vod-grid .gallery-item {
    aspect-ratio: 16 / 9 !important;
    height: auto !important;
    /* JSによる高さ固定を無効化 */
    width: 100% !important;
}

body.poster-mode .vod-grid .movie-card-wrapper,
body.poster-mode .vod-grid .gallery-item {
    aspect-ratio: 2 / 3 !important;
    height: auto !important;
    /* JSによる高さ固定を無効化 */
    width: 100% !important;
}

.vod-grid .movie-card-wrapper img.dynamic-img,
.vod-grid .gallery-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}



/* =========================================
   ナビゲーションバーのすりガラス効果（真・1枚ガラス合体版）
   ========================================= */

/* 1. バー自体の背景と影を完全に透明化（骨組みだけにする） */
body[data-vod] #navbar,
body[data-vod] .vod-platform-nav {
    background-color: transparent !important;
    background-image: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

/* 2. 下段バーの裏側に、上段まで届く「巨大な1枚のガラス」を作る */
body[data-vod] .vod-platform-nav::before {
    content: "";
    display: block !important;
    position: absolute;
    top: -68px;
    /* 上段バー（メインナビ）の高さ分上に伸ばす */
    left: 0;
    width: 100%;
    height: calc(100% + 68px);
    /* 2つのバーを完全に覆う高さ */

    /* すりガラスのデザイン（ここで1回だけ設定するから色が重ならない！） */
    background-color: rgba(20, 20, 20, 0.8) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;

    z-index: -1;
    pointer-events: none;

    /* 初期状態は透明 */
    opacity: 0;
    transition: opacity 0.3s ease !important;
}

/* 3. 50pxスクロールしたら、巨大ガラスをフワッと表示する */
body[data-vod].is-scrolled .vod-platform-nav::before {
    opacity: 1;
}

/* =========================================
   ホーム画面など、下段バーが無い時のメインバー単体の設定
   ========================================= */

/* トップ付近（透明） */
body:not([data-vod]) #navbar {
    background-color: transparent !important;
    background-image: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-bottom: none !important;
    transition: background-color 0.3s ease, backdrop-filter 0.3s ease !important;
}

/* スクロール時（すりガラス） */
body:not([data-vod]).is-scrolled #navbar {
    background-color: rgba(20, 20, 20, 0.8) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.genre-tab:focus {
    outline: none;
}

/* ジャンルバー全体のフォントを少しだけ整える */
.vod-genre-nav {
    -webkit-overflow-scrolling: touch;
    /* iOSでのスクロールをヌルヌルにする */
}

/* 並び替えコンテナのレイアウト */
.gallery-sort-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

/* 「並び替え」という文字のスタイル */
.sort-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* セレクトボックスの親要素（矢印アイコンを重ねるため） */
.modern-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* セレクトボックス本体のモダン化 */
#sort-selector {
    appearance: none;
    /* ブラウザ標準の矢印を消す */
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.05);
    /* ほのかな透明感 */
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 40px 8px 16px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    /* 背景をぼかすグラスモーフィズム */
}

/* ホバーした時 */
#sort-selector:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
}

/* フォーカスした時（クリック中） */
#sort-selector:focus {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

/* カスタム矢印アイコン */
.dropdown-icon {
    position: absolute;
    right: 12px;
    pointer-events: none;
    /* アイコンがクリックを邪魔しないようにする */
    color: white;
    font-size: 20px;
    transition: transform 0.2s ease;
}

/* セレクトボックスがフォーカスされた時、矢印を反転させる */
.modern-select-wrapper:focus-within .dropdown-icon {
    color: #000000;
    transform: rotate(180deg);
}

/* 選択肢（中身）のスタイル ※ブラウザにより限界がありますが背景を調整 */
#sort-selector option {
    background-color: #1a1a1a;
    color: white;
    padding: 10px;
}