/* ==========================
   レイアウト構造
========================== */

/* メインコンテナ */
.container {
    max-width: 800px;
    max-height: none;
    margin: 0 auto;
    padding: 15px;
    height: auto;
    overflow-y: visible;
    box-sizing: border-box;
    position: relative;
    z-index: 10;
}

.centered-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}

/* スクロール可能なコンテナ */
.scrollable-container {
    max-height: calc(100vh - 300px); /* ヘッダー高さに合わせて調整（240pxから300pxに） */
    overflow-y: auto;
    padding: 0 10px;
    position: relative;
}

/* コンテンツコンテナ */
.content-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0; /* パディングを削除してタブコンテンツが直下から始まるようにする */
    background-color: transparent; /* 背景色を透明に変更 */
    position: relative;
    top: 0; /* タブとの重複を防ぐため0に設定 */
    margin-top: 100px; /* タブの高さ分(60px) + 余白(40px)を追加 */
    margin-bottom: 300px; /* 下部に余白を追加 */
}

/* ヘッダー */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 320px; /* 高さを調整: カウントダウン(50px) + ヘッダーコンテンツ + TradingView(60px) + 余白 */
    z-index: 1000;
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    overflow: visible;
}

.header-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
    position: relative;
    z-index: 1001;
    margin-top: 50px; /* カウントダウンタイマーの高さ分下げる */
}

.header-content h1 {
    font-size: 2rem;
    margin: 0;
}

/* タブナビゲーション */
.tab {
    position: fixed;
    top: 300px; /* 20px上に移動 (ヘッダー高さ320px - 20px) */
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 900;
    background-color: var(--secondary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* タブコンテンツ */
.tab-content {
    display: none;
    height: calc(100vh - 400px); /* タブ+ヘッダーに基づいて調整：タブ位置(300px) + タブの高さ(60px) + 余白(40px) - 20px下げる */
    overflow-y: auto;
    padding-top: 30px; /* 上部パディングを増やして余白を確保 */
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
    background-color: transparent; /* 背景色を透明に変更 */
    position: relative;
    top: 0;
    transition: all 0.3s ease;
    -webkit-overflow-scrolling: touch; /* iOS向けスムーススクロール */
    margin-bottom: 20px; /* 下部余白を調整 */
    margin-top: 0; /* タブとの重複を防ぐため上部マージンを0に設定 */
}

/* 検索結果を表示するタブは特別に設定 */
#home.tab-content {
    padding-top: 20px;
}

/* 検索結果表示時の特別なスタイル - 上方向へのずれを防止 */
body.search-results-visible .tab-content {
    padding-top: 20px;
}

.tab-content.active {
    display: block;
    position: fixed;
    top: 360px; /* div.tabの下部から表示 (300px + 60px) */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    /* ブラウザサイズに応じて800px～1200pxの可変幅 */
    max-width: clamp(800px, 90vw, 1200px);
    margin-top: 0;
}

/* グリッドレイアウト */
.results-grid, .cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
    margin-top: 20px;
    background-color: transparent;
    border: none;
    box-shadow: none;
}

.link-category {
    margin-bottom: 30px;
}

.link-category h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2rem;
    text-align: center;
}

.link-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 10px;
    max-width: 700px;
    margin: 0 auto;
}

/* 検索結果コンテナ */
.search-results-container {
    padding: 20px 0;
    background-color: transparent;
    margin-top: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 440px); /* 調整: タブ位置(300px) + タブの高さ(60px) + 余白(80px) */
    -webkit-overflow-scrolling: touch; /* iOS向けスムーススクロール */
}

/* レスポンシブレイアウト - デスクトップ版の可変幅制御 */
@media (min-width: 1200px) {
    .tab-content.active {
        /* デスクトップ版: 90vwで可変、最小800px、最大1200px */
        max-width: clamp(800px, 90vw, 1200px);
    }
}

@media (min-width: 1000px) and (max-width: 1199px) {
    .tab-content.active {
        /* 中サイズデスクトップ: 85vwで可変、最小800px、最大1200px */
        max-width: clamp(800px, 85vw, 1200px);
    }
}

@media (min-width: 900px) and (max-width: 999px) {
    .tab-content.active {
        /* 小サイズデスクトップ: 90vwで可変、最小800px、最大1200px */
        max-width: clamp(800px, 90vw, 1200px);
    }
}

@media (max-width: 768px) {
    .site-header {
        height: 240px; /* モバイル用に調整（カウントダウン+ヘッダーコンテンツ+TradingView） */
    }
    
    .tab {
        top: 240px; /* ヘッダー高さに合わせて調整 */
        height: 40px;
    }
    
    .tab-content.active {
        top: 280px; /* モバイル版: div.tabの下部から表示 (240px + 40px) */
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        /* モバイル版でも800px～1200pxの可変幅を維持 */
        max-width: clamp(800px, 95vw, 1200px);
    }
    
    .content-container {
        top: 0; /* タブとの重複を防ぐため0に設定 */
        margin-top: 70px; /* モバイル用タブの高さ(40px) + 余白(30px) */
    }
    
    .tab-content {
        height: calc(100vh - 350px); /* モバイル用に調整: タブ位置(240px) + タブの高さ(40px) + 余白(70px) - 20px下げる */
        top: 0;
        padding-top: 25px; /* モバイル用の上部パディング */
    }
    
    .search-results-container {
        margin-top: 20px;
        max-height: calc(100vh - 400px); /* モバイル用に調整: タブ位置(240px) + タブの高さ(40px) + 余白(120px) */
    }
    
    .results-grid, .cards {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
    
    .container {
        padding: 10px;
    }
    
    .centered-container {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .site-header {
        height: 230px; /* 小さい画面用に調整（カウントダウン+ヘッダーコンテンツ+TradingView） */
    }
    
    .tab {
        top: 230px; /* ヘッダー高さに合わせて調整 */
        height: 30px;
    }
    
    .tab-content.active {
        top: 260px; /* 小さい画面版: div.tabの下部から表示 (230px + 30px) */
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        /* 小画面版でも800px～1200pxの可変幅を維持 */
        max-width: clamp(800px, 95vw, 1200px);
    }
    
    .content-container {
        top: 0; /* タブとの重複を防ぐため0に設定 */
        margin-top: 60px; /* 小さい画面用タブの高さ(30px) + 余白(30px) */
    }
    
    .tab-content {
        height: calc(100vh - 330px); /* 小さい画面用に調整: タブ位置(230px) + タブの高さ(30px) + 余白(70px) - 20px下げる */
        top: 0;
        padding-top: 20px; /* 小さい画面用の上部パディング */
    }
    
    .search-results-container {
        margin-top: 20px;
        max-height: calc(100vh - 380px); /* 小さい画面用に調整: タブ位置(230px) + タブの高さ(30px) + 余白(120px) */
    }
    
    .container {
        padding: 5px;
    }
    
    .results-grid, .cards {
        grid-template-columns: 1fr;
    }
}

/* おすすめ動画タブの2列レイアウト */
.recommended-content-wrapper {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

.recommended-videos-main {
    flex: 2;
    min-width: 0;
}

.video-ranking-sidebar {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    height: fit-content;
}

.video-ranking-sidebar h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1rem;
    text-align: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 6px;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    cursor: pointer;
}

.ranking-item:hover {
    background-color: #e9ecef;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.ranking-number {
    width: 30px;
    height: 30px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    margin-right: 15px;
    flex-shrink: 0;
}

.ranking-content {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.ranking-content img {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
    flex-shrink: 0;
}

.ranking-info {
    flex: 1;
    min-width: 0;
}

.ranking-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-meta {
    font-size: 0.75rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .recommended-content-wrapper {
        flex-direction: column;
        gap: 20px;
    }

    .video-ranking-sidebar {
        min-width: 0;
        max-width: none;
        position: static;
    }

    .ranking-content img {
        width: 50px;
        height: 37px;
    }

    .ranking-number {
        width: 25px;
        height: 25px;
        font-size: 0.8rem;
        margin-right: 10px;
    }
}

/* お勧めグッズのカテゴリフィルタ */
.goods-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.goods-category-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.goods-category-filter label {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

.multiselect-container {
    position: relative;
    display: inline-block;
}

.multiselect-dropdown {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.multiselect-dropdown:hover {
    border-color: #007bff;
}

.multiselect-dropdown.active {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.dropdown-arrow {
    margin-left: 8px;
    font-size: 12px;
    color: #666;
    transition: transform 0.2s ease;
}

.multiselect-dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

.multiselect-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.multiselect-option {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 14px;
}

.multiselect-option:hover {
    background-color: #f8f9fa;
}

.multiselect-option input[type="checkbox"] {
    margin-right: 8px;
}

.clear-filter-btn {
    padding: 8px 12px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.clear-filter-btn:hover {
    background: #5a6268;
}

/* グッズアイテムの表示/非表示 */
.goods-item {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.goods-item.hidden {
    display: none;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .goods-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .goods-category-filter {
        flex-direction: column;
        gap: 10px;
        width: 100%;
        max-width: 300px;
    }
    
    .multiselect-dropdown {
        width: 100%;
        min-width: auto;
    }
} 