/* ============================================
   Leaderboard — 功德排行榜
   Competitive & premium ranking experience
   ============================================ */

/* --- Container --- */
.leaderboard-container {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-void);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 var(--sp-4);
  overflow-x: hidden;
}

/* Subtle background pattern */
.leaderboard-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 215, 0, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(0, 245, 212, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* --- Header --- */
.leaderboard-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--sp-12) 0 var(--sp-6);
  width: 100%;
  max-width: 600px;
}

.leaderboard-title {
  font-family: var(--font-display), cursive;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold) 0%, #ffec99 40%, var(--gold-dark) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: goldShimmer 4s ease-in-out infinite;
  margin-bottom: var(--sp-6);
  line-height: 1.3;
}

@keyframes goldShimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* --- Tabs --- */
.leaderboard-tabs {
  display: flex;
  gap: var(--sp-1);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-full);
  padding: 3px;
  width: fit-content;
  margin: 0 auto var(--sp-6);
}

.leaderboard-tab {
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body), sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.leaderboard-tab:hover {
  color: var(--text-primary);
}

.leaderboard-tab.active {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.05) 100%);
  color: var(--gold);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.1);
}

/* --- List --- */
.leaderboard-list {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-bottom: var(--sp-20);
}

/* --- Entry --- */
.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.3s ease;
  cursor: default;
  animation: slideUp 0.5s ease-out both;
  animation-delay: var(--entry-delay, 0s);
}

.leaderboard-entry:hover {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

/* --- Rank Variants --- */

/* Rank 1 — Gold */
.leaderboard-entry.rank-1 {
  background: linear-gradient(135deg,
    rgba(255, 215, 0, 0.08) 0%,
    rgba(255, 215, 0, 0.02) 100%);
  border-color: rgba(255, 215, 0, 0.3);
  box-shadow:
    0 0 20px rgba(255, 215, 0, 0.08),
    inset 0 0 20px rgba(255, 215, 0, 0.03);
  padding: var(--sp-5) var(--sp-6);
}

.leaderboard-entry.rank-1:hover {
  border-color: rgba(255, 215, 0, 0.5);
  box-shadow:
    0 0 30px rgba(255, 215, 0, 0.15),
    inset 0 0 30px rgba(255, 215, 0, 0.05);
}

.leaderboard-entry.rank-1 .rank-number {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
  font-size: 1.6rem;
}

.leaderboard-entry.rank-1 .rank-crown {
  font-size: 1.3rem;
}

/* Rank 2 — Silver */
.leaderboard-entry.rank-2 {
  background: linear-gradient(135deg,
    rgba(192, 192, 210, 0.06) 0%,
    rgba(192, 192, 210, 0.02) 100%);
  border-color: rgba(192, 192, 210, 0.2);
  box-shadow: 0 0 16px rgba(192, 192, 210, 0.05);
}

.leaderboard-entry.rank-2:hover {
  border-color: rgba(192, 192, 210, 0.4);
  box-shadow: 0 0 24px rgba(192, 192, 210, 0.1);
}

.leaderboard-entry.rank-2 .rank-number {
  color: #c0c0d2;
  text-shadow: 0 0 10px rgba(192, 192, 210, 0.3);
  font-size: 1.4rem;
}

.leaderboard-entry.rank-2 .rank-crown {
  font-size: 1.1rem;
}

/* Rank 3 — Bronze */
.leaderboard-entry.rank-3 {
  background: linear-gradient(135deg,
    rgba(205, 127, 50, 0.06) 0%,
    rgba(205, 127, 50, 0.02) 100%);
  border-color: rgba(205, 127, 50, 0.2);
  box-shadow: 0 0 14px rgba(205, 127, 50, 0.05);
}

.leaderboard-entry.rank-3:hover {
  border-color: rgba(205, 127, 50, 0.4);
  box-shadow: 0 0 20px rgba(205, 127, 50, 0.1);
}

.leaderboard-entry.rank-3 .rank-number {
  color: #cd7f32;
  text-shadow: 0 0 8px rgba(205, 127, 50, 0.3);
  font-size: 1.3rem;
}

.leaderboard-entry.rank-3 .rank-crown {
  font-size: 1rem;
}

/* User's own entry */
.leaderboard-entry.is-user {
  border-color: rgba(0, 245, 212, 0.35);
  box-shadow:
    0 0 18px rgba(0, 245, 212, 0.08),
    inset 0 0 18px rgba(0, 245, 212, 0.03);
}

.leaderboard-entry.is-user:hover {
  border-color: rgba(0, 245, 212, 0.5);
  box-shadow:
    0 0 28px rgba(0, 245, 212, 0.15),
    inset 0 0 28px rgba(0, 245, 212, 0.05);
}

/* --- Rank Number --- */
.rank-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 48px;
  gap: 2px;
}

.rank-crown {
  font-size: 0.9rem;
  line-height: 1;
}

.rank-number {
  font-family: var(--font-display), cursive;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}

/* --- Entry Name --- */
.entry-name {
  flex: 1;
  font-family: var(--font-body), sans-serif;
  font-size: 0.95rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.entry-name .name-tag {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-left: var(--sp-2);
}

/* --- Entry Score --- */
.entry-score {
  font-family: var(--font-display), cursive;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.15);
}

.entry-score .score-label {
  font-family: var(--font-body), sans-serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 2px;
}

/* --- Refresh Button --- */
.refresh-btn {
  position: fixed;
  bottom: calc(var(--sp-20) + var(--sp-4));
  right: var(--sp-6);
  z-index: 20;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.refresh-btn:hover {
  color: var(--gold);
  border-color: rgba(255, 215, 0, 0.3);
  box-shadow: 0 4px 24px rgba(255, 215, 0, 0.1);
  transform: translateY(-2px);
}

.refresh-btn.spinning .refresh-icon {
  animation: spinRefresh 0.8s ease-in-out;
}

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

.refresh-icon {
  display: inline-block;
  transition: transform 0.3s ease;
}

/* --- Empty State --- */
.leaderboard-empty {
  text-align: center;
  padding: var(--sp-12) var(--sp-4);
  color: var(--text-muted);
  font-family: var(--font-body), sans-serif;
}

.leaderboard-empty .empty-icon {
  font-size: 3rem;
  margin-bottom: var(--sp-4);
  opacity: 0.5;
}

.leaderboard-empty .empty-text {
  font-size: 0.95rem;
}

/* --- Podium (Top 3 Summary) --- */
.leaderboard-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-4) 0 var(--sp-8);
  width: 100%;
  max-width: 600px;
}

.podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  flex: 1;
  max-width: 140px;
}

.podium-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
}

.podium-slot.first .podium-avatar {
  width: 68px;
  height: 68px;
  font-size: 1.8rem;
  border-color: rgba(255, 215, 0, 0.4);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.15);
}

.podium-name {
  font-family: var(--font-body), sans-serif;
  font-size: 0.8rem;
  color: var(--text-primary);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.podium-score {
  font-family: var(--font-display), cursive;
  font-size: 0.85rem;
  color: var(--gold);
}

.podium-bar {
  width: 100%;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: linear-gradient(to top, var(--glass-bg), rgba(255, 255, 255, 0.06));
  border: 1px solid var(--glass-border);
  border-bottom: none;
}

.podium-slot.first .podium-bar  { height: 80px; background: linear-gradient(to top, rgba(255, 215, 0, 0.05), rgba(255, 215, 0, 0.12)); border-color: rgba(255, 215, 0, 0.2); }
.podium-slot.second .podium-bar { height: 56px; background: linear-gradient(to top, rgba(192, 192, 210, 0.04), rgba(192, 192, 210, 0.08)); border-color: rgba(192, 192, 210, 0.15); }
.podium-slot.third .podium-bar  { height: 40px; background: linear-gradient(to top, rgba(205, 127, 50, 0.04), rgba(205, 127, 50, 0.08)); border-color: rgba(205, 127, 50, 0.15); }

/* --- User Summary Card --- */
.user-rank-card {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: linear-gradient(135deg,
    rgba(0, 245, 212, 0.05) 0%,
    rgba(0, 245, 212, 0.01) 100%);
  border: 1px solid rgba(0, 245, 212, 0.2);
  border-radius: var(--r-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  margin-bottom: var(--sp-6);
  z-index: 1;
}

.user-rank-label {
  font-family: var(--font-body), sans-serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.user-rank-value {
  font-family: var(--font-display), cursive;
  font-size: 1.4rem;
  color: var(--neon-cyan);
}

.user-rank-score {
  margin-left: auto;
  text-align: right;
}

.user-rank-score .score-value {
  font-family: var(--font-display), cursive;
  font-size: 1.2rem;
  color: var(--gold);
}

.user-rank-score .score-label {
  font-family: var(--font-body), sans-serif;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .leaderboard-header {
    padding-top: var(--sp-8);
  }

  .leaderboard-entry {
    padding: var(--sp-3) var(--sp-4);
    gap: var(--sp-3);
  }

  .rank-number {
    font-size: 1rem;
  }

  .entry-name {
    font-size: 0.85rem;
  }

  .entry-score {
    font-size: 0.95rem;
  }

  .leaderboard-tabs {
    width: 100%;
  }

  .leaderboard-tab {
    flex: 1;
    text-align: center;
    padding: var(--sp-2) var(--sp-3);
  }

  .podium-slot.first .podium-avatar {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
  }

  .podium-avatar {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
}
