/* News Card Hover Effect */
.news-card {
  transition: opacity 0.3s ease;
  border-radius: 0;
  cursor: pointer;
}
.news-card:hover {
  opacity: 0.5;
}

/* --- S-Rank Section Base --- */
.s-rank-section {
  background-color: #fff;
  padding: 1.5rem 0;
  border-bottom: 1px solid #dee2e6;
}

.rank-card {
  position: relative;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 25px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.rank-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: var(--primary-color);
  color: inherit;
}

.badge-rank {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 1rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 3px;
  color: #fff;
  z-index: 5;
}
.rank-title {
  font-size: 0.9rem;
  font-weight: bold;
  margin-top: 12px;
  line-height: 1.3;
}
.rank-vendor {
  font-size: 0.7rem;
  color: #777;
  margin-top: 2px;
}

/* 順位ごとの色 */
.b-1,
.b-2,
.b-3,
.b-4 {
  background: #adb5bd;
}

/* 1. Layout A: Compact Bento (1+3) */
.layout-a {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 12px;
}
.layout-a .card-1 {
  grid-row: span 2;
  background-color: #fffdf0;
  border-color: var(--gold);
}
.layout-a .card-1 .rank-title {
  font-size: 1.1rem;
  color: var(--primary-color);
}

/* 2. Layout B: 2x2 Grid */
.layout-b {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.layout-b .rank-card {
  min-height: 100px;
}

/* 3. Layout C: Slim List (4-in-a-row) */
.layout-c {
  display: flex;
  gap: 10px;
}
.layout-c .rank-card {
  flex: 1;
  min-height: 80px;
  padding: 10px;
}
.layout-c .rank-title {
  font-size: 0.8rem;
  margin-top: 8px;
}

/* Content Sections */

[data-layout] {
  display: none;
}
[data-layout].active {
  display: grid !important;
}
.layout-c.active {
  display: flex !important;
}

/* コンテナ：横に並べる設定 */
.layout-banner-container {
  display: flex;
  flex-wrap: wrap; /* 折り返しを許可 */
  justify-content: center; /* 中央寄せ */
  gap: 10px; /* バナー間の隙間 */
  padding: 10px 0;
  width: 100%;
  overflow-x: visible; /* 横スクロールを解除 */
}
/* バナー：サイズを300x100に絶対固定 */
.rank-card-banner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;

  /* 300x100を厳守 */
  width: 300px !important;
  min-width: 300px !important;
  height: 100px !important;
  min-height: 100px !important;
  background-color: #fff;
  text-decoration: none;
  color: #333;
  box-sizing: border-box;
  flex-shrink: 0; /* 絶対に縮ませない */
}
.rank-card-banner img {
  border: .5px solid #ccc;
}

/* 順位バッジ */
.badge-rank {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: bold;
  color: #fff;
  background: #666; /* デフォルト色 */
}
.b-1 {
  background-color: #f1c40f;
}
.b-2 {
  background-color: #95a5a6;
}
.b-3 {
  background-color: #d35400;
}
.b-4 {
  background-color: #34495e;
}

/* テキストがはみ出さないように制御 */
.rank-title {
  font-size: 13px;
  font-weight: bold;
  line-height: 1.3;
  margin-bottom: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2; /* 2行まで */
  -webkit-box-orient: vertical;
}

.rank-vendor {
  font-size: 11px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* 長い場合は「...」 */
}

/* Rank */
.articles__rank i,
.articles__news i {
  color: #8a8a8a;
}
.articles__rank ul > li .num-fonts {
  color: #fff;
  padding: 0.1rem 0.6rem;
  font-size: 130%;
}
.articles__rank ul > li:nth-child(1) .num-fonts {
  background-color: #c9a632; /* ゴールド */
}
.articles__rank ul > li:nth-child(2) .num-fonts {
  background-color: #868686; /* シルバー */
}
.articles__rank ul > li:nth-child(3) .num-fonts {
  background-color: #da7107; /* ブロンズ */
}

/* News */

@media (max-width: 768px) {
  .layout-a,
  .layout-b,
  .layout-c {
    grid-template-columns: 1fr !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 15px;
  }
  /* SP時に全てのカードのグリッドスパンを解除してフル幅にする */
  .layout-a .card-1,
  .layout-a .rank-card {
    grid-row: auto !important;
    grid-column: auto !important;
    min-height: 100px; /* SPでの高さを確保 */
  }
  /* 1番のバナーをSPでさらに目立たせる場合 */
  .layout-a .card-1 {
    min-height: 140px;
  }
}
