/* Workflow WR · three.js 版
 * 色票：單一強調色 #ff522f（WR 品牌準則的螢光橘）。
 *   2026-09-26 Maxi 拍：08-19 網頁 UI 標準要求橘字改用 #802918，與品牌準則的螢光橘衝突，選品牌那一邊 ——
 *   橘色的字、標語、環上標籤、按鈕底一律 #ff522f；橘底上的字用 --ink（6.8:1，08-19 標準的淺階用字規則）。
 *   ◎ 代價寫在這裡不藏：#ff522f 當字放在灰白底上是 2.59:1，低於 WCAG AA。
 *     焦點框仍用 --accent-deep —— 那是給鍵盤使用者找位置的，不是品牌色。
 *   UI 元素不出現純白、純黑。
 * 字型：沿用 WR 的系統字堆疊，零下載。 */
:root {
  --surface-1: #f2f1f9; --surface-2: #d8d9de; --surface-3: #bbbcc6;
  --line: #bbbcc6; --line-strong: #5e5e63;
  --ink: #262626; --ink-muted: #474747; --on-accent: #e6e6e6;
  --accent: #ff522f; --accent-deep: #b23921; --accent-text: #802918;
  --accent-tint: #ffd4cb; --accent-light: #ff8f78;
  --fog: #eff0f4;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --pad: clamp(20px, 5vw, 88px);
  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--fog); }
body {
  margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.7; color: var(--ink);
  background: var(--fog); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
body.loading { overflow: hidden; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 3px; }
em { font-style: normal; color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }

/* ── 舞台：畫布與 CSS3D 層都固定在視窗，捲動只提供進度 ─────────── */
#gl { position: fixed; inset: 0; width: 100vw; height: 100svh; display: block; z-index: 0; touch-action: pan-y; }
#stage3d { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
#stage3d > div { pointer-events: none; }
#stage3d .obj { pointer-events: auto; }
#stage3d .obj.is-off { pointer-events: none; }
#scroll { position: relative; z-index: 1; width: 1px; pointer-events: none; }
#content { position: relative; z-index: 3; }
html.three #content { position: absolute; left: 0; top: 0; width: 0; height: 0; overflow: visible; }

/* ── 首屏字 ─────────────────────────────────────────────────── */
.hero-copy h1 {
  margin: 0; font-size: clamp(2.4rem, 6vw, 5.6rem); font-weight: 900; letter-spacing: -.03em; line-height: .94; white-space: nowrap;
}
.hero-copy h1::after { content: ""; display: block; width: min(300px, 42%); height: 6px; margin-top: .32em; background: var(--accent); }
.hero-copy .hero-body { margin: 1.1em 0 0; font-size: 17px; color: var(--ink-muted); max-width: 34em; }
.hero-copy .status { margin: 1em 0 0; font-size: 15px; color: var(--ink-muted); display: flex; align-items: center; gap: 10px; }
.hero-copy .status b { color: var(--ink); font-weight: 800; }
.dots { display: inline-flex; gap: 6px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: block; }
.dots i.on { background: var(--accent); border-color: var(--accent); }

/* ── 環上標籤 ───────────────────────────────────────────────── */
.rl {
  display: block; font-size: 15px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); text-decoration: none; white-space: nowrap; padding: 4px 8px; border-radius: 6px;
  background: rgba(242, 241, 249, .72);
}
.rl:empty { display: none; }
.rl:hover { background: var(--accent-tint); }

/* ── 區塊標頭 ───────────────────────────────────────────────── */
.eyebrow { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .16em; color: var(--ink-muted); display: flex; align-items: center; gap: 12px; }
.eyebrow::before { content: ""; width: 34px; height: 3px; background: var(--accent); display: block; }
.slots-head h2, .rules-head h2 { margin: .2em 0 0; font-size: clamp(1.8rem, 3.2vw, 3.2rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.slots-head .lede { margin: .6em 0 0; font-size: 15px; color: var(--ink-muted); max-width: 40em; }

/* ── 卡片（掛在石碑芯上的螢幕）─────────────────────────────── */
.card { position: relative; perspective: 1400px; }
/* 翻面分兩段：轉到 90° → 換面 → 從 −90° 轉回來。任何時刻只有一面可見，
   不靠 backface-visibility —— CSS3DRenderer 的矩陣帶一次 y 軸鏡射，Chrome 在那條鏈上判背面不可靠（實測背面鏡像疊在正面上）。 */
.card__inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .3s cubic-bezier(.5, 0, .75, 0); }
.card.turn-out .card__inner { transform: rotateY(90deg); }
.card.turn-in .card__inner { transform: rotateY(-90deg); transition: none; }
.card.turn-back .card__inner { transition: transform .38s var(--ease); }
.card:not(.is-flipped) .card__back, .card.is-flipped .card__front { visibility: hidden; }
.card__face {
  position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: rgba(242, 241, 249, .95); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 18px 42px rgba(38, 38, 38, .18);
}
.card__top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; letter-spacing: .12em; color: var(--ink-muted); font-weight: 700; }
.tag { padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 11px; letter-spacing: .1em; }
.tag--shipped { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.card__name { margin: 2px 0 0; font-size: 24px; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; }
.card__kicker { display: block; margin-top: 4px; font-size: 14px; font-weight: 700; color: var(--accent); letter-spacing: 0; }
.card__line { margin: 0; font-size: 14px; line-height: 1.6; color: var(--ink); }
.card__note { margin: 0; font-size: 14px; color: var(--ink-muted); }
.spec { margin: 2px 0 0; display: grid; grid-template-columns: 1fr; gap: 0; font-size: 12.5px; line-height: 1.45; }
.spec > div { display: grid; grid-template-columns: 4.2em 1fr; gap: 8px; padding: 4px 0; border-top: 1px solid var(--line); }
.spec dt { color: var(--ink-muted); font-weight: 700; }
.spec dd { margin: 0; }
.spec .note { display: block; }
.card__actions { margin-top: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px; background: var(--accent); color: var(--ink);
  font-weight: 700; font-size: 14px; text-decoration: none; letter-spacing: .02em;
}
.btn:hover { background: var(--accent-light); }
.more {
  font: inherit; font-size: 13px; font-weight: 700; color: var(--ink); background: transparent;
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 12px; cursor: pointer;
}
.more:hover { background: var(--surface-2); }
.card__solves { margin: 4px 0 0; font-size: 18px; font-weight: 800; }
.card__pain { margin: 0; font-size: 13.5px; line-height: 1.65; }
.proof { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.proof li { padding: 5px 10px; border-radius: 8px; background: var(--surface-2); }
.proof b { margin-right: 8px; color: var(--ink-muted); }
.card__offline { margin: 0; font-size: 12px; color: var(--ink-muted); line-height: 1.55; }
.card[data-state="planned"] .card__face { background: rgba(216, 217, 222, .82); box-shadow: none; }
.card[data-state="planned"] .card__name { color: var(--ink-muted); }

/* ── 紀律（刻在主碑上的四塊牌）─────────────────────────────── */
.rules-head h2 { color: var(--ink); }
.rule {
  background: rgba(38, 38, 38, .93); color: var(--on-accent); border-radius: 12px; padding: 22px 24px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: 0 20px 44px rgba(38, 38, 38, .22);
}
.rule__num { font-size: 30px; font-weight: 900; color: var(--accent); line-height: 1; letter-spacing: -.02em; }
.rule h3 { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.3; }
.rule p { margin: 0; font-size: 14.5px; line-height: 1.65; color: var(--surface-2); }

/* ── 固定在視窗上的器物：語言、音效、游標、提示、頁尾 ────────── */
.skip { position: fixed; left: 12px; top: -60px; z-index: 400; background: var(--ink); color: var(--on-accent); padding: 8px 14px; border-radius: 8px; font-size: 14px; }
.skip:focus { top: 12px; }
.lang-switch {
  position: fixed; top: 14px; right: var(--pad); z-index: 60; display: flex; flex-direction: column; gap: 2px; padding: 4px;
  border-radius: 999px; background: rgba(242, 241, 249, .55); border: 1px solid rgba(94, 94, 99, .25);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
}
.lang-switch button {
  font: inherit; font-size: 12px; font-weight: 800; width: 36px; height: 30px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink); cursor: pointer; letter-spacing: .06em;
}
.lang-switch button[aria-pressed="true"] { background: var(--line-strong); color: var(--on-accent); }
.scrollcue {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 40; margin: 0;
  font-size: 12px; font-weight: 800; letter-spacing: .3em; color: var(--ink-muted); transition: opacity .4s;
}
.scrollcue::after { content: ""; display: block; width: 1px; height: 28px; margin: 8px auto 0; background: var(--line-strong); animation: cue 2.2s var(--ease) infinite; transform-origin: top; }
@keyframes cue { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }
.foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; gap: 22px; flex-wrap: wrap; align-items: center;
  padding: 14px var(--pad); font-size: 13px; color: var(--ink-muted); background: rgba(242, 241, 249, .82);
  border-top: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transform: translateY(100%); transition: transform .5s var(--ease);
}
.foot.is-on { transform: none; }
.foot__brand { color: var(--ink); font-weight: 800; }

/* 音效抽屜 */
.sound-dock { position: fixed; top: 98px; right: 0; z-index: 60; display: flex; align-items: flex-start; transform: translateX(calc(100% - 44px)); transition: transform .45s var(--ease); }
.sound-dock.open { transform: none; }
.sound-tab {
  width: 44px; padding: 12px 0; border: 1px solid rgba(94, 94, 99, .25); border-right: 0; border-radius: 12px 0 0 12px;
  background: rgba(242, 241, 249, .7); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); cursor: pointer;
  font: inherit; font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--ink); writing-mode: vertical-rl;
}
.sound-dock.sound-on .sound-tab { color: var(--accent); }
.sound-panel {
  width: 220px; padding: 16px 18px; background: rgba(242, 241, 249, .86); border: 1px solid rgba(94, 94, 99, .25); border-right: 0;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 13px;
}
.sound-title { margin: 0 0 10px; font-size: 11px; font-weight: 800; letter-spacing: .16em; color: var(--ink-muted); }
.sound-toggle { font: inherit; display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: transparent; cursor: pointer; font-weight: 800; color: var(--ink); }
.sound-switch { width: 34px; height: 18px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background .3s; }
.sound-switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface-1); transition: transform .3s var(--ease); }
.sound-toggle[aria-pressed="true"] .sound-switch { background: var(--line-strong); }
.sound-toggle[aria-pressed="true"] .sound-switch::after { transform: translateX(16px); }
.sound-note { margin: 10px 0 0; color: var(--ink-muted); font-size: 12px; }

/* 游標：祈禱手（精細指標才出現；觸控裝置用原生） */
.camera-cursor { position: fixed; left: 0; top: 0; z-index: 300; width: 28px; height: 32px; pointer-events: none; display: none; --hand-color: #44464b; }
.camera-cursor .hand {
  position: absolute; inset: 0; background: var(--hand-color);
  -webkit-mask: url('../assets/prayer-hands.svg') center / contain no-repeat; mask: url('../assets/prayer-hands.svg') center / contain no-repeat;
  filter: drop-shadow(0 0 var(--hand-glow, 0px) var(--hand-color));
}
@media (hover: hover) and (pointer: fine) {
  html.cursor-on, html.cursor-on * { cursor: none !important; }
  html.cursor-on .camera-cursor { display: block; }
}

/* ── 讀取畫面：祈禱手 + 十一道光 ─────────────────────────────── */
.scene-loader {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 42%, rgba(242, 241, 249, .96), rgba(216, 217, 222, .98) 62%, rgba(187, 188, 198, .98));
  transition: opacity .68s var(--ease);
}
.scene-loader.done { opacity: 0; pointer-events: none; }
.load-mark { position: relative; width: 150px; height: 150px; }
.load-hands {
  position: absolute; left: 50%; bottom: 0; width: 108px; height: 108px; transform: translateX(-50%);
  background: rgba(71, 71, 71, .20); transition: background .5s;
  -webkit-mask: url('../assets/prayer-hands-body.svg') center bottom / 108px auto no-repeat; mask: url('../assets/prayer-hands-body.svg') center bottom / 108px auto no-repeat;
}
.load-mark.complete .load-hands { background: var(--accent); }
.load-ray { position: absolute; left: 50%; top: 51px; width: 2px; height: var(--len); margin-left: -1px; background: var(--surface-3); transform-origin: 50% 100%; transform: translateY(-100%) rotate(var(--a)); border-radius: 2px; transition: background .3s, box-shadow .3s; }
.load-ray.lit { background: var(--accent); box-shadow: 0 0 8px rgba(255, 82, 47, .55); }
.load-copy { margin: 18px 0 0; text-align: center; font-size: 12px; font-weight: 800; letter-spacing: .3em; color: var(--ink-muted); }
.load-track { width: 118px; height: 1px; margin: 10px auto 0; background: var(--surface-3); overflow: hidden; }
.load-track span { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform .3s; }

/* ── 效能面板（反引號）──────────────────────────────────────── */
#hud {
  position: fixed; left: 12px; bottom: 12px; z-index: 120; display: none; padding: 12px 14px; min-width: 260px;
  font: 12px/1.6 var(--mono); color: var(--on-accent); background: rgba(38, 38, 38, .88); border-radius: 10px; white-space: pre;
}
#hud.on { display: block; }

/* ── 平面版面：減少動態、沒有 WebGL、或沒有 JavaScript 時 ─────── */
html.flat #stage3d { display: none; }
html.flat #content { padding: 12vh var(--pad) 18vh; display: block; }
html.flat .hero { min-height: 70svh; display: flex; align-items: flex-end; padding-bottom: 8vh; }
html.flat .ringlabels { display: none; }
html.flat .slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 12vh; }
html.flat .slots-head { grid-column: 1 / -1; margin-bottom: 20px; }
html.flat .card { min-height: 520px; }
html.flat .card__face { position: relative; inset: auto; height: 100%; backface-visibility: visible; }
html.flat .card:not(.is-flipped) .card__back { display: none; }
html.flat .card.is-flipped .card__front { display: none; }
html.flat .rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 12vh; }
html.flat .rules-head { grid-column: 1 / -1; }
html.flat .foot { position: static; transform: none; margin-top: 12vh; }
html.flat .scrollcue { display: none; }
html.static body { background: var(--fog) url('../assets/poster.jpg') center top / cover fixed no-repeat; }
html.static #gl { display: none; }
@media (max-width: 1080px) { html.flat .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); } html.flat .rules { grid-template-columns: 1fr; } }
@media (max-width: 640px) { html.flat .slots { grid-template-columns: 1fr; } html.flat .card { min-height: 0; } }
@media (prefers-reduced-motion: reduce) { .card__inner, .foot, .sound-dock, .scene-loader { transition: none; } .scrollcue::after { animation: none; } }

/* 量高度用的暫存區：看板排版前，元素先在這裡以目標寬度量自然高度 */
#measure { position: absolute; left: -20000px; top: 0; visibility: hidden; pointer-events: none; }
.measuring .card__face { position: relative; inset: auto; }
.measuring .card__back { visibility: visible; }
.measuring .card__inner { transform: none !important; height: auto; }

/* 3D 模式：卡片不自己開 perspective —— 那會另起一個 3D 情境，背面遮不掉（實測：背面鏡像疊在正面上）。
   改成整張卡參與場景相機的 3D 情境，翻面就是在場景裡真的翻過去。 */
html.three .card { perspective: none; transform-style: preserve-3d; }
/* 標頭直接印在石頭上時，小字與石色的對比不夠（量到約 2:1）——給一塊底板，跟卡片同一種面 */
html.three .slots-head, html.three .rules-head {
  background: rgba(242, 241, 249, .92); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px 16px;
  box-shadow: 0 14px 34px rgba(38, 38, 38, .14);
}
