/* ==========================================================================
   Liverey — Journey of Wings（翼の旅）
   全ページ連動の「夢の世界」レイヤー用スタイル
   ※既存デザインの上に重ねる追加レイヤー。既存CSSは変更しません。
   ========================================================================== */

:root {
  /* JS が進行度に応じて更新する変数（0=夜 → 1=夜明け） */
  --dream-dawn: 0;
  --dream-gold: #c8a24c;
  --dream-green: #6f8f4a;
}

/* --- 粒子キャンバス（動画の前・本文の後ろ） --- */
#dream-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* --- カーソルに追従する光の精霊 --- */
.dream-orb {
  position: fixed;
  top: 0;
  left: 0;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9998;
  background: radial-gradient(circle at 50% 50%,
      rgba(255, 244, 210, 0.95) 0%,
      rgba(226, 178, 74, 0.55) 35%,
      rgba(226, 178, 74, 0) 70%);
  mix-blend-mode: screen;
  transition: opacity .4s ease;
  will-change: transform;
}

/* --- 隠れた「灯（ともしび）」 --- */
.dream-light {
  position: fixed;
  width: 44px;
  height: 44px;
  z-index: 9997;
  cursor: pointer;
  border: 0;
  padding: 0;
  background: transparent;
  opacity: .16;                 /* 通常はほのか */
  transform: scale(.7);
  transition: opacity .5s ease, transform .5s ease;
  will-change: transform, opacity;
}
.dream-light::before {          /* 光の玉 */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%,
      #fff7e0 0%, var(--dream-gold) 45%, rgba(200, 162, 76, 0) 72%);
  box-shadow: 0 0 22px 6px rgba(226, 178, 74, 0.55);
}
.dream-light::after {           /* 小さな羽/芽のアクセント */
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 6px; height: 14px;
  margin: -7px 0 0 -3px;
  border-radius: 60% 60% 60% 60% / 70% 70% 40% 40%;
  background: var(--dream-green);
  opacity: .9;
}
.dream-light.is-near {          /* カーソルの光が近づくと現れる */
  opacity: .9;
  transform: scale(1.05);
}
.dream-light.is-lit {           /* 点灯済み */
  opacity: 1;
  transform: scale(1);
  cursor: default;
  animation: dreamPulse 3.2s ease-in-out infinite;
}
.dream-light:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 6px;
  opacity: .9;
}

@keyframes dreamPulse {
  0%, 100% { filter: brightness(1);   }
  50%      { filter: brightness(1.5); }
}

/* 点灯時に一度だけ弾ける光 */
.dream-burst {
  position: fixed;
  z-index: 9996;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255,247,224,.9), rgba(226,178,74,0));
  animation: dreamBurst .9s ease-out forwards;
}
@keyframes dreamBurst {
  0%   { transform: scale(1);  opacity: .9; }
  100% { transform: scale(14); opacity: 0;  }
}

/* --- HUD：星座のような進行インジケーター --- */
.dream-hud {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-family: 'ITC', 'Times New Roman', serif;
  color: #fff;
  user-select: none;
}
.dream-hud__label {
  font-size: 11px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}
.dream-hud__constellation {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 30px;
  background: rgba(10, 12, 18, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.dream-node {
  position: relative;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  transition: background .5s ease, box-shadow .5s ease, transform .5s ease;
  z-index: 1;
}
.dream-node[data-current="true"] {
  transform: scale(1.25);
}
.dream-node.is-lit {
  background: radial-gradient(circle, #fff7e0, var(--dream-gold));
  border-color: rgba(255, 247, 224, 0.9);
  box-shadow: 0 0 12px 2px rgba(226, 178, 74, 0.8);
}
/* ノードをつなぐ線 */
.dream-node::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 100%;
  width: 14px;
  height: 1px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.22);
  z-index: -1;
}
.dream-node:last-child::after { display: none; }
.dream-node.is-lit::after { background: rgba(226, 178, 74, 0.55); }

.dream-hud__buttons { display: flex; gap: 10px; }
.dream-hud__btn {
  font-size: 10px;
  letter-spacing: .16em;
  color: rgba(255, 255, 255, 0.6);
  background: transparent;
  border: 0;
  padding: 2px 4px;
  cursor: pointer;
  text-transform: uppercase;
  transition: color .25s ease;
}
.dream-hud__btn:hover { color: #fff; }

/* --- フィナーレ：翼の羽ばたき --- */
.dream-finale {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  background: radial-gradient(circle at 50% 42%,
      rgba(38, 28, 12, 0.82), rgba(5, 7, 11, 0.97));
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease;
}
.dream-finale.is-active {
  opacity: 1;
  pointer-events: auto;
}
.dream-finale__wing {
  width: min(46vw, 320px);
  height: auto;
  filter: drop-shadow(0 0 40px rgba(226, 178, 74, 0.7));
  transform: scale(.4);
  opacity: 0;
}
.dream-finale.is-active .dream-finale__wing {
  animation: dreamTakeoff 2.4s cubic-bezier(.2, .8, .2, 1) forwards;
}
@keyframes dreamTakeoff {
  0%   { transform: scale(.4) translateY(30px); opacity: 0; }
  40%  { transform: scale(1)  translateY(0);    opacity: 1; }
  100% { transform: scale(1.06) translateY(-10px); opacity: 1; }
}
.dream-finale__msg {
  margin-top: 30px;
  font-family: 'ITC', 'Times New Roman', serif;
  font-size: clamp(18px, 3.4vw, 30px);
  letter-spacing: .12em;
  line-height: 1.9;
  opacity: 0;
}
.dream-finale.is-active .dream-finale__msg {
  animation: dreamFadeUp 1.4s ease 1.4s forwards;
}
.dream-finale__sub {
  margin-top: 14px;
  font-size: 13px;
  letter-spacing: .1em;
  color: rgba(255, 255, 255, 0.7);
  opacity: 0;
}
.dream-finale.is-active .dream-finale__sub {
  animation: dreamFadeUp 1.4s ease 2s forwards;
}
.dream-finale__close {
  margin-top: 34px;
  padding: 12px 34px;
  font-size: 13px;
  letter-spacing: .16em;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: background .25s ease, color .25s ease;
}
.dream-finale.is-active .dream-finale__close {
  animation: dreamFadeUp 1.4s ease 2.4s forwards;
}
.dream-finale__close:hover { background: #fff; color: #111; }
@keyframes dreamFadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- オフ状態 --- */
.dream-off #dream-canvas,
.dream-off .dream-orb,
.dream-off .dream-light { display: none !important; }

/* --- 動きを減らす設定への配慮 --- */
@media (prefers-reduced-motion: reduce) {
  .dream-orb { display: none; }
  .dream-light.is-lit { animation: none; }
  .dream-finale__wing,
  .dream-finale__msg,
  .dream-finale__sub,
  .dream-finale__close { animation: none !important; opacity: 1; transform: none; }
}

/* スマホでは HUD を控えめに */
@media (max-width: 600px) {
  .dream-hud { right: 12px; bottom: 12px; }
  .dream-hud__label { font-size: 10px; }
  .dream-light { width: 38px; height: 38px; }
}

/* タッチ端末（ホバー不可）では灯を見えるように（近接演出が使えないため） */
@media (hover: none) {
  .dream-light { opacity: .7; transform: scale(.95); }
}
