/* ============================================
   $GRAFT BIO-LAB LEADERBOARD
   Purity System - Dark Bio-Horror Theme
   Reference: Gaming Rewards UI Style
   ============================================ */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
  /* Base Colors */
  --bg-dark: #0a0a0f;
  --bg-card: #12121a;
  --bg-card-hover: #1a1a24;
  --bg-elevated: #1e1e2a;

  /* Gradient Background */
  --gradient-main: linear-gradient(135deg, #0a0a0f 0%, #12121a 50%, #0f0a1a 100%);
  --gradient-accent: linear-gradient(135deg, rgba(139, 0, 0, 0.15), rgba(75, 0, 130, 0.1));

  /* Tier Colors */
  --diamond: #67e8f9;
  --diamond-glow: rgba(103, 232, 249, 0.4);
  --gold: #fcd34d;
  --gold-glow: rgba(252, 211, 77, 0.4);
  --silver: #d1d5db;
  --silver-glow: rgba(209, 213, 219, 0.3);
  --bronze: #fb923c;
  --bronze-glow: rgba(251, 146, 60, 0.3);

  /* Purity Colors */
  --pure: #22c55e;
  --pure-glow: rgba(34, 197, 94, 0.5);
  --corrupt: #ef4444;
  --corrupt-glow: rgba(239, 68, 68, 0.5);

  /* Accent */
  --accent-red: #dc2626;
  --accent-purple: #7c3aed;

  /* Text */
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(139, 0, 0, 0.3);

  /* Fonts */
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Inter', sans-serif;
}

/* ============================================
   GLOBAL STYLES
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background: var(--bg-dark);
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--gradient-main);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Organic vein overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 30%, rgba(139, 0, 0, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 70%, rgba(75, 0, 130, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ============================================
   TOP NAVIGATION
   ============================================ */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
}

.logo-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: brightness(0) invert(1) drop-shadow(0 0 8px var(--corrupt-glow));
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.3s;
}

.nav-tab svg {
  width: 16px;
  height: 16px;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: var(--text-primary);
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.live-tab {
  color: var(--pure) !important;
  cursor: default;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--pure);
  border-radius: 50%;
  animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-points {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: rgba(252, 211, 77, 0.1);
  border: 1px solid rgba(252, 211, 77, 0.25);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
}

.user-points svg {
  width: 16px;
  height: 16px;
}

.user-avatar-nav {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border-subtle);
}

.user-avatar-nav img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  position: relative;
  z-index: 1;
  padding-top: 60px;
}

/* ============================================
   TOP SPECIMENS CAROUSEL
   ============================================ */
.top-specimens-carousel {
  padding: 1rem 1.5rem;
  background: linear-gradient(180deg, rgba(10, 10, 15, 0.8), transparent);
  border-bottom: 1px solid var(--border-subtle);
}

.carousel-track {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 0.5rem 0;
  cursor: grab;
  scrollbar-width: none;
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

.carousel-track:active {
  cursor: grabbing;
}

.specimen-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  flex-shrink: 0;
  transition: all 0.3s;
}

.specimen-chip:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.specimen-chip img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.specimen-chip.diamond img { border: 2px solid var(--diamond); box-shadow: 0 0 10px var(--diamond-glow); }
.specimen-chip.gold img { border: 2px solid var(--gold); box-shadow: 0 0 10px var(--gold-glow); }
.specimen-chip.silver img { border: 2px solid var(--silver); }
.specimen-chip.bronze img { border: 2px solid var(--bronze); }

.chip-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-points {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: 600;
}

.point-icon {
  width: 12px;
  height: 12px;
  color: var(--gold);
}

/* ============================================
   LEADERBOARD CONTAINER
   ============================================ */
.leaderboard-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ============================================
   PERIOD TABS
   ============================================ */
.period-tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.period-tab {
  padding: 0.6rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s;
}

.period-tab:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.period-tab.active {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.2), rgba(124, 58, 237, 0.15));
  border-color: rgba(220, 38, 38, 0.4);
  color: var(--text-primary);
}

/* ============================================
   PODIUM SECTION - TOP 3
   ============================================ */
.podium-section {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 1rem 0;
}

.podium-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  text-align: center;
  transition: all 0.4s;
  position: relative;
}

.podium-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* First Place - Elevated */
.podium-card.first {
  width: 220px;
  padding: 1.5rem;
  background: linear-gradient(180deg, rgba(103, 232, 249, 0.08), var(--bg-card));
  border-color: rgba(103, 232, 249, 0.3);
  box-shadow: 0 0 30px rgba(103, 232, 249, 0.15);
  z-index: 2;
}

.podium-card.second,
.podium-card.third {
  width: 180px;
}

.podium-card.second {
  background: linear-gradient(180deg, rgba(252, 211, 77, 0.06), var(--bg-card));
  border-color: rgba(252, 211, 77, 0.2);
}

.podium-card.third {
  background: linear-gradient(180deg, rgba(209, 213, 219, 0.05), var(--bg-card));
  border-color: rgba(209, 213, 219, 0.15);
}

/* Crown for #1 */
.crown-icon {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  color: var(--gold);
  filter: drop-shadow(0 0 10px var(--gold-glow));
  animation: crownFloat 3s ease-in-out infinite;
}

@keyframes crownFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-5px); }
}

.podium-rank {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Avatar Wrapper */
.podium-avatar-wrapper {
  position: relative;
  margin-bottom: 0.75rem;
}

.podium-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  z-index: 2;
}

.first .podium-avatar {
  width: 85px;
  height: 85px;
}

.avatar-glow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  z-index: 1;
}

.podium-avatar-wrapper.diamond .avatar-glow {
  background: conic-gradient(from 0deg, var(--diamond), transparent, var(--diamond));
  animation: avatarSpin 4s linear infinite;
}

.podium-avatar-wrapper.gold .avatar-glow {
  background: conic-gradient(from 0deg, var(--gold), transparent, var(--gold));
  animation: avatarSpin 5s linear infinite;
}

.podium-avatar-wrapper.silver .avatar-glow {
  background: conic-gradient(from 0deg, var(--silver), transparent, var(--silver));
  animation: avatarSpin 6s linear infinite;
}

@keyframes avatarSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.tier-badge {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 24px;
  height: 24px;
  background: var(--bg-card);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.tier-badge svg {
  width: 16px;
  height: 16px;
}

.tier-badge.diamond svg { color: var(--diamond); }
.tier-badge.gold svg { color: var(--gold); }
.tier-badge.silver svg { color: var(--silver); }

.podium-name {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.podium-title {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.diamond-title { color: var(--diamond); }
.gold-title { color: var(--gold); }
.silver-title { color: var(--silver); }
.bronze-title { color: var(--bronze); }

.podium-earned {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.dna-icon {
  width: 14px;
  height: 14px;
  color: var(--pure);
}

.podium-prize {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 0.25rem;
}

.podium-prize.highlight {
  font-size: 1.5rem;
  text-shadow: 0 0 20px var(--gold-glow);
}

.podium-prize .point-icon {
  width: 18px;
  height: 18px;
}

.podium-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

/* Countdown */
.countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
}

.countdown svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.countdown span {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.countdown .time {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

/* Purity Indicator on Podium */
.purity-indicator {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.purity-indicator .purity-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pure), #4ade80);
  border-radius: 999px;
  box-shadow: 0 0 8px var(--pure-glow);
}

.purity-text {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--pure);
}

/* ============================================
   STATUS BAR
   ============================================ */
.status-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05), rgba(34, 197, 94, 0.1));
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.status-bar strong {
  color: var(--text-primary);
}

.highlight-points {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--gold) !important;
}

.point-icon-sm {
  width: 14px;
  height: 14px;
  color: var(--gold);
}

/* ============================================
   LEADERBOARD TABLE
   ============================================ */
.leaderboard-table-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  overflow: hidden;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table thead {
  background: rgba(0, 0, 0, 0.3);
}

.leaderboard-table th {
  padding: 0.75rem 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: all 0.3s;
}

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

.leaderboard-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.leaderboard-table tbody tr.contaminated {
  background: rgba(239, 68, 68, 0.05);
}

.leaderboard-table tbody tr.contaminated:hover {
  background: rgba(239, 68, 68, 0.1);
}

.leaderboard-table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

/* Place Column */
.col-place {
  width: 80px;
}

.place-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.place-badge svg {
  width: 14px;
  height: 14px;
  display: none;
}

.place-badge.diamond svg,
.place-badge.gold svg,
.place-badge.silver svg,
.place-badge.bronze svg {
  display: block;
}

.place-badge.diamond { color: var(--diamond); }
.place-badge.diamond svg { color: var(--diamond); }
.place-badge.gold { color: var(--gold); }
.place-badge.gold svg { color: var(--gold); }
.place-badge.silver { color: var(--silver); }
.place-badge.silver svg { color: var(--silver); }
.place-badge.bronze { color: var(--bronze); }
.place-badge.bronze svg { color: var(--bronze); }

.place-badge.contaminated {
  color: var(--corrupt);
}

.place-badge.contaminated svg {
  display: block;
  color: var(--corrupt);
}

/* Specimen Column */
.col-specimen {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.row-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-subtle);
}

.row-avatar.contaminated-avatar {
  border-color: var(--corrupt);
  box-shadow: 0 0 10px var(--corrupt-glow);
  animation: contaminatePulse 2s ease-in-out infinite;
}

@keyframes contaminatePulse {
  0%, 100% { box-shadow: 0 0 10px var(--corrupt-glow); }
  50% { box-shadow: 0 0 20px var(--corrupt-glow); }
}

.specimen-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.specimen-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.specimen-title {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.contaminated-title {
  color: var(--corrupt) !important;
}

.contaminated-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 0.25rem;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--corrupt);
  letter-spacing: 0.1em;
  animation: contaminateBlink 1.5s ease-in-out infinite;
}

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

/* Purity Column */
.col-purity {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 120px;
}

.purity-mini {
  width: 60px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.purity-fill-mini {
  height: 100%;
  background: linear-gradient(90deg, var(--pure), #4ade80);
  border-radius: 999px;
}

.purity-fill-mini.corrupt {
  background: linear-gradient(90deg, var(--corrupt), #ff6b6b);
}

.purity-percent {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--pure);
}

.purity-percent.corrupt {
  color: var(--corrupt);
}

/* Points Column */
.col-points {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Prize Column */
.col-prize {
  width: 100px;
}

.prize-amount {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  background: rgba(252, 211, 77, 0.1);
  border: 1px solid rgba(252, 211, 77, 0.2);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
}

/* Load More Button */
.load-more-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s;
}

.load-more-btn:hover {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
}

.load-more-btn svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   INFO BUTTON (FLOATING)
   ============================================ */
.info-btn {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 48px;
  height: 48px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  z-index: 50;
}

.info-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-glow);
}

.info-btn svg {
  width: 22px;
  height: 22px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 900px) {
  .nav-tabs {
    display: none;
  }

  .leaderboard-container {
    padding: 1rem;
  }

  .podium-section {
    flex-direction: column;
    align-items: center;
  }

  .podium-card.first {
    order: -1;
    width: 100%;
    max-width: 280px;
  }

  .podium-card.second,
  .podium-card.third {
    width: 100%;
    max-width: 240px;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 0.6rem 0.5rem;
  }

  .col-purity {
    display: none;
  }

  .col-specimen {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

@media (max-width: 600px) {
  .top-nav {
    padding: 0.5rem 1rem;
  }

  .nav-logo span:last-child {
    display: none;
  }

  .period-tabs {
    flex-wrap: wrap;
  }

  .period-tab {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
  }

  .status-bar {
    font-size: 0.75rem;
    padding: 0.6rem 1rem;
  }

  .crown-icon {
    width: 32px;
    height: 32px;
    top: -15px;
  }

  .first .podium-avatar {
    width: 70px;
    height: 70px;
  }

  .podium-prize {
    font-size: 1.1rem;
  }

  .podium-prize.highlight {
    font-size: 1.25rem;
  }

  .col-prize {
    display: none;
  }

  .col-place {
    width: 50px;
  }

  .row-avatar {
    width: 36px;
    height: 36px;
  }
}

/* ============================================
   ANIMATIONS & EFFECTS
   ============================================ */
.podium-card:hover .avatar-glow {
  animation-duration: 2s;
}

.table-row:hover .row-avatar {
  transform: scale(1.05);
  transition: transform 0.3s;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Selection */
::selection {
  background: rgba(220, 38, 38, 0.3);
  color: var(--text-primary);
}
