/* ============================================================
   ZamZam — SOLO LEVELING ENVIRONMENT EFFECTS (FX)
   Animated dungeon background, hex grid, scanlines, vignette,
   level-up flash, mission-window opening transition.
   Loaded LAST so wins over solo-system.css body::before/::after.
   ============================================================ */

/* Solid base — FX layers paint on top via real divs (NOT pseudo-elements,
   to avoid z-index quirks with opaque body bg) */
body {
  background: #000610 !important;
  min-height: 100vh;
}

/* Kill old layers from solo-system.css and styles.css that conflict */
body::before, body::after { display: none !important; }

/* ============================================================
   LAYER 1: deep-space radial nebula (real div, injected by JS)
   ============================================================ */
.fx-layer-nebula {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 60% at 20% 0%,   rgba(0, 246, 255, 0.22) 0%, transparent 55%),
    radial-gradient(ellipse 80% 70% at 100% 50%, rgba(157, 62, 255, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse 70% 60% at 50% 110%, rgba(0, 80, 255, 0.22) 0%,   transparent 60%),
    radial-gradient(ellipse 60% 50% at 0% 100%,  rgba(0, 246, 255, 0.12) 0%,  transparent 55%);
  animation: bg-nebula-pulse 14s ease-in-out infinite;
}
@keyframes bg-nebula-pulse {
  0%, 100% { opacity: 0.95; transform: scale(1) rotate(0deg); }
  50%      { opacity: 1;    transform: scale(1.04) rotate(0.4deg); }
}

/* ============================================================
   LAYER 2: animated SL grid (the signature blue mesh)
   Two grids — one big, one fine — drifting opposite directions
   ============================================================ */
.fx-layer-grid {
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    /* Coarse grid 80px */
    linear-gradient(rgba(0, 246, 255, 0.045) 1px, transparent 1px) 0 0 / 80px 80px,
    linear-gradient(90deg, rgba(0, 246, 255, 0.045) 1px, transparent 1px) 0 0 / 80px 80px,
    /* Fine grid 16px */
    linear-gradient(rgba(0, 246, 255, 0.020) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(90deg, rgba(0, 246, 255, 0.020) 1px, transparent 1px) 0 0 / 16px 16px;
  /* Perspective floor effect */
  mask-image: radial-gradient(ellipse 90% 70% at 50% 60%, #000 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 60%, #000 0%, transparent 100%);
  animation: grid-drift 32s linear infinite;
}
@keyframes grid-drift {
  from { background-position: 0 0, 0 0, 0 0, 0 0; }
  to   { background-position: 80px 80px, 80px 80px, 16px 16px, 16px 16px; }
}

/* ============================================================
   LAYER 3: stars / particles (sharp pinpoints + drift)
   ============================================================ */
.fx-layer-stars {
  position: fixed; inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%,  rgba(0, 246, 255, 0.95), transparent 60%),
    radial-gradient(1px 1px at 70% 60%,      rgba(0, 246, 255, 0.7),  transparent 60%),
    radial-gradient(2px 2px at 40% 80%,      rgba(157, 62, 255, 0.85),transparent 60%),
    radial-gradient(1px 1px at 85% 25%,      rgba(0, 246, 255, 0.6),  transparent 60%),
    radial-gradient(1.5px 1.5px at 15% 65%,  rgba(0, 246, 255, 0.7),  transparent 60%),
    radial-gradient(1px 1px at 60% 15%,      rgba(157, 62, 255, 0.55),transparent 60%),
    radial-gradient(2px 2px at 30% 50%,      rgba(0, 246, 255, 0.6),  transparent 60%),
    radial-gradient(1px 1px at 90% 80%,      rgba(255, 255, 255, 0.5),transparent 60%),
    radial-gradient(1.5px 1.5px at 5% 90%,   rgba(0, 246, 255, 0.7),  transparent 60%),
    radial-gradient(1px 1px at 50% 5%,       rgba(255, 255, 255, 0.6),transparent 60%);
  background-size: 700px 700px;
  animation: stars-drift 90s linear infinite, stars-twinkle 3s ease-in-out infinite;
}
@keyframes stars-drift {
  from { background-position: 0 0; }
  to   { background-position: -700px -700px; }
}
@keyframes stars-twinkle {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; }
}

/* ============================================================
   LAYER 4: scanlines (very subtle CRT feel) — desktop only
   ============================================================ */
.fx-layer-scan {
  position: fixed; inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 2px,
    rgba(0, 246, 255, 0.012) 2px,
    rgba(0, 246, 255, 0.012) 3px
  );
  mix-blend-mode: screen;
  contain: paint;
}

/* ============================================================
   LAYER 5: vignette + edge glow
   ============================================================ */
.fx-layer-vignette {
  position: fixed; inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    radial-gradient(ellipse 100% 100% at 50% 50%, transparent 50%, rgba(0, 0, 0, 0.65) 100%);
  mix-blend-mode: multiply;
  contain: paint;
}

/* Containment hints for paint isolation */
.fx-layer-nebula, .fx-layer-grid, .fx-layer-stars { contain: paint; }

/* Off-screen cards skip layout/paint until they scroll into view.
   Saves ~30-60% scroll cost on stats page (which has 10+ cards). */
.card {
  content-visibility: auto;
  contain-intrinsic-size: auto 240px;
}
/* Exception: keep critical above-fold cards always rendered */
.prayer-hero-card,
#playerStatusMount,
.player-status,
#sysBar {
  content-visibility: visible !important;
}

/* On low-end / mobile: drop the heaviest layers (mix-blend-mode is GPU-expensive)
   and slow down ambient anims to reduce paint frequency */
@media (max-width: 600px), (pointer: coarse) {
  .fx-layer-scan, .fx-layer-vignette { display: none; }
  .fx-layer-nebula { animation-duration: 30s; }
  .fx-layer-grid   { animation-duration: 60s; }
  .fx-layer-stars  { animation: none; opacity: 0.7; }
  .fx-layer-edge-top, .fx-layer-edge-bot { animation: none; opacity: 0.5; }
}

/* Respect user motion preference — kill all decorative animations */
@media (prefers-reduced-motion: reduce) {
  .fx-layer-grid, .fx-layer-stars, .fx-layer-nebula,
  .fx-layer-edge-top, .fx-layer-edge-bot,
  #sysBar .sys-bar-fill::after,
  .ramadan-progress-fill, .prayer-time-row.prayer-next,
  .ach-tile.unlocked, .istighfar-total span, .salawat-total span,
  .counter-total span, .ins-card.ins-urgent,
  .nav-item.active::before, .ps-buff.gold, .ps-buff.danger,
  .syslog-line, .feed-line {
    animation: none !important;
  }
  * { transition-duration: 0.05s !important; }
}

/* Top edge — like an SL system bar starting to slide down */
.fx-layer-edge-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--sys-cyan), transparent);
  box-shadow: 0 0 14px var(--sys-cyan-glow);
  z-index: 100;
  pointer-events: none;
  opacity: 0.45;
  animation: edge-pulse 4s ease-in-out infinite;
}
.fx-layer-edge-bot {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--sys-purple), transparent);
  box-shadow: 0 0 10px var(--sys-purple-glow);
  z-index: 100;
  pointer-events: none;
  opacity: 0.35;
  animation: edge-pulse 6s ease-in-out infinite reverse;
}
@keyframes edge-pulse {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 0.7; }
}

/* Make all real content sit above FX layers (which use z-index 0..4) */
.container, header, .bottom-nav, #sysBar,
.location-modal-overlay, .countdown-overlay, .toast,
.greeter-overlay, #missionClearedOverlay, #countdownOverlay,
.date-picker-overlay
  { position: relative; z-index: 10 !important; }
.bottom-nav { position: fixed !important; z-index: 50 !important; }
#sysBar { position: fixed !important; z-index: 60 !important; }
.location-modal-overlay, .countdown-overlay, .greeter-overlay,
#missionClearedOverlay, .date-picker-overlay { position: fixed !important; z-index: 9000 !important; }

/* ============================================================
   LEVEL UP — full-screen flash event
   Triggered by adding class .lvl-up-flash to body
   ============================================================ */
body.lvl-up-flash::after {
  content: 'LEVEL UP';
  display: block !important;
  position: fixed; inset: 0;
  z-index: 9998;
  background:
    radial-gradient(circle at center, rgba(0,246,255,0.5), transparent 60%),
    rgba(0, 8, 20, 0.85);
  pointer-events: none;
  animation: lvl-flash 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(48px, 14vw, 100px);
  letter-spacing: 0.18em;
  color: #fff;
  text-shadow:
    0 0 30px var(--sys-cyan),
    0 0 60px var(--sys-cyan-glow),
    0 0 120px rgba(0, 246, 255, 0.5);
  display: flex !important;
  align-items: center;
  justify-content: center;
  text-align: center;
}
@keyframes lvl-flash {
  0%   { opacity: 0; transform: scale(0.4); filter: blur(20px); }
  20%  { opacity: 1; transform: scale(1.2); filter: blur(0); }
  60%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.6); }
}

/* ============================================================
   PRAYER COMPLETED — micro flash on the row
   Add class .row-pulse-cyan to .prayer-time-row briefly
   ============================================================ */
.prayer-time-row.row-pulse-cyan {
  animation: row-pulse-cyan 0.7s ease-out;
}
@keyframes row-pulse-cyan {
  0%   { box-shadow: 0 0 0 0 rgba(0, 255, 163, 0.5), inset 0 0 0 rgba(0,255,163,0.2); }
  50%  { box-shadow: 0 0 24px rgba(0, 255, 163, 0.8), inset 0 0 14px rgba(0, 255, 163, 0.18); }
  100% { box-shadow: 0 0 0 0 rgba(0, 255, 163, 0); }
}
.prayer-time-row.row-pulse-red {
  animation: row-pulse-red 0.5s ease-out;
}
@keyframes row-pulse-red {
  0%   { box-shadow: 0 0 0 0 rgba(255, 51, 102, 0.5); }
  50%  { box-shadow: 0 0 18px rgba(255, 51, 102, 0.7); }
  100% { box-shadow: 0 0 0 0 rgba(255, 51, 102, 0); }
}

/* ============================================================
   DAILY GREETER MODAL — typewriter
   ============================================================ */
.greeter-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at center, rgba(0, 8, 20, 0.92), rgba(0, 0, 0, 0.96));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.greeter-overlay.show { opacity: 1; pointer-events: auto; }
.greeter-card {
  width: min(440px, 100%);
  background: linear-gradient(180deg, rgba(0, 20, 40, 0.95), rgba(0, 8, 20, 0.95));
  border: 1px solid var(--sys-cyan);
  box-shadow:
    0 0 50px rgba(0, 246, 255, 0.4),
    inset 0 0 30px rgba(0, 246, 255, 0.06);
  padding: 28px 22px 22px;
  font-family: 'Orbitron', monospace;
  position: relative;
  clip-path: polygon(
    0 0, calc(100% - 18px) 0, 100% 18px,
    100% 100%, 18px 100%, 0 calc(100% - 18px)
  );
  transform: translateY(20px);
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.greeter-overlay.show .greeter-card { transform: translateY(0); }
.greeter-tag {
  font-size: 10px;
  letter-spacing: 0.32em;
  color: var(--sys-cyan);
  text-shadow: 0 0 6px var(--sys-cyan-glow);
  font-weight: 800;
  margin-bottom: 14px;
}
.greeter-line {
  font-size: 14px;
  letter-spacing: 0.06em;
  color: var(--sys-text);
  margin: 6px 0;
  min-height: 18px;
  line-height: 1.5;
  font-weight: 500;
  text-shadow: 0 0 4px rgba(0, 246, 255, 0.2);
}
.greeter-line strong {
  color: var(--sys-cyan);
  font-weight: 800;
  text-shadow: 0 0 8px var(--sys-cyan-glow);
}
.greeter-cursor {
  display: inline-block;
  width: 8px; height: 14px;
  background: var(--sys-cyan);
  vertical-align: text-bottom;
  margin-left: 2px;
  box-shadow: 0 0 6px var(--sys-cyan-glow);
  animation: greeter-blink 0.8s steps(2) infinite;
}
@keyframes greeter-blink { 50% { opacity: 0; } }
.greeter-cta {
  display: inline-block;
  margin-top: 18px;
  padding: 10px 22px;
  background: var(--sys-cyan);
  color: #000;
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 18px var(--sys-cyan-glow);
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  opacity: 0;
  transition: opacity 0.3s, box-shadow 0.2s;
}
.greeter-cta.ready { opacity: 1; }
.greeter-cta:hover { box-shadow: 0 0 30px var(--sys-cyan); }

/* ============================================================
   ACHIEVEMENTS GRID
   ============================================================ */
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  padding: 12px 14px 16px;
}
@media (max-width: 600px) {
  .ach-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; padding: 8px 10px 12px; }
  .ach-icon { font-size: 18px; }
  .ach-name { font-size: 6.5px; letter-spacing: 0.06em; }
}
@media (max-width: 380px) {
  .ach-grid { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 5px; padding: 6px 8px 10px; }
  .ach-icon { font-size: 16px; }
  .ach-name { font-size: 6px; letter-spacing: 0.04em; }
}
.ach-tile {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(0, 8, 20, 0.65);
  border: 1px solid rgba(0, 246, 255, 0.15);
  cursor: help;
  transition: all 0.18s;
  font-family: 'Orbitron', monospace;
  /* Hex */
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.ach-tile.locked {
  opacity: 0.4;
  filter: grayscale(0.9);
}
.ach-tile.unlocked {
  background: linear-gradient(135deg, rgba(0, 246, 255, 0.18), rgba(0, 8, 20, 0.6));
  border-color: var(--sys-cyan);
  box-shadow: 0 0 14px rgba(0, 246, 255, 0.45);
  animation: ach-unlocked-glow 4s ease-in-out infinite;
}
@keyframes ach-unlocked-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(0, 246, 255, 0.35); }
  50%      { box-shadow: 0 0 22px rgba(0, 246, 255, 0.65); }
}
.ach-tile.unlocked.gold {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.18), rgba(0, 8, 20, 0.6));
  border-color: #ffd700;
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.5);
}
.ach-tile.unlocked.purple {
  background: linear-gradient(135deg, rgba(157, 62, 255, 0.20), rgba(0, 8, 20, 0.6));
  border-color: var(--sys-purple);
  box-shadow: 0 0 16px var(--sys-purple-glow);
}
.ach-icon {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(0, 246, 255, 0.55));
}
.ach-tile.locked .ach-icon { filter: grayscale(1) opacity(0.6); }
.ach-name {
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sys-cyan);
  text-align: center;
  line-height: 1.1;
  text-shadow: 0 0 4px var(--sys-cyan-glow);
  padding: 0 4px;
}
.ach-tile.locked .ach-name { color: var(--sys-text-muted); text-shadow: none; }

/* ============================================================
   ACTIVITY FEED — terminal log
   ============================================================ */
.feed {
  padding: 12px 14px 16px;
  font-family: 'Geist Mono', 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  max-height: 320px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 246, 255, 0.08);
  margin: 0 14px 14px;
}
.feed::-webkit-scrollbar { width: 4px; }
.feed::-webkit-scrollbar-thumb { background: var(--sys-cyan-dim); }
.feed-line {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(0, 246, 255, 0.06);
  align-items: baseline;
  opacity: 0;
  animation: feed-line-in 0.4s ease forwards;
}
@keyframes feed-line-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.feed-time {
  color: var(--sys-cyan);
  text-shadow: 0 0 3px var(--sys-cyan-glow);
  font-weight: 600;
  opacity: 0.85;
}
.feed-event {
  color: var(--sys-text);
  font-weight: 500;
}
.feed-event.event-prayer  { color: var(--sys-success); text-shadow: 0 0 4px rgba(0, 255, 163, 0.4); }
.feed-event.event-missed  { color: var(--sys-danger);  text-shadow: 0 0 4px rgba(255, 51, 102, 0.4); }
.feed-event.event-dhikr   { color: var(--sys-purple);  text-shadow: 0 0 4px var(--sys-purple-glow); }
.feed-event.event-system  { color: #ffd700;            text-shadow: 0 0 4px rgba(255, 215, 0, 0.4); }
.feed-xp {
  color: var(--sys-cyan);
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-shadow: 0 0 4px var(--sys-cyan-glow);
}
.feed-xp.neg { color: var(--sys-danger); text-shadow: 0 0 4px rgba(255, 51, 102, 0.4); }
.feed-empty {
  text-align: center;
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--sys-text-muted);
  text-transform: uppercase;
  padding: 30px 12px;
}

/* ============================================================
   MINI SYSTEM LOG (compact terminal on index/today)
   ============================================================ */
.mini-syslog {
  margin-top: 10px !important;
  margin-bottom: 12px !important;
  position: relative;
}
.syslog-body {
  font-family: 'Geist Mono', 'Orbitron', monospace;
  font-size: 10.5px;
  letter-spacing: 0.03em;
  padding: 6px 14px 4px;
  max-height: 130px;
  overflow: hidden;
  position: relative;
}
.syslog-body::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 26px;
  background: linear-gradient(transparent, rgba(0, 8, 20, 0.95));
  pointer-events: none;
}
.syslog-line {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px dashed rgba(0, 246, 255, 0.05);
  align-items: baseline;
  opacity: 0;
  animation: feed-line-in 0.3s ease forwards;
}
.syslog-line:last-child { border-bottom: none; }
.syslog-t {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--sys-cyan);
  text-shadow: 0 0 3px var(--sys-cyan-glow);
  opacity: 0.85;
}
.syslog-msg {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--sys-text);
}
.syslog-line.k-ok    .syslog-msg { color: var(--sys-success); text-shadow: 0 0 3px rgba(0,255,163,0.35); }
.syslog-line.k-err   .syslog-msg { color: var(--sys-danger);  text-shadow: 0 0 3px rgba(255,51,102,0.35); }
.syslog-line.k-dhikr .syslog-msg { color: #c19fff;            text-shadow: 0 0 3px var(--sys-purple-glow); }
.syslog-line.k-sys   .syslog-msg { color: #ffd700;            text-shadow: 0 0 3px rgba(255,215,0,0.35); }
.syslog-xp {
  font-family: 'Orbitron', monospace;
  font-weight: 800;
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--sys-cyan);
  text-shadow: 0 0 4px var(--sys-cyan-glow);
}
.syslog-xp.neg { color: var(--sys-danger); text-shadow: 0 0 4px rgba(255,51,102,0.35); }
.syslog-empty {
  text-align: center;
  font-family: 'Orbitron', monospace;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  color: var(--sys-text-muted);
  text-transform: uppercase;
  padding: 18px 12px;
  opacity: 0.7;
}
.syslog-more {
  display: block;
  text-align: right;
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.20em;
  color: var(--sys-cyan);
  text-shadow: 0 0 4px var(--sys-cyan-glow);
  text-decoration: none;
  padding: 6px 14px 10px;
  text-transform: uppercase;
  opacity: 0.85;
  transition: opacity 0.15s, color 0.15s;
}
.syslog-more:hover { opacity: 1; color: #fff; }

/* ============================================================
   FEED FILTER CHIPS (stats.html)
   ============================================================ */
.feed-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 14px 4px;
}
.feed-chip {
  font-family: 'Orbitron', monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sys-cyan);
  background: rgba(0, 246, 255, 0.05);
  border: 1px solid var(--sys-cyan-dim);
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.15s;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  text-shadow: 0 0 3px var(--sys-cyan-glow);
}
.feed-chip.active {
  background: var(--sys-cyan);
  color: #000;
  text-shadow: none;
  box-shadow: 0 0 10px var(--sys-cyan-glow);
}
.feed-chip:hover:not(.active) {
  background: rgba(0, 246, 255, 0.15);
}
