/* ========================================
   ANIME LOADING SCREEN
   Epic loading experience with funny messages
   ======================================== */

.anime-loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, 
    var(--loading-primary, oklch(var(--p))) 0%, 
    var(--loading-secondary, oklch(var(--s))) 50%, 
    var(--loading-accent, oklch(var(--a))) 100%
  );
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.anime-loading-screen.active {
  opacity: 1;
}

.anime-loading-screen.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* Animated background particles */
.loading-particles {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: oklch(var(--bc) / 0.3);
  border-radius: 50%;
  animation: float 10s infinite ease-in-out;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) translateX(50px) rotate(360deg);
    opacity: 0;
  }
}

/* Main character container */
.loading-character {
  position: relative;
  margin-bottom: 40px;
  animation: bounce 2s infinite ease-in-out;
  z-index: 10;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-20px) scale(1.05);
  }
}

/* Anime-style character - SVG icon instead of emoji */
.character-sprite {
  width: 120px;
  height: 120px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
  animation: wiggle 1s infinite ease-in-out;
  display: inline-block;
  position: relative;
  z-index: 10;
}

@keyframes wiggle {
  0%, 100% {
    transform: rotate(-5deg);
  }
  50% {
    transform: rotate(5deg);
  }
}

/* Loading message */
.loading-message {
  background: var(--loading-box-bg, #ffffff) !important;
  opacity: 1 !important;
  padding: 32px 56px;
  border-radius: 15% 85% 20% 80% / 90% 10% 75% 25%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 600px;
  text-align: center;
  animation: slideUp 0.5s ease-out, morphSplash 8s ease-in-out infinite;
  border: 4px solid var(--loading-primary, oklch(var(--p)));
  position: relative;
  z-index: 10;
  transform: rotate(-2deg);
}

@keyframes morphSplash {
  0%, 100% {
    border-radius: 15% 85% 20% 80% / 90% 10% 75% 25%;
  }
  25% {
    border-radius: 85% 15% 75% 25% / 20% 80% 15% 85%;
  }
  50% {
    border-radius: 10% 90% 25% 75% / 85% 15% 80% 20%;
  }
  75% {
    border-radius: 80% 20% 90% 10% / 25% 75% 30% 70%;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loading-message h2 {
  font-size: 2rem;
  font-weight: 700;
  color: oklch(var(--p));
  margin: 0 0 12px 0;
  animation: glow 2s infinite ease-in-out;
}

@keyframes glow {
  0%, 100% {
    text-shadow: 0 0 10px oklch(var(--p) / 0.5);
  }
  50% {
    text-shadow: 0 0 20px oklch(var(--p) / 0.8);
  }
}

.loading-message p {
  font-size: 1.1rem;
  color: oklch(var(--bc) / 0.7);
  margin: 0;
  font-weight: 500;
}

/* Progress bar */
.loading-progress {
  margin-top: 32px;
  width: 100%;
  max-width: 400px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: oklch(var(--b3));
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: oklch(var(--p));
  border-radius: 10px;
  animation: grow 3s ease-out forwards;
  width: 0%;
  transition: width 0.3s ease;
}

@keyframes grow {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
}

.progress-text {
  margin-top: 12px;
  font-size: 0.9rem;
  color: oklch(var(--bc) / 0.6);
  font-weight: 600;
  animation: pulse 2s infinite ease-in-out;
}

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

/* Fun fact at the bottom */
.loading-fun-fact {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) rotate(1deg);
  background: var(--loading-box-bg, #ffffff) !important;
  opacity: 1 !important;
  padding: 16px 32px;
  border-radius: 75% 25% 80% 20% / 15% 85% 25% 75%;
  font-size: 0.9rem;
  color: oklch(var(--bc));
  max-width: 500px;
  text-align: center;
  animation: fadeIn 1s ease-out 1s both, morphSplashSmall 6s ease-in-out infinite;
  z-index: 10;
  border: 3px solid var(--loading-primary, oklch(var(--p)));
}

@keyframes morphSplashSmall {
  0%, 100% {
    border-radius: 75% 25% 80% 20% / 15% 85% 25% 75%;
  }
  33% {
    border-radius: 20% 80% 85% 15% / 70% 30% 90% 10%;
  }
  66% {
    border-radius: 90% 10% 20% 80% / 75% 25% 15% 85%;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .character-sprite {
    font-size: 80px;
  }
  
  .loading-message {
    padding: 20px 32px;
    max-width: 90%;
  }
  
  .loading-message h2 {
    font-size: 1.5rem;
  }
  
  .loading-message p {
    font-size: 1rem;
  }
  
  .loading-fun-fact {
    font-size: 0.85rem;
    max-width: 90%;
    bottom: 20px;
  }
}

/* Special effects */
.sparkle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: oklch(var(--p));
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: sparkle 1.5s infinite ease-in-out;
}

@keyframes sparkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1) rotate(180deg);
  }
}

.sparkle:nth-child(1) { top: 20%; left: 20%; animation-delay: 0s; }
.sparkle:nth-child(2) { top: 30%; right: 25%; animation-delay: 0.3s; }
.sparkle:nth-child(3) { bottom: 30%; left: 30%; animation-delay: 0.6s; }
.sparkle:nth-child(4) { bottom: 25%; right: 20%; animation-delay: 0.9s; }
.sparkle:nth-child(5) { top: 50%; left: 10%; animation-delay: 1.2s; }
.sparkle:nth-child(6) { top: 50%; right: 10%; animation-delay: 1.5s; }

/* ========================================
   NEKOS DECORATIONS FOR LOADING SCREEN
   ======================================== */

/* Grid decorations - crooked grid pattern */
.loading-grid-decoration {
  position: absolute;
  width: 80px;
  height: 80px;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  animation: fadeInFloat 0.6s ease-out forwards, gentleFloat 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 1; /* Behind the loading message boxes */
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

@keyframes fadeInFloat {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  to {
    opacity: 0.5; /* More subtle since there are many */
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes gentleFloat {
  0%, 100% {
    transform: translate(-50%, -50%) translateY(0px);
  }
  50% {
    transform: translate(-50%, -50%) translateY(-10px);
  }
}

/* Legacy corner decorations (kept for fallback) */
.loading-corner-decoration {
  position: absolute;
  width: 150px;
  height: 150px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.7;
  animation: float 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 10;
}

.loading-corner-decoration.top-left {
  top: 20px;
  left: 20px;
  animation-delay: 0s;
}

.loading-corner-decoration.top-right {
  top: 20px;
  right: 20px;
  animation-delay: 0.5s;
}

.loading-corner-decoration.bottom-left {
  bottom: 20px;
  left: 20px;
  animation-delay: 1s;
}

.loading-corner-decoration.bottom-right {
  bottom: 20px;
  right: 20px;
  animation-delay: 1.5s;
}

/* Floating decorations */
.loading-floating-decoration {
  position: absolute;
  width: 100px;
  height: 100px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.5;
  animation: floatRandom 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 10;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-20px) rotate(5deg);
  }
}

@keyframes floatRandom {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(10px, -10px) rotate(5deg);
  }
  50% {
    transform: translate(-5px, -20px) rotate(-5deg);
  }
  75% {
    transform: translate(15px, -5px) rotate(3deg);
  }
}

/* Responsive decorations */
@media (max-width: 768px) {
  .loading-grid-decoration {
    width: 60px;
    height: 60px;
  }
  
  .loading-corner-decoration {
    width: 80px;
    height: 80px;
  }
  
  .loading-floating-decoration {
    width: 60px;
    height: 60px;
  }
}
