/* ===== 上海之窗 · Window of Shanghai ===== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;500;700;900&family=Cinzel:wght@400;600&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --gold: #e8c170;
  --gold-soft: #f4dca0;
  --ink: #06080f;
  --accent: #5fd3ff;
}

html, body {
  width: 100%; height: 100%;
  background: #02040a;
  overflow: hidden;
  font-family: 'Noto Serif SC', serif;
  color: #fff;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
  cursor: none;
}

/* ===== Custom halo cursor ===== */
#cursor-halo {
  position: fixed;
  top: 0; left: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(232, 193, 112, 0.85);
  box-shadow:
    0 0 8px rgba(232, 193, 112, 0.6),
    0 0 20px rgba(232, 193, 112, 0.3),
    inset 0 0 8px rgba(232, 193, 112, 0.15);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: width .18s ease, height .18s ease, border-color .18s ease, box-shadow .18s ease, opacity .2s ease;
  will-change: transform;
}
#cursor-halo.pressing {
  width: 22px; height: 22px;
  border-color: rgba(232, 193, 112, 1);
  box-shadow:
    0 0 16px rgba(232, 193, 112, 0.9),
    0 0 40px rgba(232, 193, 112, 0.5),
    inset 0 0 12px rgba(232, 193, 112, 0.3);
}
#cursor-halo.hovering {
  width: 52px; height: 52px;
  border-color: rgba(255, 220, 140, 0.95);
  box-shadow:
    0 0 18px rgba(232, 193, 112, 0.8),
    0 0 50px rgba(232, 193, 112, 0.45),
    inset 0 0 18px rgba(232, 193, 112, 0.2);
}

#app { position: fixed; inset: 0; z-index: 0; }
#app canvas { display: block; }

/* ===== White flash transition ===== */
#flash {
  position: fixed; inset: 0; z-index: 90;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s ease;
}
#flash.show { opacity: 1; }

/* ===== UI layers ===== */
.ui-layer {
  position: fixed; inset: 0; z-index: 20;
  display: none;
  pointer-events: none;
}
.ui-layer.active { display: block; }
.ui-layer button { pointer-events: auto; }

/* ===== Landing ===== */
.landing-sub {
  position: absolute; top: 16%; left: 50%; transform: translateX(-50%);
  font-family: 'Cinzel', serif;
  letter-spacing: .7em;
  font-size: clamp(10px, 2vw, 18px);
  color: var(--gold-soft);
  opacity: .75;
  padding-left: .7em;
  animation: fadeIn 2s ease both;
}

.gate-btn {
  position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%);
  width: 200px; height: 64px;
  background: transparent;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 2.4s ease .4s both;
}
.gate-label {
  position: relative; z-index: 2;
  font-size: 20px; letter-spacing: .35em; font-weight: 500;
  color: var(--gold-soft);
  text-shadow: 0 0 18px rgba(232,193,112,.7);
}
.gate-ring {
  position: absolute; inset: 0;
  border: 1px solid rgba(232,193,112,.55);
  border-radius: 40px;
  box-shadow: 0 0 30px rgba(232,193,112,.25), inset 0 0 24px rgba(232,193,112,.15);
  transition: all .35s ease;
}
.gate-btn:hover .gate-ring {
  box-shadow: 0 0 55px rgba(232,193,112,.6), inset 0 0 30px rgba(232,193,112,.3);
  transform: scale(1.04);
}

.hint {
  position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%);
  font-size: 12px; letter-spacing: .4em; color: rgba(255,255,255,.6);
  text-shadow: 0 0 8px rgba(255,255,255,.5), 0 0 18px rgba(232,193,112,.3);
  animation: pulse 2.6s ease-in-out infinite;
}
.enter-hint {
  bottom: 8%;
  font-size: clamp(11px, 1.4vw, 15px);
  letter-spacing: .6em; padding-left: .6em;
  color: #fff;
  padding: 0;
  background: none;
  border: none;
  text-shadow: 0 0 8px rgba(255,255,255,.8), 0 0 20px rgba(232,193,112,.45), 0 0 40px rgba(232,193,112,.25);
}

/* ===== Audio mute toggle ===== */
.corner-controls {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  display: flex; gap: 10px;
}
#audio-toggle, #fullscreen-toggle {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid rgba(232,193,112,.35);
  background: rgba(8,10,18,.5); color: var(--gold-soft);
  font-size: 18px; line-height: 1; cursor: none;
  display: flex; align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: background .25s ease, border-color .25s ease, transform .15s ease;
}
#audio-toggle:hover, #fullscreen-toggle:hover {
  background: rgba(20,24,40,.7);
  border-color: rgba(232,193,112,.75);
  transform: scale(1.07);
}
#audio-toggle svg, #fullscreen-toggle svg { width: 20px; height: 20px; display: block; }
#audio-toggle .snd-mute { display: none; }
#audio-toggle.muted .snd-wave { display: none; }
#audio-toggle.muted .snd-mute { display: block; }

/* ===== Prologue (前言) ===== */
#ui-prologue {
  z-index: 25;
  pointer-events: auto;
  opacity: 0;
  transition: opacity .8s ease;
  cursor: none;
}
#ui-prologue.in { opacity: 1; }

.prologue-bg {
  position: absolute; inset: 0;
  background: url('../dianyun/sucai/6.png?v=2') center center / cover no-repeat;
  filter: brightness(.72) saturate(.85) contrast(1.05);
  transform: scale(1.12);
  animation: prologueDrift 22s ease-out forwards;
}
/* overall left-dark → right-bright gradient: text sits in the dark left, image glows on the right */
.prologue-veil {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg,
      rgba(2,4,10,.97) 0%,
      rgba(2,4,10,.86) 24%,
      rgba(2,4,10,.58) 50%,
      rgba(2,4,10,.22) 76%,
      rgba(2,4,10,.04) 100%);
}
/* drifting golden motes — magical dust */
.prologue-motes {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 18% 32%, rgba(255,228,165,.9), transparent 60%),
    radial-gradient(1.5px 1.5px at 68% 58%, rgba(255,220,150,.7), transparent 60%),
    radial-gradient(2px 2px at 42% 78%, rgba(255,212,140,.8), transparent 60%),
    radial-gradient(1px 1px at 84% 24%, rgba(255,236,185,.85), transparent 60%),
    radial-gradient(1.5px 1.5px at 56% 14%, rgba(255,222,155,.7), transparent 60%),
    radial-gradient(2px 2px at 9% 68%, rgba(255,222,155,.7), transparent 60%),
    radial-gradient(1.5px 1.5px at 33% 50%, rgba(255,232,175,.75), transparent 60%),
    radial-gradient(1px 1px at 76% 82%, rgba(255,228,165,.8), transparent 60%);
  filter: drop-shadow(0 0 4px rgba(232,193,112,.6));
  animation: motesDrift 13s ease-in-out infinite alternate;
}
.prologue-text {
  position: absolute; left: 7%; top: 50%;
  transform: translateY(-50%);
  width: min(72%, 600px);
  text-align: left;
  font-size: clamp(14px, 1.7vw, 20px);
  line-height: 2.05; letter-spacing: .14em;
  color: #ffe9b8;
  text-shadow:
    0 0 6px rgba(255,240,205,.9),
    0 0 16px rgba(232,193,112,.7),
    0 0 34px rgba(225,160,80,.45),
    0 2px 24px rgba(0,0,0,.85);
  animation: glowBreath 3.6s ease-in-out infinite;
}
/* bilingual lines — each gently fades in */
.p-line {
  opacity: 0; transform: translateY(14px);
  transition: opacity 1.2s ease, transform 1.2s ease;
  margin-bottom: 1.15em;
}
.p-line:last-child { margin-bottom: 0; }
.p-line.show { opacity: 1; transform: translateY(0); }
.p-zh {
  font-size: clamp(14px, 1.7vw, 20px);
  letter-spacing: .14em; line-height: 1.5;
  color: #ffe9b8;
}
.p-en {
  margin-top: .4em;
  font-family: 'Cinzel', serif;
  font-size: clamp(9px, 1vw, 11px);
  letter-spacing: .18em; line-height: 1.45;
  color: rgba(255,236,195,.6);
  text-shadow: 0 0 10px rgba(232,193,112,.35);
}
.prologue-cue {
  position: absolute; left: 50%; bottom: 12%;
  transform: translateX(-50%);
  font-size: clamp(11px, 1.4vw, 14px);
  letter-spacing: .5em; padding-left: .5em;
  color: rgba(255,238,200,.8);
  text-shadow: 0 0 12px rgba(232,193,112,.6), 0 0 28px rgba(232,193,112,.35);
  opacity: 0; transition: opacity 1s ease; pointer-events: none;
}
.prologue-cue.show { opacity: 1; animation: pulse 2.4s ease-in-out infinite; }

@keyframes prologueDrift { from { transform: scale(1.12); } to { transform: scale(1.0); } }
@keyframes glowBreath {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 7px rgba(232,193,112,.3)); }
  50%      { filter: brightness(1.13) drop-shadow(0 0 18px rgba(232,193,112,.6)); }
}
@keyframes motesDrift {
  0%   { transform: translateY(12px); opacity: .35; }
  50%  { opacity: .7; }
  100% { transform: translateY(-26px); opacity: .4; }
}

/* ===== Gallery (main) ===== */
/* welcome guide text — glows in for a few seconds on entering the hall */
.gallery-guide {
  position: absolute; top: 8%; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  width: min(90%, 720px); text-align: center;
  font-size: clamp(15px, 2.3vw, 25px);
  font-weight: 500; letter-spacing: .2em; padding-left: .2em;
  color: var(--gold-soft);
  text-shadow:
    0 0 10px rgba(255,240,200,.75),
    0 0 26px rgba(232,193,112,.6),
    0 0 52px rgba(232,193,112,.35);
  opacity: 0; pointer-events: none;
  transition: opacity 1s ease, transform 1s ease;
}
.gallery-guide.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
  animation: guideGlow 2.6s ease-in-out infinite;
}
@keyframes guideGlow {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 6px rgba(232,193,112,.3)); }
  50%      { filter: brightness(1.16) drop-shadow(0 0 18px rgba(232,193,112,.55)); }
}

.main-title {
  position: absolute; top: 7%; left: 50%; transform: translateX(-50%);
  font-size: clamp(34px, 7vw, 76px);
  font-weight: 900; letter-spacing: .25em;
  padding-left: .25em;
  background: linear-gradient(180deg, #fff 0%, var(--gold) 70%, #b8893f 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 24px rgba(232,193,112,.4));
  white-space: nowrap;
}
.window-name {
  position: absolute; top: 23%; left: 50%; transform: translateX(-50%);
  font-size: clamp(22px, 4vw, 40px); font-weight: 700; letter-spacing: .3em;
  padding-left: .3em;
  color: var(--gold-soft);
  text-shadow: 0 0 24px rgba(232,193,112,.55);
  transition: opacity .4s ease, transform .4s ease;
}
.window-en {
  position: absolute; top: 31%; left: 50%; transform: translateX(-50%);
  font-family: 'Cinzel', serif;
  font-size: clamp(10px, 1.6vw, 15px); letter-spacing: .55em;
  padding-left: .55em;
  color: rgba(255,255,255,.5);
  transition: opacity .4s ease;
}

.nav-arrow {
  position: absolute; top: 52%; transform: translateY(-50%);
  background: none; border: none;
  color: var(--gold-soft); font-size: 40px; line-height: 1;
  cursor: pointer;
  text-shadow: 0 0 8px rgba(255,255,255,.5), 0 0 20px rgba(232,193,112,.4);
  transition: all .25s ease;
}
.nav-arrow:hover { text-shadow: 0 0 14px rgba(255,255,255,.8), 0 0 32px rgba(232,193,112,.7); transform: translateY(-50%) scale(1.12); }
.nav-arrow.left { left: 3%; }
.nav-arrow.right { right: 3%; }

.dots {
  position: absolute; bottom: 10%; left: 50%; transform: translateX(-50%);
  display: flex; gap: 14px; pointer-events: auto;
}
.dots .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255,255,255,.25); cursor: pointer;
  transition: all .3s ease;
}
.dots .dot.active { background: var(--gold); box-shadow: 0 0 14px var(--gold); transform: scale(1.3); }

.enter-window-btn {
  position: absolute; bottom: 8%; left: 50%; transform: translateX(-50%);
  padding: 14px 46px;
  background: linear-gradient(135deg, rgba(232,193,112,.18), rgba(232,193,112,.05));
  border: 1px solid var(--gold);
  border-radius: 40px;
  color: var(--gold-soft); font-size: 17px; letter-spacing: .3em; font-weight: 500;
  cursor: pointer; backdrop-filter: blur(6px);
  box-shadow: 0 0 26px rgba(232,193,112,.25);
  transition: all .3s ease;
}
.enter-window-btn:hover {
  background: linear-gradient(135deg, rgba(232,193,112,.35), rgba(232,193,112,.12));
  box-shadow: 0 0 44px rgba(232,193,112,.5);
  transform: translateX(-50%) translateY(-2px);
}
.swipe-hint { bottom: 3%; }

/* ===== VR room ===== */
.back-btn {
  position: absolute; top: 24px; left: 24px;
  padding: 8px 20px;
  background: none; border: none;
  color: var(--gold-soft); font-size: 16px; letter-spacing: .15em;
  cursor: pointer;
  text-shadow: 0 0 8px rgba(255,255,255,.5), 0 0 20px rgba(232,193,112,.4);
  transition: text-shadow .25s ease;
}
.back-btn:hover { text-shadow: 0 0 14px rgba(255,255,255,.8), 0 0 32px rgba(232,193,112,.7); }
.vr-room-name {
  position: absolute; top: 26px; left: 50%; transform: translateX(-50%);
  font-size: clamp(18px,3vw,28px); font-weight: 700; letter-spacing: .3em;
  padding-left: .3em; color: var(--gold-soft);
  text-shadow: 0 0 18px rgba(232,193,112,.5);
}
#vrbutton-mount {
  position: absolute; bottom: 110px; left: 50%; transform: translateX(-50%);
}
.vr-hint { bottom: 24px; }

#gallery-vrbutton-mount {
  position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%);
  z-index: 10;
}
#landing-vrbutton-mount {
  position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%);
  z-index: 10;
}
/* prominent VR entry button — only shown on VR-capable devices */
.vr-enter-btn {
  display: none;
  position: absolute; bottom: 22%; left: 50%; transform: translateX(-50%);
  padding: 18px 54px;
  background: linear-gradient(135deg, rgba(232,193,112,.22), rgba(232,193,112,.06));
  border: 1.5px solid var(--gold);
  border-radius: 50px;
  color: var(--gold-soft);
  font-family: 'Noto Serif SC', serif;
  font-size: 20px; letter-spacing: .35em; font-weight: 600;
  cursor: pointer;
  text-shadow: 0 0 12px rgba(232,193,112,.5), 0 0 28px rgba(232,193,112,.25);
  box-shadow: 0 0 30px rgba(232,193,112,.2), 0 0 60px rgba(232,193,112,.08);
  transition: all .3s ease;
  z-index: 30; pointer-events: auto;
  animation: fadeIn 2s ease .6s both, glowPulse 2.4s ease-in-out 1s infinite;
}
.vr-enter-btn.show { display: block; }
.vr-enter-btn:hover {
  background: linear-gradient(135deg, rgba(232,193,112,.38), rgba(232,193,112,.15));
  box-shadow: 0 0 50px rgba(232,193,112,.4), 0 0 90px rgba(232,193,112,.15);
  transform: translateX(-50%) translateY(-2px);
}
@keyframes glowPulse {
  0%,100% { box-shadow: 0 0 30px rgba(232,193,112,.2), 0 0 60px rgba(232,193,112,.08); }
  50%     { box-shadow: 0 0 42px rgba(232,193,112,.35), 0 0 80px rgba(232,193,112,.15); }
}
/* override three.js VRButton styling to fit theme */
#vrbutton-mount > button,
#gallery-vrbutton-mount > button,
#landing-vrbutton-mount > button {
  font-family: 'Noto Serif SC', serif !important;
  letter-spacing: .2em !important;
}
/* hide VR NOT SUPPORTED (disabled button) */
#vrbutton-mount > button:disabled,
#gallery-vrbutton-mount > button:disabled,
#landing-vrbutton-mount > button:disabled {
  display: none !important;
}

/* ===== Loading ===== */
#loading {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #02040a; gap: 30px;
  transition: opacity .6s ease;
}
#loading.hide { opacity: 0; pointer-events: none; }
.loader-dots { display: flex; gap: 16px; }
.ldot {
  display: block;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold), 0 0 22px rgba(232,193,112,.6), 0 0 40px rgba(232,193,112,.25);
  animation: dotPulse 1.4s ease-in-out infinite;
}
.ldot:nth-child(2) { animation-delay: .2s; }
.ldot:nth-child(3) { animation-delay: .4s; }
.loader-text {
  font-size: 14px; letter-spacing: .5em; color: var(--gold-soft); padding-left: .5em;
  text-shadow: 0 0 8px rgba(255,255,255,.6), 0 0 18px rgba(232,193,112,.45), 0 0 36px rgba(232,193,112,.2);
}
@keyframes dotPulse { 0%,100% { opacity:.3; transform:scale(.8); } 50% { opacity:1; transform:scale(1.4); } }

/* ===== live control panel ===== */
#controls {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 140%);
  z-index: 40; pointer-events: auto;
  display: grid; grid-template-columns: auto auto; gap: 10px 30px;
  padding: 18px 26px;
  background: rgba(8,10,18,.72); backdrop-filter: blur(10px);
  border: 1px solid rgba(232,193,112,.22); border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  opacity: 0; transition: transform .5s cubic-bezier(.2,.9,.3,1), opacity .4s ease;
}
#controls.on { transform: translate(-50%, 0); opacity: 1; }
#controls.force-hide { transform: translate(-50%, 140%) !important; opacity: 0 !important; }
.ctrl-row { display: flex; align-items: center; gap: 14px; }
.ctrl-label {
  font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: .18em;
  color: rgba(232,193,112,.85); min-width: 132px;
}
.ctrl-row.accent .ctrl-label { color: #e58fd0; }
.ctrl-row.galaxy .ctrl-label { color: #7fb6ff; }
#controls .galaxy input[type=range]::-webkit-slider-thumb { background: #7fb6ff; box-shadow: 0 0 10px #7fb6ff; }
#controls .galaxy input[type=range]::-moz-range-thumb { background: #7fb6ff; box-shadow: 0 0 10px #7fb6ff; }
#controls input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 120px; height: 4px; border-radius: 4px;
  background: rgba(255,255,255,.14); outline: none; cursor: pointer;
}
#controls input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 10px var(--gold);
}
#controls .accent input[type=range]::-webkit-slider-thumb { background: #e58fd0; box-shadow: 0 0 10px #e58fd0; }
#controls input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px; border: none; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 10px var(--gold);
}
.ctrl-hint {
  grid-column: 1 / -1; text-align: center;
  font-size: 10px; letter-spacing: .2em; color: rgba(255,255,255,.3); margin-top: 2px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%,100% { opacity:.3 } 50% { opacity:.7 } }

