/* 英語自然發音拼音表 — 互動電子海報 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c1: #4a7c3f;
  --c2: #1a5fa8;
  --c3: #8b4a00;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.18);
}

html, body {
  height: 100%;
  font-family: 'Noto Sans TC', '微軟正黑體', system-ui, sans-serif;
  background: #111;
  color: #222;
}

/* ════════════════════════════════
   畫面切換
   ════════════════════════════════ */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; min-height: 100dvh; }


/* ════════════════════════════════
   畫面 1：滿版海報
   ════════════════════════════════ */
.screen-poster {
  position: relative;
  background: #000;
  justify-content: center;
  align-items: center;
}

/* 海報圖：滿視窗，不裁切，保持比例 */
.poster-fullscreen {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  user-select: none;
  -webkit-user-drag: none;
}

/* ── 縮放容器 ── */
.zoom-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none; /* 交給 JS 處理 pinch/pan */
}
.zoom-viewport.grabbing { cursor: grabbing; }

.zoom-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  transform-origin: 0 0;
  /* transform 由 JS 控制 */
  will-change: transform;
}

/* ── 縮放控制列 ── */
.zoom-controls {
  position: absolute;
  bottom: calc(0.6rem + clamp(1.8rem, 3.5vh, 2.8rem));
  right: 0.6rem;
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(0,0,0,0.48);
  border-radius: 2rem;
  padding: 3px 8px;
  z-index: 20;
  backdrop-filter: blur(4px);
}
.zoom-btn {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
  padding: 0;
}
.zoom-btn:hover { background: rgba(255,255,255,0.3); }
.zoom-pct {
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  min-width: 2.8rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 左上導覽已移除，海報完全滿版 */

/* 右下角 CTA 按鈕群 */
.poster-cta {
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  display: flex;
  gap: 0.4rem;
  z-index: 20;
}

.cta-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border: none;
  border-radius: 2rem;
  font-size: clamp(0.72rem, 1.4vw, 0.88rem);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
  opacity: 0.92;
}
.cta-btn:hover  { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(0,0,0,0.45); opacity: 1; }
.cta-btn:active { transform: scale(0.96); }

.cta-icon  { font-size: 1em; line-height: 1; }
.cta-label { white-space: nowrap; }

.cta-interactive { background: #fff;      color: #1a5fa8; }
.cta-quiz        { background: #1a5fa8;   color: #fff; }


/* ════════════════════════════════
   子畫面共用 header
   ════════════════════════════════ */
.sub-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1rem;
  background: #fff;
  border-bottom: 1px solid #e0ddd0;
  flex-shrink: 0;
}
.sub-header h1 {
  font-size: clamp(0.85rem, 2vw, 1.05rem);
  font-weight: 700;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.back-btn {
  padding: 0.35rem 0.9rem;
  border-radius: 2rem;
  border: 2px solid #1a5fa8;
  background: transparent;
  color: #1a5fa8;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.back-btn:hover { background: #1a5fa8; color: #fff; }


/* ════════════════════════════════
   畫面 2：互動海報
   ════════════════════════════════ */
.interactive-main {
  flex: 1;
  overflow-y: auto;
  background: #fafaf5;
  padding: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* Section */
.section-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  border-radius: 4px;
  padding: 2px 8px;
  margin: 0.75rem 0 0.3rem;
}
.group-lbl {
  font-size: 0.72rem;
  color: #888;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0.3rem 0 0.3rem;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

/* 音素卡片 */
.phon-card {
  background: #fff;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 5px 3px 4px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.phon-card:hover  { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.14); }
.phon-card:active { transform: scale(0.93); }
.phon-card.speaking {
  border-color: #f5a623;
  animation: pulse 0.45s ease;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245,166,35,0.55); }
  100% { box-shadow: 0 0 0 7px rgba(245,166,35,0); }
}

.card-emoji   { font-size: 1.35rem; line-height: 1; display: block; }
.card-pattern { font-size: 1rem;    font-weight: 900; display: block; color: #222; }
.card-ipa     { font-size: 0.65rem; color: #666; display: block; }
.card-word    { font-size: 0.8rem;  font-weight: 700; color: #333; display: block; }
.card-zh      { font-size: 0.65rem; color: #999; display: block; }
.card-note    { position: absolute; top: 2px; right: 3px; font-size: 0.55rem; color: #bbb; }

/* 播放提示條 */
.speak-bar {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 1.4rem;
  border-radius: 2rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 50;
  white-space: nowrap;
}
.speak-bar.show { opacity: 1; }


/* ════════════════════════════════
   畫面 3：練習模式
   ════════════════════════════════ */
.quiz-main {
  flex: 1;
  background: #f5f5f0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem 1rem;
}
.quiz-wrap {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.quiz-header-row {
  display: flex;
  justify-content: flex-end;
}
.quiz-score {
  font-size: 0.88rem;
  font-weight: 700;
  color: #555;
}

.quiz-progress {
  height: 7px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4a7c3f, #1a5fa8);
  border-radius: 4px;
  transition: width 0.3s;
}

/* 題目卡 */
.quiz-q {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1rem;
  text-align: center;
}
.quiz-prompt {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.75rem;
}
.quiz-play-btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  background: #1a5fa8;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(26,95,168,0.3);
  transition: transform 0.1s, background 0.1s;
}
.quiz-play-btn:hover  { background: #1550a0; }
.quiz-play-btn:active { transform: scale(0.91); }
.quiz-play-btn.playing { background: #f5a623; }
.quiz-hint { font-size: 0.78rem; color: #aaa; margin-top: 0.5rem; }

/* 選項格 */
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.quiz-option {
  background: #fff;
  border: 2px solid #ddd;
  border-radius: var(--radius);
  padding: 0.7rem 0.4rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
}
.quiz-option:hover:not(:disabled) { border-color: #1a5fa8; background: #f0f6ff; }
.quiz-option .opt-emoji { font-size: 1.4rem; display: block; margin-bottom: 0.15rem; }
.quiz-option .opt-word  { font-size: 0.9rem; font-weight: 700; color: #222; display: block; }
.quiz-option .opt-pat   { font-size: 0.75rem; color: #888; display: block; }
.quiz-option.correct    { border-color: #2e8b57; background: #e8f8ee; }
.quiz-option.wrong      { border-color: #cc3333; background: #ffeaea; }
.quiz-option:disabled   { cursor: default; }

/* 回饋 */
.quiz-feedback {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  min-height: 1.4em;
}
.quiz-feedback.correct { color: #2e8b57; }
.quiz-feedback.wrong   { color: #cc3333; }

.quiz-next-btn {
  display: block;
  margin: 0 auto;
  padding: 0.5rem 2rem;
  background: #1a5fa8;
  color: #fff;
  border: none;
  border-radius: 2rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.quiz-next-btn.show { opacity: 1; pointer-events: auto; }
.quiz-next-btn:hover { background: #1550a0; }

/* 結算 */
.quiz-result {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.5rem;
  text-align: center;
  display: none;
}
.quiz-result.show { display: block; }
.result-emoji { font-size: 2.5rem; }
.result-title { font-size: 1.3rem; font-weight: 800; margin: 0.4rem 0; }
.result-score { font-size: 0.95rem; color: #555; }
.result-btns {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1rem;
}
.result-restart {
  padding: 0.5rem 1.5rem;
  background: #4a7c3f;
  color: #fff;
  border: none;
  border-radius: 2rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.result-restart:hover { background: #3a6a30; }
.result-back {
  padding: 0.5rem 1.5rem;
  background: transparent;
  color: #1a5fa8;
  border: 2px solid #1a5fa8;
  border-radius: 2rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.result-back:hover { background: #1a5fa8; color: #fff; }

/* ── 響應式 ── */
@media (max-width: 500px) {
  .poster-cta   { flex-direction: column; align-items: flex-end; gap: 0.5rem; }
  .card-grid    { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); }
  .quiz-options { grid-template-columns: 1fr 1fr; }
}
