/* Stars — Leaderboard panel
   Design tokens from specs/Stars-leaderboard/design_handoff_leaderboard.
   Sits beside the canvas-rendered scorecard during LEVEL_COMPLETE. */

/* ============================================================
   Container — positioned in JS to sit next to the scorecard.
   ============================================================ */
.lb-panel {
  position: fixed;
  z-index: 60;                       /* above canvas, below modal overlays */
  width: 380px;
  height: 500px;                     /* matches scorecard panelH */
  /* Chrome matched to scorecard: same translucent fill, same border tone +
     alpha. Keeps the two surfaces reading as the same object class. */
  background: rgba(6, 8, 14, 0.94);
  border: 1px solid rgba(230, 239, 255, 0.40);
  display: flex;
  flex-direction: column;
  font-family: 'Inter', system-ui, sans-serif;
  color: rgba(233, 237, 247, 0.92);
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
  pointer-events: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.lb-panel.is-hidden {
  display: none;
}

/* slide-in (mount) and slide-out (unmount) */
.lb-panel.is-entering {
  animation: lbSlideIn 320ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.lb-panel.is-leaving {
  animation: lbSlideOut 220ms cubic-bezier(0.4, 0, 0.7, 0.3) both;
  pointer-events: none;
}
@keyframes lbSlideIn {
  from { transform: translateX(-30px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
@keyframes lbSlideOut {
  from { transform: translateX(0);     opacity: 1; }
  to   { transform: translateX(-20px); opacity: 0; }
}

/* ============================================================
   Header
   ============================================================ */
.lb-header {
  padding: 20px 18px 18px 18px;
  flex: 0 0 auto;
}
.lb-header__eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.32em;
  color: rgba(255, 255, 255, 0.22);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.lb-header__headline {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: rgba(233, 237, 247, 0.92);
  margin-bottom: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
}
.lb-header__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.lb-stat__label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 8.5px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.22);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.lb-stat__value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: rgba(233, 237, 247, 0.92);
}
.lb-stat__value.is-dim {
  color: rgba(255, 255, 255, 0.38);
}

/* ============================================================
   View toggle (segmented)
   ============================================================ */
.lb-toggle-wrap {
  padding: 0 18px 14px;
  flex: 0 0 auto;
}
.lb-toggle {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.10);
}
.lb-toggle__btn {
  flex: 1;
  padding: 9px 0;
  background: transparent;
  border: 1px solid transparent;
  border-right: 1px solid rgba(255, 255, 255, 0.10);
  border-left: none;
  border-bottom: none;
  /* Match scorecard button typography (Inter 300 / 0.4em) — departs from the
     handoff spec's mono register so the two surfaces share one nav voice. */
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 10px;
  font-weight: 300;
  letter-spacing: 0.4em;
  color: rgba(255, 255, 255, 0.38);
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  user-select: none;
}
.lb-toggle__btn:last-child {
  border-right: none;
}
.lb-toggle__btn:hover:not(.is-active) {
  color: rgba(255, 255, 255, 0.55);
}
.lb-toggle__btn.is-active {
  /* Active = shard-blue near-white. Mirrors the scorecard buttons' active
     state — both surfaces share one selection language (faint tint fill +
     top-border accent + near-white text). 2026-05-17: amber was retired from
     both surfaces in favor of this pre-amber pattern.
     Note (2026-05-13): wire-purple and electric-blue both tried and rejected
     as too subtle. The near-white pattern was the original; we returned to it. */
  background: rgba(170, 200, 255, 0.08);
  border-top-color: rgba(170, 200, 255, 0.9);
  color: rgba(200, 220, 255, 1);
}

/* ============================================================
   Column header
   ============================================================ */
.lb-colhead {
  display: grid;
  grid-template-columns: 36px 30px 1fr 44px 70px 16px 14px 14px;
  align-items: center;
  gap: 10px;
  padding: 0 14px 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 8.5px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.22);
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
}
.lb-colhead__rank { text-align: right; }
.lb-colhead__stars { text-align: right; }
.lb-colhead__time { text-align: right; }

/* Time-map panels collapse the stars column entirely — stars are not part of
   the ranking on time maps, and showing them invited the wrong reading. The
   grid template removes the stars track; the cell content gets display:none
   so it doesn't break the row count for selectors. */
.lb-panel--time .lb-colhead,
.lb-panel--time .lb-row {
  grid-template-columns: 36px 30px 1fr 70px 16px 14px 14px;
}
.lb-panel--time .lb-colhead__stars,
.lb-panel--time .lb-row__stars {
  display: none;
}

/* ============================================================
   List region (scrollable)
   ============================================================ */
.lb-list {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.lb-list::-webkit-scrollbar { width: 6px; }
.lb-list::-webkit-scrollbar-track { background: transparent; }
.lb-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}
.lb-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

.lb-list-inner {
  flex: 0 0 auto;
}
.lb-list--has-pinned {
  /* allow pinned row to push to bottom */
}

/* ============================================================
   Row
   ============================================================ */
.lb-row {
  position: relative;
  display: grid;
  grid-template-columns: 36px 30px 1fr 44px 70px 16px 14px 14px;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 14px;
  background: transparent;
  cursor: default;
  transition: background 0.15s ease;
  outline: none;
}
.lb-row.has-replay {
  cursor: pointer;
}
.lb-row:hover:not(.is-self):not(.is-selected) {
  background: rgba(255, 255, 255, 0.035);
}
.lb-row.is-selected {
  background: rgba(255, 255, 255, 0.07);
}
.lb-row.is-self {
  background: rgba(232, 200, 121, 0.05);
}
.lb-row.is-self.is-selected {
  background: rgba(255, 255, 255, 0.07);
}
.lb-row.is-focused {
  outline: 1px solid rgba(232, 200, 121, 0.7);
  outline-offset: -1px;
}

.lb-row__rule {
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: rgba(232, 200, 121, 0.55);
}

.lb-row__rank {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.55);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* Self-row identity = whole row amber. All text columns recolor together so
   the player's own line reads as a single object, no badge needed. */
.lb-row.is-self .lb-row__rank,
.lb-row.is-self-unranked .lb-row__rank,
.lb-row.is-self .lb-row__name,
.lb-row.is-self-unranked .lb-row__name,
.lb-row.is-self .lb-row__stars,
.lb-row.is-self-unranked .lb-row__stars,
.lb-row.is-self .lb-row__time,
.lb-row.is-self-unranked .lb-row__time {
  color: #e8c879;
}

.lb-row__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.6px;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.78);
  flex: 0 0 auto;
  box-sizing: border-box;
}

.lb-row__name {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: rgba(233, 237, 247, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.lb-row__you {
  /* YOU badge retired 2026-05-17 — self identity is now carried by the whole
     row going amber. Kept here only so the panel's render code can keep
     emitting the span without breaking anything else. */
  display: none;
}

.lb-row__stars {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: rgba(233, 237, 247, 0.92);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.lb-row__time {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.55);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.lb-row__icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   Pinned self row + unranked anchor
   ============================================================ */
.lb-pinned {
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  margin-top: auto;
  flex: 0 0 auto;
}
.lb-unranked {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 6px;
  padding-top: 6px;
  flex: 0 0 auto;
}
.lb-unranked__row {
  position: relative;
  display: grid;
  grid-template-columns: 36px 30px 1fr 44px 70px 16px 14px 14px;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 14px;
  background: rgba(232, 200, 121, 0.05);
}
.lb-unranked__label {
  grid-column: span 5;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.38);
  text-transform: uppercase;
  text-align: right;
}

/* ============================================================
   Skeleton (loading)
   ============================================================ */
.lb-skeleton {
  display: grid;
  grid-template-columns: 36px 30px 1fr 44px 70px 16px 14px 14px;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 14px;
}
.lb-skeleton__bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  animation: lbPulse 1.6s ease-in-out infinite;
}
.lb-skeleton__circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  animation: lbPulse 1.6s ease-in-out infinite;
}
@keyframes lbPulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

/* ============================================================
   Empty + error states
   ============================================================ */
.lb-centered {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}
.lb-centered__headline {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 8px;
}
.lb-centered__sub {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.22);
  text-transform: uppercase;
  margin-bottom: 16px;
}
.lb-retry {
  padding: 8px 18px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.38);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.28em;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.lb-retry:hover {
  color: rgba(233, 237, 247, 0.92);
  border-color: rgba(233, 237, 247, 0.92);
}

/* ============================================================
   Cross-fade for view/state changes (no full slide re-play)
   ============================================================ */
.lb-fade {
  animation: lbCrossFade 140ms ease-out;
}
@keyframes lbCrossFade {
  from { opacity: 0.2; }
  to   { opacity: 1; }
}
