/* ═══════════════════════════════════════════════════════════════════
   SGS Atelier Stage — shared atmospheric backdrop for game pages.

   Drops a cream-to-jade stage behind every screen so games have
   a rich atmospheric backdrop. Three layered elements:
     • spotlight  — overhead jade pool, mix-blend-screen for warmth
     • floor      — gradient floor with a fine jade horizon line
     • grain      — uses .sgs-grain from sgs-editorial.css (existing)

   Markup pattern (drop near top of <body>, above any #ui-layer):

     <div class="sgs-stage" aria-hidden="true">
       <div class="sgs-stage-spotlight"></div>
       <div class="sgs-stage-floor"></div>
     </div>
     <div class="sgs-grain" aria-hidden="true"></div>

   Knowledge Chair has its own PIXI-based stage and does NOT load this.
   ═══════════════════════════════════════════════════════════════════ */

.sgs-stage {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  overflow: hidden;
  opacity: 0; animation: sgsStageFade 1.4s 0.3s ease-out forwards;
}
.sgs-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(0, 201, 142, var(--sgs-stage-art-glow-opacity, 0.14)) 0%, transparent 58%),
    linear-gradient(180deg,
      rgba(250,248,245, var(--sgs-stage-overlay-top, 0.12)) 0%,
      rgba(250,248,245, var(--sgs-stage-overlay-mid, 0.32)) 55%,
      rgba(250,248,245, var(--sgs-stage-overlay-bottom, 0.58)) 100%),
    var(--sgs-stage-art, none) center center / cover no-repeat;
  opacity: var(--sgs-stage-art-opacity, 1);
  transform: scale(var(--sgs-stage-art-scale, 1.02));
  filter: saturate(var(--sgs-stage-saturation, 1.08)) contrast(var(--sgs-stage-contrast, 1.06));
}
.sgs-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 201, 142, 0.12) 0%, transparent 11%, transparent 89%, rgba(0, 201, 142, 0.12) 100%),
    radial-gradient(circle at 50% 12%, rgba(255,255,255,0.12), transparent 28%);
  opacity: var(--sgs-stage-overlay-opacity, 0.82);
}
/* Stage tunables — see sgs-editorial.css :root for defaults. Per-game
   overrides set these on the page wrapper to vary the visual without
   forking the stylesheet. */
.sgs-stage-spotlight {
  position: absolute; left: 50%; top: -8%; transform: translateX(-50%);
  width: clamp(600px, 80%, 1200px);
  height: var(--sgs-stage-spot-height, 60%);
  background: radial-gradient(
    ellipse 55% 75% at 50% 0%,
    rgba(0, 201, 142, var(--sgs-stage-spot-opacity, 0.22)) 0%,
    rgba(0, 201, 142, calc(var(--sgs-stage-spot-opacity, 0.22) * 0.36)) 35%,
    transparent 70%
  );
  filter: blur(var(--sgs-stage-spot-blur, 28px));
  mix-blend-mode: multiply;
}
.sgs-stage-floor {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--sgs-stage-floor-height, 34%);
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(0, 201, 142, var(--sgs-stage-floor-opacity, 0.06)) 30%,
    rgba(0, 40, 28, 0.08) 100%
  );
  border-top: 1px solid var(--sgs-stage-floor-line, rgba(0, 201, 142, 0.40));
  box-shadow: 0 -1px 0 rgba(0, 201, 142, 0.20), 0 -8px 32px rgba(0, 201, 142, 0.06);
}
.sgs-stage-floor::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 6%,
    rgba(0, 201, 142, 0.10) 6%,
    rgba(0, 201, 142, 0.10) calc(6% + 1px)
  );
  mask-image: linear-gradient(180deg, transparent 0%, #000 50%, #000 100%),
              radial-gradient(ellipse 60% 100% at 50% 0%, #000 0%, transparent 80%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 50%, #000 100%),
                      radial-gradient(ellipse 60% 100% at 50% 0%, #000 0%, transparent 80%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}

@keyframes sgsStageFade { to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .sgs-stage { animation: none !important; opacity: 1 !important; }
}

/* Halve the spotlight blur radius on phones — students on low-end
   Android/Chromebook devices were the load-time bottleneck on test
   builds with full 28px GPU blur on every screen. Per-page overrides
   still flow through because we set the variable, not the property. */
@media (max-width: 768px) {
  .sgs-stage { --sgs-stage-spot-blur: 16px; }
}
