/*
Theme Name: CVI Theme
Theme URI: https://yourdomain.com/
Author: Your Name
Author URI: https://yourdomain.com/
Description: CSV Video Importer Pluginと連携するためのテーマ。
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: cvitheme
*/

/* ----------------------------------------------------
 * ★★ box-sizing リセットルールの追加 ★★
 * ---------------------------------------------------- */
* {
    box-sizing: border-box; 
}

/* ----------------------------------------------------
 * 基本レイアウトとタイポグラフィ
 * ---------------------------------------------------- */
body {
    background-color: #f4f4f4;
    color: #333;
    font-family: sans-serif;
    margin: 0;
    padding: 0;
    /* 💡 修正点: オーバーレイ表示時のスクロール制御用にトランジション追加 */
    transition: padding-bottom 0.3s;
}

/* 💡 修正点: モーダル/ドロワー表示時に背景のスクロールを禁止 */
body.modal-open {
    overflow: hidden;
}

/* サイト全体の中央揃えと最大幅を設定 */
.container {
    max-width: 1100px;  
    margin: 0 auto;
}

/* ----------------------------------------------------
 * カラムレイアウトの設定 (PC/デフォルト)
 * ---------------------------------------------------- */

.site-main-container {
    display: flex;      
    flex-direction: row;
    gap: 20px;          
    padding: 20px;      
}

/* メインカラム (コンテンツエリア) の設定 (PC/デフォルト) */
#primary {
    width: 800px; 
    flex-shrink: 0; 
    background-color: #fff;
    padding: 20px;
}

/* サイドバーカラムの設定 (PC/デフォルト) */
#secondary {
    width: 240px; 
    flex-shrink: 0; 
    background-color: #fff;
    padding: 10px;
}

/* ウィジェット内の要素の調整 */
.widget {
    margin-bottom: 20px;
    padding: 10px;
    /* 💡 修正: サイドバーの各ウィジェットの枠線を削除 */
    border: none; 
}

.widget-title {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    font-size: 1.1em;
}


/* ----------------------------------------------------
 * カスタムカレンダーのスタイル調整
 * ---------------------------------------------------- */

/* カレンダー全体のラッパー（ウィジェット内部） */
#custom-calendar-content {
    width: 100%;    
    max-width: 220px;
    margin-left: auto;      
    margin-right: auto; 
}

/* テーブル自体の幅とレイアウトの強制 */
#custom-calendar-content .wp-calendar-table {
    width: 100%;            
    table-layout: fixed;            
    border-collapse: collapse;
}

/* 日付セルを均等に設定 */
#custom-calendar-content .wp-calendar-table th,
#custom-calendar-content .wp-calendar-table td {
    padding: 0;
    text-align: center;
    width: calc(100% / 7);      
    height: 30px;               
    line-height: 30px;      
    font-size: 14px;
    box-sizing: border-box;
    border: 1px solid #eee; 
}

/* キャプション（年月）のスタイル */
#custom-calendar-content .wp-calendar-table caption {
    display: none;      
    padding: 5px 0;
    font-weight: bold;
    font-size: 1.1em;
    caption-side: top;
}

/* カレンダーナビゲーションの強制一行化 */
#custom-calendar-content thead tr:first-child td {
    white-space: nowrap;        
    box-sizing: border-box;
    padding: 5px 0; 
    border: none;
}

/* 前月/次月リンクのセル幅設定 */
#custom-calendar-content .wp-calendar-table td#prev {
    width: 25%; 
    text-align: left;   
    padding-left: 5px;
}

#custom-calendar-content .wp-calendar-table td#current_month {
    width: 50%; 
    text-align: center; 
    font-weight: bold;
}

#custom-calendar-content .wp-calendar-table td#next {
    width: 25%; 
    text-align: right;  
    padding-right: 5px;
}

/* ナビゲーション（前月/次月）のリンクスタイル */
#custom-calendar-content .wp-calendar-table td#prev,
#custom-calendar-content .wp-calendar-table td#next {
    font-size: 0.9em;
}

#custom-calendar-content .wp-calendar-table td#prev a,
#custom-calendar-content .wp-calendar-table td#next a {
    text-decoration: none;
    color: #0073aa;
}


/* 記事がある日付のリンクスタイル */
#custom-calendar-content .wp-calendar-table .has-posts a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    background-color: #e0f7fa;     
    color: #00796b;
    font-weight: bold;
}

/* 土日表示 */
#custom-calendar-content .sun { 
    color: #d32f2f; /* 赤 */
}
#custom-calendar-content .sat { 
    color: #1976d2; /* 青 */
}

/* パディング用セル（月の初めの空白など）の調整 */
#custom-calendar-content .pad {
    border: none !important;    
    background: transparent;
}


/* ----------------------------------------------------
 * ページネーションのスタイル
 * ---------------------------------------------------- */

/* ページネーション全体を中央揃えにする */
#primary .navigation.pagination {
    clear: both;
    text-align: center;
    padding: 20px 0;
    margin: 20px 0;
}

/* リンク全体のコンテナ (.nav-links) */
#primary .navigation.pagination .nav-links {
    display: inline-block;  
}

/* 各ページ番号リンクやスパン (.page-numbers) の見た目 */
#primary .navigation.pagination .page-numbers {
    display: inline-block;  
    margin: 0 5px;
    padding: 8px 14px;
    border: 1px solid #ccc;
    border-radius: 5px;
    color: #333;
    text-decoration: none;
    background-color: #fff;
    transition: all 0.2s ease-in-out;
    float: none;            
}

/* ホバー時 */
#primary .navigation.pagination .page-numbers:hover {
    background-color: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

/* 現在のページ */
#primary .navigation.pagination .page-numbers.current {
    background-color: #0073aa;
    color: #fff;
    border-color: #0073aa;
    font-weight: bold;
    cursor: default;
}

/* 省略記号（...） */
#primary .navigation.pagination .page-numbers.dots {
    border: none;
    background: transparent;
    cursor: default;
}


/* ----------------------------------------------------
 * フッターの回り込み防止
 * ---------------------------------------------------- */

.site-footer,  
#colophon {
    clear: both;        
    width: 100%;        
}

.site-info,      
.footer-menu,
.footer-navigation {
    clear: both;
}


/* ----------------------------------------------------
 * ★★ モバイルフッターメニューとオーバーレイのCSS ★★
 * ---------------------------------------------------- */

/* モバイルフッターメニューの基本スタイル */
#mobile-footer-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 48px;  /* 💡 修正 */
    background-color: #333;
    color: #fff;
    z-index: 9999;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2);
}

#mobile-footer-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: space-around;
    height: 100%;
}

#mobile-footer-menu li {
    flex: 1;
    text-align: center;
}

#mobile-footer-menu a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: inherit;
    font-size: 10px;  /* 💡 修正 */
    padding: 3px 0; /* 💡 修正 */
}

#mobile-footer-menu .menu-icon {
    font-size: 20px; /* 💡 修正 */
    line-height: 1;
}

/* サイドバーオーバーレイ (ドロワー) の初期設定 */
.sidebar-overlay {
    position: fixed;
    top: 0;
    right: 0;       
    width: 300px;   
    max-width: 80%;
    height: 100%;
    background-color: #fff;
    z-index: 10000;
    overflow-y: auto;
    
    /* 初期状態は非表示（画面外に配置） */
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3);
}

/* 表示状態 */
.sidebar-overlay.is-open {
    transform: translateX(0);   
}

/* 閉じるボタン */
#sidebar-close-button {
    position: sticky;
    top: 0;
    display: block;
    text-align: right;
    font-size: 30px;
    padding: 10px 15px;
    text-decoration: none;
    color: #333;
    background-color: #fff;
    z-index: 10001;         
}

/* サイドバーの内容エリア */
.sidebar-content {
    padding: 20px 15px 50px;
}


/* ----------------------------------------------------
 * ★★ カスタムタームリンクのスタイル ★★
 * ---------------------------------------------------- */
.custom-term-meta-output-group a {
    /* 文字色を #0073aa に設定 */
    color: #0073aa;
    
    /* リンクの下線を削除 */
    text-decoration: none;
    
    /* トランジションを追加（ホバー時の変化を滑らかにするため） */
    transition: text-decoration 0.2s ease;
}

.custom-term-meta-output-group a:hover {
    /* ホバー時に下線を出す */
    text-decoration: underline;
}

.custom-term-meta-item {
    /* ウィジェット内の各項目間隔 */
    margin-bottom: 5px;
}

.custom-term-meta-item h4.term-name-link {
    /* <h4>のデフォルトのマージンを調整 */
    margin: 0;
    font-size: 1em; /* サイズを通常テキストに近づける */
    font-weight: normal; /* 太字を解除 */
}


/* ----------------------------------------------------
 * ★★ タクソノミーアーカイブリンクウィジェットの装飾 ★★
 * ---------------------------------------------------- */

/* ウィジェット内のリンク全体をリストのように見せる */
.widget .taxonomy-archive-link-group {
    list-style: none; /* リストマークを消す */
    padding: 0;
    margin: 0;
}

/* 各リンクアイテムの装飾 */
.widget .taxonomy-archive-link-item {
    /* 💡 修正: 各カテゴリリンクの下の横線 (border-bottom) を削除 */
    border-bottom: none; 
    padding: 5px 0; /* 上下の余白 */
}

/* リンクテキスト自体の装飾 */
.widget .taxonomy-archive-link-item a {
    display: block; /* リンク全体をクリック可能にする */
    color: #0073aa; /* 文字色を他のウィジェットリンクと同じ色に設定 */
    text-decoration: none; /* デフォルトの下線を非表示 */
    padding: 3px 0;
    transition: color 0.2s, text-decoration 0.2s;
}

/* ホバー時の装飾 */
.widget .taxonomy-archive-link-item a:hover {
    color: #005580; /* ホバー時の文字色を少し濃くする */
    text-decoration: underline; /* ホバー時に下線を表示 */
}


/* ----------------------------------------------------
 * ★★ 閲覧数ランキング TOP10 (月間) V2 のスタイル (スタック版) ★★
 * ---------------------------------------------------- */

.ranking-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ranking-list li {
    /* 縦積み構造のため、Flexを解除し、ブロック要素に戻す */
    display: block; 
    margin-bottom: 15px; /* 項目間の間隔を少し広げる */
    padding-bottom: 10px;
    border-bottom: 1px dashed #eee;
}

.ranking-list li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.ranking-list .ranking-link-wrapper {
    /* リンク全体を縦積みのFlexコンテナにする */
    display: flex;
    flex-direction: column; 
    text-decoration: none;
    color: #333;
    width: 100%;
}

/* 1. サムネイルのラッパー（1行目） */
.ranking-list .ranking-thumb-wrapper {
    width: 100%;
    margin-bottom: 5px; /* 画像とタイトルの間のスペース */
    text-align: center; /* サイドバー中央に画像を寄せる */
}

/* サムネイル画像自体 */
.ranking-list .ranking-thumb {
    width: 100%; /* 親要素の幅いっぱい（240px程度）に広げる */
    max-width: 150px; /* 画像の最大幅を制限（サイドバーの見た目に合わせて調整可） */
    height: auto;
    object-fit: cover;
    /* 💡 修正: グレーの枠線 (#ddd) を削除 */
    border: none;
}

/* 2. 順位とタイトルのラッパー（2行目） */
.ranking-list .ranking-content-wrapper {
    display: flex; /* 順位とタイトルを横並びにする */
    align-items: flex-start;
    font-size: 13px;
    line-height: 1.4;
}

/* 2-1. ランキング番号のスタイル */
.ranking-list .rank-number {
    font-weight: bold;
    color: #0073aa;
    width: 20px; /* 番号の固定幅 */
    flex-shrink: 0;
    text-align: right;
    margin-right: 5px;
}

/* 2-2. タイトルテキストのスタイル */
.ranking-list .ranking-post-title {
    flex-grow: 1; 
    overflow: hidden; 
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2; /* タイトルを最大2行に制限 */
    max-height: 2.8em; 
}


/* ----------------------------------------------------
 * ★★ page-tax-listing.php のタームリスト装飾とレイアウト (再修正: 枠と余白を削除) ★★
 * ---------------------------------------------------- */

/* タクソノミーリスト全体を囲むULタグ */
#primary .taxonomy-term-list {
    list-style: none; /* リストマークを非表示 */
    margin: 10px 0; /* 全体の上下マージンを少し減らす */
    padding: 0;
    border-top: 1px solid #ddd; /* リスト上部に区切り線は維持 */
    
    /* Flex設定はULに移管 */
    display: flex;
    flex-wrap: wrap; 
    gap: 0; /* 項目間の隙間を削除 */
}

/* リンクテキスト（女優名、メーカー名など）の装飾 */
#primary .taxonomy-term-list .term-item a {
    color: #0073aa; 
    text-decoration: none; 
    font-size: 1.0em; 
    display: block; 
    padding: 3px 5px; /* 💡 リンク内の上下余白を最小限に (3px) */
    transition: text-decoration 0.2s; 
}

/* ホバー時の装飾 */
#primary .taxonomy-term-list .term-item a:hover {
    text-decoration: underline; 
}

/* ----------------------------------------------------
 * ★★ リスト項目を横並び（グリッド）にするための修正 ★★
 * ---------------------------------------------------- */

.term-list-grid {
    display: flex;
    flex-wrap: wrap; 
    gap: 0; /* 隙間を削除 */
    margin: 0;
    padding: 0;
}

/* ULタグ (taxonomy-term-list) が Flex Item になるため、全幅に設定 */
#primary .taxonomy-term-list {
    border-top: none; 
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap; 
    gap: 0; /* 隙間を削除 */
}

/* 3. 各リスト項目 (li.term-item) の幅を設定 */
/* 枠と上下の余白を削除し、幅のみを維持 */
#primary .taxonomy-term-list .term-item {
    padding: 0; /* 💡 リストアイテム自体のパディングを削除 */
    
    /* 枠線を削除 */
    border: none; 
    
    /* 100%を5で割る計算 (隙間がないためシンプル) */
    width: 20%; 
    
    margin-bottom: 0; /* マージンを削除 */
    box-sizing: border-box;
}

/* ----------------------------------------------------
 * スマートフォン表示のレスポンシブ対応
 * ---------------------------------------------------- */

@media (max-width: 767px) {
    
    /* 💡 修正点 1: モバイルフッターが画面を占有しないよう、bodyにパディングを追加 */
    body {
        padding-bottom: 48px;  /* 👈 修正 */
    }

    /* 1. 全体のコンテナパディングを調整し、画面端に近づける */
    .site-main-container {
        padding: 10px;  
        flex-direction: column;     
        gap: 10px;  
    }

    /* 2. メインカラムの固定幅を解除し、幅を100%にする */
    #primary {
        width: 100%;        
        flex-shrink: 1;     
        flex-grow: 1;
        padding: 0; 
    }

    /* 💡 修正点 2: スマホでは通常のサイドバーを非表示にする */
    #secondary {
        display: none;      
    }
    
    /* カレンダーのスマホ調整 (幅100%になるため、中央寄せは維持) */
    #custom-calendar-content {  
        max-width: 100%;
    }
    
    /* ---------------------------------------------------- */
    /* 💡 新規: page-tax-listing.php のスマホレイアウト */
    /* ---------------------------------------------------- */
    
    /* タームリストを1カラムにする */
    #primary .term-list-grid {
        gap: 0; 
        margin: 0;
    }
    
    /* ULタグも隙間をなくし、縦に並べる設定 */
    #primary .taxonomy-term-list {
        gap: 0;
        margin: 10px 0;
        border-top: 1px solid #ddd; /* スマホではULタグに上線を設定 */
    }

    /* リスト項目を100%幅にし、リストデザインに戻す */
    #primary .taxonomy-term-list .term-item {
        width: 100% !important; 
        padding: 0; /* 💡 スマホのリストアイテムのパディングを削除 */
        margin-bottom: 0;   
        border: none;   
        border-bottom: 1px solid #eee; /* 項目間に下線を表示 (線は維持) */
    }
    
    /* リンク内の上下余白を調整 */
    #primary .taxonomy-term-list .term-item a {
        padding: 5px 0; /* 💡 スマホ表示時は上下5pxの余白を確保 */
    }
}

@media (min-width: 768px) {
    /* 💡 デスクトップではモバイルフッターを非表示 */
    #mobile-footer-menu {
        display: none !important;
    }
}