/*
 * Custom leaderboard styling for HexaGameHub.
 * This stylesheet introduces dark‑mode friendly tables with neon accents,
 * hexagon rank badges for the top positions and improved typography for
 * readability. Adjust colours here to fine‑tune the vibe of your hub.
 */

/* Section wrapper */
.leaderboard-section {
  background: linear-gradient(135deg, rgba(14, 24, 56, 0.6), rgba(16, 18, 41, 0.8));
  border: 1px solid rgba(98, 182, 240, 0.3);
  border-radius: 16px;
  margin-bottom: 24px;
  padding: 16px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
}

.leaderboard-section h3 {
  margin: 0 0 12px 0;
  font-size: 1.5rem;
  color: #f08fd1;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* Table layout */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  overflow: hidden;
  /* Fix column widths so long timestamps don’t push the table wider */
  table-layout: fixed;
}

.leaderboard-table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #8fa3c7;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-table td {
  padding: 12px 14px;
  font-size: 0.95rem;
  color: #e2e8f9;
}

.leaderboard-table td.score {
  font-weight: 700;
  color: #ffd700;
}

.leaderboard-table td.when {
  font-size: 0.75rem;
  color: #7c89b6;
  /* Prevent long date strings from overflowing the table on desktop */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hide the "When" column on narrow screens to avoid overflow */
@media (max-width: 640px) {
  .leaderboard-table th:nth-child(4),
  .leaderboard-table td.when {
    display: none;
  }
}

/* Row striping */
.leaderboard-table tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.04);
}

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

/* Rank cell with hexagon badge */
.leaderboard-table td.rank {
  position: relative;
  font-weight: 700;
  text-align: center;
  width: 48px;
  padding-left: 40px;
  color: #e2e8f9;
}

.leaderboard-table td.rank::before {
  content: attr(data-rank);
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  line-height: 32px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #0d1331;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  background: linear-gradient(135deg, #62b6f0, #9b5cf3);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* Medal colours for top ranks */
.leaderboard-table tr.top-1 td.rank::before {
  background: linear-gradient(135deg, #ffd700, #f2d06b);
}

.leaderboard-table tr.top-2 td.rank::before {
  background: linear-gradient(135deg, #c0c0c0, #d3d3d3);
}

.leaderboard-table tr.top-3 td.rank::before {
  background: linear-gradient(135deg, #cd7f32, #b87333);
}

/* Colour emphasis for names and scores in top ranks */
.leaderboard-table tr.top-1 td.player,
.leaderboard-table tr.top-1 td.score {
  color: #ffd700;
}

.leaderboard-table tr.top-2 td.player,
.leaderboard-table tr.top-2 td.score {
  color: #c0c0c0;
}

.leaderboard-table tr.top-3 td.player,
.leaderboard-table tr.top-3 td.score {
  color: #cd7f32;
}

/* Empty state */
.leaderboard-table td.empty {
  text-align: center;
  padding: 16px;
  color: #8fa3c7;
}

/* ----------------------------------------------------------------------
 * Additional styling for the leaderboard page
 *
 * The global header and XP bar elements inherit colours from the base
 * stylesheet. On the leaderboard page these values appeared too dark
 * against the background, making text like the site name (HexaGameHub),
 * level indicator (Lv • XP) and the “Leaderboards” heading difficult to
 * read. The rules below override those colours to brighter hues in
 * keeping with the neon arcade vibe.
 *
 * We also remove the deprecated local‑scores notice and give the
 * “Return to Game” button a distinctive gradient so it stands out.
 */

/* Hide the old local storage notice that appears beneath the boards */
#boards + .hx-muted {
  display: none;
}

/* Brighten the site brand and XP bar labels on dark backgrounds */
.hx-nav .hx-brand,
.hx-nav .hx-brand a {
  color: #e2e8f9 !important;
}
#hx-xp-bar .lvl,
#hx-xp-bar .label {
  color: #f08fd1 !important;
}

/* Style the Return‑to‑Game button with a neon gradient */
.btn[data-action="history-back"],
a.btn[href*="play"] {
  background: linear-gradient(135deg, #62b6f0, #9b5cf3) !important;
  color: #0d1331 !important;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  text-decoration: none;
}

/* ----------------------------------------------------------------------
 * Header auth buttons (Sign In, Create Account) styling
 *
 * On the leaderboard page, the Sign In and Create Account buttons sit next
 * to the “Return to Game” link in the header. They shared the same base
 * styles as other buttons on the site, which made them hard to see
 * against the dark background. These rules give them the same neon
 * gradient as the return button and ensure they adapt gracefully on
 * narrow screens by stacking vertically.
 */

.hx-nav .hx-actions .hx-btn {
  background: linear-gradient(135deg, #62b6f0, #9b5cf3) !important;
  color: #0d1331 !important;
  border: none;
  padding: 8px 14px;
  font-weight: 700;
  border-radius: 8px;
}

@media (max-width: 640px) {
  .hx-nav .hx-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .hx-nav .hx-actions .hx-btn {
    width: 100%;
    text-align: center;
  }
}

/* Generic styling for links in the header actions area on the leaderboard page.
 * Some header links (e.g. Sign In, Create Account) do not carry the .hx-btn
 * class, so they weren’t styled by the rules above. Apply the same neon
 * gradient and button chrome to any anchor under .hx-actions to ensure
 * consistency. This will also style the return link uniformly.
 */
.hx-nav .hx-actions a {
  background: linear-gradient(135deg, #62b6f0, #9b5cf3) !important;
  color: #0d1331 !important;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 700;
  text-decoration: none;
}

/* Give the middle action button a contrasting dark style.  On the
 * leaderboard page the order of actions is typically Sign In, Create
 * Account and Return to Game.  Styling the second link differently
 * helps break up the uniform look of three identical buttons. */
.hx-nav .hx-actions a:nth-child(2) {
  background: #0c1022 !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

@media (max-width: 640px) {
  .hx-nav .hx-actions a {
    display: block;
    width: 100%;
    text-align: center;
    margin-bottom: 6px;
  }
  .hx-nav .hx-actions a:last-child {
    margin-bottom: 0;
  }
}
