/* eng-convo — English Conversation Learning (spec §29/§30/§33) */
:root {
  --navy: #1b2a4a;         /* 主要:專業學習介面 */
  --navy-dark: #131f38;
  --blue: #2563eb;         /* Speaker A / 主要動作 */
  --blue-soft: #eff4ff;
  --orange: #ea6a2a;       /* Speaker B / 次要 speaker */
  --orange-soft: #fff3ec;
  --green: #16a34a;        /* 難度 / 學習狀態 */
  --green-soft: #eaf7ef;
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1f2937;
  --dim: #6b7280;
  --border: #e5e7eb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.7; min-height: 100vh;
}
a { color: var(--blue); }
button { font-family: inherit; }

/* ── 頂部導航 (spec §3) ── */
.site-nav {
  background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.site-nav .nav-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px; height: 56px;
  display: flex; align-items: center; gap: 24px;
}
.site-nav .brand { font-weight: 800; font-size: 17px; letter-spacing: .3px; color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.site-nav .brand .mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--blue), #60a5fa); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.site-nav nav { display: flex; gap: 4px; }
.site-nav nav a { color: rgba(255,255,255,.8); text-decoration: none; padding: 7px 13px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.site-nav nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.site-nav nav a.active { background: rgba(255,255,255,.18); color: #fff; }
.site-nav .nav-search { margin-left: auto; }
.site-nav .nav-search input {
  border: 0; border-radius: 8px; padding: 7px 12px; width: 180px; font-size: 13px;
  background: rgba(255,255,255,.14); color: #fff; outline: none;
}
.site-nav .nav-search input::placeholder { color: rgba(255,255,255,.55); }

/* ── Hero (spec §4) ── */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 60%, #24355e 100%);
  color: #fff; text-align: center; padding: 64px 20px 56px;
}
.hero h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 800; line-height: 1.25; }
.hero h1 em { font-style: normal; color: #7db4ff; }
.hero .sub { font-size: 18px; color: rgba(255,255,255,.75); margin: 10px 0 26px; letter-spacing: 1px; }
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .btn {
  padding: 12px 26px; border-radius: 10px; font-size: 15px; font-weight: 700; text-decoration: none;
  border: 0; cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.hero .btn-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,.4); }
.hero .btn-ghost { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.hero .btn:hover { transform: translateY(-1px); }
.hero .features { margin-top: 34px; display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; color: rgba(255,255,255,.85); font-size: 14px; }
.hero .features span { display: flex; align-items: center; gap: 6px; }

/* ── 通用容器 ── */
.container { max-width: 1080px; margin: 0 auto; padding: 32px 20px 80px; }
.section-title { font-size: 22px; font-weight: 800; color: var(--navy); margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }
.section-title .bar { width: 5px; height: 22px; border-radius: 3px; background: var(--blue); }

/* ── 過濾器 (spec §5) ── */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; align-items: center; }
.filters .fgroup { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 20px; background: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--dim);
}
.filter-btn:hover { border-color: var(--blue); color: var(--blue); }
.filter-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.filters input[type="search"] {
  flex: 1; min-width: 180px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 14px; background: #fff;
}

/* ── 課程卡 (spec §5) ── */
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.ep-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 20px;
  text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 8px;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.ep-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(27,42,74,.1); border-color: #c7d4ef; }
.ep-card .ep-no { font-size: 12px; font-weight: 800; color: var(--blue); letter-spacing: 1px; }
.ep-card h3 { font-size: 18px; font-weight: 700; color: var(--navy); line-height: 1.35; }
.ep-card .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.level-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 14px; font-size: 12px; font-weight: 700; }
.level-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.level-badge.elementary { background: var(--green-soft); color: var(--green); }
.level-badge.intermediate { background: #fff4e0; color: #b45309; }
.level-badge.advanced { background: #fdeaea; color: #b91c1c; }
.ep-card .cats { font-size: 12px; color: var(--dim); }
.ep-card .open { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--blue); }
.ep-card.pending { opacity: .6; }
.ep-card.pending:hover { transform: none; box-shadow: none; }
/* 狀態燈:已生成綠燈 / 未生成灰燈(唔靠顏色 alone,配文字) */
.status-light { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-light.green { background: var(--green); box-shadow: 0 0 6px rgba(22,163,74,.5); }
.status-light.gray { background: #cbd5e1; }

/* ── 課程頁 (spec §7/§8) ── */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); text-decoration: none; font-size: 14px; margin-bottom: 18px; }
.back:hover { color: var(--blue); }
.lesson-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.lesson-head h1 { font-size: clamp(28px, 4vw, 38px); font-weight: 800; color: var(--navy); line-height: 1.25; }
.lesson-head .ep-no { font-size: 14px; font-weight: 800; color: var(--blue); letter-spacing: 2px; }
.lesson-actions { display: flex; gap: 10px; margin: 16px 0 24px; flex-wrap: wrap; }
.lesson-actions .btn {
  padding: 10px 20px; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer; border: 1px solid var(--border); background: #fff;
}
.lesson-actions .btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.lesson-actions .btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.lesson-actions .btn:hover { filter: brightness(.96); }

/* 對話 (spec §8/§9/§10) */
.dialogue { display: flex; flex-direction: column; gap: 14px; margin-bottom: 34px; }
.dialogue-turn {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px;
  display: flex; gap: 14px; transition: border-color .15s, box-shadow .15s;
}
.dialogue-turn.playing { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.dialogue-turn.speaker-a { border-left: 4px solid var(--blue); }
.dialogue-turn.speaker-b { border-left: 4px solid var(--orange); }
.speaker-label {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #fff;
}
.speaker-a .speaker-label { background: var(--blue); }
.speaker-b .speaker-label { background: var(--orange); }
.dialogue-content { flex: 1; min-width: 0; }
.dialogue-content .english { font-size: 21px; font-weight: 600; line-height: 1.5; color: var(--ink); }
.dialogue-content .translation { font-size: 17px; color: #4b5563; margin-top: 4px; }
.dialogue-content .translation.hidden { display: none; }
.dialogue-content .chinese-only .english { display: none; }
.audio-controls { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.audio-controls .btn-mini {
  padding: 6px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--border); background: #fafafa; color: var(--ink); display: inline-flex; align-items: center; gap: 5px;
}
.audio-controls .btn-mini:hover { border-color: var(--blue); color: var(--blue); }
.audio-controls .btn-mini.play { border-color: #c7d4ef; color: var(--blue); }

/* 詞彙 (spec §14/§15) */
.vocab-section { margin-bottom: 34px; }
.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.vocab-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; break-inside: avoid; }
.vocab-card .term { font-size: 20px; font-weight: 800; color: var(--navy); }
.vocab-card .pos { font-size: 12px; color: var(--dim); font-style: italic; margin-top: -2px; }
.vocab-card .def { font-size: 15px; color: var(--ink); margin-top: 8px; }
.vocab-card .cn { font-size: 14px; color: #4b5563; margin-top: 2px; }
.vocab-card .listen { margin-top: 10px; }
.vocab-section.supp .vocab-card { border-left: 4px solid var(--green); }
.vocab-section.supp .section-title .bar { background: var(--green); }

/* 練習模式 (spec §12) */
.practice-box {
  background: linear-gradient(135deg, #f0f6ff, #fafbff); border: 1px solid #c7d4ef; border-radius: 14px;
  padding: 26px; margin-bottom: 34px; text-align: center;
}
.practice-box h3 { color: var(--navy); font-size: 18px; margin-bottom: 6px; }
.practice-box .steps { color: var(--dim); font-size: 13px; margin-bottom: 16px; letter-spacing: 1px; }
.practice-box .big-listen { padding: 12px 30px; border-radius: 12px; border: 0; background: var(--blue); color: #fff; font-size: 16px; font-weight: 800; cursor: pointer; }
.practice-box .speak-btn { padding: 14px 34px; border-radius: 30px; border: 0; background: var(--green); color: #fff; font-size: 16px; font-weight: 800; cursor: pointer; }
.practice-box .note { margin-top: 14px; font-size: 12px; color: var(--dim); }

/* 進度條 (spec §23, optional) */
.progress-strip { display: inline-flex; gap: 3px; }
.progress-strip i { width: 14px; height: 6px; border-radius: 3px; background: #e5e7eb; display: inline-block; }
.progress-strip i.done { background: var(--green); }

/* ── 列印 (spec §18) ── */
.print-sheet { display: none; }
@media print {
  .site-nav, .hero, .lesson-actions, .audio-controls, .practice-box, .back, .nav-search, .filters, .site-footer, .print-button { display: none !important; }
  body { background: #fff; color: #000; }
  .container { max-width: none; padding: 0; }
  .lesson-head h1 { font-size: 26pt; }
  .dialogue { gap: 10px; }
  .dialogue-turn { border: 1px solid #ccc; border-left-width: 4px; border-radius: 6px; break-inside: avoid; padding: 10px 14px; }
  .dialogue-content .english { font-size: 14pt; }
  .dialogue-content .translation { font-size: 12.5pt; color: #333; }
  .vocab-card { border: 1px solid #ccc; break-inside: avoid; }
  .vocab-card .term { font-size: 13pt; }
  .vocab-card .def, .vocab-card .cn { font-size: 11pt; }
  .print-head { display: block !important; text-align: center; margin-bottom: 18px; }
  .print-head h2 { font-size: 15pt; letter-spacing: 3px; color: #000; }
  .print-head p { font-size: 11pt; }
  .print-hide { display: none !important; }
}

/* ── 頁腳 ── */
.site-footer { background: var(--navy); color: rgba(255,255,255,.7); text-align: center; padding: 22px; font-size: 13px; }
.site-footer a { color: #7db4ff; }

/* ── 響應式 (spec §29) ── */
@media (max-width: 720px) {
  .site-nav nav a { padding: 6px 9px; font-size: 13px; }
  .site-nav nav a span { display: none; }   /* 只留 icon */
  .site-nav .nav-search input { width: 120px; }
  .dialogue-content .english { font-size: 19px; }
  .dialogue-content .translation { font-size: 16px; }
  .ep-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .site-nav .nav-inner { gap: 10px; }
  .dialogue-turn { flex-direction: row; }
}
