/* ============================================================
   styles.extra.css — 補遺層
   ------------------------------------------------------------
   為什麼獨立一個檔案：
   本機就地覆寫既有檔會失敗（ReplaceFileW EIO），故 styles.css
   建立後無法再改；此檔補上 js/render.js 實際會產生、而
   styles.css 未涵蓋的 class（summary-card / section-btn /
   book-* / badge-* / stats-* / sum-* / diff-chip / btn-fav 等）。

   index.html 的載入順序（固定）：
     styles.css  →  styles.extra.css
   （在 <link rel="stylesheet" href="styles.css"> 之後加一行
     <link rel="stylesheet" href="styles.extra.css">）

   全部只用到 styles.css 已定義的變數，深色／淺色皆自動跟隨。
   純 CSS：無 @import、無外部 URL、無圖片。
   ============================================================ */

/* ---------- 分數／正確率：動態著色 ---------- */
.good { color: var(--ok) !important; font-weight: 700; }
.bad  { color: var(--bad) !important; font-weight: 700; }
.warn { color: var(--warn) !important; font-weight: 700; }

/* ---------- 收藏／練習按鈕的選中狀態 ---------- */
.btn-fav.active,
.q-fav.active {
  color: #22190a;
  background: var(--accent);
  border-color: transparent;
}
body.light .btn-fav.active,
body.light .q-fav.active { color: #fff; }
.btn-fav { white-space: nowrap; }

.q-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

/* ---------- 題目卡補充（render.js 產生） ---------- */
.q-subject,
.q-id,
.q-diff {
  display: inline-flex;
  align-items: center;
  padding: .14em .55em;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.q-subject { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 40%, var(--line)); }
.q-id { font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace; }
.q-diff { letter-spacing: .06em; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }

.q-empty {
  margin: 0;
  padding: 10px 12px;
  color: var(--muted);
  font-style: italic;
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.q-explain-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: .5em;
}
.q-verdict {
  display: inline-flex;
  align-items: center;
  padding: .16em .7em;
  font-size: .84rem;
  font-weight: 800;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.q-verdict.ok {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  border-color: color-mix(in srgb, var(--ok) 55%, var(--line));
}
.q-verdict.no {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 16%, transparent);
  border-color: color-mix(in srgb, var(--bad) 55%, var(--line));
}
.q-answer {
  font-size: .84rem;
  font-weight: 700;
  color: var(--text);
}
.q-explanation { margin: 0 0 .5em; line-height: 1.7; }
.q-source { font-size: .8rem; color: var(--muted); }

/* ---------- 考試資訊卡（summaryCard） ---------- */
.summary-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.sum-title { font-size: 1rem; }
.sum-facts {
  font-size: .86rem;
  font-weight: 700;
  color: var(--accent-2);
}
.sum-desc { font-size: .88rem; color: var(--muted); }
.sum-block { display: flex; flex-direction: column; gap: 6px; }
.sum-h {
  font-size: .82rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: none;
}

.sum-list,
.sum-plan {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.sum-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  font-size: .86rem;
}
.sum-label { color: var(--text); }
.sum-count { color: var(--accent); font-variant-numeric: tabular-nums; }
.sum-bar {
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.sum-bar-in {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: inherit;
}

.sum-diff { display: flex; flex-wrap: wrap; gap: 6px; }
.diff-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: .2em .65em;
  font-size: .8rem;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.diff-stars { color: var(--accent); letter-spacing: .08em; }
.diff-count { color: var(--muted); font-variant-numeric: tabular-nums; }

.plan-item,
.plan-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 10px;
  font-size: .86rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.plan-total {
  margin-top: 2px;
  font-weight: 800;
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.plan-label { color: var(--text); }
.plan-total .plan-label { color: var(--accent); }
.plan-count { font-variant-numeric: tabular-nums; }

.sum-empty,
.section-empty,
.book-empty,
.badge-empty,
.q-empty {
  margin: 0;
  padding: 8px 10px;
  font-size: .86rem;
  color: var(--muted);
  font-style: italic;
}
.summary-empty { opacity: .8; }

/* ---------- 分區練習按鈕（sectionButtons） ---------- */
.section-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.section-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: .5em .95em;
  font: inherit;
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
}
.section-btn:hover {
  transform: translateY(-1px);
  background: var(--card);
  border-color: color-mix(in srgb, var(--accent-2) 55%, var(--line));
}
.section-name { white-space: nowrap; }
.section-count {
  padding: .05em .45em;
  font-size: .76rem;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 錯題本列（bookItem） ---------- */
.book-main { flex: 1 1 60%; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.book-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: .78rem; }
.book-section,
.book-subject,
.book-diff,
.book-id {
  display: inline-flex;
  align-items: center;
  padding: .12em .5em;
  color: var(--muted);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.book-section { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 38%, var(--line)); }
.book-diff { color: var(--accent); letter-spacing: .06em; }
.book-id { font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace; }
.book-stem { margin: 0; color: var(--text); font-size: .92rem; line-height: 1.6; }
.book-fav { align-self: flex-start; font-size: .78rem; font-weight: 700; color: var(--accent); }
.book-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.btn-remove { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: transparent; }
.btn-drill { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 45%, var(--line)); background: transparent; }

/* ---------- 徽章牆（badgeWall） ---------- */
.badge-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.badge-emoji { font-size: 1.6rem; line-height: 1; }
.badge-name { font-weight: 700; }
.badge-desc { font-weight: 400; color: var(--muted); font-size: .78rem; }
.badge-date { font-size: .72rem; color: var(--accent-2); }
.badge-lock { font-size: .74rem; color: var(--muted); }
.badge-unlocked {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 14%, var(--card)), var(--card));
  opacity: 1;
  filter: none;
}
.badge-unlocked .badge-emoji { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 65%, transparent)); }

/* ---------- 練習紀錄表（statsTable） ---------- */
.stats-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.stats-table-wrap .stats-table { min-width: 640px; }
.stats-acc { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.stats-empty-row td {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

/* ---------- 列印：補遺層同樣只留題目內容 ---------- */
@media print {
  .btn-fav,
  .book-actions,
  .section-btns,
  .badge-wall,
  .stats-table-wrap,
  .q-actions { display: none !important; }

  .summary-card,
  .book-item,
  .badge,
  .plan-item,
  .plan-total,
  .q-explain-head,
  .diff-chip {
    background: #fff !important;
    color: #000 !important;
    border-color: #999 !important;
    box-shadow: none !important;
  }
  .sum-bar { border-color: #999 !important; }
  .sum-bar-in { background: #666 !important; }
  .q-verdict.ok,
  .q-verdict.no { color: #000 !important; background: #eee !important; border-color: #999 !important; }
  .q-subject, .q-topic, .q-diff, .q-id,
  .book-section, .book-subject, .book-diff, .book-id { color: #000 !important; background: #eee !important; border-color: #999 !important; }
}

/* ==========================================================================
 * styles.extra.css — 追加層
 * 今日目標環 + 打卡熱力格（由 js/app.js 的 renderToday() / calendarSection() 產生）
 * 使用 styles.css 已定義的變數：--card --line --text --muted --accent --ok
 * ========================================================================== */

/* ---------- 首頁：今日目標面板 ---------- */
#today-panel { margin: 0 0 18px; }

.today-goal {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.today-goal.is-done {
  border-color: var(--ok);
  box-shadow: inset 0 0 0 1px var(--ok), var(--shadow);
}

.today-ring {
  width: 92px;
  height: 92px;
  flex: 0 0 auto;
}

.today-ring-bg {
  fill: none;
  stroke: var(--line);
  stroke-width: 10;
}

.today-ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset .5s ease, stroke .3s ease;
}

.today-goal.is-done .today-ring-fg { stroke: var(--ok); }

.today-goal-info {
  flex: 1 1 200px;
  min-width: 0;
}

.today-goal-title { font-weight: 800; font-size: .95rem; }
.today-goal-num   { font-size: 1.6rem; font-weight: 800; line-height: 1.25; }
.today-goal-hint  { font-size: .84rem; color: var(--muted); margin-bottom: 8px; }
.today-goal-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 打卡熱力格 ---------- */
.today-cal { flex: 1 1 100%; margin-top: 4px; }

.today-cal-cells {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  max-width: 280px;
}

.today-cal-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: .66rem;
  color: var(--muted);
  background: rgba(159, 176, 208, .14);
}

.today-cal-cell.lv1 { background: rgba(76, 201, 240, .28); }
.today-cal-cell.lv2 { background: rgba(76, 201, 240, .50); color: #06131f; }
.today-cal-cell.lv3 { background: rgba(76, 201, 240, .76); color: #06131f; font-weight: 700; }
.today-cal-cell.lv4 { background: var(--ok); color: #04140d; font-weight: 800; }
.today-cal-cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }

.today-cal-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: .74rem;
  color: var(--muted);
}

.today-cal-sum { flex: 1 1 auto; }

.today-cal-key {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: rgba(159, 176, 208, .14);
}

.today-cal-key.lv1 { background: rgba(76, 201, 240, .28); }
.today-cal-key.lv2 { background: rgba(76, 201, 240, .50); }
.today-cal-key.lv3 { background: rgba(76, 201, 240, .76); }
.today-cal-key.lv4 { background: var(--ok); }

/* ---------- 統計頁 ---------- */
.today-cal-section .today-cal-cells { max-width: 420px; }

/* ---------- 列印：熱力格改為黑白可辨 ---------- */
@media print {
  .today-goal,
  .today-cal-cell,
  .today-cal-key {
    box-shadow: none !important;
    background: #fff !important;
    border: 1px solid #999 !important;
    color: #000 !important;
  }
  .today-cal-cell.lv1,
  .today-cal-cell.lv2,
  .today-cal-cell.lv3,
  .today-cal-cell.lv4 { background: #ddd !important; }
  .today-ring-bg { stroke: #999 !important; }
  .today-ring-fg { stroke: #000 !important; }
}
