/* CarbonMC leaderboards. Scoped to .cmc-lb so it can sit inside the NamelessMC theme, and uses the
   theme's colour variables (with fallbacks) so it matches either site. */

.cmc-lb {
  --lb-gold: var(--primary, #ffaa00);
  --lb-card: var(--background-primary, #1b1b1b);
  --lb-inner: rgba(255, 255, 255, 0.04);
  --lb-text: var(--text-primary, rgba(255, 255, 255, 0.75));
  --lb-muted: var(--text-secondary, rgba(255, 255, 255, 0.5));
  --lb-divider: rgba(255, 255, 255, 0.05);
  --lb-silver: #a8b0bd;
  --lb-bronze: #d7843f;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  font-family: Montserrat, "Segoe UI", Arial, sans-serif;
  color: var(--lb-text);
}

.cmc-lb * { box-sizing: border-box; }
.cmc-lb h2, .cmc-lb p, .cmc-lb ol { margin: 0; }
.cmc-lb ol { padding: 0; list-style: none; }
.cmc-lb a { text-decoration: none; }
.cmc-lb button { font: inherit; cursor: pointer; }

/* --- Sidebar ----------------------------------------------------------------------------------- */
.cmc-lb-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem;
  background: var(--lb-card);
  border-radius: 0.5rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}

.cmc-lb-sidebar-label {
  margin: 0.75rem 0 0.25rem;
  padding: 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--lb-muted);
}

.cmc-lb-board {
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  color: var(--lb-text);
  background: none;
  border: 0;
  border-radius: 0.5rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.cmc-lb-board:hover { color: #fff; background: var(--lb-inner); }

.cmc-lb-board.active {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
  background: var(--lb-gold);
}

/* --- Panel ------------------------------------------------------------------------------------- */
.cmc-lb-panel {
  min-width: 0;
  overflow: hidden;
  background: var(--lb-card);
  border-radius: 0.5rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}

.cmc-lb-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem 0.75rem;
}

.cmc-lb-trophy { font-size: 1.5rem; line-height: 1; }

.cmc-lb-title { font-size: 1.6rem; font-weight: 800; color: #fff; }

.cmc-lb-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1.5rem 1rem;
  border-bottom: 1px solid var(--lb-divider);
}

.cmc-lb-tab {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--lb-text);
  background: var(--lb-inner);
  border: 0;
  border-radius: 99px;
  transition: background 0.2s ease, color 0.2s ease;
}

.cmc-lb-tab:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.cmc-lb-tab[aria-selected="true"] { color: #fff; background: var(--lb-gold); }

.cmc-lb-message { padding: 3rem 1.5rem; text-align: center; color: var(--lb-muted); }
.cmc-lb-error { color: #ff6b6b; }

/* --- Podium ------------------------------------------------------------------------------------ */
.cmc-lb-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 1rem;
  padding: 1.5rem 1.5rem 0;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 170, 0, 0.12), transparent 70%);
}

.cmc-lb-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  text-align: center;
}

.cmc-lb-spot-skin {
  display: block;
  width: 96px;
  height: auto;
  margin-bottom: 0.25rem;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.4));
}

.cmc-lb-spot-1 .cmc-lb-spot-skin { width: 120px; }
.cmc-lb-spot-skin.fallback { width: 64px; margin-bottom: 0.5rem; }
.cmc-lb-spot-1 .cmc-lb-spot-skin.fallback { width: 80px; }

.cmc-lb-spot-name { justify-content: center; font-size: 1.05rem; }

.cmc-lb-spot-value {
  margin: 0.15rem 0 0.6rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--lb-muted);
}

.cmc-lb-step {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-size: 2rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  border-radius: 0.5rem 0.5rem 0 0;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.cmc-lb-spot-1 .cmc-lb-step { height: 80px; background: var(--lb-gold); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.15); }
.cmc-lb-spot-2 .cmc-lb-step { height: 56px; background: var(--lb-silver); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.15); }
.cmc-lb-spot-3 .cmc-lb-step { height: 40px; background: var(--lb-bronze); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.15); }

/* --- Table ------------------------------------------------------------------------------------- */
.cmc-lb-table-head,
.cmc-lb-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
}

.cmc-lb-table-head {
  height: 40px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
  background: var(--lb-gold);
}

.cmc-lb-row {
  min-height: 60px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--lb-divider);
}

.cmc-lb-row:last-child { border-bottom: 0; }
.cmc-lb-row:hover { background: var(--lb-inner); }

.cmc-lb-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--lb-muted);
  background: var(--lb-inner);
  border-radius: 0.5rem;
}

.cmc-lb-rank-1 { color: #fff; background: var(--lb-gold); }
.cmc-lb-rank-2 { color: #fff; background: var(--lb-silver); }
.cmc-lb-rank-3 { color: #fff; background: var(--lb-bronze); }

.cmc-lb-player { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }

.cmc-lb-head {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 0.35rem;
  image-rendering: pixelated;
}

.cmc-lb-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
  font-weight: 600;
  color: #fff;
}

.cmc-lb-name:hover .cmc-lb-username { text-decoration: underline; }

.cmc-lb-level, .cmc-lb-prefix { font-size: 0.85em; font-weight: 800; white-space: pre; }

.cmc-lb-username { overflow-wrap: anywhere; color: #ffff55; /* Minecraft &e */ }

.cmc-lb-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: #fff;
}

.cmc-lb-table-head .cmc-lb-value { color: #fff; font-weight: 600; }

/* --- Small screens ----------------------------------------------------------------------------- */
@media (max-width: 991px) {
  .cmc-lb { grid-template-columns: 1fr; }

  /* Boards become a scrollable strip above the table */
  .cmc-lb-sidebar {
    flex-direction: row;
    gap: 0.4rem;
    padding: 0.6rem;
    overflow-x: auto;
  }
  .cmc-lb-sidebar-label { display: none; }
  .cmc-lb-board { flex: none; white-space: nowrap; }
}

@media (max-width: 600px) {
  .cmc-lb-header { padding: 1rem 1rem 0.6rem; }
  .cmc-lb-tabs { padding: 0 1rem 0.85rem; }
  .cmc-lb-podium { gap: 0.5rem; padding: 1rem 0.75rem 0; }
  .cmc-lb-spot-name { font-size: 0.85rem; }
  .cmc-lb-spot-skin { width: 72px; }
  .cmc-lb-spot-1 .cmc-lb-spot-skin { width: 90px; }
  .cmc-lb-spot-skin.fallback { width: 48px; }
  .cmc-lb-spot-1 .cmc-lb-spot-skin.fallback { width: 60px; }
  .cmc-lb-spot-name .cmc-lb-level, .cmc-lb-spot-name .cmc-lb-prefix { display: none; }
  .cmc-lb-table-head, .cmc-lb-row { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 0.6rem; padding-left: 0.75rem; padding-right: 0.75rem; }
  .cmc-lb-rank { width: 30px; height: 30px; font-size: 0.85rem; }
  .cmc-lb-head { width: 28px; height: 28px; }
}
