/* ==========================================================================
   國中數學三年課程地圖 — 共用標準範本樣式表 (Unit Standard Style v1.0)
   適用於：筆電、平板、教室大型觸控黑板 (RWD + clamp() 保底大字級)
   ========================================================================== */
:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #475569;
  --border: #e2e8f0;
  --accent-1: #0284c7;
  --accent-2: #059669;
  --accent-3: #d97706;
  --accent-ex: #4f46e5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--ink);
  font-size: clamp(15px, 1.15vw, 18px);
  line-height: 1.7;
  padding-bottom: 92px;
}

.wrap {
  max-width: 1340px;
  margin: 0 auto;
  padding: 18px 20px;
}

.unit-header {
  background: linear-gradient(135deg, #1e293b 0%, #312e81 100%);
  color: #ffffff;
  padding: 20px 26px;
  border-radius: 20px;
  margin-bottom: 18px;
  box-shadow: 0 10px 24px rgba(30, 41, 59, 0.16);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.unit-header h1 { font-size: clamp(22px, 2vw, 30px); font-weight: 900; }
.unit-header p { font-size: clamp(14px, 1vw, 16px); color: #cbd5e1; margin-top: 4px; }

.badge-standard {
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid rgba(110, 231, 183, 0.55);
  color: #a7f3d0;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

/* Navigation Tabs */
.nav-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
@media (max-width: 768px) { .nav-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.tab-btn {
  min-height: 52px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-size: clamp(15px, 1.1vw, 17px);
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.tab-btn:hover { border-color: #94a3b8; transform: translateY(-1px); }
.tab-btn.active-1 { background: var(--accent-1); border-color: var(--accent-1); color: #fff; }
.tab-btn.active-2 { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.tab-btn.active-3 { background: var(--accent-3); border-color: var(--accent-3); color: #fff; }
.tab-btn.active-ex { background: var(--accent-ex); border-color: var(--accent-ex); color: #fff; }

.panel-section { display: none; }
.panel-section.active { display: block; }

.split-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.15fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 960px) { .split-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}
.card-title {
  font-size: clamp(18px, 1.4vw, 22px);
  font-weight: 900;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Resource-class friendly blocks */
.guide-block {
  border-radius: 12px;
  padding: 12px 15px;
  margin-bottom: 10px;
  border-left: 5px solid #64748b;
  background: #f8fafc;
}
.guide-block.plain { border-left-color: #0284c7; background: #f0f9ff; }
.guide-block.life { border-left-color: #16a34a; background: #f0fdf4; }
.guide-block.mnemonic { border-left-color: #d97706; background: #fffbeb; }
.guide-block.math { border-left-color: #4f46e5; background: #eef2ff; }
.guide-label {
  display: inline-block;
  font-weight: 900;
  font-size: 14px;
  margin-bottom: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
}

.preset-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.preset-btn {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.preset-btn:hover { background: #e2e8f0; border-color: #64748b; }
.preset-btn.selected { background: #0f172a; color: #fff; border-color: #0f172a; }

.svg-stage {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 16px;
  touch-action: none;
  user-select: none;
  display: block;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.stat-pill {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}

/* Problem Bank + Question-Figure Side-by-Side */
.filter-row-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.filter-bar { display: flex; flex-wrap: wrap; gap: 7px; }
.theme-filter-btn, .tier-filter-btn {
  min-height: 40px;
  padding: 6px 13px;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  background: #fff;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}
.theme-filter-btn.active { background: #0f172a; border-color: #0f172a; color: #fff; }
.tier-filter-btn.active { background: #059669; border-color: #059669; color: #fff; }

.ex-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 16px;
  max-height: 155px;
  overflow-y: auto;
  padding: 10px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
}
.ex-pill {
  min-height: 38px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.ex-pill:hover { border-color: var(--accent-ex); }
.ex-pill.active { background: var(--accent-ex); border-color: var(--accent-ex); color: #fff; }

.problem-header-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 20px;
  align-items: start;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 2px solid #e2e8f0;
}
@media (max-width: 600px) { .problem-header-grid { grid-template-columns: 1fr; } }

/* 獨立區塊文字放大縮小控制列 */
.zoom-mini-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.zoom-mini-btn {
  padding: 3px 9px;
  border-radius: 7px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.zoom-mini-btn:hover { background: #e2e8f0; border-color: #64748b; }

/* 輔助說明收合按鈕列（點按才出現，不一次擺滿畫面） */
.helper-btn-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1.5px dashed #cbd5e1;
}
.helper-toggle-btn {
  min-height: 40px;
  padding: 6px 13px;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}
.helper-toggle-btn:hover { border-color: #0284c7; background: #f0f9ff; }
.helper-toggle-btn.open { background: #0f172a; border-color: #0f172a; color: #fff; }
.helper-drawer {
  display: none;
  margin-top: 10px;
}
.helper-drawer.open { display: block; }

.problem-fig-box {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 16px;
  padding: 10px;
}
.fig-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.fig-mini-btn {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.fig-mini-btn.active { background: #0284c7; border-color: #0284c7; color: #fff; }

.pdf-fig-gallery {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 220px;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
}
.pdf-fig-gallery img {
  max-width: 100%;
  max-height: 290px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.page-tag {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}
.tier-tag {
  display: inline-block;
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #818cf8;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 800;
}

.tts-btn {
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 10px;
  border: 2px solid #0284c7;
  background: #f0f9ff;
  color: #0369a1;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.tts-btn:hover { background: #e0f2fe; }

.step-item {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  margin-bottom: 10px;
  transition: all 0.2s ease;
}
.step-item.revealed { background: #eef2ff; border-color: #818cf8; }
.step-item.hidden-step { opacity: 0.4; filter: blur(4px); user-select: none; }

.answer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px dashed #cbd5e1;
}
.big-input {
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 2px solid #94a3b8;
  font-size: 18px;
  font-weight: 700;
  width: 190px;
  background: #fff;
  color: #0f172a;
}
.big-input:focus { outline: none; border-color: var(--accent-ex); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2); }

.action-btn {
  min-height: 48px;
  padding: 8px 18px;
  border-radius: 12px;
  border: none;
  background: var(--accent-ex);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.action-btn.secondary { background: #0f172a; }

.feedback-msg { margin-top: 10px; font-weight: 800; font-size: 16px; min-height: 26px; }
.feedback-msg.ok { color: #059669; }
.feedback-msg.err { color: #dc2626; }

/* Full-screen Figure Zoom Modal */
.fig-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.82);
  z-index: 9995;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.fig-modal.open { display: flex; }
.fig-modal-inner {
  background: #fff;
  border-radius: 20px;
  padding: 18px;
  width: min(92vw, 960px);
  max-height: 90vh;
  overflow: auto;
  position: relative;
}

/* ==========================================================================
   學障友善：視覺分塊微卡片 + 重點螢光膠囊 + 點擊單條焦點閱讀 + 單區獨立放大
   ========================================================================== */
.ld-def-box {
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border: 2px solid #93c5fd;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 1.03em;
  line-height: 1.75;
}
.ld-def-box.green { background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%); border-color: #6ee7b7; }
.ld-def-box.amber { background: linear-gradient(135deg, #fffbeb 0%, #fefce8 100%); border-color: #fcd34d; }

.ld-def-title {
  display: inline-block;
  font-size: 0.85em;
  font-weight: 900;
  color: #fff;
  background: #0284c7;
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.ld-def-box.green .ld-def-title { background: #059669; }
.ld-def-box.amber .ld-def-title { background: #d97706; }

.ld-rule-hint {
  font-size: 13px;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ld-rule-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ld-rule-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1.7;
}
.ld-rule-card:hover {
  border-color: #38bdf8;
  background: #f8fafc;
}
.ld-rule-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0284c7;
  color: #ffffff;
  font-weight: 900;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.ld-rule-num.green { background: #059669; }
.ld-rule-num.amber { background: #d97706; }

/* 焦點閱讀：點選某一條時，該條放大高亮、其餘自動淡化 */
.ld-rule-list.has-focus .ld-rule-card:not(.focused) {
  opacity: 0.34;
  transform: scale(0.985);
}
.ld-rule-list.has-focus .ld-rule-card.focused {
  border-color: #f59e0b;
  background: #fffbeb;
  box-shadow: 0 8px 22px rgba(245, 158, 11, 0.22);
  transform: scale(1.015);
}

/* 關鍵詞螢光膠囊（讓學障學生 0.5 秒抓到重點） */
.kw {
  display: inline-block;
  padding: 0 6px;
  border-radius: 6px;
  font-weight: 900;
  background: #fef08a;
  color: #854d0e;
}
.kw-b { background: #dbeafe; color: #1e40af; }
.kw-g { background: #d1fae5; color: #065f46; }
.kw-r { background: #ffe4e6; color: #9f1239; }

.sub-pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.sub-pill {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.92em;
  font-weight: 800;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
}
.sub-pill.in  { background: #dcfce7; border-color: #86efac; color: #166534; }
.sub-pill.out { background: #ffe4e6; border-color: #fda4af; color: #9f1239; }
.sub-pill.mid { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }

/* 單一區塊獨立全螢幕放大模式 */
.card.section-expanded {
  position: fixed !important;
  inset: 22px 32px !important;
  z-index: 9980 !important;
  overflow-y: auto !important;
  max-width: 1120px !important;
  margin: auto !important;
  font-size: 122% !important;
  box-shadow: 0 0 0 100vmax rgba(15, 23, 42, 0.72), 0 24px 48px rgba(0,0,0,0.4) !important;
  border-color: #38bdf8 !important;
}

/* ==========================================================================
   v2.1 精緻化：右方畫板固定對照、精巧柔和題目鈕、任何區塊獨立放大、原圖輪播
   ========================================================================== */
@media (min-width: 961px) {
  .sticky-fig-card {
    position: sticky;
    top: 16px;
  }
}

.soft-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.soft-action-btn {
  min-height: 36px;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1.5px solid #c7d2fe;
  background: #eef2ff;
  color: #3730a3;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.14s ease;
}
.soft-action-btn:hover { background: #e0e7ff; border-color: #6366f1; }
.soft-action-btn.muted {
  border-color: #cbd5e1;
  background: #f1f5f9;
  color: #334155;
}
.soft-action-btn.muted:hover { background: #e2e8f0; }
.soft-action-btn.sky {
  border-color: #bae6fd;
  background: #f0f9ff;
  color: #0369a1;
}
.soft-action-btn.sky:hover { background: #e0f2fe; }

.pdf-carousel-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.pdf-nav-btn {
  padding: 4px 10px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.pdf-nav-btn:hover { background: #f1f5f9; border-color: #0284c7; }
.pdf-nav-btn.active { background: #0f172a; color: #fff; border-color: #0f172a; }

.section-expanded {
  position: fixed !important;
  inset: 22px 32px !important;
  z-index: 9980 !important;
  overflow-y: auto !important;
  max-width: 1120px !important;
  margin: auto !important;
  padding: 26px 30px !important;
  background: #ffffff !important;
  border-radius: 20px !important;
  font-size: 124% !important;
  box-shadow: 0 0 0 100vmax rgba(15, 23, 42, 0.72), 0 24px 48px rgba(0,0,0,0.4) !important;
  border: 2px solid #38bdf8 !important;
}

/* ==========================================================================
   v2.2 全視窗「左講解白板 ＋ 右側大圖」放大講解模式 & 五分頁支援
   ========================================================================== */
.nav-tabs.five-cols {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .nav-tabs.five-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.tab-btn.active-vis { background: #7c3aed; border-color: #7c3aed; color: #fff; }

.fig-modal {
  padding: 0 !important;
  z-index: 9980 !important; /* 低於懸浮畫筆 (9985) 與工具列 (9996)，讓老師在全視窗放大時也能直接畫筆書寫！ */
}
.fig-modal-inner {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  padding: 16px 24px !important;
  display: flex;
  flex-direction: column;
}
.full-stage-split {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 20px;
  min-height: 0;
  align-items: stretch;
}
@media (max-width: 820px) {
  .full-stage-split { grid-template-columns: 1fr; }
}
.full-stage-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.full-stage-whiteboard {
  flex: 1;
  min-height: 280px;
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
  background-color: #ffffff;
  background-image: radial-gradient(#cbd5e1 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  padding: 14px;
  position: relative;
}
.full-stage-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px;
  overflow: auto;
}
.full-stage-right img,
.full-stage-right svg {
  width: 100%;
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
}
.ld-rule-zoom-btn {
  margin-left: auto;
  flex-shrink: 0;
  padding: 4px 9px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}
.ld-rule-zoom-btn:hover {
  background: #e0f2fe;
  border-color: #0284c7;
  color: #0369a1;
}

/* ==========================================================================
   v2.3 題目標題右側純圖示按鈕 & 視覺圖解固定置中防跑位容器
   ========================================================================== */
.title-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  border-left: 5px solid #2563eb;
  background: linear-gradient(90deg, #eff6ff 0%, #f8fafc 100%);
  border-top: 1px solid #dbeafe;
  border-right: 1px solid #dbeafe;
  border-bottom: 1px solid #dbeafe;
  flex-wrap: wrap;
}
.title-action-row .card-title {
  margin-bottom: 0;
  flex: 1;
  min-width: 180px;
  color: #1d4ed8;
  font-weight: 900;
  letter-spacing: 0.3px;
}
#ex-question {
  color: #1e293b;
  line-height: 1.75;
  padding: 2px 4px;
}
.icon-action-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}
.icon-only-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
  font-size: 17px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.14s ease;
}
.icon-only-btn:hover { background: #e0e7ff; border-color: #6366f1; transform: translateY(-1px); }
.icon-only-btn.sky:hover { background: #e0f2fe; border-color: #0284c7; }

.vis-single-frame {
  width: 100%;
  height: min(64vh, 560px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.vis-single-frame img {
  max-width: 100%;
  max-height: calc(100% - 34px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  border: 2px solid #cbd5e1;
  cursor: pointer;
  display: block;
}
