@import url('../../theme.css');

/* ============================================================
   学習ページ共通ラッパー
   ============================================================ */
.lesson-page {
  background: var(--color-background);
  min-height: 100vh;
}

/* ============================================================
   ヒーローヘッダー
   ============================================================ */
.lesson-hero {
  background: linear-gradient(135deg, #060f1d 0%, #091e38 55%, #143d6b 100%);
  color: #fff;
  padding: var(--space-10) 0 var(--space-8);
  position: relative;
  overflow: hidden;
}
.lesson-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 10% 80%, rgba(123,163,204,.1) 0%, transparent 50%),
    radial-gradient(circle at 90% 10%, rgba(14,47,86,.4) 0%, transparent 50%);
  pointer-events: none;
}
.lesson-hero__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  position: relative;
  z-index: 1;
}
.lesson-hero__left { flex: 1; min-width: 0; }

/* チャプターピル */
.lesson-hero__chapter-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: rgba(123,163,204,.18);
  border: 1px solid rgba(123,163,204,.3);
  color: #7ba3cc;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-3);
}

/* タイトル */
.lesson-hero__title {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: var(--font-weight-bold);
  line-height: 1.3;
  color: #fff;
  margin-bottom: var(--space-3);
}

/* メタ情報 */
.lesson-hero__meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--font-size-sm);
  color: rgba(255,255,255,.5);
  margin-bottom: var(--space-4);
}
.lesson-hero__passed-badge {
  background: rgba(39,174,96,.2);
  border: 1px solid rgba(39,174,96,.35);
  color: #5dd18a;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

/* 進捗ドット */
.lesson-hero__dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.lesson-hero__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  transition: background var(--transition-fast);
}
.lesson-hero__dot--done {
  background: #7ba3cc;
}
.lesson-hero__dot--current {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,.2);
}

/* 進捗リング */
.lesson-hero__progress-ring {
  position: relative;
  width: 72px; height: 72px;
  flex-shrink: 0;
}
.lesson-hero__progress-ring svg {
  width: 100%; height: 100%;
}
.lesson-hero__progress-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: #fff;
}

/* ============================================================
   メインレイアウト（2カラム）
   ============================================================ */
.lesson-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--space-8);
  align-items: start;
  padding-block: var(--space-8) var(--space-16);
}

/* ============================================================
   メインコンテンツエリア
   ============================================================ */
.lesson-main {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-width: 0;
}

/* 本文 */
.lesson-content {
  padding: var(--space-10) var(--space-10);
  line-height: var(--line-height-relaxed);
  color: var(--color-text);
  font-size: var(--font-size-base);
  border-bottom: 1px solid var(--color-border);
}
.lesson-content h2 {
  font-family: var(--font-heading);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin-top: 2.5em;
  margin-bottom: .75em;
  padding: .5em .9em;
  background: rgba(14,47,86,.04);
  border-left: 4px solid var(--color-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.35;
}
.lesson-content h3 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin-top: 2em;
  margin-bottom: .5em;
  padding-bottom: .4em;
  border-bottom: 2px solid var(--color-border);
}
.lesson-content p { margin-bottom: 1.2em; }
.lesson-content ul, .lesson-content ol {
  margin: 0 0 1.2em 1.4em;
  display: flex;
  flex-direction: column;
  gap: .5em;
}
.lesson-content li { line-height: var(--line-height-relaxed); }
.lesson-content strong { font-weight: var(--font-weight-bold); }

/* ゲート（非会員） */
.lesson-gate {
  padding: var(--space-16) var(--space-10);
  text-align: center;
  background: linear-gradient(180deg, var(--color-surface) 0%, rgba(14,47,86,.03) 100%);
}
.lesson-gate__icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-4);
  line-height: 1;
}
.lesson-gate__title {
  font-family: var(--font-heading);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}
.lesson-gate__message {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-8);
  max-width: 400px;
  margin-inline: auto;
}
.lesson-gate__actions {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.lesson-gate__btn--primary { min-width: 180px; }
.lesson-gate__btn--outline { min-width: 120px; }

/* 前後ナビゲーション */
.lesson-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--color-border);
  border-top: 1px solid var(--color-border);
}
.lesson-nav__prev, .lesson-nav__next {
  background: var(--color-surface);
}
.lesson-nav__link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-5) var(--space-6);
  text-decoration: none;
  color: var(--color-text);
  transition: background var(--transition-fast);
  height: 100%;
}
.lesson-nav__link:hover { background: rgba(14,47,86,.04); }
.lesson-nav__link--prev { align-items: flex-start; }
.lesson-nav__link--next { align-items: flex-end; text-align: right; }
.lesson-nav__arrow {
  font-size: var(--font-size-lg);
  color: var(--color-primary);
  line-height: 1;
}
.lesson-nav__label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  letter-spacing: .05em;
  font-weight: var(--font-weight-bold);
}
.lesson-nav__ttl {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  line-height: 1.4;
}

/* ============================================================
   サイドバー
   ============================================================ */
.lesson-sidebar {
  position: sticky;
  top: calc(64px + var(--space-6));
}

.chapter-nav {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* ヘッダー部 */
.chapter-nav__head {
  background: linear-gradient(135deg, #091e38 0%, #0e2f56 100%);
  padding: var(--space-5) var(--space-5);
  color: #fff;
}
.chapter-nav__eyebrow {
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  letter-spacing: .15em;
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
  margin-bottom: var(--space-1);
}
.chapter-nav__name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: #fff;
  margin-bottom: var(--space-4);
  line-height: 1.4;
}

/* 進捗バー */
.chapter-nav__bar-wrap {
  height: 5px;
  background: rgba(255,255,255,.12);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-2);
}
.chapter-nav__bar {
  height: 100%;
  background: linear-gradient(90deg, #7ba3cc, #a8c4de);
  border-radius: var(--radius-full);
  transition: width .4s ease;
  min-width: 4px;
}
.chapter-nav__bar-label {
  font-size: var(--font-size-xs);
  color: rgba(255,255,255,.45);
}

/* リスト */
.chapter-nav__list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.chapter-nav__item {
  border-bottom: 1px solid var(--color-border);
}
.chapter-nav__item:last-child { border-bottom: none; }

.chapter-nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
  color: var(--color-text);
  font-size: var(--font-size-sm);
  transition: background var(--transition-fast);
  line-height: 1.4;
}
.chapter-nav__link:hover { background: rgba(14,47,86,.05); }

.chapter-nav__num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--color-background);
  border: 2px solid var(--color-border);
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.chapter-nav__link-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 現在の講義 */
.chapter-nav__item--current .chapter-nav__link { background: rgba(14,47,86,.06); }
.chapter-nav__item--current .chapter-nav__num {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.chapter-nav__item--current .chapter-nav__link-text {
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  white-space: normal;
}

/* 合格済み */
.chapter-nav__item--passed:not(.chapter-nav__item--current) .chapter-nav__num {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}
.chapter-nav__item--passed:not(.chapter-nav__item--current) .chapter-nav__link-text {
  color: var(--color-text-muted);
}

/* フッター */
.chapter-nav__footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-background);
}
.chapter-nav__all-link {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
}
.chapter-nav__all-link:hover { color: var(--color-primary); }

/* ============================================================
   アーカイブ ヒーロー追加要素
   ============================================================ */
.lessons-archive-hero__eyebrow {
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  margin-bottom: var(--space-2);
}
.lessons-archive-hero__stats {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-top: var(--space-6);
}
.lessons-archive-hero__stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lessons-archive-hero__stat-num {
  font-size: 1.75rem;
  font-weight: var(--font-weight-bold);
  color: #fff;
  line-height: 1;
}
.lessons-archive-hero__stat-label {
  font-size: var(--font-size-xs);
  color: rgba(255,255,255,.45);
  letter-spacing: .05em;
}
.lessons-archive-hero__stat-div {
  width: 1px;
  height: 32px;
  background: rgba(255,255,255,.15);
}

/* ============================================================
   アーカイブページ
   ============================================================ */
.lesson-chapter {
  margin-bottom: var(--space-8);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* チャプターヘッダー */
.lesson-chapter__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-8);
  background: linear-gradient(135deg, #091e38 0%, #0e2f56 100%);
  position: relative;
  overflow: hidden;
}
.lesson-chapter__deco-num {
  position: absolute;
  right: var(--space-5);
  top: 50%;
  transform: translateY(-50%);
  font-size: 5rem;
  font-weight: var(--font-weight-bold);
  color: rgba(255,255,255,.06);
  line-height: 1;
  pointer-events: none;
  font-family: var(--font-heading);
  letter-spacing: -.02em;
}
.lesson-chapter__head-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  position: relative;
  z-index: 1;
}
.lesson-chapter__eyebrow {
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  letter-spacing: .15em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  margin-bottom: 3px;
}
.lesson-chapter__title {
  font-family: var(--font-heading);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: #fff;
  line-height: 1.3;
}
.lesson-chapter__progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.lesson-chapter__progress-text {
  font-size: var(--font-size-xs);
  color: rgba(255,255,255,.45);
  white-space: nowrap;
}
.lesson-chapter__progress-bar-wrap {
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,.12);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.lesson-chapter__progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #7ba3cc, #a8c4de);
  border-radius: var(--radius-full);
  transition: width .4s ease;
  min-width: 4px;
}

/* レッスンリスト */
.lesson-list {
  list-style: none;
  padding: var(--space-2) 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
}
.lesson-list__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-fast);
}
.lesson-list__item:last-child { border-bottom: none; }
.lesson-list__item:hover { background: rgba(14,47,86,.04); }

.lesson-list__num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--color-background);
  border: 2px solid var(--color-border);
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.lesson-list__item--passed .lesson-list__num {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.lesson-list__link {
  flex: 1;
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  line-height: var(--line-height-snug);
  font-size: var(--font-size-sm);
}
.lesson-list__link:hover { color: var(--color-primary); }
.lesson-list__item--passed .lesson-list__link { color: var(--color-text-muted); }
.lesson-list__link--locked { color: var(--color-text-muted); }
.lesson-list__link--locked:hover { color: var(--color-text-muted); }

.lesson-list__title {
  flex: 1;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}
.lesson-list__title--locked { color: var(--color-text-muted); }

.lesson-list__arrow {
  color: var(--color-primary-light);
  opacity: .7;
  flex-shrink: 0;
}
.lesson-list__lock {
  color: var(--color-text-muted);
  opacity: .45;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* 未ログイン CTA */
.lesson-chapter__cta {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: center;
  background: var(--color-background);
}

.lesson-empty { color: var(--color-text-muted); }

/* ============================================================
   レスポンシブ
   ============================================================ */
@media (max-width: 900px) {
  .lesson-layout {
    grid-template-columns: 1fr;
  }
  .lesson-sidebar {
    position: static;
    order: -1;
  }
  .lesson-content { padding: var(--space-6); }
  .lesson-quiz { padding: var(--space-6); }
  .lesson-hero__progress-ring { display: none; }
}
@media (max-width: 600px) {
  .lesson-nav { grid-template-columns: 1fr; }
  .lesson-nav__next { border-top: 1px solid var(--color-border); }
}
