/* ════════════════════════════════════════════════════════════
   V3 沉浸式體驗 — 完整樣式
   ════════════════════════════════════════════════════════════ */

#v3-shell {
  position: fixed; inset: 0; z-index: 1000;
  background: #000; overflow: hidden;
  transition: opacity 0.9s ease;
}

/* ── Generic Stage ── */
.v3-stage {
  position: absolute; inset: 0;
  opacity: 0; pointer-events: none;
  transition: opacity 0.6s ease;
}
.v3-stage--active { opacity: 1; pointer-events: auto; }
.v3-stage:not(.v3-stage--active) * { pointer-events: none !important; }

/* ══════════════
   IDLE Stage
   ══════════════ */
#v3-idle {
  background: #000;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.v3-language-picker {
  position: absolute;
  right: clamp(18px, 4vw, 40px);
  bottom: clamp(18px, 4vh, 34px);
  z-index: 20;
}

.v3-language-picker::after {
  content: '';
  position: absolute;
  top: 17px;
  right: 17px;
  width: 7px;
  height: 7px;
  border-right: 1px solid rgba(255, 232, 183, 0.8);
  border-bottom: 1px solid rgba(255, 232, 183, 0.8);
  transform: rotate(45deg);
  pointer-events: none;
}

.v3-language-picker select {
  appearance: none;
  min-width: 148px;
  min-height: 44px;
  padding: 0 38px 0 16px;
  border: 1px solid rgba(255, 221, 153, 0.38);
  border-radius: 999px;
  color: rgba(255, 244, 218, 0.94);
  background: rgba(18, 14, 9, 0.78);
  box-shadow: 0 0 18px rgba(224, 168, 77, 0.12), inset 0 0 12px rgba(255, 226, 168, 0.04);
  backdrop-filter: blur(12px);
  font: 500 13px/1.2 'Noto Serif TC', 'Georgia', serif;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.v3-language-picker select:hover {
  border-color: rgba(255, 232, 183, 0.78);
  background-color: rgba(30, 22, 12, 0.9);
  box-shadow: 0 0 22px rgba(224, 168, 77, 0.22);
}

.v3-language-picker select:focus-visible {
  outline: 2px solid rgba(255, 232, 183, 0.88);
  outline-offset: 4px;
}

.v3-language-picker option {
  color: #f8e8c7;
  background: #100d09;
}

/* ── 呼吸框（整體浮動）── */
.v3-breathing {
  display: flex; flex-direction: column; align-items: center;
  gap: 0;
  animation: v3-breathe 3.6s ease-in-out infinite;
  transition: opacity 0.5s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
/* 點擊後淡出（意謜） */
.v3-breathing--gone {
  opacity: 0 !important;
  pointer-events: none;
}
.v3-breathing--fade { opacity: 0; }

@keyframes v3-breathe {
  0%,100% { transform: translateY(-9px); }
  50%     { transform: translateY(9px); }
}

/* 矩形邊框（亮暗脈動） */
.v3-breathing__frame {
  width: clamp(220px, 48vw, 320px);
  height: clamp(120px, 17vw, 180px);
  border: 1.5px solid rgba(255,255,255,0.12);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.5s, box-shadow 0.5s;
}
/* hover：整個框亮度提升，明確告知可點擊 */
.v3-breathing:hover .v3-breathing__frame {
  border-color: rgba(255, 235, 190, 1) !important;
  box-shadow:
    0 0 30px rgba(255, 219, 143, 0.82),
    0 0 76px rgba(224, 168, 77, 0.48),
    inset 0 0 24px rgba(255, 226, 168, 0.22) !important;
}
.v3-breathing:hover .v3-breathing__text {
  color: rgba(255,255,255,0.9) !important;
  letter-spacing: 0.6em;
  transition: letter-spacing 0.3s ease, color 0.2s;
}

.v3-breathing__frame::before,
.v3-breathing__frame::after {
  content: '';
  position: absolute;
  width: 7px; height: 7px;
  background: rgba(255,255,255,0.15);
  transform: rotate(45deg);
  animation: v3-corner-pulse 3.6s ease-in-out infinite;
  transition: opacity 0.5s;
}
.v3-breathing__frame::before { top: -4px; left: -4px; }
.v3-breathing__frame::after  { bottom: -4px; right: -4px; }
@keyframes v3-corner-pulse {
  0%,100% { background: rgba(255,255,255,0.25); box-shadow: none; }
  50%     { background: rgba(255,255,255,0.90); box-shadow: 0 0 12px rgba(255,255,255,0.5); }
}

/* 框內文字「開始占卜」 */
.v3-breathing__text {
  font-family: 'Noto Serif TC','Georgia','宋體',serif;
  font-size: clamp(14px, 3vw, 19px);
  color: rgba(255, 244, 218, 0.96);
  text-shadow: 0 0 12px rgba(255, 218, 143, 0.38);
  letter-spacing: 0.5em;
  text-align: center;
  margin: 0; padding: 0;
  /* translateX 補正 letter-spacing 右偏：0.5em/2 */
  transform: translateX(0.25em);
  user-select: none;
  animation: v3-text-pulse 3.6s ease-in-out infinite;
  transition: opacity 1.5s ease;
}
@keyframes v3-text-pulse {
  0%,100% { opacity: 0.72; }
  50% { opacity: 1; }
}

/* ── 操作區 ── */
/* ══════════════
   影片層
   ══════════════ */
.v3-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.v3-video--on { opacity: 1; }

/* ══════════════
   Stone Selection Stage
   ══════════════ */
#v3-stones { background: #000; }

.v3-bg-med {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 2.5s ease; z-index: 0;
}
.v3-bg-med--on { opacity: 0.6; }

.v3-cvs {
  position: absolute; inset: 0;
  width: 100%; height: 100%; display: block;
}
.v3-cvs--star  { pointer-events: none; z-index: 1; }
.v3-cvs--stone { pointer-events: inherit; cursor: default; z-index: 2; }
.v3-stage--active .v3-cvs--stone { pointer-events: auto; }

.v3-hint {
  position: absolute; top: 11%; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.78); font-family: 'Noto Serif TC',serif;
  font-size: clamp(15px,3.2vw,20px); letter-spacing: 0.35em; text-align: center;
  pointer-events: none; opacity: 0; transition: opacity 1.2s ease;
  white-space: nowrap; z-index: 3; padding-right: 0.35em;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}
.v3-hint--on { opacity: 1; }

.v3-counter {
  position: absolute; top: 17%; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.3); font-size: 11px; letter-spacing: 0.25em;
  pointer-events: none; opacity: 0; transition: opacity 1.2s ease;
  font-family: 'Noto Serif TC',serif; z-index: 3;
}
.v3-counter--on { opacity: 1; }
#v3-count { color: rgba(255,220,100,0.7); font-size: 13px; }

/* ══════════════════
   底部：已選石頭大圖槽（4 個）
   ══════════════════ */
.v3-picked {
  position: absolute; bottom: 4%; left: 50%; transform: translateX(-50%);
  display: flex; gap: clamp(10px,3.5vw,28px); align-items: flex-end;
  z-index: 3; opacity: 0; transition: opacity 1.5s ease;
  pointer-events: none;
}
.v3-picked--on { opacity: 1; }

.v3-picked__item {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  transition: transform 0.2s;
}
/* 有石頭的槽可以點擊（移除） */
.v3-picked__item--filled {
  pointer-events: auto !important;
  cursor: pointer;
}
.v3-picked__item--filled:hover { transform: scale(1.05); }
/* hover 時顯示移除提示 */
.v3-picked__item--filled:hover .v3-picked__ring {
  border-color: rgba(255, 90, 90, 0.5);
  box-shadow: 0 0 12px rgba(255,80,80,0.15);
}

.v3-picked__stone-wrap {
  width: clamp(60px,11vw,95px); height: clamp(60px,11vw,95px);
  position: relative; display: flex; align-items: center; justify-content: center;
}
.v3-picked__ring {
  position: absolute; inset: 5px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.08);
  transition: border-color 0.4s, box-shadow 0.4s;
}
/* 石頭落入槽位：路小聞轉諟動畫 (pop flash) */
.v3-picked__item--filled .v3-picked__ring {
  border-color: rgba(255,210,70,0.45);
  box-shadow: 0 0 14px rgba(255,210,70,0.1);
  animation: v3-slot-pop 0.75s ease-out;
}
@keyframes v3-slot-pop {
  0%   { transform: scale(1.4); border-color: rgba(255,255,255,0.9);
         box-shadow: 0 0 30px rgba(255,255,255,0.5); }
  40%  { transform: scale(1.1); border-color: rgba(255,210,70,0.9);
         box-shadow: 0 0 22px rgba(255,210,70,0.4); }
  100% { transform: scale(1);   border-color: rgba(255,210,70,0.45);
         box-shadow: 0 0 14px rgba(255,210,70,0.1); }
}
.v3-picked__item--system .v3-picked__ring {
  border-style: dashed; border-color: rgba(255,255,255,0.12);
}
.v3-picked__item--sensing .v3-picked__ring {
  animation: v3-sensing-pulse 0.8s ease-in-out infinite;
  border-style: solid;
}
@keyframes v3-sensing-pulse {
  0%,100% { border-color: rgba(255,210,70,0.2); box-shadow: none; }
  50%     { border-color: rgba(255,210,70,0.9); box-shadow: 0 0 20px rgba(255,210,70,0.3); }
}

.v3-picked__img {
  width: 100%; height: 100%; object-fit: contain; opacity: 0;
  transform: scale(0.75) translateY(-15px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.34,1.56,0.64,1);
  position: relative; z-index: 1;
}
.v3-picked__item--filled .v3-picked__img { opacity: 1; transform: scale(1) translateY(0); }
/* 逆位石頭：180°翻轉 */
.v3-picked__item--filled .v3-picked__img.v3-img--reversed {
  transform: scale(1) translateY(0) rotate(180deg);
}

.v3-picked__label {
  font-family: 'Noto Serif TC',serif;
  font-size: clamp(10px,2vw,12px);
  color: rgba(255,255,255,0.22); letter-spacing: 0.15em;
  transition: color 0.5s; padding-right: 0.15em;
}
.v3-picked__item--filled .v3-picked__label { color: rgba(255,210,70,0.7); }
.v3-picked__item--system .v3-picked__label { color: rgba(255,255,255,0.12); }
.v3-picked__item--system.v3-picked__item--filled .v3-picked__label {
  color: rgba(255, 226, 145, 0.96);
  text-shadow: 0 0 8px rgba(255, 210, 105, 0.82), 0 0 20px rgba(224, 168, 77, 0.48);
  animation: v3-overall-label-breathe 2.6s ease-in-out infinite;
}
@keyframes v3-overall-label-breathe {
  0%,100% { opacity: 0.78; }
  50% { opacity: 1; }
}

/* ── 點擊拾取特效（金色光環）── */
.v3-pick-ring {
  position: fixed;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(255,200,50,0.9);
  pointer-events: none;
  transform: translate(-50%,-50%) scale(0.3);
  animation: v3-pick-ring 1.2s cubic-bezier(0.15,0.8,0.4,1) forwards;
  z-index: 9999;
}
@keyframes v3-pick-ring {
  0%   { transform: translate(-50%,-50%) scale(0.3); opacity: 1; }
  40%  { opacity: 0.8; }
  100% { transform: translate(-50%,-50%) scale(2.6); opacity: 0; }
}

/* ══════════════
   Fade Overlay
   ══════════════ */
.v3-fade {
  position: absolute; inset: 0; background: #000;
  opacity: 0; pointer-events: none; z-index: 998;
  transition: opacity 0.15s linear;
}
.v3-fade--on { opacity: 1; pointer-events: auto; }

/* ══════════════════════
   結果頁：十字石頭佈局
   上=整體，左=過去，中=現在，右=未來
   ══════════════════════ */
.v3-spread {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  grid-template-areas:
    ". overall ."
    "past present future";
  gap: clamp(12px,3vw,32px) clamp(10px,3vw,28px);
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(12px,3vh,28px) 0;
  width: 100%;
}
.v3-spread__item {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  cursor: pointer; transition: transform 0.2s;
  opacity: 0;
  animation: v3-card-rise 0.65s ease forwards;
}
/* 過去→現在→未來→整體 依序淡入 */
.v3-spread__item:nth-child(1) { animation-delay: 0.15s; }
.v3-spread__item:nth-child(2) { animation-delay: 0.35s; }
.v3-spread__item:nth-child(3) { animation-delay: 0.55s; }
.v3-spread__item:nth-child(4) { animation-delay: 0.75s; }
.v3-spread__item:hover { transform: translateY(-4px); }

.v3-spread__stone-wrap {
  width: clamp(72px,13vw,120px); height: clamp(72px,13vw,120px);
  border-radius: 50%; overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
  transition: box-shadow 0.3s;
}
.v3-spread__item:hover .v3-spread__stone-wrap {
  box-shadow: 0 6px 30px rgba(255,210,70,0.3);
}
.v3-spread__stone-img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.v3-spread__stone-img--reversed { transform: rotate(180deg); }

.v3-spread__info {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.v3-spread__position {
  font-family: 'Noto Serif TC',serif;
  font-size: clamp(11px,2vw,13px);
  color: rgba(255,210,70,0.85); letter-spacing: 0.18em;
}
.v3-spread__name {
  font-size: clamp(10px,1.8vw,13px);
  color: rgba(255,255,255,0.65); font-family: 'Noto Serif TC',serif;
}
.v3-spread__orient {
  font-size: 10px; color: rgba(255,255,255,0.35);
}

/* 結果頁卡片：進場 stagger */
.v3-result-ready .result-rune {
  opacity: 0; animation: v3-card-rise 0.65s ease forwards;
}
.v3-result-ready .result-rune:nth-child(1) { animation-delay: 0.1s; }
.v3-result-ready .result-rune:nth-child(2) { animation-delay: 0.3s; }
.v3-result-ready .result-rune:nth-child(3) { animation-delay: 0.5s; }
.v3-result-ready .result-rune:nth-child(4) { animation-delay: 0.7s; }
.v3-result-ready .interpretation {
  opacity: 0; animation: v3-card-rise 0.65s ease 0.9s forwards;
}
@keyframes v3-card-rise {
  from { opacity:0; transform:translateY(28px); }
  to   { opacity:1; transform:translateY(0); }
}

/* ══════════════
   影片播放時淡入的「請靜心沉思」
   畫面中央下方 margin+1rem
   ══════════════ */
.v3-picked__img:not([src]),
.v3-picked__img[src=''],
.v3-picked__img[src='data:,'] {
  visibility: hidden;
}

/* ══════════════════════════════════════
   影片結束後「心已如水止」星空轉場文字
   移植自 code_artifact.html 的 center-hint 節奏
   ══════════════════════════════════════ */
#v3-starfield-text {
  position: fixed; inset: 0; z-index: 1010;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0;
  pointer-events: none;
  /* opacity 全由 JS 配 style.transition + style.opacity 控制 */
}

/* 兩行文字基礎樣式（相同大小，輸流起點 0） */
/* 共用結構 */
.v3-starfield-text__main,
.v3-starfield-text__sub {
  font-family: 'Noto Serif TC', serif;
  font-size: clamp(20px, 3.5vw, 30px);
  font-weight: 300;
  letter-spacing: 0.30em;
  margin: 0;
  opacity: 0;
  position: absolute;
  left: 50%; transform: translateX(-50%);
  white-space: nowrap;
}
/* 心已如止水：暗淡灰藍，較不教眼 */
.v3-starfield-text__main {
  color: rgba(210, 225, 255, 0.78);
  text-shadow: 0 0 24px rgba(150, 200, 255, 0.25), 0 2px 16px rgba(0, 0, 0, 0.8);
}
/* 抬頭便是整片星空：亮白發光 */
.v3-starfield-text__sub {
  color: rgba(220, 235, 255, 0.90);
  text-shadow:
    0 0 40px rgba(125, 211, 252, 0.45),
    0 2px 20px rgba(0, 0, 0, 0.9);
}

/* ══════════════════════════════════════
   首頁 v3：全螢幕置中呼吸燈按鈕
   ══════════════════════════════════════ */
.v3-homepage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
}

/* IDLE 和 homepage 的 .v3-breathing 當 button 使用，reset 原生樣式 */
#v3-idle .v3-breathing,
#homepage .v3-breathing {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

/* IDLE 呼吸框改為圆圈 */
#v3-idle .v3-breathing__frame {
  width:  clamp(140px, 22vmin, 200px);
  height: clamp(140px, 22vmin, 200px);
  border-radius: 50%;
  border-color: rgba(255, 232, 183, 0.72);
  background: rgba(12, 9, 4, 0.18);
  box-shadow:
    0 0 18px rgba(255, 219, 143, 0.32),
    0 0 46px rgba(224, 168, 77, 0.16),
    inset 0 0 20px rgba(255, 226, 168, 0.08);
  isolation: isolate;
}

/* 柔和金色光暈只改 opacity，避免每幀重算尺寸或位置 */
#v3-idle .v3-breathing__frame::before {
  display: block;
  inset: -32px;
  width: auto;
  height: auto;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(255, 205, 115, 0.28) 0%, rgba(216, 158, 71, 0.12) 38%, transparent 72%);
  filter: blur(12px);
  opacity: 0.34;
  transform: none;
  z-index: 0;
  animation: v3-aura-pulse 3.6s ease-in-out infinite;
}

#v3-idle .v3-breathing__frame::after { display: none; }

#v3-idle .v3-breathing__text {
  position: relative;
  z-index: 1;
}

@keyframes v3-aura-pulse {
  0%,100% { opacity: 0.3; }
  50% { opacity: 0.88; }
}

#v3-idle .v3-breathing:focus-visible .v3-breathing__frame {
  outline: 2px solid rgba(255, 232, 183, 0.9);
  outline-offset: 10px;
}

@media (prefers-reduced-motion: reduce) {
  #v3-idle .v3-breathing,
  #v3-idle .v3-breathing__frame,
  #v3-idle .v3-breathing__frame::before,
  #v3-idle .v3-breathing__text,
  .v3-picked__item--system.v3-picked__item--filled .v3-picked__label {
    animation: none;
  }

  #v3-idle .v3-breathing__frame {
    border-color: rgba(255, 232, 183, 0.85);
    box-shadow: 0 0 24px rgba(255, 219, 143, 0.58), 0 0 58px rgba(224, 168, 77, 0.28);
  }
  #v3-idle .v3-breathing__frame::before { opacity: 0.7; }
}

