/* 1. 全体のレイアウト：ナビ2段分(約125px)コンテンツを下げる */



/* ギャラリービューの基本 */
#gallery-view {
    display: none;
    width: 100%;
    margin-top: 3vh;
    background: transparent;
    min-height: 100vh;
    position: relative;
    z-index: 10;
}

/* 2. ナビゲーションの透明化（背景は後のプレートに任せる） */


/* navbarの設定は home-layout.css に統合しました */

/* 3. プラットフォームバーをメインナビ（マイリスト等）のすぐ隣に配置 */
.vod-platform-nav {
    display: none !important; /* デフォルトは非表示 */
    align-items: center;
    gap: 0; /* ボタン間の隙間を削除 */
    
    margin-left: -20px; /* 余白をさらに詰め、ライブラリ等と統一感を出す */
    width: auto;
    white-space: nowrap;
    
    pointer-events: auto;
    background: transparent;
    z-index: 1001;
}

/* 仕切り線のデザイン */
.nav-separator {
    color: rgba(255, 255, 255, 0.3);
    font-size: 1.1rem;
    margin-right: 5px; /* gapを0にしたので、重なりを防ぐためにプラスのマージンに修正 */
    font-weight: 300;
    user-select: none;
    pointer-events: none;
}

/* ギャラリービュー（VOD）の時だけ表示する制御 */
body.show-platform-nav .vod-platform-nav {
    display: flex !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;
    font-family: inherit !important; /* ボタン特有のフォントを上書き */
    padding: 6px 14px !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;
    /* 選択中はクリック反応を消す */
}

/* プラットフォームロゴ（PNG画像 @2x Retina対応） */
.platform-tab-logo {
    height: 28px;
    width: auto;
    display: block;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.platform-tab[data-id="local"] {
    padding: 12px 14px !important;
}

.platform-tab:hover .platform-tab-logo {
    opacity: 1;
}

.platform-tab.active .platform-tab-logo {
    opacity: 1;
}


/* 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;

    position: relative;
    isolation: isolate;
    z-index: 1;
}

@media (min-aspect-ratio: 2/1) {
    .vod-grid {
        /* ウルトラワイド時は変数(10)に従う */
        grid-template-columns: repeat(var(--display-cards, 10), minmax(0, 1fr)) !important;
    }
}

/* （おまけ）ノート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以上） */
@media (min-width: 1921px) and (min-aspect-ratio: 2/1) {
    /* サムネイルモード用 */
    .vod-grid, #genre-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    }
    
    /* ポスターモード用 */
    body.poster-mode .vod-grid,
    body.poster-mode #genre-grid {
        grid-template-columns: repeat(10, 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枚ガラス合体版のCSSは削除され、メインナビの背景に統合されました）
   ========================================= */

.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;
}