/**
 * Performance & Loading Styles
 * Includes loading indicators and lazy loading styles
 */

/* Loading Indicator */
.senara-loading-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: white;
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f0f0f0;
  border-top: 4px solid #8b7355;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-text {
  color: #8b7355;
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
}

/* Lazy Loading Placeholder */
.lazy-loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  min-height: 200px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Skeleton Loading - Shared across pages */
.skeleton {
  background: linear-gradient(90deg, #f5ede0 25%, #ebe3d5 50%, #f5ede0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 0.5rem;
}

.skeleton-card {
  border-radius: 1.25rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(5px);
  height: 480px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Lazy Loaded Image Animation */
.lazy-loaded {
  animation: fadeInImage 0.4s ease-in-out;
}

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

/* Image Optimization */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Responsive Images */
@media (max-width: 768px) {
  .senara-loading-indicator {
    padding: 1.5rem;
    width: 90%;
    max-width: 300px;
  }

  .loading-spinner {
    width: 32px;
    height: 32px;
    border-width: 3px;
  }

  .loading-text {
    font-size: 0.95rem;
  }
}

/* Scene Loading Indicator for Visual Novels */
.scene-loading {
  position: relative;
}

.scene-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease-in-out;
}

/* Prevent layout shift during image loading */
img[loading="lazy"] {
  background: #f0f0f0;
}

/* Optimize for slow networks */
@media (prefers-reduced-motion: reduce) {
  .senara-loading-indicator,
  .lazy-loaded,
  .loading-spinner {
    animation: none;
  }
}
