/*
 * お題ページと下層ページ（利用規約、プライバシーポリシー、お問い合わせ）の共通スタイル。
 * デザイントークン、リセット、ヘッダー、パンくずは common.css にあるため、
 * 各ページは必ず common.css を先に読み込むこと。
 */

/* common.css の基本値の上書き */
body {
  line-height: 1.9;
}

.container {
  max-width: 800px;
}

.header .container {
  max-width: 1200px;
}

/* Topic Header */
.topic-header {
  padding: 24px 0 40px;
}

.topic-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.5;
}

.badge svg {
  width: 14px;
  height: 14px;
}

.badge-type {
  background: var(--primary);
  color: white;
}

/* 難易度の色はアプリ (src/contexts/ThemeContext.tsx の difficulty1〜5) と揃える */
.badge-difficulty {
  color: white;
}

.badge-difficulty-1 {
  background: #06b6d4;
}

.badge-difficulty-2 {
  background: #84cc16;
}

.badge-difficulty-3 {
  background: #f59e0b;
}

.badge-difficulty-4 {
  background: #f97316;
}

.badge-difficulty-5 {
  background: #ef4444;
}

.badge-genre {
  /* 一覧は白カード上、詳細はグレーのページ背景上に置かれる。
     ページ背景と同じ色だと詳細でピルが地に同化するため、白地に枠線で統一する */
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.topic-title {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 20px;
}

/* お題のイメージ画像。Topic.imageUrl（16:9 で生成されている）をそのまま表示する。
   height: auto は必須。img の height 属性が presentational hint として効くため、
   これが無いと高さが属性値で固定され aspect-ratio が無視される */
.topic-image {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  margin-bottom: 24px;
  background: var(--border);
}

.topic-lead {
  font-size: 1.05rem;
  color: var(--text-secondary);
}

/* Content Blocks */
.topic-section {
  background: var(--surface);
  border-radius: 8px;
  padding: 32px;
  margin-bottom: 24px;
}

.topic-section h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topic-section h2 svg {
  width: 22px;
  height: 22px;
  stroke: var(--primary);
  flex-shrink: 0;
}

.section-note {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.topic-section p + p {
  margin-top: 16px;
}

/* 課題文（sourceText を持つお題でのみ使う） */
.source-text {
  background: var(--background);
  border-radius: 4px;
  padding: 24px;
  font-size: 0.95rem;
}

/* Hints */
.hint-list {
  list-style: none;
  counter-reset: hint;
}

.hint-item {
  display: flex;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.hint-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.hint-number {
  counter-increment: hint;
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}

.hint-number::before {
  content: counter(hint);
}

.hint-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.hint-description {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

/* Rubric Table */
.rubric-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.rubric-table th,
.rubric-table td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
}

.rubric-table th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.rubric-table td:first-child {
  font-weight: 600;
  white-space: nowrap;
}

.rubric-table .rubric-point {
  text-align: right;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.rubric-table tfoot td {
  border-bottom: none;
  font-weight: 700;
  padding-top: 16px;
}

/* CTA */
.topic-cta {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 8px;
  padding: 48px 32px;
  text-align: center;
  color: white;
  margin-bottom: 24px;
}

.topic-cta h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.topic-cta p {
  opacity: 0.95;
  margin-bottom: 32px;
  font-size: 0.98rem;
}

.cta-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.store-badge {
  display: inline-flex;
  align-items: center;
  transition: transform 0.2s;
}

.store-badge:hover {
  transform: translateY(-2px);
}

.store-badge img {
  height: 44px;
  width: auto;
}

/* Related Topics */
.related-list {
  display: grid;
  gap: 12px;
}

.related-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: var(--background);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition:
    transform 0.2s,
    background 0.2s;
}

.related-card:hover {
  transform: translateX(4px);
  background: #eef2f6;
}

.related-card-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.related-card-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.related-card svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-secondary);
  flex-shrink: 0;
}

/* Topic List (お題一覧ページ) */
.list-header {
  padding: 24px 0 40px;
}

.list-title {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 16px;
}

.list-lead {
  font-size: 1.05rem;
  color: var(--text-secondary);
}

.list-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.topic-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* アプリのお題カードと同じく、上に画像、下に説明を積む */
.topic-list-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.topic-list-card-image {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: var(--border);
}

.topic-list-card-body {
  padding: 20px;
  min-width: 0;
  flex: 1;
}

.topic-list-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.07);
}

.topic-list-card .topic-badges {
  margin-bottom: 12px;
}

/* カードの高さを揃えるため行数を制限する */
.topic-list-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.topic-list-card-excerpt {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.8;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Footer */
.footer {
  background: var(--text);
  color: white;
  padding: 48px 0 24px;
  margin-top: 60px;
}

.footer .container {
  max-width: 1200px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-bottom: 32px;
}

.footer-links a {
  color: white;
  text-decoration: none;
  font-size: 0.85rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.footer-links a:hover {
  opacity: 1;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 24px;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.6;
}

/* Responsive */
@media (max-width: 640px) {
  body {
    line-height: 1.8;
  }

  .topic-title {
    font-size: 1.5rem;
  }

  .topic-section {
    padding: 24px 20px;
  }

  .topic-list {
    grid-template-columns: 1fr;
  }

  .topic-cta {
    padding: 36px 20px;
  }

  .cta-buttons {
    flex-direction: column;
    align-items: center;
  }

  .rubric-table th,
  .rubric-table td {
    padding: 12px 6px;
  }

  .related-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .related-card svg {
    display: none;
  }
}
