/*
 * 石頭記－共鳴時刻｜參加者前台
 *
 * 高度單位一律 `100vh`（SPEC §7）：**不得改用 `dvh`**——那會隨網址列收放變動，
 * 捲動時背景會反覆縮放跳動。`vh` 取大視窗高度，固定不變。
 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --ink: rgba(255, 255, 255, 0.92);
  --ink-soft: rgba(255, 255, 255, 0.78);
  /*
   * 遮罩濃度：211 底圖是**淺色宣紙**，0.62 時白字對比不足（本機 412 寬實測）。
   * 0.74 才讓主文清楚可讀，仍看得見底圖的水墨與金線（SPEC §11.4「深色半透明遮罩＋置中白字」）。
   */
  --veil: rgba(8, 6, 14, 0.74);
  --serif: "Noto Serif TC", "Songti TC", "STSong", "PMingLiU", serif;
}

html,
body {
  height: 100%;
  background: #0a0810;
}

body {
  font-family: var(--serif);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  overflow: hidden; /* 單頁滿版，任何捲動都是版面出錯 */
}

/* ── 版面 ───────────────────────────────────────────── */

.screen {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 24px) 28px calc(env(safe-area-inset-bottom) + 24px);
  text-align: center;
}

/* 背景圖：一律 cover（SPEC §7／H7）。fixed ＋ 100vh 才不會隨網址列縮放。 */
.bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  z-index: 0;
}

.bg--s1 {
  background-image: url("../assets/s1-111-v1.jpg");
}

.bg--base {
  background-image: url("../assets/bg-211-v1.jpg");
}

/* 深色半透明遮罩（SPEC §11.4）：底圖上疊白字用 */
.veil {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--veil);
  z-index: 1;
}

/* ── 文字 ───────────────────────────────────────────── */

.msg {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 560px;
}

.msg-main {
  font-size: clamp(1.375rem, 6.4vw, 1.75rem);
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: 0.1em;
  /* 主文用純白＋較實的陰影：底圖是淺色宣紙，半透明白在細筆畫上會糊掉 */
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.75), 0 0 28px rgba(0, 0, 0, 0.45);
}

.msg-sub {
  font-size: clamp(0.9375rem, 4.2vw, 1.0625rem);
  line-height: 2;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.5);
}

/* 卡片編號（SPEC §4-12／G2）：全程角落顯示，不顯示完整序號 */
.card-no {
  position: fixed;
  right: calc(env(safe-area-inset-right) + 16px);
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  z-index: 3;
  font-size: 0.8125rem;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  background: rgba(10, 8, 16, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 4px 12px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

/* 連線異常提示條（SPEC §3.5）：疊在畫面上方，**不取代畫面** */
.offline {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: rgba(10, 8, 16, 0.82);
  font-size: 0.8125rem;
  letter-spacing: 0.14em;
  color: var(--ink);
}

/*
 * ── 再次感應提示 ＋ NFC 動畫 ──────────────────────────
 *
 * 移植自「給當下的你×曼陀羅」`public/css/style.css:129–139`（CR-005 J1／J2）。
 * **幾何、時間軸、關鍵影格數值與原設計逐字相同**，僅下列 scoped 調整：
 *   M3 顏色：原 `.reTap.dark{color:var(--text-accent)}`（暖棕）→ 本案深底，改繼承白字
 *   M4 尺寸：原 `124px` 固定 → `min(148px,42vw)`（本案為滿版鎖屏，非含 header 的準備頁）
 *   M5 命名：容器 `.reTap` → `.retap`；動畫本體 class 與 keyframes 名稱沿用
 *   M6 刪除原本的淺／深雙色分支（本案只有深底一種情境）
 *   M10 `.nfcA--inline`：提示條用的小尺寸變體，**只改寬度**
 * 使用點僅三處（J8）：鎖屏、未帶序號入口、連線異常提示。
 */
.retap {
  gap: 10px;
  color: var(--ink);
}

.nfcA {
  width: min(148px, 42vw);
  height: auto;
  display: block;
  margin-bottom: 6px;
}

.nfcA--inline {
  /* 提示條是橫向窄條：實測 88px 會壓縮文字空間，收到 72px（只改寬度，動畫不變） */
  width: min(72px, 20vw);
  margin-bottom: 0;
}

.nfcPhone {
  transform-box: fill-box;
  transform-origin: center;
  animation: nfcMove 2.6s cubic-bezier(0.4, 0, 0.35, 1) infinite;
}

.nfcCard {
  opacity: 0.92;
}

.nfcRing {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  animation: nfcRip 2.6s ease-out infinite;
}

.nfcRing2 {
  animation-delay: 0.16s;
}

.nfcRing3 {
  animation-delay: 0.32s;
}

@keyframes nfcMove {
  0% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(22px);
  }
  60% {
    transform: translateX(22px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes nfcRip {
  0%,
  26% {
    opacity: 0;
    transform: scale(0.35);
  }
  42% {
    opacity: 0.85;
    transform: scale(0.95);
  }
  62% {
    opacity: 0;
    transform: scale(1.95);
  }
  100% {
    opacity: 0;
  }
}

/* M9／J7：來源無此分支，本案新增。動畫語意不變，只是尊重系統設定。 */
@media (prefers-reduced-motion: reduce) {
  .nfcPhone,
  .nfcRing {
    animation: none;
  }
  .nfcRing {
    opacity: 0.55;
  }
}
