/* ═══════════════════════════════════════════════════════════════
   HERO STAGE — Reusable cinematic page framework
   Shared UI system for Welcome, Kingdom tabs, Campaign, Shop,
   Settings, Versus, Custom, etc. Inspired by Admin Sanctum.

   Usage:
     <div class="stage">
       <div class="stage-bg" style="background-image:url(...)"></div>
       <div class="stage-vignette"></div>
       <div class="stage-embers">... embers ...</div>
       <div class="stage-content">
         <div class="stage-hero">
           <div class="stage-flourish stage-flourish--left"></div>
           <h1 class="stage-title">TITLE</h1>
           <div class="stage-flourish stage-flourish--right"></div>
         </div>
         <div class="stage-subtitle">Subtitle text</div>
         ... your content ...
       </div>
     </div>
   ═══════════════════════════════════════════════════════════════ */

.stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  font-family: 'Crimson Text', serif;
  color: #e8d5a3;
  /* Break out of .menu-content 24px 36px 0 padding so bg fills full width */
  margin: -24px -36px 0;
  width: calc(100% + 72px);
}

@media (max-width: 768px) {
  .stage {
    margin: -11px -8px 0;
    width: calc(100% + 16px);
  }
}

/* Background image layer (pan animation) */
.stage-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.32) saturate(0.85);
  animation: stageBgPan 60s ease-in-out infinite alternate;
  z-index: 0;
}
@keyframes stageBgPan {
  0%   { transform: scale(1.05) translate(0, 0); }
  100% { transform: scale(1.12) translate(-20px, -15px); }
}

/* Vignette overlay (darkens edges for focus) */
.stage-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 20%, rgba(5, 3, 2, 0.75) 90%),
    linear-gradient(180deg, rgba(10, 6, 2, 0.5) 0%, transparent 40%, rgba(10, 6, 2, 0.6) 100%);
  z-index: 1;
  pointer-events: none;
}

/* Ember particles layer */
.stage-embers {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}
.stage-ember {
  position: absolute;
  bottom: -20px;
  left: var(--e-x, 50vw);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 100, 0.9) 0%, rgba(212, 140, 60, 0.6) 40%, transparent 100%);
  box-shadow: 0 0 8px rgba(255, 180, 80, 0.6);
  animation: stageEmberRise 16s linear infinite;
  animation-delay: var(--e-delay, 0s);
}
@keyframes stageEmberRise {
  0%   { bottom: -20px; opacity: 0; transform: translateX(0) scale(0.6); }
  10%  { opacity: 0.9; }
  50%  { transform: translateX(calc(var(--e-x, 0) * 0.1)) scale(1); }
  90%  { opacity: 0.7; }
  100% { bottom: 105vh; opacity: 0; transform: translateX(-40px) scale(0.3); }
}

/* Content wrapper (above all layers) */
.stage-content {
  position: relative;
  z-index: 10;
  padding: 40px 60px;
  min-height: 100vh;
}

/* Hero title block */
.stage-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  margin-bottom: 20px;
  padding-top: 30px;
}
.stage-flourish {
  flex: 1;
  max-width: 220px;
  height: 2px;
  background: linear-gradient(var(--flourish-dir, 90deg), transparent 0%, rgba(212,165,69,0.7) 50%, transparent 100%);
  position: relative;
}
.stage-flourish--left { --flourish-dir: 90deg; }
.stage-flourish--right { --flourish-dir: 270deg; }
.stage-flourish::before {
  content: '';
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  background: #d4a545;
  transform: translateY(-50%) rotate(45deg);
  box-shadow: 0 0 10px rgba(212,165,69,0.6);
}
.stage-flourish--left::before { right: 0; }
.stage-flourish--right::before { left: 0; }

.stage-title {
  font-family: 'Crimson Text', serif;
  font-size: 3.4rem;
  font-weight: 700;
  letter-spacing: 6px;
  color: #ffd700;
  margin: 0;
  text-shadow:
    0 0 20px rgba(255, 215, 0, 0.4),
    0 0 40px rgba(212, 165, 69, 0.3),
    0 4px 12px rgba(0, 0, 0, 0.9);
  animation: stageTitleGlow 4s ease-in-out infinite alternate;
  white-space: nowrap;
}
@keyframes stageTitleGlow {
  0%   { text-shadow: 0 0 20px rgba(255, 215, 0, 0.4), 0 0 40px rgba(212, 165, 69, 0.3), 0 4px 12px rgba(0, 0, 0, 0.9); }
  100% { text-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 0 60px rgba(212, 165, 69, 0.5), 0 4px 12px rgba(0, 0, 0, 0.9); }
}

.stage-subtitle {
  text-align: center;
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 1.25rem;
  color: #c8a96e;
  letter-spacing: 2px;
  margin-bottom: 40px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

/* Back button (absolute top-left) */
.stage-back-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 20;
  padding: 10px 20px;
  background: rgba(20, 12, 6, 0.7);
  border: 1px solid rgba(212, 165, 69, 0.5);
  color: #e8d5a3;
  font-family: 'Crimson Text', serif;
  font-size: 1rem;
  letter-spacing: 1px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: all 0.3s;
  border-radius: 4px;
}
.stage-back-btn:hover {
  background: rgba(40, 24, 10, 0.85);
  border-color: rgba(212, 165, 69, 0.85);
  color: #ffd700;
  box-shadow: 0 0 16px rgba(212, 165, 69, 0.3);
}

/* Grid layout for cards */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto;
}
.stage-grid--1col { grid-template-columns: 1fr; max-width: 720px; }
.stage-grid--2col { grid-template-columns: repeat(2, 1fr); }
.stage-grid--3col { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) {
  .stage-grid,
  .stage-grid--2col,
  .stage-grid--3col { grid-template-columns: 1fr; }
}

/* Generic card with corner ornaments (reusable) */
.stage-card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(30, 20, 12, 0.92) 0%, rgba(20, 12, 6, 0.95) 100%);
  border: 1px solid rgba(212, 165, 69, 0.35);
  border-radius: 6px;
  padding: 26px 28px;
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(212, 165, 69, 0.15);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.stage-card:hover {
  border-color: rgba(212, 165, 69, 0.6);
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.7),
    0 0 24px rgba(212, 165, 69, 0.12),
    inset 0 1px 0 rgba(212, 165, 69, 0.25);
}
/* Corner ornaments (L-shape gold borders) */
.stage-card::before,
.stage-card::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: rgba(212, 165, 69, 0.65);
  border-style: solid;
  transition: border-color 0.3s;
}
.stage-card::before {
  top: 6px; left: 6px;
  border-width: 1px 0 0 1px;
}
.stage-card::after {
  bottom: 6px; right: 6px;
  border-width: 0 1px 1px 0;
}
.stage-card:hover::before,
.stage-card:hover::after { border-color: #d4a545; }

.stage-card-icon {
  width: 42px; height: 42px;
  object-fit: contain;
  margin-bottom: 14px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.8));
}
.stage-card-title {
  font-family: 'Crimson Text', serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: #ffd700;
  letter-spacing: 2px;
  margin: 0 0 8px 0;
  text-shadow: 0 2px 6px rgba(0,0,0,0.9);
}
.stage-card-desc {
  color: #c8a96e;
  font-size: 0.98rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* Generic action button (gold variant, with glint) */
.stage-btn {
  position: relative;
  display: inline-block;
  padding: 12px 22px;
  background: linear-gradient(180deg, #8a6a20 0%, #5a4210 100%);
  border: 1px solid rgba(212, 165, 69, 0.65);
  border-radius: 4px;
  color: #f5ede0;
  font-family: 'Crimson Text', serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.25s;
  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 230, 140, 0.2);
}
.stage-btn:hover {
  background: linear-gradient(180deg, #b88a30 0%, #8a6a20 100%);
  border-color: #d4a545;
  color: #fff;
  box-shadow:
    0 5px 16px rgba(0, 0, 0, 0.7),
    0 0 20px rgba(212, 165, 69, 0.35),
    inset 0 1px 0 rgba(255, 240, 170, 0.3);
  transform: translateY(-1px);
}
.stage-btn:active { transform: translateY(1px); }
.stage-btn::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 210, 0.25) 50%, transparent 100%);
  transform: skewX(-18deg);
  animation: stageBtnGlint 3.2s ease-in-out infinite;
}
@keyframes stageBtnGlint {
  0%, 100% { left: -100%; }
  50%      { left: 120%; }
}

/* Button variants */
.stage-btn--danger {
  background: linear-gradient(180deg, #8a2020 0%, #5a1010 100%);
  border-color: rgba(220, 80, 80, 0.65);
}
.stage-btn--danger:hover {
  background: linear-gradient(180deg, #b83030 0%, #8a2020 100%);
  border-color: #dc4040;
  box-shadow: 0 5px 16px rgba(0,0,0,0.7), 0 0 20px rgba(220, 80, 80, 0.35);
}

.stage-btn--info {
  background: linear-gradient(180deg, #203a6a 0%, #10204a 100%);
  border-color: rgba(90, 140, 220, 0.65);
}
.stage-btn--info:hover {
  background: linear-gradient(180deg, #305080 0%, #203a6a 100%);
  border-color: #5090e0;
  box-shadow: 0 5px 16px rgba(0,0,0,0.7), 0 0 20px rgba(90, 140, 220, 0.35);
}

.stage-btn--large {
  padding: 16px 32px;
  font-size: 1.2rem;
  letter-spacing: 2px;
}

/* ──────────── Responsive ──────────── */
@media (max-width: 900px) {
  .stage-content { padding: 30px 24px; }
  .stage-title { font-size: 2.6rem; letter-spacing: 4px; }
  .stage-flourish { max-width: 120px; }
  .stage-subtitle { font-size: 1.05rem; margin-bottom: 28px; }
}
@media (max-width: 600px) {
  .stage-content { padding: 20px 14px; }
  .stage-title { font-size: 1.9rem; letter-spacing: 3px; }
  .stage-flourish { max-width: 60px; }
  .stage-hero { gap: 12px; }
  .stage-card { padding: 18px 16px; }
  .stage-card-title { font-size: 1.2rem; }
}
@media (max-width: 420px) {
  .stage-title { font-size: 1.5rem; letter-spacing: 2px; }
  .stage-hero { gap: 8px; padding-top: 10px; }
  .stage-flourish { max-width: 40px; }
}

/* ═══════════════════════════════════════════════════════════════
   WELCOME PAGE — centered hero, no clutter
   ═══════════════════════════════════════════════════════════════ */
.welcome-content {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 60px;
}
.welcome-hero-wrap {
  text-align: center;
  max-width: 900px;
  animation: welcomeFadeIn 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
@keyframes welcomeFadeIn {
  0%   { opacity: 0; transform: translateY(24px); }
  100% { opacity: 1; transform: translateY(0); }
}
.welcome-hint {
  margin-top: 18px;
  font-family: 'Crimson Text', serif;
  font-style: italic;
  font-size: 1.05rem;
  color: rgba(200, 169, 110, 0.75);
  letter-spacing: 1px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}

@media (max-width: 900px) {
  .welcome-content { padding: 30px 24px; }
  .welcome-hint { font-size: 0.95rem; }
}
@media (max-width: 600px) {
  .welcome-content { padding: 20px 16px; }
  .welcome-hint { font-size: 0.88rem; }
}

/* Welcome-specific: lets underlying .menu-screen background show through.
   Only adds a dark tint + vignette + embers.
   Uses position:fixed so tint covers the ENTIRE viewport regardless of parent padding. */
.welcome-stage {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  margin: 0;
  width: 100%;
  min-height: 0;
  pointer-events: none;
  z-index: 1;
}
.welcome-stage .stage-vignette,
.welcome-stage .stage-embers {
  position: fixed;
  inset: 0;
}
.welcome-tint {
  background: linear-gradient(180deg,
    rgba(5, 3, 2, 0.42) 0%,
    rgba(5, 3, 2, 0.58) 100%);
}
/* When admin banner is active, welcome tint starts below the banner */
body.maint-banner-active .welcome-stage,
body.maint-banner-active .welcome-stage .stage-vignette,
body.maint-banner-active .welcome-stage .stage-embers {
  top: 44px;
}
