/*
 * ============================================================
 *  GRAFT LEAGUE — LEADERBOARD PAGE STYLES
 *  leaderboard.css
 *
 *  Page: leaderboard.html
 *  Depends on: style.css (must be loaded first)
 *
 *  Sections:
 *    1.  Page header
 *    2.  Refresh bar
 *    3.  Tab navigation
 *    4.  Podium (top 3 display)
 *    5.  Leaderboard table
 *    6.  Empty state
 *    7.  Activity heatmap
 *    8.  Mobile overrides
 * ============================================================
 */


/* ============================================================
   1. PAGE HEADER
   Centred heading with eyebrow, subtitle and back link.
   ============================================================ */

header {
  padding:       2.5rem 2rem 2rem;
  border-bottom: 2px solid var(--ink);
  background:    var(--bg);
  text-align:    center;
}

/* "Group Progress" eyebrow */
.eyebrow {
  font-size:      0.7rem;
  letter-spacing: 0.35em;
  color:          var(--red);
  text-transform: uppercase;
  margin-bottom:  0.75rem;
}

/* "The Graft Table" heading */
h1 {
  font-family: var(--font-display);
  font-size:   clamp(3rem, 8vw, 5.5rem);
  line-height: 0.9;
  color:       var(--ink);
}

h1 span { color: var(--red); }

/* Subtitle below heading */
.subtitle {
  color:      var(--muted);
  font-size:  0.82rem;
  margin-top: 0.75rem;
  font-weight: 300;
}

/* Back to training pill link */
.back-link {
  display:        inline-flex;
  align-items:    center;
  gap:            0.4rem;
  margin-top:     1.25rem;
  background:     transparent;
  border:         2px solid var(--border);
  color:          var(--muted);
  font-size:      0.72rem;
  font-weight:    500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding:        0.55rem 1.1rem;
  border-radius:  100px;
  cursor:         pointer;
  text-decoration: none;
  transition:     all 0.2s;
}

.back-link:hover { border-color: var(--red); color: var(--red); }


/* ============================================================
   2. REFRESH BAR
   Thin bar with a manual refresh button.
   ============================================================ */

.refresh-bar {
  text-align:     center;
  padding:        0.75rem;
  border-bottom:  1px solid var(--border);
  background:     var(--surface);
}

/* Refresh button — small pill */
.refresh-btn {
  background:     transparent;
  border:         1px solid var(--border);
  color:          var(--muted);
  font-size:      0.7rem;
  font-weight:    500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding:        0.4rem 1rem;
  border-radius:  100px;
  cursor:         pointer;
  transition:     all 0.2s;
}

.refresh-btn:hover { border-color: var(--red); color: var(--red); }


/* ============================================================
   3. TAB NAVIGATION
   Four tabs: This Week / All-Time / Streaks / Heatmap.
   Active tab is solid red.
   ============================================================ */

.tabs {
  display:         flex;
  justify-content: center;
  gap:             0.4rem;
  padding:         2rem 1rem 1rem;
  flex-wrap:       wrap;
}

/* Individual tab pill */
.tab {
  background:     var(--surface);
  border:         2px solid var(--border);
  color:          var(--muted);
  font-size:      0.72rem;
  font-weight:    500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding:        0.55rem 1.2rem;
  cursor:         pointer;
  border-radius:  100px;
  transition:     all 0.2s;
}

.tab:hover { border-color: var(--red); color: var(--red); }

/* Active state */
.tab.active {
  background:   var(--red);
  border-color: var(--red);
  color:        #fff;
  font-weight:  700;
}


/* ============================================================
   4. PODIUM (top 3 display)
   Three slots arranged as a podium (2nd left, 1st centre,
   3rd right). Each has an avatar, name, score, and a raised
   block whose height reflects their position.
   ============================================================ */

/* Podium outer wrapper */
.podium-wrap {
  max-width: 680px;
  margin:    0 auto;
  padding:   1rem 1.5rem 0;
}

/* Flex row — aligns to bottom so blocks look like podium steps */
.podium {
  display:         flex;
  align-items:     flex-end;
  justify-content: center;
  gap:             1rem;
  margin-bottom:   2rem;
}

/* One podium slot (avatar + name + score + block) */
.podium-slot {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  gap:            0.5rem;
  flex:           1;
  max-width:      160px;
}

/* Circular avatar with initials */
.podium-avatar {
  width:           56px;
  height:          56px;
  border-radius:   50%;
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-family:     var(--font-display);
  font-size:       1.3rem;
  border:          2px solid;
}

/* Gold / silver / bronze colour treatments */
.podium-slot.p1 .podium-avatar { background: rgba(230,51,35,0.1);   border-color: var(--red);    color: var(--red); }
.podium-slot.p2 .podium-avatar { background: rgba(17,17,17,0.06);   border-color: var(--ink);    color: var(--ink); }
.podium-slot.p3 .podium-avatar { background: rgba(245,200,0,0.1);   border-color: var(--yellow); color: var(--yellow); }

.podium-name {
  font-size:     0.78rem;
  font-weight:   600;
  color:         var(--text);
  text-align:    center;
  max-width:     120px;
  overflow:      hidden;
  text-overflow: ellipsis;
  white-space:   nowrap;
}

/* Score number */
.podium-score {
  font-family: var(--font-display);
  font-size:   1.5rem;
  line-height: 1;
}

.podium-slot.p1 .podium-score { color: var(--red); }
.podium-slot.p2 .podium-score { color: var(--ink); }
.podium-slot.p3 .podium-score { color: var(--yellow); }

/* "workouts" label under the score */
.podium-score-label {
  font-size:      0.6rem;
  color:          var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* The physical podium block — height conveys ranking */
.podium-block {
  width:         100%;
  border-radius: 4px 4px 0 0;
}

.podium-slot.p1 .podium-block { height: 80px; background: rgba(230,51,35,0.08);   border: 1px solid rgba(230,51,35,0.2); }
.podium-slot.p2 .podium-block { height: 55px; background: rgba(17,17,17,0.04);    border: 1px solid rgba(17,17,17,0.15); }
.podium-slot.p3 .podium-block { height: 38px; background: rgba(245,200,0,0.08);   border: 1px solid rgba(245,200,0,0.2); }

/* Medal emoji */
.medal { font-size: 1.4rem; }


/* ============================================================
   5. LEADERBOARD TABLE
   Full rankings below the podium.
   Highlights the current user's row in red.
   ============================================================ */

.table-wrap {
  max-width: 720px;
  margin:    0 auto;
  padding:   0 1.5rem 3rem;
}

/* Table resets */
.lb-table {
  width:           100%;
  border-collapse: collapse;
}

.lb-table thead tr { border-bottom: 2px solid var(--ink); }

/* Column headers */
.lb-table th {
  font-size:      0.62rem;
  color:          var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight:    500;
  padding:        0.5rem 0.75rem;
  text-align:     left;
}

.lb-table th:not(:first-child) { text-align: center; }

/* Table cells */
.lb-table td {
  padding:        0.75rem;
  border-bottom:  1px solid var(--border);
  vertical-align: middle;
}

.lb-table td:not(:first-child) { text-align: center; }

/* Row hover */
.lb-row { transition: background 0.15s; cursor: default; }
.lb-row:hover { background: rgba(17,17,17,0.03); }

/* Current user row is subtly highlighted */
.lb-row.you { background: rgba(230, 51, 35, 0.04); }

/* Red left border on the user's row */
.lb-row.you td:first-child { border-left: 3px solid var(--red); }

/* Rank number — large display font */
.rank-num {
  font-family: var(--font-display);
  font-size:   1.1rem;
  color:       var(--muted);
  width:       32px;
}

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

/* User cell: avatar circle + name */
.user-cell {
  display:     flex;
  align-items: center;
  gap:         0.65rem;
}

/* Small avatar circle */
.mini-avatar {
  width:           30px;
  height:          30px;
  border-radius:   50%;
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-family:     var(--font-display);
  font-size:       0.75rem;
  flex-shrink:     0;
}

.user-name { font-size: 0.85rem; font-weight: 500; }

/* "You" tag badge */
.you-tag {
  font-size:     0.6rem;
  color:         var(--red);
  background:    rgba(230, 51, 35, 0.08);
  border:        1px solid rgba(230, 51, 35, 0.2);
  border-radius: 100px;
  padding:       0.1rem 0.5rem;
  margin-left:   0.4rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Stat numbers in the table */
.stat-cell {
  font-family: var(--font-display);
  font-size:   1.2rem;
  color:       var(--ink);
}

/* Highlighted stat (e.g. streaks) */
.stat-cell.hi { color: var(--red); }

/* Mini progress bar column */
.bar-cell { width: 120px; }

.mini-bar-bg {
  height:        4px;
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: 2px;
  overflow:      hidden;
}

/* Fill colour — red brand colour */
.mini-bar-fill {
  height:        100%;
  background:    var(--red);
  border-radius: 2px;
}


/* ============================================================
   6. EMPTY STATE
   Shown when no data is available yet.
   ============================================================ */

.empty {
  text-align: center;
  padding:    4rem 2rem;
  color:      var(--muted);
}

.empty .empty-icon { font-size: 3rem; margin-bottom: 1rem; }

.empty h3 {
  font-family:   var(--font-display);
  font-size:     1.8rem;
  color:         var(--ink);
  margin-bottom: 0.5rem;
}

.empty p { font-size: 0.82rem; line-height: 1.6; }


/* ============================================================
   7. ACTIVITY HEATMAP
   35-day grid of coloured squares per user.
   Done days = red, empty days = light paper.
   ============================================================ */

.heatmap-wrap {
  max-width: 720px;
  margin:    0 auto;
  padding:   0 1.5rem 3rem;
}

/* "Activity Heatmap" heading */
.heatmap-title {
  font-family:   var(--font-display);
  font-size:     1.4rem;
  margin-bottom: 1.25rem;
  color:         var(--ink);
}

.heatmap-title span { color: var(--red); }

/* One user's heatmap block */
.heatmap-user { margin-bottom: 2rem; }

/* User name + avatar above their grid */
.heatmap-user-name {
  font-size:   0.78rem;
  font-weight: 600;
  color:       var(--ink);
  margin-bottom: 0.65rem;
  display:     flex;
  align-items: center;
  gap:         0.5rem;
}

/* Grid of day squares */
.heatmap-grid {
  display:   flex;
  gap:       3px;
  flex-wrap: wrap;
}

/* Individual day square */
.hm-day {
  width:         16px;
  height:        16px;
  border-radius: 3px;
  position:      relative;
  cursor:        default;
}

/* Tooltip on hover — shows the date */
.hm-day[title]:hover::after {
  content:    attr(title);
  position:   absolute;
  bottom:     calc(100% + 4px);
  left:       50%;
  transform:  translateX(-50%);
  background: var(--ink);
  color:      var(--cream);
  font-size:  0.65rem;
  padding:    0.2rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index:    10;
}

/* Day states */
.hm-empty { background: var(--paper); border: 1px solid var(--border); }  /* Future / no data */
.hm-done  { background: var(--red); }                                      /* Workout logged */
.hm-none  { background: var(--surface); border: 1px solid var(--border); } /* Past, no workout */

/* Legend row below the grid */
.hm-legend {
  display:     flex;
  align-items: center;
  gap:         0.4rem;
  margin-top:  0.65rem;
  font-size:   0.65rem;
  color:       var(--muted);
}


/* ============================================================
   8. MOBILE OVERRIDES (leaderboard page)
   ============================================================ */

@media (max-width: 600px) {
  header { padding: 2rem 1rem 1.5rem; }

  .table-wrap,
  .podium-wrap,
  .heatmap-wrap { padding-left: 1rem; padding-right: 1rem; }

  /* Hide the bar chart column on small screens — too narrow */
  .bar-cell      { display: none; }
  th.hide-mob,
  td.hide-mob    { display: none; }
}


/* ============================================================
   METRIC NOTE
   Small explainer line under the tabs clarifying what the
   "Week" and "Streak" columns mean — prevents confusion when
   a streak crosses a week boundary.
   ============================================================ */

.metric-note {
  text-align:     center;
  font-size:      0.68rem;
  color:          var(--muted);
  padding:        0 1.5rem 0.5rem;
  letter-spacing: 0.02em;
  max-width:      680px;
  margin:         0 auto;
}
