/* ============================================================================
   css/v2-shell.css — 喵星補習社 MeowLab V2 AppShell（PR-V2-01）
   - 載入順序喺 shell.css 之後：本檔負責 V2 外殼，舊殼規則逐步被覆蓋；
     內層功能（彈窗、考場、默書房）嘅樣式唔喺本 PR 改動範圍。
   - ≥1024px：頂部導覽列（品牌＋年級膠囊｜5 格膠囊分頁｜連勝＋榮譽分），
     舊 HUD 頂／底列隱藏（DOM 保留，所有既有綁定與數據更新照常運作）。
   - <1024px：底部固定 5 格拇指導覽（點擊高度 ≥52px），舊四頁籤／左欄移除。
   - ≥1280px：內容封頂 1280px 置中，畫布色填滿兩側（取代舊暮光填邊）。
   - 舊「免費禮物」浮動貼紙已由 index.html 移除，本檔唔再為佢留位。
   ============================================================================ */

/* ---------- 全站基底：畫布色＋香港字形字體 ---------- */
body { background: var(--bg-canvas); }
#game-client {
  background: var(--bg-canvas);
  border: none;
  box-shadow: none;
  font-family: var(--font-app);
  color: var(--text-primary);
}

/* ---------- V2 頂欄（預設隱藏，≥1024px 先顯示） ---------- */
#v2-topbar { display: none; }

@media (min-width: 1024px) {
  #v2-topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 18px;
    position: absolute; top: 0; left: 0; right: 0; z-index: 40;
    padding: 12px 20px;
    /* 頂欄必須不透明：底下視圖捲動時內容唔可以透出嚟同品牌／分頁重疊（審查 P1） */
    background: var(--bg-canvas);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 6px 24px rgba(15, 28, 38, 0.05);
  }
  /* 頂欄接管後，舊 HUD 兩列功成身退（DOM 與綁定保留） */
  #hud-top, #hud-bottom { display: none; }
  /* Today Deck 槽位落返頂欄之下（內容屬 PR-07，本 PR 只調整位置） */
  #today-deck { top: 84px; }
  /* 舊左欄已移除：舞台唔再左讓 76px，右邊繼續俾 Deck 留位 */
  #diorama-viewport { left: 0; }
  /* V2 首頁／榮譽榜路由下隱藏舊小鎮畫布：右欄 Today Deck 周邊唔好露出紙藝小鎮，
     由 #game-client 嘅畫布色填滿（審查 P1）；考場／默書路由唔受影響 */
  body[data-route="learn"] #diorama-viewport,
  body[data-route="leaderboard"] #diorama-viewport { display: none; }
}

.v2-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.v2-brand-mark { font-size: 30px; line-height: 1; }
.v2-brand-text {
  display: flex; flex-direction: column; line-height: 1.15;
  font-size: 19px; font-weight: 900; color: var(--text-primary); white-space: nowrap;
}
.v2-brand-text small { font-size: 11px; font-weight: 700; color: var(--text-secondary); letter-spacing: 0.08em; }
.v2-grade-capsule {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 40px; padding: 7px 14px; margin-left: 6px;
  background: var(--surface-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius-btn); box-shadow: var(--shadow-bento);
  color: var(--text-primary); font: inherit; font-size: 14px; font-weight: 800;
  cursor: pointer; white-space: nowrap;
}
.v2-grade-arrow { color: var(--text-secondary); font-size: 11px; }

.v2-tabs {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius-btn); box-shadow: var(--shadow-bento);
  padding: 5px;
}
.v2-tab {
  min-height: 42px; padding: 8px 20px;
  background: transparent; border: none; border-radius: var(--radius-btn);
  color: var(--text-secondary); font: inherit; font-size: 15px; font-weight: 800;
  cursor: pointer; white-space: nowrap;
}
.v2-tab.is-active { background: var(--brand-emerald); color: #fff; }

.v2-top-stats { display: flex; align-items: center; gap: 8px; }
.v2-stat-chip {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 40px; padding: 7px 14px;
  background: var(--surface-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius-btn); box-shadow: var(--shadow-bento);
  font-size: 14px; font-weight: 800; color: var(--text-primary); white-space: nowrap;
}

/* ---------- V2 手機底部 5 格導覽（預設隱藏，<1024px 顯示） ---------- */
#v2-tabbar { display: none; }

@media (max-width: 1023px) {
  #v2-tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface-card);
    border-top: 1px solid var(--border-soft);
    box-shadow: 0 -8px 28px rgba(15, 28, 38, 0.08);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .v2-tab-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 54px; padding: 6px 2px;
    background: transparent; border: none; border-radius: 16px;
    color: var(--text-secondary); font: inherit; font-size: 12.5px; font-weight: 800;
    cursor: pointer; white-space: nowrap;
  }
  .v2-tab-btn .v2-tab-ico { font-size: 20px; line-height: 1.15; }
  .v2-tab-btn.is-active { background: var(--brand-mint-soft); color: var(--brand-emerald-dark); }
  /* 底部舊三掣 Dock 由新導覽取代；摺摺 ribbon 升起避開導覽列 */
  #hud-bottom .bottom-dock-bar { display: none; }
  #hud-bottom { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  /* V2 首頁／榮譽榜路由：成個舊 V1 HUD 退場，唔再上下夾住新視圖（審查 P1）；
     其他路由（考場／默書／家長等彈窗流程）沿用舊 HUD 行為不變 */
  body[data-route="learn"] #hud-top,
  body[data-route="learn"] #hud-bottom,
  body[data-route="leaderboard"] #hud-top,
  body[data-route="leaderboard"] #hud-bottom { display: none; }
  body[data-route="learn"] .v2-view-inner,
  body[data-route="leaderboard"] .v2-view-inner { padding: 20px 14px 96px; }
}

/* ---------- 桌面封頂：1280px 置中＋畫布填邊（取代 PR-05 暮光處理） ---------- */
@media screen and (min-width: 1280px) {
  body { background: var(--bg-canvas); }
  #game-client {
    width: 100%;
    max-width: 1280px;
    margin-inline: auto;
    box-shadow: 0 0 0 1px var(--border-soft), 0 0 60px rgba(15, 28, 38, 0.10);
  }
}

/* ---------- 視圖容器：學習首頁／榮譽榜（Router 以 .open 切換） ---------- */
#view-learn, #view-leaderboard {
  display: none;
  position: absolute; inset: 0; z-index: 15;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg-canvas);
}
#view-learn.open, #view-leaderboard.open { display: block; }
/* 榮譽榜開住時唔顯示 Today Deck（避免無關浮層壓住內容） */
body[data-route="leaderboard"] #today-deck { display: none; }

.v2-view-inner {
  display: flex; flex-direction: column; gap: 16px;
  max-width: 880px; margin: 0 auto;
  padding: 118px 14px 250px; /* 手機預設：避開頂 HUD 與底部摺摺列＋導覽列；learn／leaderboard 路由由上方規則收窄 */
}
@media (min-width: 1024px) {
  #view-learn { right: 316px; } /* 右欄俾 Today Deck（292px＋邊距） */
  .v2-view-inner { padding: 84px 24px 32px; }
}

.v2-card {
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-bento);
  padding: 20px;
}
.v2-card-title { font-size: var(--fs-card-title); font-weight: 900; color: var(--text-primary); margin-bottom: 12px; }
.v2-card-note { font-size: 13px; color: var(--text-secondary); line-height: 1.55; margin-top: 12px; }

.v2-learn-hero { background: linear-gradient(135deg, #FFFFFF 0%, var(--brand-mint-soft) 100%); }
.v2-learn-title { font-size: 26px; font-weight: 900; color: var(--text-primary); margin-bottom: 4px; }
.v2-learn-sub { font-size: 14.5px; color: var(--text-secondary); line-height: 1.55; }
.v2-duty-cat { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.v2-duty-cat img { width: 64px; height: 64px; object-fit: contain; }
.v2-duty-cat-txt { font-size: 13.5px; font-weight: 800; color: var(--brand-emerald-dark); line-height: 1.45; }
.v2-duty-cat-txt small { display: block; font-weight: 600; color: var(--text-secondary); }

.v2-subject-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 560px) { .v2-subject-grid { grid-template-columns: repeat(2, 1fr); } }
.v2-subject-btn {
  min-height: 56px; padding: 12px 8px;
  background: var(--surface-subtle); border: 1px solid var(--border-soft);
  border-radius: 18px;
  color: var(--text-primary); font: inherit; font-size: 17px; font-weight: 900;
  cursor: pointer;
}
.v2-subject-btn:active { background: var(--brand-mint-soft); }

.v2-quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 560px) { .v2-quick-grid { grid-template-columns: repeat(2, 1fr); } }
.v2-quick-btn {
  min-height: 52px; padding: 10px 8px;
  background: var(--surface-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius-btn); box-shadow: var(--shadow-bento);
  color: var(--text-primary); font: inherit; font-size: 14px; font-weight: 800;
  cursor: pointer;
}
.v2-quick-btn:active { background: var(--brand-mint-soft); }

.v2-lb-card { text-align: center; padding: 36px 24px; }
.v2-lb-emoji { font-size: 44px; margin-bottom: 10px; }
.v2-lb-card p { font-size: 14.5px; color: var(--text-secondary); line-height: 1.65; max-width: 460px; margin: 0 auto; }

/* 答題字體階層（規格 §1.3）：iPad／桌面題幹放大 */
@media (min-width: 1024px) {
  :root { --fs-stem: 23px; }
}
