/* ===========================================
   📱 clusters.php スマホ表示完全修正版
   style.cssの末尾に追加または既存のモバイルCSSと統合
   =========================================== */

/* 🎯 基本レイアウト修正 */
@media (max-width: 768px) {
    
    /* メインコンテナ - 1カラムに */
    .main-container {
        grid-template-columns: 1fr !important;
        padding: 0.5rem !important;
        gap: 0 !important;
    }
    
    /* メインコンテンツ幅調整 */
    .main-content {
        width: 100% !important;
        min-width: 100% !important;
        margin: 0 !important;
    }
    
    /* ===========================================
       🍞 パンくずリスト スマホ最適化
       =========================================== */
    .breadcrumb {
        flex-wrap: wrap;
        justify-content: flex-start !important;
        padding: 0.75rem 1rem !important;
        margin-bottom: 1rem !important;
        font-size: 0.85rem;
    }
    
    .breadcrumb a,
    .breadcrumb span {
        padding: 0.2rem 0.4rem;
        white-space: nowrap;
    }
    
    /* ===========================================
       📄 コンテンツヘッダー スマホ最適化
       =========================================== */
    .content-header {
        padding: 1.5rem 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    .page-title {
        font-size: 1.5rem !important;
        margin: 0.5rem 0 !important;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 0.5rem;
        line-height: 1.3;
    }
    
    .page-title span {
        font-size: 1.3rem;
    }
    
    /* ===========================================
       🎬 動画グリッド スマホ最適化（最重要）
       =========================================== */
    .videos-grid {
        grid-template-columns: 1fr !important; /* 1カラム表示 */
        gap: 1.5rem !important;
        padding: 0 0.5rem;
        margin: 1rem 0 !important;
    }
    
    /* 動画カード */
    .video-card {
        border-radius: 12px;
        box-shadow: 0 2px 12px rgba(0,0,0,0.1) !important;
    }
    
    .video-card:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
    }
    
    /* サムネイル高さ調整 */
    .video-thumbnail {
        height: 220px !important; /* スマホで見やすい高さ */
    }
    
    /* 動画情報パディング調整 */
    .video-info {
        padding: 1rem !important;
    }
    
    /* タイトル行数調整 */
    .video-title {
        font-size: 0.95rem !important;
        margin-bottom: 0.75rem !important;
        height: auto !important;
        min-height: 2.8rem;
        -webkit-line-clamp: 2;
    }
    
    /* 統計情報 */
    .video-stats {
        flex-wrap: wrap;
        gap: 0.5rem;
        font-size: 0.8rem;
    }
    
    .stat-item {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .stat-item i {
        font-size: 0.7rem;
    }
    
    /* ===========================================
       🏷️ サブクラスターナビ スマホ最適化
       =========================================== */
    .sub-cluster-nav {
        margin: 1rem 0.5rem !important;
        padding: 1.5rem 1rem !important;
        border-radius: 15px;
    }
    
    .sub-cluster-nav h2 {
        font-size: 1.2rem !important;
        margin-bottom: 1rem !important;
    }
    
    .sub-cluster-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* 2カラム */
        gap: 0.75rem !important;
    }
    
    .sub-cluster-card {
        padding: 1rem 0.75rem !important;
        font-size: 0.85rem;
        min-height: 80px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    .sub-cluster-card:hover {
        transform: scale(1.02) !important;
    }
    
    /* ===========================================
       📄 ページネーション スマホ最適化
       =========================================== */
    .pagination {
        flex-wrap: wrap;
        gap: 0.4rem !important;
        padding: 0 0.5rem;
        margin: 2rem 0 !important;
    }
    
    .pagination a,
    .pagination span {
        padding: 0.6rem 0.8rem !important;
        font-size: 0.85rem !important;
        min-width: 40px !important;
    }
    
    /* 省略記号を小さく */
    .pagination span:not(.current) {
        padding: 0.6rem 0.4rem !important;
    }
    
    /* ===========================================
       🎨 カテゴリ一覧ページ スマホ最適化
       =========================================== */
    .cluster-overview {
        padding: 1rem 0.5rem !important;
    }
    
    .cluster-hero {
        padding: 2.5rem 1.5rem !important;
        border-radius: 15px !important;
        margin-bottom: 1.5rem !important;
    }
    
    .cluster-hero h1 {
        font-size: 1.8rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .cluster-stats {
        flex-direction: row !important;
        justify-content: space-around;
        gap: 1rem !important;
    }
    
    .stat-item {
        padding: 0.75rem 1rem !important;
        min-width: 120px;
    }
    
    .stat-number {
        font-size: 1.5rem !important;
    }
    
    .stat-label {
        font-size: 0.85rem;
    }
    
    /* ピラーグリッド */
    .pillar-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }
    
    .pillar-card {
        padding: 1.5rem !important;
        border-radius: 15px;
    }
    
    .pillar-header {
        flex-direction: row;
        gap: 0.75rem;
    }
    
    .pillar-icon {
        font-size: 2rem !important;
        width: 50px !important;
        height: 50px !important;
    }
    
    .pillar-title {
        font-size: 1.3rem !important;
    }
    
    .pillar-description {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    /* サブクラスタータグ */
    .sub-clusters {
        padding: 0.75rem;
        margin: 0.75rem 0;
    }
    
    .sub-cluster-tags {
        gap: 0.4rem;
    }
    
    .sub-cluster-tag {
        padding: 0.3rem 0.7rem;
        font-size: 0.8rem;
    }
    
    /* ピラー統計 */
    .pillar-stats {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .video-count {
        text-align: center;
        font-size: 0.95rem;
    }
    
    .view-all-btn {
        width: 100%;
        text-align: center;
        padding: 0.85rem 1.5rem !important;
        font-size: 0.95rem !important;
    }
    
    /* ===========================================
       🔧 空の状態メッセージ
       =========================================== */
    .no-videos-message {
        padding: 3rem 1.5rem !important;
    }
    
    .no-videos-message > div:first-child {
        font-size: 3rem !important;
    }
    
    .no-videos-message h2 {
        font-size: 1.3rem !important;
    }
    
    .no-videos-message p {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    /* ===========================================
       🌙 ダークモード微調整
       =========================================== */
    .dark-mode .video-card {
        background: #2a2a2a !important;
    }
    
    .dark-mode .video-title {
        color: #e0e0e0 !important;
    }
    
    .dark-mode .stat-item {
        background: #333 !important;
        color: #ccc !important;
    }
    
    .dark-mode .breadcrumb {
        background: #2a2a2a !important;
    }
    
    .dark-mode .pillar-card,
    .dark-mode .sub-cluster-nav {
        background: #2a2a2a !important;
    }
    
    .dark-mode .sub-cluster-card {
        background: #333 !important;
        color: #e0e0e0;
    }
}

/* ===========================================
   📱 超小型画面（400px以下）追加最適化
   =========================================== */
@media (max-width: 400px) {
    .page-title {
        font-size: 1.3rem !important;
    }
    
    .video-thumbnail {
        height: 200px !important;
    }
    
    .sub-cluster-grid {
        grid-template-columns: 1fr !important; /* 1カラムに */
    }
    
    .pagination a,
    .pagination span {
        padding: 0.5rem 0.6rem !important;
        font-size: 0.8rem !important;
        min-width: 36px !important;
    }
    
    .breadcrumb {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem !important;
    }
}

/* ===========================================
   🎯 iPhone SE（375px以下）最終調整
   =========================================== */
@media (max-width: 375px) {
    .cluster-hero {
        padding: 2rem 1rem !important;
    }
    
    .cluster-hero h1 {
        font-size: 1.6rem !important;
    }
    
    .stat-item {
        padding: 0.6rem 0.75rem !important;
        min-width: 100px;
    }
    
    .stat-number {
        font-size: 1.3rem !important;
    }
    
    .pillar-card {
        padding: 1.25rem !important;
    }
    
    .pillar-icon {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.8rem !important;
    }
    
    .pillar-title {
        font-size: 1.2rem !important;
    }
}

/* ===========================================
   ⚡ タッチデバイス最適化
   =========================================== */
@media (hover: none) and (pointer: coarse) {
    .video-card:active {
        transform: scale(0.98) !important;
        transition: transform 0.1s ease;
    }
    
    .sub-cluster-card:active,
    .view-all-btn:active {
        transform: scale(0.96) !important;
    }
    
    /* タップハイライト削除 */
    .video-card,
    .sub-cluster-card,
    .pagination a,
    .breadcrumb a {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
}

/* ===========================================
   🔧 iOS Safari特有の問題修正
   =========================================== */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        .video-thumbnail {
            /* iOS Safariのレンダリング最適化 */
            transform: translateZ(0);
            -webkit-backface-visibility: hidden;
        }
        
        .video-card {
            /* iOS Safariのスクロール改善 */
            -webkit-transform: translate3d(0, 0, 0);
        }
    }
}

/* ===========================================
   🎨 アニメーション削減（省電力モード）
   =========================================== */
@media (prefers-reduced-motion: reduce) {
    .video-card,
    .pillar-card,
    .sub-cluster-card {
        transition: none !important;
        animation: none !important;
    }
    
    .video-card:hover,
    .pillar-card:hover {
        transform: none !important;
    }
}

/* ===========================================
   📊 デバッグ用（開発時のみ使用）
   =========================================== */
/* 
.videos-grid {
    border: 2px solid red;
}

.video-card {
    border: 1px solid blue;
}
*/