/* ============================================================
   AI4Kids Junior · 舞台式版型共用樣式（_stage-layout.css）
   版本：v0.2（2026-10-16 晚，角色欄改右、不鏡像；v0.1 同日 T2-U5 試做）
   搭配：_stage-layout.js（等比縮放 + 直向提示）
   設計稿：_stage-template-mock.html

   核心規則
   1. 單元是一個 1280×800 的固定舞台（.stage），由 JS 依視窗等比縮放、置中。
      body 永遠 overflow:hidden，任何螢幕都不捲動。
   2. 舞台內固定四區：
      - 頂列 HUD：56px（.stage .hud）
      - 左側內容區：其餘空間（.stage-content，不捲動）
      - 右側角色區：300px（.stage-actor，order:2：對話泡泡在上、Lottie 角色站底、一律不鏡像）
      - 底部動作列：92px（.stage-actions：上一頁靠左、主按鈕靠右）
   3. 一個 scene 只放一件事；塞不下就拆 scene 或把說明移進泡泡，
      不加捲軸、內容字級不低於 16px（以舞台座標計）。
   4. 直向視窗：舞台照比例縮小置中，底部顯示「把平板橫放」提示。

   套用到其他單元（由黃金模板 _UNIT-TEMPLATE.html 衍生的單元）
   - <head> 加 <link rel="stylesheet" href="_stage-layout.css">
   - <body class="stage-mode">，把 HUD 與 <main> 包進
     <div class="stage-viewport"><div class="stage" id="stage">…</div></div>
   - 每個 scene 改成：
       <section class="scene stage-scene" id="scene-xxx">
         <div class="stage-body">
           <aside class="stage-actor">
             <div class="stage-bubble"><div class="briefing-text">…</div></div>
             <div class="stage-actor-lottie" role="img" aria-label="小狐 Foxy"></div>  <!-- 角色一律 Lottie，禁舊 PNG -->
           </aside>
           <div class="stage-content">…</div>
         </div>
         <div class="stage-actions"><span class="stage-actions-spacer"></span>主按鈕</div>
       </section>
   - 「上一頁」(#backBtn) 放在舞台層級的 .stage-back，所有 scene 共用。
   - 本檔以「.stage 範圍內較高權重」的選擇器蓋掉黃金模板裡
     與舞台衝突的樣式（main/.hud 的 position:fixed、.scene.active 的 flex、
     浮動角色 .persistent-mascot），所以單元檔可以不刪舊樣式也能運作。
   - 顏色一律沿用黃金模板 :root 的 CSS 變數，本檔不定義新品牌色。
   ============================================================ */

/* ---------- 0. 全頁：不捲動、背景沿用品牌漸層 ---------- */
html, body {
  height: 100%;
  overflow: hidden;
}
body.stage-mode {
  min-height: 0;
  background: var(--gradient-main, linear-gradient(135deg, #F5F9FA 0%, #FEF4F6 50%, #FAF7EF 100%));
}

/* ---------- 1. 舞台外框與本體 ---------- */
.stage-viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
/* 舞台固定 1280×800；left/top/transform 由 _stage-layout.js 設定 */
.stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 800px;
  transform-origin: 0 0;
  background: var(--white, #fff);
  border-radius: 26px;
  box-shadow: 0 10px 40px rgba(0, 40, 45, 0.08);
  overflow: hidden;
}

/* 直向提示：只在 body.portrait 顯示（由 JS 切換） */
.stage-rotate-hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 20px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-sub, #5A6472);
  display: none;
  z-index: 300;
}
body.portrait .stage-rotate-hint { display: block; }

/* ---------- 2. 頂列 HUD（56px） ---------- */
/* 蓋掉黃金模板 .hud 的 position:fixed，改成舞台內的絕對定位 */
.stage .hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: 20;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: none;
  border-bottom: 1px solid var(--bg-card, #E6F3F4);
}
/* 退出鈕佔位：正式版由平台接手（prototype 內不動作） */
.stage-exit {
  flex-shrink: 0;
  background: #EEF3F4;
  color: var(--text-sub, #5A6472);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: default;
}
.stage-hud-title {
  flex-shrink: 0;
  font-size: 18px;
  font-weight: 900;
  color: var(--teal-700, #006B70);
  letter-spacing: 1px;
}
/* scene 名（沿用模板 #sceneLabel） */
.stage-hud-scene {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--text-sub, #5A6472);
}
.stage .hud .hud-progress-wrap {
  flex: 1;
  max-width: 300px;
  height: 8px;
  margin: 0 16px;
  border-radius: 4px;
}
.stage-hud-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stage .hud .hud-stat { font-size: 16px; }
.stage .hud .hud-star-icon { font-size: 18px; }
.stage .hud .hud-star-total { font-size: 16px; }
.stage .hud #soundBtn { font-size: 16px; padding: 4px 12px; }

/* ---------- 3. scene 容器 ---------- */
/* 蓋掉黃金模板 main 的 position:fixed 與 padding */
.stage main.stage-scenes {
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0;
  overflow: hidden;
  z-index: 1;
}
.stage .scene.stage-scene {
  position: absolute;
  inset: 0;
  display: none;
  height: auto;
  width: auto;
}
.stage .scene.stage-scene.active {
  display: block;
  animation: stageSceneIn 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes stageSceneIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 主體：內容 ＋ 角色 300px（2026-10-16 Inky 拍板改為角色在右）；底部留 92px 給動作列 */
.stage-body {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 92px;
  display: grid;
  grid-template-columns: 1fr 300px;
}

/* ---------- 4. 右側角色區（泡泡在上、角色站底；角色不鏡像） ---------- */
.stage-actor {
  order: 2;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 24px 18px 8px;
  background: linear-gradient(180deg, #F3FAFB, var(--bg-card, #E6F3F4));
  overflow: hidden;
}
/* 對話泡泡：高度隨字數長，角色圖自動縮小讓位（兩者不重疊） */
.stage-bubble {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  background: var(--white, #fff);
  border: 2px solid var(--teal-500, #02BDC7);
  border-radius: 18px;
  padding: 14px 16px;
  font-size: 17px;
  line-height: 1.6;
  font-weight: 700;
  color: var(--text-main, #2D3748);
}
.stage-bubble::after {
  content: '';
  position: absolute;
  bottom: -13px;
  left: 50%;
  width: 22px;
  height: 22px;
  background: var(--white, #fff);
  border-right: 2px solid var(--teal-500, #02BDC7);
  border-bottom: 2px solid var(--teal-500, #02BDC7);
  transform: translateX(-50%) rotate(45deg);
}
/* 泡泡裡的說話者名字（沿用模板 briefing 的 <strong> 寫法） */
.stage-bubble .briefing-text { font-size: 17px; line-height: 1.6; }
.stage-bubble .briefing-text strong:first-child { color: var(--yellow-700, #A07825); }
.stage-bubble.bubble-bobo { border-color: var(--bobo, #1FA876); }
.stage-bubble.bubble-bobo::after { border-color: var(--bobo, #1FA876); }
.stage-bubble.bubble-bobo .briefing-text strong { color: var(--bobo-deep, #0F6348); }
.stage-bubble.bubble-oli { border-color: var(--oli, #7B68E0); }
.stage-bubble.bubble-oli::after { border-color: var(--oli, #7B68E0); }
.stage-bubble.bubble-oli .briefing-text strong { color: var(--oli-deep, #391FC3); }

.stage-actor-img {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 230px;
  object-fit: contain;
  object-position: center bottom;
  mix-blend-mode: multiply; /* 角色圖若是白底，貼合淺色背景 */
  filter: drop-shadow(0 8px 16px rgba(0, 60, 65, 0.12));
}

/* ---------- 5. 中央內容區（不捲動） ---------- */
.stage-content {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 24px 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}
/* 小標（例：先想想看／核心實作） */
.stage-tag {
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--teal-700, #006B70);
  margin: 0;
}
.stage-content h2.stage-title {
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.3;
  margin: 0;
  color: var(--text-main, #2D3748);
}
/* 讓某一塊吃掉剩餘高度（例：大圖、樹） */
.stage-fill {
  flex: 1;
  min-height: 0;
}

/* hero 型 scene：內容區整塊是大圖，標題疊圖 */
.stage-hero {
  flex: 1;
  min-height: 0;
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background-color: var(--bg-card, #E6F3F4);
  background-size: cover;
  background-position: center;
}
.stage-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 40%, rgba(0, 70, 80, 0.78));
}
.stage-hero-cap {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 24px;
  z-index: 1;
  color: var(--white, #fff);
  text-shadow: 0 2px 12px rgba(0, 30, 35, 0.5);
}
.stage-hero-cap .stage-hero-pill {
  display: inline-block;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
  padding: 4px 14px;
  border-radius: 22px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 3px;
  margin-bottom: 8px;
}
.stage-hero-cap h1 {
  color: var(--white, #fff);
  text-align: left;
  font-size: 40px;
  font-weight: 900;
  line-height: 1.2;
  margin: 0;
}
.stage-hero-cap p {
  color: var(--white, #fff);
  font-size: 19px;
  margin: 6px 0 0;
  opacity: 0.95;
}

/* 學習目標：三顆大 chip 一列（沿用模板 .goal-check 打勾狀態） */
.stage-goals {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.stage-goal {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card, #E6F3F4);
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
}
.stage-goal .goal-check { width: 28px; height: 28px; font-size: 16px; }

/* ---------- 6. 底部動作列（92px，永遠看得到） ---------- */
.stage-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 0 18px 0 24px; /* 右側 18px = 角色欄左右內距，主按鈕才能和對話框對齊 */
  border-top: 1px solid var(--bg-card, #E6F3F4);
  background: var(--white, #fff);
}
/* 主按鈕：沿用模板 .btn 配色，只放大尺寸 */
/* 主按鈕寬度 = 角色欄對話框寬度（300 − 18×2 = 264px），左右邊緣與對話框對齊
   （2026-10-16 Inky 拍板，PLAYBOOK §11.18-B9） */
.stage-actions .btn {
  width: 264px;
  min-width: 0;
  margin: 0;
  padding: 16px 12px;
  white-space: nowrap;
  font-size: 20px;
  font-weight: 900;
  border-radius: 16px;
}
.stage-actions .btn.hidden { display: none !important; }

/* 上一頁（舞台層共用一顆，蓋在每個 scene 動作列的左側） */
.stage-back {
  position: absolute;
  left: 24px;
  bottom: 0;
  height: 92px;
  display: flex;
  align-items: center;
  z-index: 5;
  pointer-events: none;
}
.stage-back .stage-back-btn {
  pointer-events: auto;
  background: #EEF3F4;
  color: var(--text-sub, #5A6472);
  border: 0;
  border-radius: 14px;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
}
.stage-back .stage-back-btn:hover { background: var(--bg-card, #E6F3F4); color: var(--teal-700, #006B70); }
.stage-back .stage-back-btn.invisible { visibility: hidden; }

/* ---------- 7. 與舞台衝突的模板元件 ---------- */
/* 浮動角色：角色區已經有固定角色，舞台模式一律隱藏（DOM 保留，平台 loader 不會報錯） */
body.stage-mode .persistent-mascot { display: none !important; }
/* score-popup / confetti 仍以視窗座標顯示，不需調整 */
