/* =========================================
   SoHG World Rankings Leaderboard
   Uses existing site CSS variables
   ========================================= */

.leaderboard-container {
  max-width: 900px;
  margin: 0 auto;
}

.leaderboard-container.loading {
  animation: Pulse 2s ease-in-out infinite;
}

@keyframes Pulse {
  from { opacity: 1; }
  50% { opacity: 0.5; }
  to { opacity: 1; }
}

/* Filters Section */
.leaderboard-filters {
  background: var(--stripe-white);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--stripe-slate-100);
  display: flex;
  gap: var(--space-xl);
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group,
form > div:not(.form-body).filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  flex: 1;
  min-width: 180px;
  padding: 0;
}

.filter-group label,
form > div:not(.form-body).filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--stripe-slate-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-group select,
form > div:not(.form-body).filter-group select {
  width: 100%;
  max-width: none;
}

.results-count,
form > div:not(.form-body).results-count {
  display: block;
  font-size: 0.875rem;
  color: var(--stripe-slate-500);
  margin-left: auto;
  padding: 10px 16px;
  background: var(--stripe-slate-50);
  border-radius: var(--radius-md);
  white-space: nowrap;
}

.results-count strong,
form > div:not(.form-body).results-count strong {
  color: var(--stripe-slate-900);
  font-weight: 600;
}

.filter-footer,
form > .filter-footer:not(.form-body) {
  display: none;
}

/* Table Container */
/* Overflow stays visible so the validity-warning tooltips can extend past the
   container; the corner cells carry the rounding instead of an overflow clip. */
.leaderboard-table-container {
  background: var(--stripe-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--stripe-slate-100);
}

.leaderboard-table thead th:first-child {
  border-top-left-radius: var(--radius-lg);
}

.leaderboard-table thead th:last-child {
  border-top-right-radius: var(--radius-lg);
}

.leaderboard-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--radius-lg);
}

.leaderboard-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--radius-lg);
}

/* Table Styles */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table thead th {
  background: var(--stripe-slate-50);
  color: var(--stripe-slate-500);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--stripe-slate-100);
}

.leaderboard-table thead th:first-child {
  width: 70px;
  text-align: center;
  border-radius: 0;
}

.leaderboard-table thead th:last-child {
  text-align: right;
  width: auto;
  min-width: auto;
}

.leaderboard-table tbody tr {
  border-bottom: 1px solid var(--stripe-slate-100);
  transition: background-color var(--transition-fast);
  animation: fadeInUp var(--transition-slow) ease-out;
}

.leaderboard-table tbody tr:last-child {
  border-bottom: none;
}

.leaderboard-table tbody tr:hover {
  background-color: var(--stripe-slate-50);
}

.leaderboard-table tbody td {
  padding: var(--space-md) var(--space-lg);
  font-size: 0.9375rem;
  color: var(--stripe-slate-700);
  border: none;
  vertical-align: middle;
}

.leaderboard-table tbody td:first-child {
  text-align: center;
  width: 70px;
  min-width: 70px;
}

.leaderboard-table tbody td:last-child {
  text-align: right;
  width: auto;
  min-width: auto;
}

/* Rank Badges */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8125rem;
}

.rank-1 {
  background: linear-gradient(135deg, #ffd700 0%, #ffb347 100%);
  color: #744210;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

.rank-2 {
  background: linear-gradient(135deg, #c0c0c0 0%, #a8a8a8 100%);
  color: #4a5568;
  box-shadow: 0 2px 8px rgba(192, 192, 192, 0.4);
}

.rank-3 {
  background: linear-gradient(135deg, #cd7f32 0%, #b8860b 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(205, 127, 50, 0.4);
}

.rank-default {
  background: var(--stripe-slate-100);
  color: var(--stripe-slate-500);
}

/* Player Info */
.player-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--stripe-slate-900) 0%, #1a3a52 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--stripe-white);
  font-weight: 600;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.player-details {
  display: flex;
  flex-direction: column;
}

.player-name {
  font-weight: 600;
  color: var(--stripe-slate-900);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.player-country {
  font-size: 0.8125rem;
  color: var(--stripe-slate-500);
  margin-top: 2px;
}

.trophy-icon {
  color: var(--warning);
  font-size: 0.875rem;
}

/* Handicap Display */
.handicap-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 6px 14px;
  background: linear-gradient(135deg, var(--stripe-slate-900) 0%, #1a3a52 100%);
  color: var(--stripe-white);
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
}

.handicap-badge.scratch {
  background: linear-gradient(135deg, #d69e2e 0%, #ecc94b 100%);
  color: #744210;
}

/* Course & Rounds */
.home-course {
  color: var(--stripe-slate-700);
}

.rounds-played {
  color: var(--stripe-slate-500);
}

/* Responsive Design */
@media (max-width: 768px) {
  .leaderboard-filters {
    padding: var(--space-md);
    gap: var(--space-md);
  }

  .filter-group {
    min-width: 140px;
  }

  .results-count {
    width: 100%;
    text-align: center;
    margin-left: 0;
  }

  .leaderboard-table thead th,
  .leaderboard-table tbody td {
    padding: var(--space-sm) var(--space-md);
  }

  .player-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
  }

  .home-course-cell {
    display: none;
  }

  .leaderboard-table thead th:nth-child(3) {
    display: none;
  }
}

@media (max-width: 480px) {
  .leaderboard-filters {
    flex-direction: column;
  }

  .filter-group {
    width: 100%;
  }

  .player-info {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .player-avatar {
    display: none;
  }
}

/* Animation keyframes */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered row animations */
.leaderboard-table tbody tr:nth-child(1) {
  animation-delay: 0.02s;
}

.leaderboard-table tbody tr:nth-child(2) {
  animation-delay: 0.04s;
}

.leaderboard-table tbody tr:nth-child(3) {
  animation-delay: 0.06s;
}

.leaderboard-table tbody tr:nth-child(4) {
  animation-delay: 0.08s;
}

.leaderboard-table tbody tr:nth-child(5) {
  animation-delay: 0.10s;
}

.leaderboard-table tbody tr:nth-child(6) {
  animation-delay: 0.12s;
}

.leaderboard-table tbody tr:nth-child(7) {
  animation-delay: 0.14s;
}

.leaderboard-table tbody tr:nth-child(8) {
  animation-delay: 0.16s;
}

.leaderboard-table tbody tr:nth-child(9) {
  animation-delay: 0.18s;
}

.leaderboard-table tbody tr:nth-child(10) {
  animation-delay: 0.20s;
}

.leaderboard-table tbody tr:nth-child(11) {
  animation-delay: 0.22s;
}

.leaderboard-table tbody tr:nth-child(12) {
  animation-delay: 0.24s;
}

.leaderboard-table tbody tr:nth-child(13) {
  animation-delay: 0.26s;
}

.leaderboard-table tbody tr:nth-child(14) {
  animation-delay: 0.28s;
}

.leaderboard-table tbody tr:nth-child(15) {
  animation-delay: 0.30s;
}

.leaderboard-table tbody tr:nth-child(16) {
  animation-delay: 0.32s;
}

.leaderboard-table tbody tr:nth-child(17) {
  animation-delay: 0.34s;
}

.leaderboard-table tbody tr:nth-child(18) {
  animation-delay: 0.36s;
}

.leaderboard-table tbody tr:nth-child(19) {
  animation-delay: 0.38s;
}

.leaderboard-table tbody tr:nth-child(20) {
  animation-delay: 0.40s;
}