/* ============================================================
   leaderboard-shell.css — "Leaderboard Shell" for pages/leaderboard.html
   (see leaderboard-layout-suggestion.md)

   Four stacked zones inside <main class="lb-shell">:
     lb-identity   — h1 + status
     lb-controlzone (sticky) — board tabs + filter field
     lb-listhead   — count + column labels
     lb-ledger     — one continuous ranked list (ranks 1..100)

   Tokens: the neutral --ss-* scale from css/series-shell.css, which
   MUST be loaded before this file. No purple, no per-page palette.
   Spacing scale: 4 / 8 / 12 / 16 / 24 / 32 / 48px only.
   ============================================================ */

/* ---------- Shell frame ---------- */
.lb-shell {
  max-width: var(--ss-max, 1120px);
  margin: 0 auto;
  padding: 0 16px 48px;
  color: var(--ss-text);
}
.lb-shell *,
.lb-shell *::before,
.lb-shell *::after { box-sizing: border-box; }

.lb-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- Zone 1: identity strip ---------- */
.lb-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 24px 0 12px;
}
.lb-h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--ss-text);
}
.lb-sub {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ss-text-muted);
}
.lb-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ss-text-muted);
}

/* ---------- Buttons: one neutral set ---------- */
.lb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  color: var(--ss-ghost-fg);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.lb-btn:hover { background: var(--ss-ghost-bg-hover); color: var(--ss-text); }
.lb-btn:focus-visible { outline: 2px solid var(--ss-border-strong); outline-offset: 2px; }

/* ---------- Zone 2: sticky control zone ---------- */
.lb-controlzone {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0 12px;
  background: var(--ss-bg);
  border-bottom: 1px solid var(--ss-border);
}
.lb-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px;
  background: var(--ss-surface);
  border: 1px solid var(--ss-border);
  border-radius: 8px;
}
.lb-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ss-text-muted);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}
.lb-tab:hover { color: var(--ss-text); background: var(--ss-ghost-bg-hover); }
.lb-tab.is-active {
  background: var(--ss-primary-bg);
  color: var(--ss-primary-fg);
}
.lb-tab:focus-visible { outline: 2px solid var(--ss-border-strong); outline-offset: 2px; }

.lb-find {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  min-width: 220px;
  padding: 0 12px;
  background: var(--ss-surface);
  border: 1px solid var(--ss-border);
  border-radius: 8px;
  color: var(--ss-text-muted);
}
.lb-find:focus-within { border-color: var(--ss-border-strong); }
.lb-find input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--ss-text);
}
.lb-find input::placeholder { color: var(--ss-text-muted); }

/* ---------- Zone 3: list head ---------- */
.lb-listhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 12px 8px;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ss-text-muted);
}
.lb-listhead-count { font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 13px; }

/* ---------- Zone 4: the ledger ---------- */
.lb-ledger {
  border: 1px solid var(--ss-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--ss-surface);
}

.lb-rowitem {
  position: relative;
  display: grid;
  grid-template-columns: 44px 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ss-border);
  text-decoration: none;
  color: inherit;
  transition: background-color 120ms ease;
}
.lb-rowitem:last-child { border-bottom: 0; }
.lb-rowitem:hover { background: var(--ss-surface-2); }
.lb-rowitem:focus-visible { outline: 2px solid var(--ss-border-strong); outline-offset: -2px; }

/* Ranks 1–3: a leading accent rail + medal tint, no separate podium */
.lb-rowitem--medal::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--ss-border-strong);
}
.lb-rowitem--medal-1::before { background: #d4a017; }
.lb-rowitem--medal-2::before { background: #9ca3af; }
.lb-rowitem--medal-3::before { background: #b45309; }

.lb-rank {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: var(--ss-text-muted);
  text-align: right;
}
.lb-rowitem--medal .lb-rank { color: var(--ss-text); font-size: 16px; }

.lb-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  object-fit: cover;
  background: var(--ss-surface-2);
  border: 1px solid var(--ss-border);
}

.lb-who { min-width: 0; }
.lb-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 600;
  color: var(--ss-text);
}
.lb-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.lb-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--ss-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-metric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 600;
  color: var(--ss-text);
  white-space: nowrap;
}
.lb-metric-unit {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ss-text-muted);
}

/* ---------- States ---------- */
.lb-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--ss-text-muted);
  font-size: 14px;
}
.lb-state i { font-size: 20px; display: block; margin-bottom: 12px; }
.lb-state p { margin: 0 0 4px; }

.lb-skeleton {
  display: grid;
  grid-template-columns: 44px 40px minmax(0, 1fr) 80px;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ss-border);
}
.lb-skeleton:last-child { border-bottom: 0; }
.lb-skeleton span {
  display: block;
  height: 12px;
  border-radius: 4px;
  background: var(--ss-surface-2);
  animation: lb-pulse 1.2s ease-in-out infinite;
}
.lb-skeleton span.lb-skeleton-avatar { height: 40px; border-radius: 999px; }
@keyframes lb-pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) {
  .lb-skeleton span { animation: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .lb-controlzone { align-items: stretch; }
  .lb-tabs { width: 100%; }
  .lb-tab { flex: 1; justify-content: center; padding: 0 8px; }
  .lb-find { width: 100%; }
  .lb-rowitem,
  .lb-skeleton { grid-template-columns: 32px 36px minmax(0, 1fr) auto; gap: 8px; padding: 12px; }
  .lb-avatar { width: 36px; height: 36px; }
  .lb-listhead-cols { display: none; }
}
