/*
 * ----------------------------------------------------------------------------
 * # Plugin Integration: Haru PV Monitor
 * ----------------------------------------------------------------------------
 */

/* レイアウト調整: ウィジェットの二重パディングを解消 */
#secondary .widget_haru_pv_monitor_widget {
    padding: 0; /* カード自体のパディングをリセット */
}

#secondary .widget_haru_pv_monitor_widget .haru-popular-posts-widget {
    border: none; /* プラグインが持つボーダーを削除 */
    padding: 0; /* プラグインが持つパディングも削除 */
}

/* タブのデザイン */
.haru-popular-posts-tabs {
    display: flex;
    flex-wrap: nowrap; /* 明示的に折り返しを禁止 */
    justify-content: space-around; /* タブを均等に配置 */
    list-style: none;
    margin: 0;
    /*padding: 1rem 1.5rem 0 1.5rem; */
    border-bottom: 1px solid #e9ecef;
    background-color: #f8f9fa; /* ウィジェットタイトルと背景色を合わせる */
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    overflow-x: auto; /* 画面が狭い場合にスクロール可能にする */
}

.haru-popular-posts-tabs li {
    margin: 0;
    padding: 0;
    flex-grow: 1; /* 各タブが均等な幅になるように */
    text-align: center; /* テキストを中央揃え */
}

.haru-popular-posts-tabs li a {
    display: block;
    padding: 0.8rem 0.5rem; /* 左右のパディングを少し減らす */
    font-size: 0.9rem;
    font-weight: 600;
    color: #6c757d;
    text-decoration: none;
    border-bottom: 2px solid transparent; /* 下線を少し細く */
    transition: color 0.2s ease, border-color 0.2s ease;
}

.haru-popular-posts-tabs li.active a,
.haru-popular-posts-tabs li a:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* コンテンツエリア */
.haru-popular-posts-content {
    padding: 1.5rem; /* カードのパディングをここに適用 */
}

.haru-popular-posts-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.haru-popular-post-item {
    display: flex; /* デフォルトでFlexbox */
    align-items: center; /* 垂直方向中央揃え */
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0; /* 各記事の区切り線 */
}

.haru-popular-post-item:last-child {
    margin-bottom: 0;
    border-bottom: none; /* 最後の記事は区切り線なし */
}

/* PC表示時のレイアウト調整 */
@media (min-width: 769px) {
    .haru-popular-post-item {
        display: block; /* PCではブロック要素に戻す */
        text-align: center; /* 中央揃え */
    }
}

/* ランキング数字 */
.haru-popular-post-item .rank-number {
    /* PCとモバイルでスタイルを分けるため、一旦リセット */
    position: static; /* デフォルトはstatic */
    top: auto;
    left: auto;
    background-color: var(--primary); /* 背景色 */
    color: #fff; /* 文字色 */
    font-size: 1rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 0px; /* 角を丸める */
    z-index: auto;
    min-width: 25px; /* 1桁でも2桁でも崩れないように */
    min-height: 25px;
    text-align: center;
    /*line-height: 1;*/
    box-shadow: 0 2px 4px rgba(0,0,0,0.2); /* 影 */
    flex-shrink: 0; /* 縮まない */
    margin-right: 0.8rem; /* サムネイルとの余白 */
}

/* PC表示時のバッジ位置調整 */
@media (min-width: 769px) {
    .haru-popular-post-item .rank-number {
        position: absolute; /* サムネイルに重ねる */
        /**top: 0; **/
        /**left: 0; **/
        z-index: 1; /* サムネイルより手前に */
        transform: translate(-300%, 0%); /* 中心を基準に配置 */
    }
}

/* モバイル表示時のレイアウト調整 */
@media (max-width: 768px) {
    .haru-popular-post-item {
        display: flex; /* Flexboxで横並び */
        align-items: center; /* 垂直方向中央揃え */
    }
}

/* サムネイル */
.haru-popular-post-item .popular-post-thumbnail {
    position: relative; /* バッジの基準位置 */
    margin-bottom: 0; /* Flexboxで余白を調整するためリセット */
    display: block; /* Flexアイテムとして */
    width: auto; /* 幅はコンテンツに合わせる */
    text-align: center; /* 画像を中央に */
    flex-shrink: 0; /* 縮まない */
    margin-right: 1rem; /* タイトルとの余白 */
}

/* PC表示時のサムネイル調整 */
@media (min-width: 769px) {
    .haru-popular-post-item .popular-post-thumbnail {
        margin-bottom: 0.5rem; /* タイトルとの余白 */
        width: auto; /* 幅はコンテンツに合わせる */
        flex-shrink: 0; /* 縮まない */
        margin-right: 0; /* タイトルとの余白をリセット */
    }
}
.haru-popular-post-item .popular-post-thumbnail img {
    max-width: 100%; /* 親要素の幅に合わせる */
    height: auto; /* 高さを自動調整 */
    object-fit: cover;
    border-radius: 5px;
    margin: 0 auto; /* 中央揃え */
}

/* タイトル */
.haru-popular-post-item .popular-post-title {
    font-size: 0.85rem; /* さらに小さめに */
    line-height: 1.5;
    font-weight: 600;
    text-align: left; /* 左揃え */
    flex-grow: 1; /* 残りのスペースを埋める */
}

/* PC表示時のタイトル調整 */
@media (min-width: 769px) {
    .haru-popular-post-item .popular-post-title {
        text-align: center; /* 中央揃え */
        flex-grow: 0; /* Flexboxのgrowをリセット */
    }
}

.haru-popular-post-item .popular-post-title a {
    color: #343a40;
    text-decoration: none;
    transition: color 0.2s ease;
}

.haru-popular-post-item .popular-post-title a:hover {
    color: var(--primary);
}

#secondary .widget ul.haru-popular-posts-tabs a::before{
    content: none;
}