/* ranking.css */

.ranking-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    background-color: transparent;
    border-radius: var(--border-radius);
    box-shadow: none;
}

.ranking-header {
    text-align: center;
    padding: 10px;
}

.ranking-list {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    justify-content: center;
}

.ranking-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border-radius: var(--border-radius);
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    background-color: var(--card-background);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    min-height: 400px;
}

.ranking-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.ranking-item.rank-1 {
    grid-column: 1 / -1;
    min-height: 500px;
    max-width: 1200px;
    margin: 20px auto;
    padding-top:3px;
    padding-bottom:3px;
}

.ranking-item.rank-1 .ranking-item-image {
    max-width: 50%;
    margin: 0 auto 10px;
}

.ranking-item.rank-1 .ranking-item-image img {
    width: 100%;
    max-height: 500px;
}

.ranking-item.rank-1 .ranking-rank {
    font-size: 3em;
    color: var(--secondary-color);
}

.ranking-rank {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--primary-color);
    text-align: center;
    white-space: nowrap;
}

.ranking-item-image {
    max-width: 100%;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
}

.ranking-item-image img {
    width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    object-fit: contain;
    max-height: 300px;
}

.ranking-item-details {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 0;
    flex-grow: 1;
    justify-content: space-between;
}

.ranking-item-title {
    font-size: 0.8em;
    margin-bottom: 5px;
    word-wrap: break-word;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    max-width: 100%;
    padding:10px 5px !important;
}

.ranking-item-price {
    font-size: 1em;
    color: var(--muted-text-color);
    word-wrap: break-word;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
    padding-bottom: 0;
}

@media (max-width: 1023px) {
    .ranking-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .ranking-item.rank-1 {
        grid-column: 1 / -1;
        min-height: 350px;
    }
    .ranking-item:not(.rank-1) {
        min-height: 300px;
    }
    .ranking-item-title {
        font-size: 0.7em;
    }
    .ranking-rank {
         font-size: 1.2em;
     }
    /* 立ち読み・サンプル動画ボタン (btn-highlight を使用するボタン) */
    .ranking-item-details .btn-highlight {
         padding: 5px 10px;
         font-size: 0.7em;
     }
}

@media (max-width: 480px) {
     .ranking-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .ranking-item:not(.rank-1) {
       min-height: 250px;
    }
    .ranking-item.rank-1 {
       min-height: 300px;
    }
    .ranking-item-title {
        font-size: 0.7em;
    }
     .ranking-rank {
       font-size: 1em;
     }
    /* モード切り替えボタンやその他の .btn-highlight */
    .mode-button, .ranking-item-details .btn-highlight {
        margin-left: 0px;
        margin-right: 0px;
    }
}

@media (orientation: landscape) and (max-width: 1023px) {
    .ranking-list {
        grid-template-columns: repeat(4, 1fr);
    }
     .ranking-item-details .btn-highlight{ /* 立ち読み・サンプル動画ボタン */
        margin-top: 0;
    }
}

/* 立ち読み・サンプル動画ボタンの共通スタイル */
.dmm-sample-movie-button,
.ranking-item-details a.btn-highlight[target="_blank"] { /* 立ち読みも共通化 */
    display: inline-block;
    padding: 5px 10px;
    font-size: 0.8em;
    background-color: #ff6f61; /* 基本のハイライト色 */
    color: #fff;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
    text-align: center;
    transition: background-color 0.3s, transform 0.3s;
    cursor: pointer;
    border: none;
    margin-top: 5px;
}
.dmm-sample-movie-button:hover,
.ranking-item-details a.btn-highlight[target="_blank"]:hover {
  background-color: #ffdc7a;
  transform: translateY(-3px);
  color: #333;
}


.ranking-item-review::before {
    display: inline-block;
    margin-right: 5px;
    font-weight: bold;
    color: var(--text-color);
  }

.ranking-container .ranking-header h3 {
    margin-bottom: 0;
    text-align: left;
}

/* --- ランキング情報ポップアップ (モーダル) --- */
.ranking-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* script.js 側のモーダルより手前に来ないように調整が必要な場合あり */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ranking-modal-overlay.is-visible {
    display: flex;
    opacity: 1;
}

.ranking-modal-window {
    background-color: #fff;
    padding: 25px 30px;
    border-radius: var(--border-radius);
    max-width: 90%;
    width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.ranking-modal-overlay.is-visible .ranking-modal-window {
    transform: scale(1);
}

.ranking-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #aaa;
    padding: 5px;
}
.ranking-modal-close:hover {
    color: #333;
}

.ranking-modal-content p {
    margin-bottom: 0.8em;
    font-size: 0.9em;
    line-height: 1.6;
}
.ranking-modal-content b {
    display: inline-block;
    min-width: 70px;
    margin-right: 5px;
}
.ranking-modal-content a {
    color: var(--primary-color);
    text-decoration: underline;
}
.ranking-modal-content a:hover {
    color: #3f6fb1;
}
.ranking-modal-content .sample-images {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}
.ranking-modal-content .sample-images img {
    max-width: 80px;
    height: auto;
    border-radius: 3px;
    border: 1px solid #eee;
}

@media (max-width: 768px) {
    .ranking-modal-window {
        width: 90%;
        padding: 20px;
    }
    .ranking-modal-content b {
        min-width: auto;
    }
}

/* ★★★ 「商品情報を見る」ボタンのスタイル（視認性向上版） - 汎用化 ★★★ */
/* ボタン自体の基本スタイル */
.open-dmm-item-detail-modal {
    display: inline-block;
    padding: 6px 12px;
    /* margin-top: 8px; /* ランキングリスト内の調整は別途行う */
    font-size: 0.85em;
    line-height: 1.4;
    font-weight: 500;
    color: var(--text-color);
    background-color: #f0f0f0; /* 薄いグレーの背景 */
    border: 1px solid #dcdcdc; /* やや濃いめのグレーの枠線 */
    border-radius: var(--border-radius);
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.open-dmm-item-detail-modal:hover {
    background-color: #e0e0e0;
    border-color: #c0c0c0;
    color: var(--text-color);
}

/* ランキングリスト内の「商品情報を見る」ボタンのマージン調整 */
.ranking-item .ranking-item-details .open-dmm-item-detail-modal {
    margin-top: 8px; /* ランキングリスト内でのみ上マージンを適用 */
}
/* ★★★ ここまで修正 ★★★ */