/* ============================================================
 *  shell.css — App stage, scene container, transition overlay,
 *  shared Velvet Room background, dialogue box, return buttons
 * ============================================================ */

/* ============ Stage ============ */
#stage {
  position: fixed;
  inset: 0;
  background: var(--vr-blue-deep);
  overflow: hidden;
}

/* ============ Scene container (full screen, hidden by default) ============ */
.scene {
  position: absolute;
  inset: 0;
  display: none;            /* Manager toggles to flex */
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.scene.is-active {
  display: flex;
}

/* ============ Velvet Room shared background ============ */
.vr-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center top,
      var(--vr-blue-light) 0%,
      var(--vr-blue-mid) 50%,
      var(--vr-blue-deep) 100%);
  z-index: 0;
}
.vr-bg::before {
  /* velvet cross-hatch texture */
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(45deg, transparent, transparent 3px,
      rgba(255,255,255,0.025) 3px, rgba(255,255,255,0.025) 4px),
    repeating-linear-gradient(-45deg, transparent, transparent 3px,
      rgba(0,0,0,0.05) 3px, rgba(0,0,0,0.05) 4px);
  pointer-events: none;
}
.vr-bg::after {
  /* vignette */
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 200px 60px rgba(0,0,0,0.7);
  pointer-events: none;
}
.vr-bg--dim::after {
  box-shadow: inset 0 0 240px 90px rgba(0,0,0,0.85);
}

/* ============ Ambient particles — see js/particles.js (canvas) ============ */
/* The <canvas id="particle-layer"> element covers the viewport at z-index: 1
 * and is driven by a single rAF loop. Scenes call Particles.setMode(...) to
 * switch visual. No .vr-particles DOM element is used in this fork. */

/* ============ Dialogue box (Igor & Farewell) ============ */
.dialogue-box {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 70%;
  max-width: 880px;
  min-height: 160px;
  background: linear-gradient(180deg,
    rgba(10, 20, 56, 0.95) 0%,
    rgba(5, 10, 32, 0.97) 100%);
  border: 2px solid var(--vr-gold);
  border-radius: 6px;
  padding: 30px 40px 24px 40px;
  z-index: 5;
  box-shadow:
    0 0 30px rgba(201, 164, 97, 0.3),
    inset 0 0 0 1px rgba(245, 230, 200, 0.15);
}
.dialogue-box::before,
.dialogue-box::after {
  /* Corner ornaments */
  content: '◆';
  position: absolute;
  color: var(--vr-gold);
  font-size: 0.8rem;
}
.dialogue-box::before { top: 6px; left: 8px; }
.dialogue-box::after  { top: 6px; right: 8px; }

.dialogue-nameplate {
  position: absolute;
  top: -16px;
  left: 30px;
  background: var(--vr-blue-mid);
  border: 2px solid var(--vr-gold);
  color: var(--vr-gold);
  padding: 4px 18px;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 4px;
  font-size: 0.95rem;
  text-shadow: 0 0 8px rgba(201, 164, 97, 0.5);
}

.dialogue-text {
  font-family: var(--font-body);
  font-size: 1.5rem;
  line-height: 1.55;
  color: var(--vr-ivory);
  min-height: 80px;
  font-style: italic;
}

.dialogue-continue {
  position: absolute;
  bottom: 8px;
  right: 16px;
  color: var(--vr-gold);
  font-size: 1.1rem;
  opacity: 0;
  text-shadow: 0 0 8px rgba(201, 164, 97, 0.7);
}

/* ============ Return buttons ============ */
.vr-return {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 10;
  background: linear-gradient(180deg,
    rgba(201, 164, 97, 0.18),
    rgba(201, 164, 97, 0.05));
  border: 1px solid var(--vr-gold);
  color: var(--vr-cream);
  padding: 10px 22px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 4px;
  text-shadow: 0 0 10px rgba(201, 164, 97, 0.6);
  transition: all 0.2s ease;
}
.vr-return:hover {
  background: linear-gradient(180deg,
    rgba(201, 164, 97, 0.4),
    rgba(201, 164, 97, 0.15));
  box-shadow: 0 0 16px rgba(201, 164, 97, 0.6);
  color: var(--vr-ivory);
}

.p3-return {
  border-color: var(--p3-cyan);
  background: linear-gradient(180deg,
    rgba(0, 212, 255, 0.18),
    rgba(0, 212, 255, 0.05));
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.6);
}
.p3-return:hover {
  background: linear-gradient(180deg,
    rgba(0, 212, 255, 0.4),
    rgba(0, 212, 255, 0.12));
  box-shadow: 0 0 16px rgba(0, 212, 255, 0.6);
}

.p5-return {
  position: absolute;
  bottom: 54px;              /* sit above the 38px status bar with margin */
  right: 22px;
  z-index: 50;
  background: var(--p5-red);
  color: #fff;
  padding: 0.7rem 1.6rem 0.7rem 1.1rem;
  font-family: var(--font-p5-display);
  font-size: 1.05rem;
  letter-spacing: 4px;
  border: none;
  /* angular clip-path matches the .cs-btn style from the reference HTML */
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  transition: background 0.18s ease, transform 0.15s ease, letter-spacing 0.2s ease;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
}
.p5-return:hover {
  background: #ff1a2e;
  transform: scale(1.04);
  letter-spacing: 5px;
}
.p5-return:active {
  transform: scale(0.98);
}

/* ============ Transition overlay ============ */
.transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
}
.transition-overlay.is-active {
  pointer-events: all;
}
.transition-blue {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center,
      rgba(37, 64, 143, 0.95) 0%,
      rgba(10, 20, 56, 0.98) 60%,
      rgba(5, 10, 32, 1) 100%);
}
.transition-blue::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(212, 175, 55, 0.35) 0%, transparent 50%);
}
.transition-blue::after {
  content: '';
  position: absolute;
  inset: -10%;
  background:
    linear-gradient(120deg,
      rgba(255, 255, 255, 0) 32%,
      rgba(255, 248, 222, 0.14) 42%,
      rgba(255, 255, 255, 0.6) 50%,
      rgba(255, 248, 222, 0.14) 58%,
      rgba(255, 255, 255, 0) 68%);
  mix-blend-mode: screen;
  opacity: 0;
}
.transition-overlay.is-active .transition-blue::after {
  animation: transitionSweep 0.42s ease-out both;
}
@keyframes transitionSweep {
  0% { opacity: 0; transform: translateX(-20%) scaleX(0.8); }
  30% { opacity: 0.95; }
  100% { opacity: 0; transform: translateX(20%) scaleX(1.05); }
}
.transition-flash {
  position: absolute;
  inset: 0;
  background: var(--p5-white);
  opacity: 0;
}
.transition-core {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center,
      rgba(255, 245, 220, 0.92) 0%,
      rgba(212, 175, 55, 0.48) 12%,
      rgba(212, 175, 55, 0.12) 26%,
      transparent 42%);
  mix-blend-mode: screen;
  opacity: 0;
}
/* .transition-streaks and .transition-sparkles are now rendered on the
 * shared <canvas id="particle-layer"> (see js/particles.js ephemerals). */

/* ============ HUD ornament shared ============ */
.hud-corner {
  position: absolute;
  font-family: var(--font-display);
  color: var(--vr-gold);
  letter-spacing: 3px;
  font-size: 0.85rem;
  text-shadow: 0 0 8px rgba(201, 164, 97, 0.6);
  z-index: 5;
}

/* ============================================================
 *  Custom Persona cursor
 *  - red P5 diamond on P5 scenes
 *  - gold circle with diamond inner on Velvet Room scenes
 *  - hidden on touch devices (see @media hover: none at bottom)
 * ============================================================ */
#cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  pointer-events: none;
  z-index: 10000;
  margin: -8px 0 0 -8px;           /* center on cursor position */
  /* Position is driven by the individual `translate` property in JS
     (app.js) so the P5 `rotate: 45deg` below can compose in place —
     a `transform: translate(...)` would get rotated around the screen
     origin and the diamond would drift off the mouse. */
  will-change: translate;
  transition:
    background 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    width 0.15s ease,
    height 0.15s ease,
    margin 0.15s ease,
    border-radius 0.18s ease,
    rotate 0.18s ease;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
  border-radius: 50%;
}

/* P5 variant — red square rotated 45° (diamond) */
#cursor.cursor--p5 {
  background: var(--p5-red);
  border-radius: 0;
  rotate: 45deg;
  box-shadow:
    0 0 10px rgba(232, 0, 29, 0.85),
    0 0 22px rgba(255, 0, 60, 0.55);
}
#cursor.cursor--p5.is-hover {
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  background: var(--p5-yellow);
  box-shadow:
    0 0 14px rgba(245, 195, 0, 0.95),
    0 0 30px rgba(245, 195, 0, 0.55);
}

/* Velvet Room variant — gold circle */
#cursor.cursor--vr {
  background: var(--vr-gold-bright);
  border: 1px solid var(--vr-cream);
  border-radius: 50%;
  box-shadow:
    0 0 10px rgba(212, 175, 55, 0.85),
    0 0 22px rgba(201, 164, 97, 0.55);
}
#cursor.cursor--vr.is-hover {
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  background: transparent;
  border: 2px solid var(--vr-gold-bright);
  box-shadow:
    0 0 16px rgba(212, 175, 55, 0.9),
    inset 0 0 12px rgba(212, 175, 55, 0.5);
}

/* Click pulse — both variants */
#cursor.is-click {
  transform-origin: center;
  filter: brightness(1.6);
}

/* Hide the native cursor on desktop — the custom one replaces it */
@media (hover: hover) and (pointer: fine) {
  html, body { cursor: none; }
  a, button, [data-return],
  .compendium-item, .confidant-row, .cc-file,
  .mm-item, #gift-box, #tarot-card {
    cursor: none;
  }
}

/* On real touch devices, hide the custom cursor and restore native.
   Require BOTH hover:none AND pointer:coarse so hybrid touch laptops
   and DevTools device emulation don't accidentally hide it. */
@media (hover: none) and (pointer: coarse) {
  #cursor { display: none !important; }
}

/* ============================================================
 *  Keyboard focus — visible outline for keyboard users only
 *  (`:focus-visible` skips the outline on mouse clicks)
 * ============================================================ */
:focus-visible {
  outline: 2px solid var(--vr-gold-bright);
  outline-offset: 3px;
  border-radius: 2px;
}
/* P5 scenes get a red/yellow focus instead of gold */
#scene-status :focus-visible,
#scene-calling-card :focus-visible,
#scene-confidants :focus-visible,
#scene-finale :focus-visible {
  outline-color: var(--p5-yellow);
}

/* ============================================================
 *  Performance-lite profile
 *  Applied automatically on weaker/mobile devices so the site
 *  keeps its style without paying the full blur/animation cost.
 * ============================================================ */
/* perf-lite particle density is handled inside js/particles.js */
html.perf-lite .splash-prism,
html.perf-lite .countdown-prism,
html.perf-lite .finale-prism {
  filter: blur(18px) !important;
  animation-duration: 36s !important;
}
html.perf-lite .splash-rays,
html.perf-lite .finale-aura-rays {
  filter: blur(2px) !important;
  animation-duration: 44s !important;
}
html.perf-lite .countdown-aura,
html.perf-lite .finale-aura-core,
html.perf-lite .watch-glow,
html.perf-lite .watch-reflection,
html.perf-lite .gift-light-beam {
  filter: blur(3px) !important;
}
html.perf-lite .finale-stars,
html.perf-lite .watch-spinner::after,
html.perf-lite .countdown-unit::before,
html.perf-lite .countdown-rings::after,
html.perf-lite .watch-sparkles span,
html.perf-lite .watch-sparkles span.flame,
html.perf-lite .splash-title-big::after,
html.perf-lite .finale-reveal-card::after {
  animation: none !important;
}
html.perf-lite .finale-reveal-card,
html.perf-lite #music-toggle,
html.perf-lite #language-toggle,
html.perf-lite .cf-modal-backdrop,
html.perf-lite .welcome-gate-shell {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html.perf-lite .transition-core {
  opacity: 0.75;
}

/* ============================================================
 *  Reduced motion — respect user's OS setting.
 *  Continuous decorative animations (drift, sparkles, gacha rays)
 *  are stopped; one-shot entrance animations are left alone so
 *  the site still reads as cinematic.
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .finale-stars,
  .finale-aura-rays,
  .finale-reveal-card,
  .finale-reveal-card::after,
  .splash-prism,
  .splash-rays,
  .countdown-prism,
  .countdown-rings::after,
  .countdown-unit::before,
  .rarity-star.is-pop,
  .watch-spinner::after,
  .watch-sparkles span,
  .watch-sparkles span.flame {
    animation: none !important;
  }
  /* Freeze the press-start pulse and dialogue blink indicators */
  .splash-press,
  .dialogue-continue {
    animation: none !important;
  }
}
