/* css/pages/leaderboard.css
   Leaderboard page — mobile-first.
   Colours, radii and shadows come from assets/css/tokens.css (loaded by
   header.php). The three medal colours are page-specific, so they live on
   .leaderboard-page rather than in tokens.css.
   ─────────────────────────────────────────────────────── */

.leaderboard-page {
  --lb-gold: #f5b301;
  --lb-silver: #9aa5b1;
  --lb-bronze: #c77b43;

  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 5rem; /* clear the bottom tab bar */
}

/* ── Header (sticks under the navbar) ───────────────────────────────────── */
.leaderboard-head {
  position: sticky;
  top: calc(4rem + env(safe-area-inset-top, 0px));
  z-index: 5;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  padding: 0.9rem 1rem 0;
}

.leaderboard-head__title {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-text);
}

.leaderboard-head__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.leaderboard-pill {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-full);
  padding: 0.15rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.leaderboard-pill--period {
  background: var(--color-blue-light);
  color: #2b6cb0;
}

.leaderboard-pill--clock {
  background: var(--color-nav-active-bg);
  color: var(--color-nav-active-text);
}

/* ── Photos / Clubs switch ──────────────────────────────────────────────── */
.leaderboard-tabs {
  display: flex;
  gap: 0.4rem;
  padding-bottom: 0.75rem;
}

.leaderboard-tabs__btn {
  flex: 1;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  border-radius: var(--radius-full);
  padding: 0.5rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-light);
  cursor: pointer;
}

.leaderboard-tabs__btn--active {
  background: var(--color-nav-active-bg);
  border-color: var(--color-accent);
  color: var(--color-nav-active-text);
}

/* ── Body ───────────────────────────────────────────────────────────────── */
.leaderboard-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem;
}

.leaderboard-status {
  margin: 0;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--color-text-light);
}

.leaderboard-status__retry {
  display: inline-block;
  margin-top: 0.75rem;
  border: 1px solid var(--color-blue);
  background: var(--color-white);
  color: var(--color-blue);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ── Info strips ────────────────────────────────────────────────────────── */
.lb-cut {
  background: var(--color-review-bg);
  border: 1px solid var(--color-review-border);
  color: var(--color-review-text);
  border-radius: var(--radius-xl);
  padding: 0.65rem 0.8rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

.lb-cut strong {
  display: block;
  font-size: 0.85rem;
}

/* ── Live indicator (header) ────────────────────────────────────────────── */
.leaderboard-live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-basis: 100%; /* always its own line, so it can't hop rows as the countdown text changes length */
  font-size: 0.7rem;
}

.leaderboard-live__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--color-accent);
  animation: lb-pulse 1.6s infinite;
}

@keyframes lb-pulse {
  50% {
    opacity: 0.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  .leaderboard-live__dot {
    animation: none;
  }
}

/* ── Section headings ───────────────────────────────────────────────────── */
.lb-section-title {
  margin: 0.4rem 0.15rem 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
}

.lb-section-sub {
  margin: -0.3rem 0.15rem 0;
  font-size: 0.75rem;
  color: var(--color-text-light);
}

/* ── "Your photos" cards (private to the logged-in member) ──────────────── */
.lb-mine {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 0.65rem;
}

.lb-mine--safe {
  border-color: var(--color-accent);
}

.lb-mine--edge,
.lb-mine--close,
.lb-mine--reach,
.lb-mine--far {
  border-color: var(--color-review-border);
}

.lb-mine__head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.lb-mine__thumb {
  flex: 0 0 auto;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: var(--radius-lg);
  background: var(--color-background);
}

.lb-mine__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

.lb-mine__info {
  flex: 1;
  min-width: 0;
}

.lb-mine__rank {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.lb-mine__rank small {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-light);
}

.lb-mine__votes {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.lb-mine__msg {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
}

.lb-mine__msg--close {
  color: var(--color-review-text);
  font-weight: 600;
}

.lb-mine__msg--safe {
  color: var(--color-success-text);
}

.lb-mine__msg--muted {
  color: var(--color-text-light);
}

/* Progress toward the safe line. The width is the one per-card computed value
   (votes / line), so it is set inline by leaderboard.js. */
.lb-mine__meter {
  height: 0.45rem;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--color-border);
}

.lb-mine__meter-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-review-border);
}

.lb-mine__meter-fill--ok {
  background: var(--color-accent);
}

.lb-mine__legend {
  display: flex;
  justify-content: space-between;
  margin-top: -0.2rem;
  font-size: 0.65rem;
  color: var(--color-text-light);
}

.lb-mine__actions {
  display: flex;
  gap: 0.5rem;
}

/* ── Status chips + card buttons ────────────────────────────────────────── */
.lb-chip {
  flex: 0 0 auto;
  border-radius: var(--radius-full);
  padding: 0.15rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.lb-chip--safe {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.lb-chip--edge,
.lb-chip--close,
.lb-chip--reach,
.lb-chip--far {
  background: var(--color-review-bg);
  color: var(--color-review-text);
}

.lb-chip--pending {
  background: var(--color-blue-light);
  color: var(--color-blue);
}

.lb-chip--cut {
  background: var(--color-border);
  color: var(--color-text-light);
}

/* A removed photo: same card, thumbnail greyed out. */
.lb-mine--cut .lb-mine__img {
  filter: grayscale(1);
  opacity: 0.5;
}

.lb-btn {
  flex: 1; /* Vote and Share link split the row evenly on mobile */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.lb-btn--vote {
  border: none;
  background: var(--color-accent);
  color: var(--color-white);
}

.lb-btn--share {
  border: 1px solid var(--color-border);
  background: var(--color-white);
  color: var(--color-text);
}

.lb-more-btn {
  border: 1px solid var(--color-border);
  background: var(--color-white);
  border-radius: var(--radius-xl);
  padding: 0.6rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-blue);
  cursor: pointer;
}

.lb-cta__btn {
  margin-top: 0.5rem;
  border: none;
  background: var(--color-blue);
  color: var(--color-white);
  border-radius: var(--radius-full);
  padding: 0.45rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* A thumbnail that failed to load (e.g. a removed file) shows the tile's
   background instead of the browser's broken-image icon. */
img.is-broken {
  visibility: hidden;
}

.lb-cta {
  background: var(--color-white);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-xl);
  padding: 0.8rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.lb-cta a {
  color: var(--color-blue);
  font-weight: 600;
}

/* ── Rows ───────────────────────────────────────────────────────────────── */
.lb-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 0.6rem;
  color: inherit;
  text-decoration: none;
}

a.lb-row {
  cursor: pointer;
}

.lb-row--mine {
  border-color: var(--color-accent);
  background: var(--color-nav-active-bg);
}

.lb-row--gold {
  border-color: var(--lb-gold);
}

.lb-row--silver {
  border-color: var(--lb-silver);
}

.lb-row--bronze {
  border-color: var(--lb-bronze);
}

.lb-row__rank {
  flex: 0 0 auto;
  width: 1.9rem;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-light);
}

.lb-row--top .lb-row__rank {
  font-size: 1.25rem;
}

.lb-row__thumb {
  position: relative;
  flex: 0 0 auto;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-lg);
  background: var(--color-background);
}

.lb-row__thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-lg);
  display: block;
}

.lb-row__badge {
  position: absolute;
  right: -0.3rem;
  bottom: -0.3rem;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  object-fit: cover;
}

.lb-row__main {
  flex: 1;
  min-width: 0;
}

.lb-row__name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.lb-row__name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-row__sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--color-text-light);
}

.lb-row__gap {
  margin-top: 0.1rem;
  font-size: 0.72rem;
  color: var(--color-review-text);
}

.lb-row__side {
  flex: 0 0 auto;
  text-align: right;
}

.lb-row__votes {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
}

.lb-row__votes small {
  display: block;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--color-text-light);
}

.lb-row__cta {
  display: inline-block;
  margin-top: 0.25rem;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.85rem;
}

.lb-tag {
  flex: 0 0 auto;
  background: var(--color-accent);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.05rem 0.45rem;
}

/* ── Club rows ──────────────────────────────────────────────────────────── */
.lb-club__icon {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-background);
  border: 1px solid var(--color-border);
}

.lb-club__icon--initials {
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-light);
}

.lb-club__stats {
  font-size: 0.72rem;
  color: var(--color-text-light);
}

/* ── Footer links ───────────────────────────────────────────────────────── */
.lb-link {
  display: block;
  padding: 0.7rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-blue);
  text-decoration: none;
}

.lb-link--card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  color: var(--color-text);
}

/* ── Dark mode ──────────────────────────────────────────────────────────── */
.np-dark-mode .leaderboard-head,
.np-dark-mode .lb-row,
.np-dark-mode .lb-mine,
.np-dark-mode .lb-more-btn,
.np-dark-mode .lb-btn--share,
.np-dark-mode .lb-cta,
.np-dark-mode .lb-link--card,
.np-dark-mode .leaderboard-tabs__btn:not(.leaderboard-tabs__btn--active),
.np-dark-mode .leaderboard-status__retry {
  background: var(--color-surface-dark, #1e1e2e);
  border-color: var(--color-border-dark, #333);
}

.np-dark-mode .lb-row--mine {
  background: rgba(46, 204, 113, 0.12);
  border-color: var(--color-accent);
}

.np-dark-mode .lb-row--gold {
  border-color: var(--lb-gold);
}

.np-dark-mode .lb-row--silver {
  border-color: var(--lb-silver);
}

.np-dark-mode .lb-row--bronze {
  border-color: var(--lb-bronze);
}

.np-dark-mode .leaderboard-head__title,
.np-dark-mode .lb-row__name,
.np-dark-mode .lb-row__votes,
.np-dark-mode .lb-mine__rank,
.np-dark-mode .lb-section-title,
.np-dark-mode .lb-link--card {
  color: var(--color-text-dark, #e5e7eb);
}

.np-dark-mode .leaderboard-tabs__btn--active {
  background: color-mix(in srgb, var(--color-accent) 15%, transparent);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ── Desktop ────────────────────────────────────────────────────────────── */
@media (min-width: 769px) {
  .leaderboard-page {
    padding-top: 1rem;
  }

  .leaderboard-head {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
  }

  .lb-row__thumb {
    width: 4rem;
    height: 4rem;
  }

  /* Vote and Share link are the same fixed size on desktop, instead of Vote
     stretching across the card. The card itself keeps its width. */
  .lb-btn {
    flex: 0 0 7.5rem;
    width: 7.5rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
  }
}
