/* =========================================================
   three.css — .three-stage（THREE-01〜04）の土台
   three.js のキャンバスを敷き、その上に文字（.three-stage__content）を載せる。
   フォールバック（.three-stage__fallback）は最初から表示しておき、描画が始まって
   stage に .is-ready が付いたら透明にする。WebGL 不可・reduced-motion では表示したまま。
   z-index はステージ内に閉じる（isolation）ので、ヘッダー 100 やスマホ CTA バー 80 と競合しない。
   ========================================================= */

.three-stage {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: clamp(360px, 70svh, 720px);
  background: var(--c-bg-cream);
  color: var(--c-text);
}
.three-stage canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.three-stage__fallback {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  background: linear-gradient(135deg, var(--c-primary-soft) 0%, var(--c-bg-cream) 55%, var(--c-primary-soft) 100%);
  transition: opacity 0.9s ease;
}
.three-stage__fallback img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.three-stage.is-ready .three-stage__fallback {
  opacity: 0;
  pointer-events: none;
}

/* 文字・ボタンを載せる層。キャンバスの上に来る */
.three-stage__content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: inherit;
  padding: 72px 0;
}
.three-stage__content .container { width: 100%; }

/* 読みやすさの確保：暗いシーンには --dark、明るいシーンには --light を付ける */
.three-stage--dark { background: var(--c-primary-deep); color: #fff; }
.three-stage--dark .three-stage__fallback {
  background: linear-gradient(135deg, var(--c-primary-deep) 0%, var(--c-primary) 100%);
}
.three-stage--light .three-stage__content { text-shadow: 0 1px 2px rgba(255,255,255,0.6); }

/* 用途別の高さ */
.three-stage--hero { min-height: calc(100svh - var(--header-h)); }
.three-stage--band { min-height: 320px; }
.three-stage--viewer { min-height: clamp(320px, 56svh, 560px); background: var(--c-bg); }

@media (max-width: 768px) {
  .three-stage { min-height: clamp(280px, 60svh, 560px); }
  .three-stage--hero { min-height: calc(88svh - var(--header-h)); }
  .three-stage--band { min-height: 260px; }
  .three-stage__content { padding: 56px 0; }
}

/* 動きを抑える設定では、キャンバスを作らずフォールバックを見せ続ける。
   すでに描画中に設定が変わった場合も、この規則で静止画へ戻る。 */
@media (prefers-reduced-motion: reduce) {
  .three-stage canvas { display: none; }
  .three-stage.is-ready .three-stage__fallback { opacity: 1; pointer-events: auto; }
}
