/**
 * /courses/ コース一覧 — デザインラフ準拠スキン (issue #126)。
 *
 * 「コースカタログ」: 上部カテゴリ フィルタタブ + ソート(select) + 多カラム
 * カードグリッド + 末尾スキル診断 CTA バンド。/lessons/ (#122) / /quizzes/
 * (#120) 再設計と同じ idiom (breadcrumb / H1+lead / .filter-tab 流用 /
 * card grid / data-zone="free" ラッパ) を踏襲する。
 *
 * 全クラスは `.wf-courses__*` 接頭辞。既存 .filter-tab / .badge / .btn-primary
 * は流用 (再定義しない。anchor 化に伴う最小補正のみ)。カテゴリ色のみインライン
 * 注入。それ以外は design-tokens.css のトークン (zone palette は
 * <div class="wf-courses" data-zone="free"> で適用)。
 */

/* ---- 0. wrapper + container --------------------------------------- */
.wf-courses {
  background: var(--color-bg);
}
.wf-courses__container {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-5) var(--space-10);
}

/* ---- 1. breadcrumb ------------------------------------------------ */
.wf-courses__breadcrumb {
  margin-bottom: var(--space-5);
  font-size: var(--text-caption);
}
.wf-courses__breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--color-text-secondary);
}
.wf-courses__breadcrumb-item:not(:last-child)::after {
  content: "›";
  margin-left: var(--space-2);
  color: var(--color-text-muted);
}
.wf-courses__breadcrumb a {
  color: var(--color-accent);
  text-decoration: none;
}
.wf-courses__breadcrumb a:hover {
  text-decoration: underline;
}
.wf-courses__breadcrumb a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---- 2. page header ----------------------------------------------- */
.wf-courses__header {
  margin-bottom: var(--space-6);
}
.wf-courses__title {
  font-size: var(--text-h1);
  font-weight: var(--weight-bold);
  line-height: 1.3;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-2);
}
.wf-courses__lead {
  font-size: var(--text-body);
  line-height: 1.75;
  color: var(--color-text-secondary);
  margin: 0;
}

/* ---- 3. toolbar: category tabs + sort ----------------------------- */
.wf-courses__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.wf-courses__filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
/* .filter-tab / .filter-tab--active は anchor。装飾を整える。 */
.wf-courses__filter-tab {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
/* active タブ (背景=accent / 文字=#fff) は hover 上書きから除外。除外しないと
   accent 背景上に accent 文字 = 不可視になる (lessons / quizzes 同方針)。 */
a.wf-courses__filter-tab.filter-tab:not(.filter-tab--active):hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
/* 堅牢性: active タブのピル形状を base に依存せず補完。 */
.wf-courses__filter-tab.filter-tab--active {
  border: 1px solid var(--color-accent);
  border-radius: var(--zone-radius-button, var(--radius-pill));
}

/* ソート (select) */
.wf-courses__sort {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.wf-courses__sort-label {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
}
.wf-courses__sort-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  padding: 8px 34px 8px 14px;
  cursor: pointer;
  /* 内蔵キャレット (背景 svg) — ::after は select 内描画不可のため。 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.wf-courses__sort-select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-bg);
}
.wf-courses__sort-go {
  margin-left: var(--space-2);
}

/* ---- 4. card grid (5→4→3→2→1) ------------------------------------ */
.wf-courses__grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-5);
}
.wf-courses__grid-item {
  display: flex;
}
.wf-courses__card {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--zone-radius-card, var(--radius-xl));
  overflow: hidden;
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}
.wf-courses__card:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-3px);
  border-color: var(--color-accent-light);
}
.wf-courses__card:focus-within {
  box-shadow: var(--shadow-card);
  border-color: var(--color-accent);
}

/* サムネイル領域 (カテゴリ淡色背景はインライン) */
.wf-courses__thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  text-decoration: none;
}
.wf-courses__thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.wf-courses__thumb-icon {
  font-size: 2rem;
  font-weight: var(--weight-bold);
  opacity: 0.55;
}
/* カテゴリバッジ (top-left, 色はインライン) */
.wf-courses__cat-badge {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  display: inline-flex;
  align-items: center;
  font-size: var(--text-tiny);
  font-weight: var(--weight-semibold);
  line-height: 1;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  max-width: calc(100% - 56px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* ブックマーク (top-right) */
.wf-courses__bookmark {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-circle);
  background: rgba(255, 255, 255, 0.92);
  color: var(--color-text-secondary);
}

.wf-courses__card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  flex: 1;
}
.wf-courses__card-title {
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  line-height: 1.45;
  color: var(--color-text-primary);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.wf-courses__card-title a {
  color: inherit;
  text-decoration: none;
}
.wf-courses__card-title a:hover {
  color: var(--color-accent);
}
.wf-courses__card-title a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.wf-courses__card-desc {
  font-size: var(--text-caption);
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 統計行 (講座 / 問 / ケース) */
.wf-courses__stats {
  list-style: none;
  margin: 0;
  padding: var(--space-2) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-small);
  color: var(--color-text-secondary);
}
.wf-courses__stat {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.wf-courses__stat-label {
  color: var(--color-text-muted);
}
.wf-courses__stat-num {
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}

/* 学習時間の目安 */
.wf-courses__duration {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-size: var(--text-small);
  color: var(--color-text-secondary);
}
.wf-courses__duration-icon {
  color: var(--color-text-muted);
}

/* コース詳細を見る (カテゴリ色アウトライン、--cta-* はインライン) */
.wf-courses__card-cta {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 14px;
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  color: var(--cta-accent, var(--color-accent));
  background: transparent;
  border: 1px solid var(--cta-accent, var(--color-accent));
  border-radius: var(--zone-radius-button, var(--radius-md));
  transition: background 0.15s, color 0.15s;
}
.wf-courses__card-cta:hover {
  background: var(--cta-bg, var(--color-accent-bg));
}
.wf-courses__card-cta:focus-visible {
  outline: 2px solid var(--cta-accent, var(--color-accent));
  outline-offset: 2px;
}

/* ---- pagination --------------------------------------------------- */
.wf-courses__pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-8);
}
.wf-courses__pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 8px 14px;
  font-size: var(--text-caption);
  color: var(--color-text-primary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  text-decoration: none;
}
.wf-courses__pagination a.page-numbers:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.wf-courses__pagination .page-numbers.current {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--zone-accent-on-accent, #fff);
  font-weight: var(--weight-semibold);
}

.wf-courses__empty {
  text-align: center;
  font-size: var(--text-body);
  color: var(--color-text-secondary);
  padding: var(--space-10) var(--space-4);
}
.wf-courses__empty a {
  color: var(--color-accent);
}
.wf-courses__empty a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---- 6. スキル診断 CTA バンド ------------------------------------- */
.wf-courses__cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  margin-top: var(--space-10);
  padding: clamp(20px, 3vw, 32px);
  background: var(--color-accent-bg);
  border: 1px solid var(--color-accent-light);
  border-radius: var(--zone-radius-card, var(--radius-xl));
}
.wf-courses__cta-body {
  flex: 1;
  min-width: 0;
}
.wf-courses__cta-title {
  font-size: var(--text-h2);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  margin: 0 0 var(--space-2);
}
.wf-courses__cta-sub {
  font-size: var(--text-body);
  line-height: 1.7;
  color: var(--color-text-secondary);
  margin: 0;
}
.wf-courses__cta-btn {
  flex: none;
  white-space: nowrap;
}

/* ---- responsive --------------------------------------------------- */
@media (max-width: 1280px) {
  .wf-courses__grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1024px) {
  .wf-courses__grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .wf-courses__grid { grid-template-columns: repeat(2, 1fr); }
  .wf-courses__toolbar { align-items: stretch; }
}
@media (max-width: 520px) {
  .wf-courses__grid { grid-template-columns: 1fr; }
  .wf-courses__cta {
    flex-direction: column;
    text-align: center;
    align-items: stretch;
  }
  .wf-courses__cta-btn {
    width: 100%;
    text-align: center;
  }
}
