/**
 * featured-topics.css
 * TOPページ「注目トピック」セクション専用スタイル
 *
 * 関連 PHP: includes/components/featured_topics.php
 * 関連 JS:  public/js/featured-topics.js
 */

/* ========================================
   注目トピック（ファーストビュー）
======================================== */
.featured-topics {
  width: min(1920px, calc(100vw - 64px));
  margin-left: 50%;
  margin-bottom: 36px;
  transform: translateX(-50%);
}

/* 矢印は marquee の外側ラッパーに配置する。
   marquee 自身は overflow-x: auto のスクロールコンテナなので、
   その擬似要素として絶対配置するとスクロールに引きずられて流れてしまうため。 */
.topic-marquee-wrap {
  position: relative;
}

.topic-marquee {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 8px;
  padding: 7px 0;
  cursor: grab;
  scrollbar-width: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 42px, #000 calc(100% - 42px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 42px, #000 calc(100% - 42px), transparent 100%);
}

.topic-marquee::-webkit-scrollbar {
  display: none;
}

.topic-marquee.is-dragging {
  cursor: grabbing;
}

/* ドラッグ中にカード内の <a> や <img> がブラウザ標準のドラッグ動作で
   横スクロールを邪魔しないよう、子孫要素のドラッグを完全に殺す */
.topic-marquee a,
.topic-marquee img {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

/* 左右ナビゲーションボタン（クリックでカード単位スクロール）。
   marquee の overflow にスクロールが乗っているため、外側ラッパーに absolute 配置。 */
.topic-marquee-nav {
  position: absolute;
  top: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 36px;
  height: 56px;
  margin: 0;
  padding: 0;
  color: #007bff;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(31, 41, 51, 0.14);
  cursor: pointer;
  transform: translateY(-50%);
  transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.topic-marquee-nav:hover {
  background: #fff;
  box-shadow: 0 4px 10px rgba(31, 41, 51, 0.18);
}

.topic-marquee-nav:active {
  transform: translateY(-50%) scale(0.96);
}

.topic-marquee-nav:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

.topic-marquee-prev {
  left: 4px;
}

.topic-marquee-next {
  right: 4px;
}

.topic-track {
  display: flex;
  width: max-content;
}

.topic-set {
  display: flex;
  gap: 14px;
  padding-right: 14px;
}

.topic-card {
  flex-shrink: 0;
  width: clamp(320px, 19vw, 370px);
  height: 148px;
  display: flex;
  overflow: hidden;
  color: #222;
  text-decoration: none;
  background: #fff;
  border: 1px solid #dce5ee;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.08);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.topic-card:hover,
.topic-card:focus-within {
  transform: translateY(-2px);
  border-color: #8dbff5;
  box-shadow: 0 8px 18px rgba(31, 41, 51, 0.14);
}

.topic-card-media {
  width: clamp(470px, 30vw, 560px);
  display: grid;
  /* サムネ領域60%でニコ動サムネ(16:9)がほぼぴったり収まる枠縦横比に。
     残り40%をテキスト領域に確保(約190〜224px、ラベル+日付+結果ボタンには十分) */
  grid-template-columns: minmax(280px, 60%) minmax(150px, 1fr);
  border-top: 3px solid #007bff;
  /* バナーカード(.topic-card-banner)の aspect-ratio: 5/2 と同じ計算結果になる
     高さ式。これで全カードがビューポート幅に応じて同じ高さで揃う。
     bannerの幅 clamp(370px, 24vw, 460px) × 2/5 = clamp(148px, 9.6vw, 184px) */
  height: clamp(148px, 9.6vw, 184px);
}

.topic-card-archive {
  border-top: 3px solid #ffc840;
}

.topic-card-short {
  border-top: 3px solid #ff5757;
}

.topic-card-sp {
  border-top-color: #007bff;
}

.topic-card-x {
  border-top: 3px solid #3d3430;
}

.topic-card-1000 {
  border-top: 3px solid #ff5757;
}

.topic-card-my9 {
  border-top: 3px solid #ffc840;
}

.topic-card-banner {
  position: relative;
  width: clamp(370px, 24vw, 460px);
  height: auto;
  aspect-ratio: 5 / 2;
  display: block;
  border: 1px solid #dce5ee;
  background: #fff;
}

.topic-card-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.topic-card-banner picture {
  display: block;
  width: 100%;
  height: 100%;
}

.topic-card-banner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s;
}

.topic-card-banner:hover img,
.topic-card-banner:focus img {
  transform: scale(1.02);
}

.topic-thumb-link {
  min-width: 0;
  height: 100%;
  display: block;
  background: #eef3f8;
  overflow: hidden;
  transition: opacity 0.2s;
}

.topic-thumb-link:hover {
  opacity: 0.88;
}

.topic-thumb-link img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.topic-card-body,
.topic-card-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  text-decoration: none;
  color: inherit;
}

.topic-label {
  color: #0066cc;
  font-size: 0.72rem;
  font-weight: 700;
}

.topic-card h3 {
  margin: 0;
  color: #222;
  font-size: 1rem;
  line-height: 1.35;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.topic-card p {
  flex: 1;
  margin: 0;
  color: #536170;
  font-size: 0.82rem;
  line-height: 1.55;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.topic-action {
  align-self: flex-start;
  margin-top: auto;
  padding: 5px 10px;
  color: #fff;
  background: #007bff;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
}

.topic-card-x .topic-action {
  background: #3d3430;
}

/* ========================================
   レスポンシブ対応
======================================== */
@media (max-width: 768px) {
  .featured-topics {
    width: calc(100vw - 24px);
  }

  .topic-marquee {
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 26px, #000 calc(100% - 26px), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 26px, #000 calc(100% - 26px), transparent 100%);
  }

  .topic-marquee-nav {
    width: 30px;
    height: 46px;
    font-size: 18px;
  }

  .topic-marquee-prev {
    left: 2px;
  }

  .topic-marquee-next {
    right: 2px;
  }

  .topic-set {
    gap: 10px;
    padding-right: 10px;
  }

  .topic-card {
    width: 300px;
    height: 136px;
  }

  .topic-card-banner {
    width: min(88vw, 360px);
    height: auto;
    aspect-ratio: 5 / 2;
  }

  .topic-card-media {
    width: min(88vw, 380px);
    grid-template-columns: 60% 1fr;
    /* モバイル時バナーの幅 min(88vw, 360px) × 2/5 = clamp(132px, 35.2vw, 144px) */
    height: clamp(132px, 35.2vw, 144px);
  }

  .topic-card-body,
  .topic-card-content {
    padding: 12px;
  }

  .topic-card h3 {
    font-size: 0.92rem;
  }

  .topic-card p {
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .topic-marquee {
    overflow-x: auto;
    -webkit-mask-image: none;
    mask-image: none;
  }
}
