/* ===============================
   PAC-MAN LOADING — OPTIMIZED
================================ */

:root {
  --pacman-size: 120px;
  --pacman-color: #ffcc00;
  --dot-size: 14px;
  --dot-color: #4a90e2;
  --speed: 0.8s;
  --text-color: #cbd5f5;
}

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Container */
.app-loading {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  font-family: system-ui, sans-serif;
  color: var(--text-color);
}

/* Pac-Man */
.pacman-loader {
  position: relative;
  width: var(--pacman-size);
  height: var(--pacman-size);
}

.pacman {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--pacman-color);
  clip-path: polygon(
    50% 50%,
    100% 20%,
    100% 80%
  );
  animation: chomp var(--speed) infinite ease-in-out;
  will-change: clip-path;
}

@keyframes chomp {
  0%, 100% {
    clip-path: polygon(50% 50%, 100% 25%, 100% 75%);
  }
  50% {
    clip-path: polygon(50% 50%, 100% 0%, 100% 100%);
  }
}

/* Dots */
.pacman-dots {
  position: absolute;
  top: 50%;
  right: -80px;
  display: flex;
  gap: 12px;
  transform: translateY(-50%);
}

.pacman-dots span {
  width: var(--dot-size);
  height: var(--dot-size);
  border-radius: 50%;
  background: var(--dot-color);
  animation: dot-move calc(var(--speed) * 1.5) infinite linear;
}

.pacman-dots span:nth-child(2) {
  animation-delay: -0.3s;
}

.pacman-dots span:nth-child(3) {
  animation-delay: -0.6s;
}

@keyframes dot-move {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-40px);
    opacity: 0;
  }
}

/* Message */
.app-loading__message {
  font-size: 1rem;
  opacity: 0.85;
  animation: fade 2s infinite ease-in-out;
}

@keyframes fade {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --text-color: #e5e7eb;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .pacman,
  .pacman-dots span,
  .app-loading__message {
    animation: none;
  }
}
