/*
 * 抽象大師離線版：關卡選單（index.html）與影片頁（video.html）共用樣式
 *
 * 版面沿用線上版 course.svg／video-view.svg 的 1280×800 設計座標：
 * .stage 固定 1280×800px，由 menu/common.js 依視窗大小等比縮放置中
 * （等同線上 SVG viewBox 的 preserveAspectRatio="xMidYMid meet"）。
 *
 * 不載入任何外部字型；字型清單沿用線上 SVG（方正蘭亭中黑／蘭亭黑），
 * 沒有安裝時依序退回 macOS、Windows 內建的正體中文字型。
 */

:root {
  --font-main: "FZLTZHB--B51-0", "Lantinghei TC", "PingFang TC", "Microsoft JhengHei",
    "Noto Sans TC", "Heiti TC", sans-serif;
  --font-back: "HiraKakuStd-W8-83pv-RKSJ-H", "Hiragino Kaku Gothic Std", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  --scale: 1;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  -webkit-font-smoothing: antialiased;
}

body.page-course {
  background: #17237a;
}

body.page-video {
  background: #f7c6a6;
}

/* 視窗：鋪滿畫面，舞台在中間等比縮放 */
.viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1280px;
  height: 800px;
  margin: 0;
  transform: translate(-50%, -50%) scale(var(--scale));
  transform-origin: 50% 50%;
  user-select: none;
}

.stage-bg {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 800px;
  pointer-events: none;
}

/* 頁首：線上版放玩家名稱與角色，離線版免登入，改放標題 */
.banner {
  position: absolute;
  left: 440px;
  top: 0;
  width: 400px;
  height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  pointer-events: none;
}

.banner-title {
  margin: 0;
  font-size: 32px;
  font-weight: bold;
  letter-spacing: 0.12em;
  line-height: 1.15;
  text-shadow: 0 2px 4px rgba(10, 20, 90, 0.45);
}

.banner-sub {
  margin-top: 2px;
  font-size: 15px;
  letter-spacing: 0.2em;
  opacity: 0.9;
}

/* ---------- 關卡選單 ---------- */

.course-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* 每一列的位置對應 course.svg 的 data-class 群組（左上角 363.5, 100.76 起，每列 ≈99.9px） */
.course-row {
  position: absolute;
  left: 363.5px;
  width: 553px;
  height: 99px;
  background: url("img/course/btn-03-gray.png") no-repeat 0 0 / 553px 99px;
}

.course-row[hidden] {
  display: none;
}

.course-index {
  position: absolute;
  left: 40px;
  top: 22.5px;
  height: 54px;
  display: flex;
  align-items: center;
  color: #3876f2;
  font-size: 21px;
}

.course-practice,
.course-video,
.course-slide {
  position: absolute;
  display: block;
  border-radius: 14px;
  transition: transform 0.12s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

/* 練習按鈕（線上點題目名稱另開作答畫面） */
.course-practice {
  left: 84px;
  top: 22.5px;
  width: 121px;
  height: 54px;
  padding: 0 8px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url("img/course/btn-06.png") no-repeat 0 0 / 121px 54px;
  color: #fff;
  text-decoration: none;
  font-size: 21px;
  white-space: nowrap;
}

.course-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 教學影片、講義圖示（線上座標 757.79／814.79，55×55） */
.course-video,
.course-slide {
  top: 22px;
  width: 55px;
  height: 55px;
  border-radius: 50%;
}

.course-video {
  left: 394.29px;
  background: url("img/course/btn-01.png") no-repeat 0 0 / 55px 55px;
}

.course-slide {
  left: 451.29px;
  background: url("img/course/btn-02.png") no-repeat 0 0 / 55px 55px;
}

.course-practice:hover,
.course-video:hover,
.course-slide:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.course-practice:active,
.course-video:active,
.course-slide:active {
  transform: translateY(1px);
}

.course-practice:focus-visible,
.course-video:focus-visible,
.course-slide:focus-visible,
.pager-btn:focus-visible,
.back-link:focus-visible {
  outline: 3px solid #ffe066;
  outline-offset: 2px;
}

/* 講義檔不存在（已偵測到）時變灰 */
.course-slide.is-missing {
  filter: grayscale(1) opacity(0.55);
}

/* 分頁按鈕（線上 page-1 在 587.75, 704.34，scale .89） */
.pager {
  position: absolute;
  left: 0;
  top: 704.34px;
  width: 1280px;
  height: 49px;
  display: flex;
  justify-content: center;
  gap: 6.55px;
}

.pager-btn {
  width: 48.95px;
  height: 48.95px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent no-repeat 0 0 / 48.95px 48.95px;
  cursor: pointer;
  color: transparent;
  font: inherit;
  font-size: 0;
}

/* 超過線上素材頁數（第 3 頁以後）時的備用樣式 */
.pager-btn.is-text {
  background: #b9bfe0;
  color: #fff;
  font-size: 24px;
  border: 3px solid #fff;
}

.pager-btn.is-text[aria-current="page"] {
  background: #f5a623;
}

/* 返回（左下角，線上 text 位置 32.3, 770.5） */
.back-link {
  position: absolute;
  left: 32px;
  top: 737px;
  line-height: 1;
  font-size: 33px;
  text-decoration: none;
  cursor: pointer;
}

.page-video .back-link {
  color: #b35329;
  font-family: var(--font-back);
  font-weight: bold;
}

.page-video .back-link:hover {
  color: #d66a3a;
}

/* 訊息提示（例如講義檔不存在）：放在畫面上方蓋住標題，不擋任何按鈕的點擊 */
.toast {
  position: fixed;
  left: 50%;
  top: 2vh;
  z-index: 10;
  max-width: min(90vw, 640px);
  padding: 14px 22px;
  border-radius: 12px;
  background: rgba(20, 24, 60, 0.92);
  color: #fff;
  font-size: 18px;
  line-height: 1.5;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.toast[hidden] {
  display: none;
}

/* ---------- 影片頁 ---------- */

.page-video .stage-bg {
  left: -0.5px;
  top: -0.5px;
  width: 1281px;
  height: 801px;
}

.page-video .banner {
  left: 330px;
  width: 620px;
  height: 84px;
}

.video-title {
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  font-size: 30px;
  font-weight: bold;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow: 0 2px 4px rgba(150, 60, 10, 0.55);
}

/* 線上 foreignObject：x=240 y=150 800×480 */
.video-box {
  position: absolute;
  left: 240px;
  top: 150px;
  width: 800px;
  height: 480px;
  background: #000;
}

.video-box video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.video-box video[hidden] {
  display: none;
}

.video-message {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 70px;
  color: #fff;
  text-align: center;
  user-select: text;
}

.video-message[hidden] {
  display: none;
}

.video-message-title {
  margin: 0 0 18px;
  font-size: 32px;
  font-weight: bold;
  color: #ffd166;
}

.video-message-body {
  margin: 0 0 10px;
  font-size: 21px;
  line-height: 1.7;
}

.video-message-note {
  margin: 8px 0 0;
  font-size: 16px;
  line-height: 1.6;
  opacity: 0.75;
}

.video-message code {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.16);
  font-family: Menlo, Consolas, monospace;
  font-size: 0.92em;
}

noscript .noscript {
  position: fixed;
  inset: auto 0 0 0;
  padding: 12px;
  background: #fff3cd;
  color: #5c3c00;
  text-align: center;
  font-size: 18px;
}
