/* =====================================================================
   ⭐ STAR WARS — May the 4th
   - Background FX (Death Star + X-Wings vs TIE Fighters dogfight)
   - Trench Run takeover scene
   ===================================================================== */

/* ---- Background FX layer (active while body.mrv-theme-starwars) ---- */
.mrv-sw-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;          /* above main bg canvas, below content */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.mrv-sw-bg.ready { opacity: 1; }

body.mrv-theme-starwars .mrv-sw-stamp {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #ffe81f;
  letter-spacing: 2px;
  text-shadow: 0 0 8px #ffe81f, 0 0 14px rgba(255, 232, 31, 0.45);
  pointer-events: none;
  opacity: 0.85;
  z-index: 1;
}

/* When star wars theme is active, dim the regular bg invaders behind the new layer */
body.mrv-theme-starwars #bg-canvas { opacity: 0.55; }

/* ---- Trench Run Takeover ---- */
.mrv-sw-takeover {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9998;
  overflow: hidden;
  font-family: 'VT323', monospace;
  color: #ffe81f;
  animation: mrv-sw-fadein 0.6s ease;
}
@keyframes mrv-sw-fadein {
  from { opacity: 0; filter: blur(8px); }
  to   { opacity: 1; filter: blur(0); }
}
.mrv-sw-takeover.exiting { animation: mrv-sw-fadeout 0.5s ease forwards; }
@keyframes mrv-sw-fadeout {
  to { opacity: 0; filter: blur(8px); }
}

.mrv-sw-takeover canvas.mrv-sw-trench {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* ---- Cockpit HUD frame ---- */
.mrv-sw-cockpit {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.mrv-sw-cockpit::before,
.mrv-sw-cockpit::after {
  content: '';
  position: absolute;
  background: rgba(0, 0, 0, 0.92);
  box-shadow: 0 0 0 2px rgba(255, 232, 31, 0.25) inset;
}
.mrv-sw-cockpit::before { /* top strut */
  left: 0; right: 0; top: 0; height: 12%;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 70% 60%, 30% 60%, 0 100%);
}
.mrv-sw-cockpit::after { /* bottom strut */
  left: 0; right: 0; bottom: 0; height: 22%;
  clip-path: polygon(0 100%, 100% 100%, 100% 0, 70% 30%, 30% 30%, 0 0);
}

/* HUD panels on the bottom strut */
.mrv-sw-hud {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 22%;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 4vw 12px;
  pointer-events: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: #ffe81f;
  text-shadow: 0 0 6px rgba(255, 232, 31, 0.5);
}
.mrv-sw-panel {
  background: rgba(20, 14, 0, 0.7);
  border: 1px solid rgba(255, 232, 31, 0.35);
  padding: 8px 12px;
  min-width: 130px;
  letter-spacing: 1px;
}
.mrv-sw-panel .lbl { font-size: 8px; opacity: 0.7; display: block; margin-bottom: 4px; }
.mrv-sw-panel .val { font-size: 14px; color: #fff; }
.mrv-sw-panel .val.danger { color: #ff2a2a; animation: mrv-sw-flash 0.5s steps(2) infinite; }
@keyframes mrv-sw-flash { 50% { opacity: 0.3; } }

.mrv-sw-r2 {
  position: absolute;
  bottom: 18%;
  left: 18px;
  width: 56px;
  height: 60px;
  z-index: 3;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(0, 240, 255, 0.5));
}

/* Reticle / crosshair */
.mrv-sw-reticle {
  position: absolute;
  width: 64px;
  height: 64px;
  top: 50%;
  left: 50%;
  margin: -32px 0 0 -32px;
  pointer-events: none;
  z-index: 4;
  border: 2px solid #ffe81f;
  border-radius: 50%;
  box-shadow: 0 0 8px #ffe81f, 0 0 12px rgba(255, 232, 31, 0.5) inset;
  opacity: 0.9;
  transition: transform 0.1s linear, border-color 0.2s, box-shadow 0.2s;
}
.mrv-sw-reticle::before,
.mrv-sw-reticle::after {
  content: '';
  position: absolute;
  background: #ffe81f;
}
.mrv-sw-reticle::before { left: 50%; top: -10px; bottom: -10px; width: 2px; margin-left: -1px; }
.mrv-sw-reticle::after  { top: 50%; left: -10px; right: -10px; height: 2px; margin-top: -1px; }
.mrv-sw-reticle.lock {
  border-color: #ff2a2a;
  box-shadow: 0 0 12px #ff2a2a, 0 0 18px rgba(255, 42, 42, 0.6) inset;
  animation: mrv-sw-lock 0.3s steps(2) infinite;
}
@keyframes mrv-sw-lock { 50% { transform: scale(1.15); } }

/* Centered messages */
.mrv-sw-msg {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  color: #ffe81f;
  text-align: center;
  letter-spacing: 2px;
  text-shadow: 0 0 12px #ffe81f, 0 0 22px rgba(255, 232, 31, 0.6);
  pointer-events: none;
  opacity: 0;
  animation: mrv-sw-msg 4s ease;
}
.mrv-sw-msg.persist { animation: mrv-sw-msgIn 0.6s ease forwards; }
@keyframes mrv-sw-msg {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); }
}
@keyframes mrv-sw-msgIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.mrv-sw-msg .sub {
  display: block;
  margin-top: 10px;
  font-size: 11px;
  color: #fff;
  opacity: 0.8;
  letter-spacing: 1px;
}

/* Exit button */
.mrv-sw-exit {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 6;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid #ffe81f;
  color: #ffe81f;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 8px 12px;
  letter-spacing: 1px;
  cursor: pointer;
  text-shadow: 0 0 6px rgba(255, 232, 31, 0.5);
}
.mrv-sw-exit:hover { background: rgba(255, 232, 31, 0.18); }

/* Briefing screen (intro before the run) */
.mrv-sw-briefing {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: radial-gradient(ellipse at center, #001a30 0%, #000 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  animation: mrv-sw-fadein 0.6s ease;
}
.mrv-sw-briefing h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 22px;
  color: #ffe81f;
  margin: 0 0 18px;
  letter-spacing: 3px;
  text-shadow: 0 0 16px #ffe81f;
}
.mrv-sw-briefing p {
  font-size: 22px;
  color: #cfeaff;
  max-width: 640px;
  line-height: 1.4;
  margin: 0 0 20px;
}
.mrv-sw-briefing .target {
  width: 60px;
  height: 60px;
  margin: 10px auto 16px;
  border: 2px dashed #ff2a2a;
  border-radius: 50%;
  position: relative;
  animation: mrv-sw-lock 1s steps(2) infinite;
}
.mrv-sw-briefing .target::before {
  content: '';
  position: absolute;
  inset: 18px;
  background: #ff2a2a;
  border-radius: 50%;
  box-shadow: 0 0 10px #ff2a2a;
}
.mrv-sw-briefing button {
  background: transparent;
  border: 2px solid #ffe81f;
  color: #ffe81f;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  padding: 12px 22px;
  letter-spacing: 2px;
  cursor: pointer;
  margin-top: 10px;
}
.mrv-sw-briefing button:hover {
  background: #ffe81f;
  color: #000;
  text-shadow: none;
}
.mrv-sw-briefing .hint {
  margin-top: 14px;
  font-size: 16px;
  opacity: 0.7;
  color: #ffe81f;
}

/* Result screen */
.mrv-sw-result {
  position: absolute;
  inset: 0;
  z-index: 12;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  animation: mrv-sw-fadein 0.5s ease;
}
.mrv-sw-result h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 24px;
  margin: 0 0 18px;
  letter-spacing: 3px;
}
.mrv-sw-result h2.win  { color: #39ff14; text-shadow: 0 0 18px #39ff14; }
.mrv-sw-result h2.lose { color: #ff2a2a; text-shadow: 0 0 18px #ff2a2a; }
.mrv-sw-result p { font-size: 22px; color: #fff; margin: 0 0 20px; max-width: 600px; }
.mrv-sw-result button {
  background: transparent;
  border: 2px solid #ffe81f;
  color: #ffe81f;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  padding: 10px 18px;
  cursor: pointer;
  letter-spacing: 1px;
}
.mrv-sw-result button:hover { background: #ffe81f; color: #000; }

/* May 4th opt-in banner (shown alongside the seasonal banner) */
.mrv-sw-banner {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 90;
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid #ffe81f;
  color: #ffe81f;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  letter-spacing: 1px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(255, 232, 31, 0.35);
  animation: mrv-sw-fadein 0.6s ease;
}
.mrv-sw-banner:hover { background: rgba(255, 232, 31, 0.15); }
.mrv-sw-banner .ico { margin-right: 6px; }

/* Mobile */
@media (max-width: 720px) {
  .mrv-sw-cockpit::before { height: 14%; }
  .mrv-sw-cockpit::after  { height: 26%; }
  .mrv-sw-hud { height: 26%; padding: 0 12px 10px; font-size: 8px; }
  .mrv-sw-panel { min-width: 0; padding: 6px 8px; }
  .mrv-sw-panel .val { font-size: 12px; }
  .mrv-sw-msg { font-size: 12px; }
  .mrv-sw-r2 { width: 40px; height: 44px; left: 8px; }
  .mrv-sw-briefing h2 { font-size: 16px; }
  .mrv-sw-briefing p  { font-size: 18px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .mrv-sw-takeover, .mrv-sw-takeover.exiting,
  .mrv-sw-msg, .mrv-sw-msg.persist,
  .mrv-sw-result, .mrv-sw-briefing,
  .mrv-sw-banner { animation: none !important; }
  .mrv-sw-reticle.lock,
  .mrv-sw-panel .val.danger,
  .mrv-sw-briefing .target { animation: none !important; }
}
