/* ========================================
   画像カードコンポーネント
   ======================================== */

/* ========== ベーススタイル ========== */

.image-card {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  text-decoration: none;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ホバーアニメーション */
.image-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.image-card:hover .image-card__image {
  transform: scale(1.03);
}

/* ========== 画像ラッパー ========== */

.image-card__image-wrapper {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

/* アスペクト比を CSS で制御 */
.image-card--16\:9 .image-card__image-wrapper {
  padding-bottom: 56.25%; /* 16:9 = 9/16 = 0.5625 */
}

.image-card--4\:3 .image-card__image-wrapper {
  padding-bottom: 75%; /* 4:3 = 3/4 = 0.75 */
}

/* ========== 画像スタイル ========== */

.image-card__image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.3s ease;
}

/* ========== グラデーションオーバーレイ ========== */

.image-card__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.85) 100%);
  z-index: 10;
  pointer-events: none; /* クリック可能にする */
}

/* ========== テキストコンテンツ ========== */

.image-card__content {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  z-index: 20;
  padding: 15px;
  box-sizing: border-box;
  pointer-events: none; /* 親のクリックを阻害しない */
}

/* ========== タイトルスタイル ========== */

.image-card__title {
  margin: 0;
  font-size: 13px;
  font-weight: bold;
  color: #FFFFFF;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2; /* 最大2行 */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

/* ========== サイズバリエーション ========== */

/* デフォルトサイズ */
.image-card--default {
  width: 100%;
}

/* 小さいサイズ（サイドバー用） */
.image-card--small {
  width: 100%;
  margin-bottom: 12px;
}

.image-card--small .image-card__title {
  font-size: 12px;
}

/* 大きいサイズ */
.image-card--large {
  width: 100%;
  margin-bottom: 16px;
}

.image-card--large .image-card__title {
  font-size: 14px;
}

/* ========== レスポンシブ対応 ========== */

@media (max-width: 768px) {
  .image-card__title {
    font-size: 12px;
  }

  .image-card__content {
    padding: 12px;
  }
}

@media (max-width: 480px) {
  .image-card__title {
    font-size: 11px;
    line-height: 1.3;
  }

  .image-card__content {
    padding: 10px;
  }
}

/* ========== サイドバー専用スタイル ========== */

.sidebar-cards {
  display: flex;
  flex-direction: column;
  gap: 12px; /* カード間の隙間 */
}

.sidebar-card {
  width: 100%;
  margin-bottom: 0; /* 親の gap で制御 */
}

/* ========== グリッド表示（複数カラム） ========== */

.image-card-grid {
  display: grid;
  gap: 15px;
  margin-bottom: 20px;
}

/* デスクトップ：3カラム */
@media (min-width: 1200px) {
  .image-card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* タブレット：2カラム */
@media (min-width: 768px) and (max-width: 1199px) {
  .image-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* モバイル：1カラム */
@media (max-width: 767px) {
  .image-card-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== ダークモード対応（オプション） ========== */

@media (prefers-color-scheme: dark) {
  .image-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  }

  .image-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  }
}

/* ========================================
   ランダム記事グリッド（PC: 4列×2行 / スマホ: 2列×4行、計8件）
   ======================================== */

.random-article-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 768px) {
  .random-article-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
}

.random-article-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.random-article-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.random-article-card__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.3s ease;
}

.random-article-card:hover .random-article-card__image {
  transform: scale(1.04);
}

.random-article-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 35%, rgba(0, 0, 0, 0.85) 100%);
  pointer-events: none;
}

.random-article-card__title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 8px 10px;
  color: #ffffff;
  font-size: 12px;
  font-weight: bold;
  line-height: 1.4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.random-article-grid__skeleton {
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: linear-gradient(135deg, #f0f0f0 0%, #e4e4e4 100%);
  animation: random-article-pulse 1.4s ease-in-out infinite;
}

@keyframes random-article-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@media (prefers-color-scheme: dark) {
  .random-article-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  }

  .random-article-card:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
  }
}
