/**
 * Skeleton Screen Styles
 *
 * Provides loading placeholders for better perceived performance.
 * Use while content is loading to reduce layout shift and improve UX.
 */

/* Base skeleton animation */
@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 0%,
    #e0e0e0 20%,
    #f0f0f0 40%,
    #f0f0f0 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 4px;
  display: inline-block;
  position: relative;
  overflow: hidden;
}

/* Skeleton variants */
.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
  width: 100%;
}

.skeleton-text-short {
  width: 60%;
}

.skeleton-text-medium {
  width: 80%;
}

.skeleton-title {
  height: 2rem;
  margin-bottom: 1rem;
  width: 70%;
}

.skeleton-card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.skeleton-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}

.skeleton-avatar-large {
  width: 100px;
  height: 100px;
  border-radius: 50%;
}

.skeleton-button {
  height: 40px;
  width: 120px;
  border-radius: 4px;
}

.skeleton-image {
  width: 100%;
  height: 200px;
  border-radius: 8px;
}

.skeleton-image-square {
  width: 100%;
  padding-top: 100%;
  position: relative;
}

/* Skeleton table */
.skeleton-table {
  width: 100%;
}

.skeleton-table-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.skeleton-table-cell {
  flex: 1;
  height: 40px;
}

/* Skeleton list */
.skeleton-list {
  list-style: none;
  padding: 0;
}

.skeleton-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: #fff;
  border-radius: 8px;
}

/* Dashboard skeleton */
.skeleton-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.skeleton-stat-card {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.skeleton-stat-value {
  height: 3rem;
  width: 60%;
  margin-bottom: 0.5rem;
}

.skeleton-stat-label {
  height: 1rem;
  width: 80%;
}

/* Question skeleton */
.skeleton-question {
  background: #fff;
  padding: 2rem;
  border-radius: 12px;
  margin: 2rem 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.skeleton-question-text {
  height: 1.5rem;
  width: 90%;
  margin-bottom: 1rem;
}

.skeleton-question-text:last-child {
  width: 70%;
}

.skeleton-options {
  margin-top: 2rem;
}

.skeleton-option {
  height: 50px;
  margin-bottom: 1rem;
  border-radius: 8px;
}

/* Leaderboard skeleton */
.skeleton-leaderboard {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
}

.skeleton-leaderboard-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid #f0f0f0;
}

.skeleton-rank {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.skeleton-user-info {
  flex: 1;
}

.skeleton-username {
  height: 1rem;
  width: 150px;
  margin-bottom: 0.5rem;
}

.skeleton-score {
  height: 1.5rem;
  width: 80px;
}

/* Hide real content while skeleton is showing */
.skeleton-wrapper.loading .real-content {
  display: none;
}

.skeleton-wrapper:not(.loading) .skeleton {
  display: none;
}

/* Fade in effect when content loads */
.skeleton-wrapper .real-content {
  animation: fade-in 0.3s ease-in-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .skeleton {
    background: linear-gradient(
      90deg,
      #2a2a2a 0%,
      #3a3a3a 20%,
      #2a2a2a 40%,
      #2a2a2a 100%
    );
  }

  .skeleton-card,
  .skeleton-list-item,
  .skeleton-stat-card,
  .skeleton-question,
  .skeleton-leaderboard {
    background: #1a1a1a;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background: #e0e0e0;
  }
}
