/* 100svh Zero-Scroll Atmospheric Stage & Pixel-Art Actors */
.launcher-stage {
  position: relative;
  width: 100%;
  height: 100svh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: var(--bg-night);
  isolation: isolate;
}

/* Background Backdrop Layer */
.scene-backdrop {
  position: absolute;
  inset: 0;
  z-index: -3;
  background-image: url('../images/web_bg.jpg');
  background-image: image-set(
    url('../images/web_bg.avif') type('image/avif') 1x,
    url('../images/web_bg-2x.avif') type('image/avif') 2x,
    url('../images/web_bg.webp') type('image/webp') 1x,
    url('../images/web_bg-2x.webp') type('image/webp') 2x,
    url('../images/web_bg.jpg') type('image/jpeg') 1x,
    url('../images/web_bg-2x.jpg') type('image/jpeg') 2x
  );
  background-size: cover;
  background-position: center 42%;
  filter: saturate(0.95) contrast(1.06);
  transform: scale(1.02);
}

.scene-vignette {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 50% 24%, rgba(229, 169, 60, 0.14) 0%, transparent 52%),
    linear-gradient(
      180deg,
      rgba(15, 19, 26, 0.84) 0%,
      rgba(15, 19, 26, 0.44) 38%,
      rgba(15, 19, 26, 0.38) 64%,
      rgba(15, 19, 26, 0.94) 100%
    );
  pointer-events: none;
}

/* Subtle CSS Ember Particles */
.scene-embers {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.ember {
  position: absolute;
  bottom: -12px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-ember);
  box-shadow: 0 0 8px var(--accent-gold), 0 0 14px var(--accent-ember);
  opacity: 0;
}

.ember:nth-child(1) { left: 12%; animation: ember-rise 7s linear infinite 0.5s; }
.ember:nth-child(2) { left: 28%; width: 3px; height: 3px; animation: ember-rise 9s linear infinite 2s; }
.ember:nth-child(3) { left: 46%; animation: ember-rise 6.5s linear infinite 1s; }
.ember:nth-child(4) { left: 64%; width: 5px; height: 5px; animation: ember-rise 8.5s linear infinite 3s; }
.ember:nth-child(5) { left: 79%; width: 3px; height: 3px; animation: ember-rise 7.5s linear infinite 1.8s; }
.ember:nth-child(6) { left: 91%; animation: ember-rise 8s linear infinite 4s; }

@keyframes ember-rise {
  0% {
    transform: translateY(0) translateX(0) scale(0.8);
    opacity: 0;
  }
  15% {
    opacity: 0.85;
  }
  80% {
    opacity: 0.55;
  }
  100% {
    transform: translateY(-72svh) translateX(18px) scale(0.2);
    opacity: 0;
  }
}

/* Interactive Pixel-Art Scene Actors */
.scene-actors {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

/* Ground Horizon Line with Pixel Grass Tufts & Pebbles */
.scene-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--hud-height) + 80px);
  height: 18px;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 10%, #000 90%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 10%, #000 90%, transparent 100%);
}

.scene-ground-track {
  width: calc(100% + 360px);
  height: 100%;
  background-repeat: repeat-x;
  background-size: 160px 18px;
  background-position: 0 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='18' viewBox='0 0 160 18' shape-rendering='crispEdges'%3E%3Crect x='0' y='10' width='160' height='1' fill='%234A586F' opacity='0.85'/%3E%3Crect x='0' y='11' width='160' height='2' fill='%2328313F' opacity='0.95'/%3E%3Crect x='0' y='13' width='160' height='2' fill='%23161C25' opacity='0.75'/%3E%3Crect x='16' y='8' width='2' height='2' fill='%233A5B3C'/%3E%3Crect x='18' y='6' width='2' height='4' fill='%23507B4E'/%3E%3Crect x='20' y='8' width='2' height='2' fill='%233A5B3C'/%3E%3Crect x='40' y='9' width='4' height='2' fill='%2359667A'/%3E%3Crect x='44' y='10' width='2' height='1' fill='%23333D4D'/%3E%3Crect x='66' y='7' width='2' height='3' fill='%23476D47'/%3E%3Crect x='68' y='5' width='2' height='5' fill='%235F8E5B'/%3E%3Crect x='70' y='8' width='2' height='2' fill='%233A5B3C'/%3E%3Crect x='94' y='9' width='5' height='2' fill='%234E5A6E'/%3E%3Crect x='96' y='8' width='2' height='1' fill='%236B7991'/%3E%3Crect x='120' y='7' width='2' height='3' fill='%233A5B3C'/%3E%3Crect x='122' y='8' width='2' height='2' fill='%23507B4E'/%3E%3Crect x='144' y='9' width='3' height='2' fill='%235E6A7E'/%3E%3C/svg%3E");
  translate: 0 0;
  transition: translate 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.scene-actors.is-approaching .scene-ground-track,
.scene-actors.is-fighting .scene-ground-track {
  translate: -320px 0;
}

.actor-sprite {
  position: absolute;
  image-rendering: pixelated;
  pointer-events: none;
}

/* Modal/Drawer veya sekme gizliyken sahne animasyonlarını duraklat (GPU/FPS tasarrufu) */
body:has(dialog[open]) .ember,
body:has(dialog[open]) .actor-sprite,
.scene-actors.is-paused .actor-sprite {
  animation-play-state: paused;
}

/* Dark Knight Base + Idle Spritesheet: 1700x170 -> 10 frames of 170x170 */
.actor-knight {
  left: 50%;
  margin-left: -85px;
  bottom: calc(var(--hud-height) + 14px);
  width: 170px;
  height: 170px;
  background-image: url('../sprites/dark_knight/idle.png');
  background-repeat: no-repeat;
  background-size: 1700px 170px;
  background-position: 0 0;
  transform: scale(1.25);
  transform-origin: bottom center;
  translate: clamp(-390px, -28vw, -112px) 0;
  transition: translate 1.5s cubic-bezier(0.22, 0.61, 0.36, 1);
  animation: knight-idle 1.15s steps(10) infinite;
}

.scene-actors.is-approaching .actor-knight,
.scene-actors.is-fighting .actor-knight {
  translate: -56px 0;
}

.scene-actors.is-approaching .actor-knight {
  background-image: url('../sprites/dark_knight/run.png');
  background-size: 1360px 170px;
  animation: knight-run 0.56s steps(8) infinite;
}

.actor-knight.state-attack1 {
  background-image: url('../sprites/dark_knight/attack.png');
  background-size: 680px 170px;
  animation: knight-atk4 0.38s steps(4) infinite;
}

.actor-knight.state-attack2 {
  background-image: url('../sprites/dark_knight/Attack2.png');
  background-size: 680px 170px;
  animation: knight-atk4 0.38s steps(4) infinite;
}

.actor-knight.state-attack3 {
  background-image: url('../sprites/dark_knight/Attack3.png');
  background-size: 1020px 170px;
  animation: knight-atk6 0.52s steps(6) infinite;
}

.actor-knight.state-hit {
  background-image: url('../sprites/dark_knight/hit.png');
  background-size: 510px 170px;
  animation: knight-hit 0.34s steps(3) infinite;
}

@keyframes knight-idle {
  from { background-position: 0 0; }
  to { background-position: -1700px 0; }
}

@keyframes knight-run {
  from { background-position: 0 0; }
  to { background-position: -1360px 0; }
}

@keyframes knight-atk4 {
  from { background-position: 0 0; }
  to { background-position: -680px 0; }
}

@keyframes knight-atk6 {
  from { background-position: 0 0; }
  to { background-position: -1020px 0; }
}

@keyframes knight-hit {
  from { background-position: 0 0; }
  to { background-position: -510px 0; }
}

/* Boss Kroxus Base + Idle Spritesheet: 2000x250 -> 8 frames of 250x250 */
.actor-kroxus {
  left: 50%;
  margin-left: -125px;
  bottom: calc(var(--hud-height) + 12px);
  width: 250px;
  height: 250px;
  background-image: url('../sprites/boss_kroxus/idle.png');
  background-repeat: no-repeat;
  background-size: 2000px 250px;
  background-position: 0 0;
  transform: scaleX(-1) scale(0.92);
  transform-origin: bottom center;
  translate: clamp(114px, 19vw, 250px) 0;
  transition: translate 1.5s cubic-bezier(0.22, 0.61, 0.36, 1);
  animation: kroxus-idle 1.15s steps(8) infinite;
}

.scene-actors.is-approaching .actor-kroxus,
.scene-actors.is-fighting .actor-kroxus {
  translate: 72px 0;
}

.actor-kroxus.state-attack1 {
  background-image: url('../sprites/boss_kroxus/attack.png');
  background-size: 2000px 250px;
  animation: kroxus-idle 0.72s steps(8) infinite;
}

.actor-kroxus.state-attack2 {
  background-image: url('../sprites/boss_kroxus/attack2.png');
  background-size: 2000px 250px;
  animation: kroxus-idle 0.76s steps(8) infinite;
}

@keyframes kroxus-idle {
  from { background-position: 0 0; }
  to { background-position: -2000px 0; }
}

@media (max-width: 768px) {
  .scene-ground {
    bottom: calc(var(--hud-height) + 58px);
  }

  .actor-knight {
    bottom: calc(var(--hud-height) + 12px);
    transform: scale(0.92);
    translate: clamp(-142px, -31vw, -96px) 0;
  }

  .scene-actors.is-approaching .actor-knight,
  .scene-actors.is-fighting .actor-knight {
    translate: -36px 0;
  }

  .actor-kroxus {
    bottom: calc(var(--hud-height) + 10px);
    transform: scaleX(-1) scale(0.68);
    translate: clamp(98px, 31vw, 146px) 0;
  }

  .scene-actors.is-approaching .actor-kroxus,
  .scene-actors.is-fighting .actor-kroxus {
    translate: 48px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ember {
    display: none;
  }
  .scene-ground-track,
  .actor-knight,
  .actor-kroxus {
    animation: none;
    transition: none;
  }
}
