/* ═══════════════════════════════════════════════════════════════
   Obsidian Terminal — Pixel Sprite Animations & Ambient Effects
   Walk cycles, flying sprites, particles, portal pulses, rune glow
   ═══════════════════════════════════════════════════════════════ */

/* ── Sprite container (absolute positioned, clipped ── */
.px-sprite {
  position: fixed;
  pointer-events: none;
  z-index: 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Keyframes: sprite walk cycle (4-frame strip) ── */
@keyframes px-walk-right {
  0%   { background-position: 0 0; }
  100% { background-position: calc(-1 * var(--sheet-w)) 0; }
}
@keyframes px-walk-left {
  0%   { background-position: 0 0; transform: scaleX(-1); }
  100% { background-position: calc(-1 * var(--sheet-w)) 0; transform: scaleX(-1); }
}

/* ── Keyframes: sprite idle (4-frame strip, slower) ── */
@keyframes px-idle {
  0%   { background-position: 0 0; }
  100% { background-position: calc(-1 * var(--sheet-w)) 0; }
}

/* ── Keyframes: dragon fly (4-frame strip) ── */
@keyframes px-fly {
  0%   { background-position: 0 0; }
  100% { background-position: calc(-1 * var(--sheet-w)) 0; }
}

/* ── Knight walking across screen ── */
.px-sprite--knight {
  width: calc(var(--sprite-w) * 2px);
  height: calc(var(--sprite-h) * 2px);
  background: url('../assets/sprites/knight-walk.png') no-repeat;
  background-size: calc(var(--sheet-w) * var(--sprite-w) * 2px) auto;
}
@keyframes knight-patrol {
  0%   { left: -10%; }
  100% { left: 110%; }
}
.px-sprite--knight.patrol {
  animation: knight-patrol 20s linear infinite, px-walk-right 0.6s steps(4) infinite;
}

/* ── Dragon circling (parabolic path) ── */
.px-sprite--dragon {
  width: calc(24 * 2px);
  height: calc(16 * 2px);
  background: url('../assets/sprites/dragon-fly.png') no-repeat;
  background-size: calc(4 * 24 * 2px) auto;
}
@keyframes dragon-soar {
  0%   { left: -15%; top: 15%; }
  25%  { left: 30%; top: 5%; }
  50%  { left: 60%; top: 18%; }
  75%  { left: 90%; top: 6%; }
  100% { left: 115%; top: 12%; }
}
.px-sprite--dragon.soar {
  animation: dragon-soar 30s ease-in-out infinite, px-fly 0.5s steps(4) infinite;
}

/* ── Mage floating (gentle vertical bob) ── */
.px-sprite--mage {
  width: calc(16 * 2px);
  height: calc(16 * 2px);
  background: url('../assets/sprites/mage-cast.png') no-repeat;
  background-size: calc(4 * 16 * 2px) auto;
}
@keyframes mage-float {
  0%, 100% { top: 25%; }
  50%      { top: 22%; }
}
@keyframes mage-drift {
  0%   { left: 65%; }
  100% { left: 75%; }
}
.px-sprite--mage.floating {
  animation: mage-float 3s ease-in-out infinite, mage-drift 6s ease-in-out alternate infinite, px-idle 0.8s steps(4) infinite;
}

/* ── Trader crossing ── */
.px-sprite--trader {
  width: calc(16 * 2px);
  height: calc(16 * 2px);
  background: url('../assets/sprites/trader-walk.png') no-repeat;
  background-size: calc(4 * 16 * 2px) auto;
}
@keyframes trader-cross {
  0%   { left: -8%; }
  100% { left: 108%; }
}
.px-sprite--trader.crossing {
  animation: trader-cross 18s linear infinite, px-walk-right 0.7s steps(4) infinite;
}

/* ── Void creature pulsing ── */
.px-sprite--void {
  width: calc(16 * 2px);
  height: calc(16 * 2px);
  background: url('../assets/sprites/void-idle.png') no-repeat;
  background-size: calc(4 * 16 * 2px) auto;
}
@keyframes void-pulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50%      { transform: scale(1.3); opacity: 1; }
}
@keyframes void-wander {
  0%   { left: 70%; top: 60%; }
  25%  { left: 72%; top: 56%; }
  50%  { left: 68%; top: 55%; }
  75%  { left: 65%; top: 58%; }
  100% { left: 70%; top: 60%; }
}
.px-sprite--void.wandering {
  animation: void-wander 8s ease-in-out infinite, void-pulse 2s ease-in-out infinite, px-idle 1s steps(4) infinite;
}

/* ═══════════════════════════════════════════════════════════════
   Ambient Particles — floating embers, gold motes, sparkles, runes
   ═══════════════════════════════════════════════════════════════ */

/* ── Floating ember (forge, void gate) ── */
.px-ember {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  width: 4px;
  height: 4px;
  background: var(--ember-color, #ff6020);
  image-rendering: pixelated;
  box-shadow: 0 0 6px var(--ember-color, #ff6020);
}
@keyframes ember-rise {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 0.6; }
  100% { transform: translateY(-120px) translateX(30px); opacity: 0; }
}
.px-ember.f1 { animation: ember-rise 3s ease-out infinite; }
.px-ember.f2 { animation: ember-rise 4s ease-out 1s infinite; }
.px-ember.f3 { animation: ember-rise 3.5s ease-out 2s infinite; }
.px-ember.f4 { animation: ember-rise 5s ease-out 0.5s infinite; }
.px-ember.f5 { animation: ember-rise 2.8s ease-out 1.5s infinite; }
.px-ember.f6 { animation: ember-rise 4.2s ease-out 2.5s infinite; }
.px-ember.f7 { animation: ember-rise 3.3s ease-out 3s infinite; }
.px-ember.f8 { animation: ember-rise 3.8s ease-out 0.8s infinite; }

/* ── Gold mote (vault, hoard) ── */
.px-mote {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  width: 3px;
  height: 3px;
  background: #f0c040;
  image-rendering: pixelated;
  box-shadow: 0 0 5px #f0c040;
}
@keyframes mote-rise {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  15%  { opacity: 0.8; }
  85%  { opacity: 0.5; }
  100% { transform: translateY(-100px) translateX(-15px); opacity: 0; }
}
.px-mote.m1 { animation: mote-rise 4s ease-out infinite; }
.px-mote.m2 { animation: mote-rise 5s ease-out 1.2s infinite; }
.px-mote.m3 { animation: mote-rise 3.5s ease-out 0.4s infinite; }
.px-mote.m4 { animation: mote-rise 4.5s ease-out 2s infinite; }
.px-mote.m5 { animation: mote-rise 3.8s ease-out 3s infinite; }
.px-mote.m6 { animation: mote-rise 5.2s ease-out 0.6s infinite; }
.px-mote.m7 { animation: mote-rise 4.3s ease-out 1.8s infinite; }
.px-mote.m8 { animation: mote-rise 3.2s ease-out 2.4s infinite; }

/* ── Sparkle / twinkle (star field, arcane) ── */
.px-sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  width: 2px;
  height: 2px;
  background: #fff;
  image-rendering: pixelated;
  box-shadow: 0 0 4px #c8b0ff;
}
@keyframes sparkle-twinkle {
  0%, 100% { opacity: 0.2; }
  50%      { opacity: 1; }
}
.px-sparkle.s1 { animation: sparkle-twinkle 2s ease-in-out infinite; }
.px-sparkle.s2 { animation: sparkle-twinkle 2.5s ease-in-out 0.5s infinite; }
.px-sparkle.s3 { animation: sparkle-twinkle 1.8s ease-in-out 1s infinite; }
.px-sparkle.s4 { animation: sparkle-twinkle 3s ease-in-out 1.5s infinite; }
.px-sparkle.s5 { animation: sparkle-twinkle 2.2s ease-in-out 2s infinite; }
.px-sparkle.s6 { animation: sparkle-twinkle 2.8s ease-in-out 0.3s infinite; }
.px-sparkle.s7 { animation: sparkle-twinkle 1.6s ease-in-out 0.8s infinite; }
.px-sparkle.s8 { animation: sparkle-twinkle 3.2s ease-in-out 1.8s infinite; }

/* ── Data stream particle (cyber-grid, market) ── */
.px-data {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  width: 2px;
  height: 8px;
  background: linear-gradient(to bottom, transparent, #40f0ff);
  image-rendering: pixelated;
}
@keyframes data-fall {
  0%   { transform: translateY(-20px); opacity: 0; }
  10%  { opacity: 0.8; }
  90%  { opacity: 0.3; }
  100% { transform: translateY(110vh); opacity: 0; }
}
.px-data.d1 { animation: data-fall 6s linear infinite; }
.px-data.d2 { animation: data-fall 5s linear 1s infinite; }
.px-data.d3 { animation: data-fall 7s linear 2s infinite; }
.px-data.d4 { animation: data-fall 4.5s linear 0.5s infinite; }
.px-data.d5 { animation: data-fall 5.5s linear 2.5s infinite; }
.px-data.d6 { animation: data-fall 6.5s linear 3s infinite; }
.px-data.d7 { animation: data-fall 4s linear 1.5s infinite; }
.px-data.d8 { animation: data-fall 7.5s linear 3.5s infinite; }

/* ── Floating rune (arcane, indicators) ── */
.px-rune {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  width: 8px;
  height: 8px;
  image-rendering: pixelated;
  background: #9050ff;
  box-shadow: 0 0 8px #9050ff;
}
@keyframes rune-float {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.4; }
  50%      { transform: translateY(-15px) rotate(15deg); opacity: 0.8; }
}
.px-rune.r1 { animation: rune-float 4s ease-in-out infinite; }
.px-rune.r2 { animation: rune-float 5s ease-in-out 1s infinite; background: #c050ff; box-shadow: 0 0 8px #c050ff; }
.px-rune.r3 { animation: rune-float 3.5s ease-in-out 2s infinite; background: #ff50a0; box-shadow: 0 0 8px #ff50a0; }
.px-rune.r4 { animation: rune-float 4.5s ease-in-out 0.5s infinite; }
.px-rune.r5 { animation: rune-float 3s ease-in-out 1.5s infinite; background: #50c0ff; box-shadow: 0 0 8px #50c0ff; }
.px-rune.r6 { animation: rune-float 5.5s ease-in-out 2.5s infinite; background: #c050ff; box-shadow: 0 0 8px #c050ff; }

/* ═══════════════════════════════════════════════════════════════
   Portal pulse (index, auth) — concentric ring expansion
   ═══════════════════════════════════════════════════════════════ */

.px-portal {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
  border: 2px solid rgba(140, 60, 240, 0.4);
  box-shadow: 0 0 30px rgba(140, 60, 240, 0.15), inset 0 0 30px rgba(140, 60, 240, 0.1);
  animation: portal-expand 6s ease-out infinite;
}
@keyframes portal-expand {
  0%   { width: 60px; height: 60px; opacity: 0.8; }
  100% { width: 500px; height: 500px; opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   Scanline enhancement — animate the scanline sweep
   ═══════════════════════════════════════════════════════════════ */

@keyframes scanline-sweep {
  0%   { top: 0; }
  100% { top: 100%; }
}
.px-scanline {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(140, 60, 240, 0.08);
  box-shadow: 0 0 20px rgba(140, 60, 240, 0.05);
  animation: scanline-sweep 8s linear infinite;
}

/* ═══════════════════════════════════════════════════════════════
   Hovering AI chip glow pulse
   ═══════════════════════════════════════════════════════════════ */

@keyframes chip-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(140, 60, 240, 0.3); }
  50%      { box-shadow: 0 0 16px rgba(140, 60, 240, 0.6); }
}

/* ═══════════════════════════════════════════════════════════════
   CSS variables for sprites (set per sprite instance)
   ═══════════════════════════════════════════════════════════════ */

.px-sprite {
  --sprite-w: 16;
  --sprite-h: 16;
  --sheet-w: 64;  /* 4 frames × 16px each */
}
.px-sprite--knight { --sprite-w: 16; --sprite-h: 16; --sheet-w: 64; }
.px-sprite--dragon  { --sprite-w: 24; --sprite-h: 16; --sheet-w: 96; }
.px-sprite--mage    { --sprite-w: 16; --sprite-h: 16; --sheet-w: 64; }
.px-sprite--trader  { --sprite-w: 16; --sprite-h: 16; --sheet-w: 64; }
.px-sprite--void    { --sprite-w: 16; --sprite-h: 16; --sheet-w: 64; }
