/* ═══════════════════════════════════════════════════════════════════
   ZENMAGMA — CINEMATIC INTRO OVERLAY SYSTEM
   Full-screen video intro played before every game.
   Architecture: IntroManager (js/intro-manager.js) controls this DOM.
   ═══════════════════════════════════════════════════════════════════ */

/* ── OVERLAY CONTAINER ── */
#zm-intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #05010F;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  /* Fade state — JS toggles .zm-intro-fadeout */
  opacity: 1;
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

#zm-intro-overlay.zm-intro-fadeout {
  opacity: 0;
  pointer-events: none;
}

#zm-intro-overlay.zm-intro-hidden {
  display: none;
}

/* ── PARTICLE / AMBIENT GLOW BACKGROUND ── */
.zm-intro-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.zm-intro-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: zm-orb-drift 8s ease-in-out infinite alternate;
  opacity: 0.35;
}
.zm-intro-orb:nth-child(1) {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #7C3AED, transparent 70%);
  top: -120px; left: -100px;
  animation-duration: 9s;
}
.zm-intro-orb:nth-child(2) {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #06B6D4, transparent 70%);
  bottom: -80px; right: -80px;
  animation-duration: 11s;
  animation-direction: alternate-reverse;
}
.zm-intro-orb:nth-child(3) {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #EC4899, transparent 70%);
  top: 40%; left: 55%;
  animation-duration: 7s;
  opacity: 0.2;
}

@keyframes zm-orb-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.08); }
}

/* Scanline texture overlay */
.zm-intro-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 2;
}

/* ── LOADING STATE ── */
#zm-intro-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 5;
  transition: opacity 0.5s ease;
}

#zm-intro-loader.zm-hidden {
  opacity: 0;
  pointer-events: none;
}

.zm-loader-logo {
  font-family: 'Orbitron', 'Space Grotesk', sans-serif;
  font-size: clamp(24px, 5vw, 48px);
  font-weight: 900;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, #C084FC, #67E8F9, #F472B6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  animation: zm-logo-pulse 2s ease-in-out infinite;
}

@keyframes zm-logo-pulse {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(192,132,252,0.6)); }
  50%       { filter: drop-shadow(0 0 28px rgba(103,232,249,0.8)); }
}

.zm-loader-ring {
  width: 56px;
  height: 56px;
  border: 3px solid rgba(168,85,247,0.15);
  border-top-color: #A855F7;
  border-right-color: #06B6D4;
  border-radius: 50%;
  animation: zm-spin 0.9s linear infinite;
}

@keyframes zm-spin {
  to { transform: rotate(360deg); }
}

.zm-loader-text {
  font-family: 'Sora', system-ui, sans-serif;
  font-size: 13px;
  color: rgba(192,132,252,0.6);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* Progress bar */
.zm-loader-progress-track {
  width: 200px;
  height: 2px;
  background: rgba(168,85,247,0.15);
  border-radius: 2px;
  overflow: hidden;
}

.zm-loader-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7C3AED, #06B6D4);
  border-radius: 2px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(168,85,247,0.8);
}

/* ── VIDEO WRAPPER ── */
#zm-intro-video-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.6s ease;
}

#zm-intro-video-wrap.zm-video-visible {
  opacity: 1;
}

#zm-intro-video {
  width: 100%;
  height: 100%;
  object-fit: contain; /* never stretches; letterboxes cleanly */
  max-width: 100vw;
  max-height: 100vh;
}

/* Cinematic letterbox bars — subtle premium feel */
.zm-intro-letterbox-top,
.zm-intro-letterbox-bot {
  position: absolute;
  left: 0; right: 0;
  height: clamp(20px, 4vh, 60px);
  background: #05010F;
  z-index: 4;
  pointer-events: none;
}
.zm-intro-letterbox-top { top: 0; }
.zm-intro-letterbox-bot { bottom: 0; }

/* Vignette over video */
.zm-intro-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(5,1,15,0.7) 100%);
  z-index: 4;
  pointer-events: none;
}

/* ── SKIP BUTTON ── */
#zm-skip-btn {
  position: absolute;
  bottom: clamp(28px, 6vh, 60px);
  right: clamp(20px, 4vw, 48px);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  background: rgba(12, 0, 28, 0.75);
  border: 1px solid rgba(192,132,252,0.35);
  border-radius: 50px;
  color: #EDE9FE;
  font-family: 'Orbitron', 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 0 20px rgba(124,58,237,0.3), inset 0 1px 0 rgba(255,255,255,0.06);

  /* Hidden by default — JS shows after 1.5s */
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#zm-skip-btn.zm-skip-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#zm-skip-btn:hover {
  background: rgba(124,58,237,0.35);
  border-color: rgba(192,132,252,0.7);
  box-shadow: 0 0 32px rgba(124,58,237,0.6), 0 0 60px rgba(6,182,212,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
  color: #fff;
}

#zm-skip-btn:active {
  transform: scale(0.97);
}

.zm-skip-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(192,132,252,0.6);
  border-radius: 50%;
  font-size: 9px;
  line-height: 1;
  flex-shrink: 0;
}

/* Countdown ring around skip button */
.zm-skip-countdown {
  font-size: 10px;
  color: rgba(192,132,252,0.5);
  font-family: 'Orbitron', monospace;
  min-width: 14px;
}

/* ── MUTE BUTTON ── */
#zm-mute-btn {
  position: absolute;
  bottom: clamp(28px, 6vh, 60px);
  left: clamp(20px, 4vw, 48px);
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 0, 28, 0.75);
  border: 1px solid rgba(192,132,252,0.25);
  border-radius: 50%;
  color: rgba(192,132,252,0.7);
  font-size: 16px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
  opacity: 0;
  pointer-events: none;
}

#zm-mute-btn.zm-skip-visible {
  opacity: 1;
  pointer-events: auto;
}

#zm-mute-btn:hover {
  color: #fff;
  border-color: rgba(192,132,252,0.6);
  box-shadow: 0 0 16px rgba(124,58,237,0.5);
}

/* ── END-FRAME REVEAL ── */
#zm-intro-endframe {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  background: #05010F;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

#zm-intro-endframe.zm-endframe-visible {
  opacity: 1;
}

.zm-endframe-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(18px, 4vw, 36px);
  font-weight: 900;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, #C084FC, #67E8F9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: zm-logo-pulse 1.5s ease-in-out infinite;
}

.zm-endframe-sub {
  font-family: 'Sora', system-ui, sans-serif;
  font-size: 14px;
  color: rgba(192,132,252,0.5);
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

/* ── TRANSITION VARIANTS ── */

/* Variant: glitch flash on skip */
@keyframes zm-glitch {
  0%   { clip-path: inset(0 0 95% 0); transform: translateX(-4px); }
  20%  { clip-path: inset(30% 0 40% 0); transform: translateX(4px); }
  40%  { clip-path: inset(70% 0 10% 0); transform: translateX(-2px); }
  60%  { clip-path: inset(10% 0 80% 0); transform: translateX(2px); }
  80%  { clip-path: inset(50% 0 30% 0); transform: translateX(-4px); }
  100% { clip-path: inset(0 0 0 0); transform: translateX(0); }
}

.zm-glitch-flash {
  animation: zm-glitch 0.25s steps(1) forwards;
}

/* ── MOBILE ADJUSTMENTS ── */
@media (max-width: 600px) {
  #zm-intro-video {
    object-fit: cover; /* fill on small screens — no letterbox gap */
  }
  .zm-intro-letterbox-top,
  .zm-intro-letterbox-bot {
    display: none;
  }
}

/* ── ULTRAWIDE CLAMP ── */
@media (min-width: 2560px) {
  #zm-intro-video {
    max-width: 1920px;
    max-height: 1080px;
    border-radius: 4px;
    box-shadow: 0 0 120px rgba(124,58,237,0.4);
  }
}
