/* ==========================================================================
   EzyGamers — the leaderboard page.

   Only leaderboard.html loads this. The standings row itself lives in
   style.css, because four other pages draw one too; what is here is the
   chrome that belongs to the full board - the game picker, the podium, the
   period control and the player's own position.
   ========================================================================== */

.lb-chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================== game picker ==============================
   Fifteen games as wrapping pills stacked three hundred pixels of buttons
   above the data on a phone. One horizontal rail scrolls instead, so the
   board itself is always the first thing on screen.
   ======================================================================= */
/* A rail that scrolls needs to look like one. The fade only appears while
   there is actually more to the right, so it never lies about a list that
   already fits. */
.lb-pickwrap { position: relative; }
.lb-pickwrap::after {
  content: "";
  position: absolute; top: 0; right: 0; bottom: 10px;
  width: 46px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s var(--ease);
  background: linear-gradient(90deg, rgba(8, 9, 16, 0), var(--bg, #080910));
}
.lb-pickwrap.is-overflowing:not(.is-end)::after { opacity: 1; }

.lb-picker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 10px;
  margin-bottom: 18px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.lb-picker::-webkit-scrollbar { height: 6px; }
.lb-picker::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 999px; }
.lb-picker::-webkit-scrollbar-track { background: transparent; }

.lb-pick {
  flex: 0 0 auto;
  scroll-snap-align: center;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 14px 7px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .04);
  color: var(--muted);
  font-size: 13px; font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: color .18s var(--ease), border-color .18s var(--ease),
              background .18s var(--ease), transform .18s var(--ease);
}
.lb-pick:hover { color: #fff; border-color: var(--purple-bright); transform: translateY(-1px); }
.lb-pick:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.lb-pick__art {
  width: 30px; height: 30px; flex: 0 0 auto;
  border-radius: 50%;
  overflow: hidden;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
}
.lb-pick__art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb-pick__emoji { font-size: 15px; line-height: 1; }
.lb-pick__name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }

.lb-pick.is-active {
  background: var(--grad);
  color: #0b0c14;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(108, 76, 255, .38);
}
.lb-pick.is-active .lb-pick__art { background: rgba(0, 0, 0, .22); border-color: rgba(0, 0, 0, .22); }

/* ================================= hero ================================== */
.lb-hero { margin-bottom: 18px; }
/* With no data there is nothing to put in it, and an empty banner reads as a
   broken one. */
.lb-hero[hidden] { display: none; }
.lb-hero .stats-row { margin: 0 0 22px; }
.lb-hero .stats-row:empty { display: none; }

/* ================================ podium =================================
   Second, first, third. The medal each card carries comes from the player's
   rank, never from where the card sits, so a two-player board does not hand
   silver to the leader.
   ======================================================================= */
.lb-podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: end;
  max-width: 520px;
  margin: 0 auto;
  min-height: 40px;
}
.lb-podium[data-count="0"] { display: none; }
.lb-podium[data-count="1"] { grid-template-columns: minmax(0, 220px); justify-content: center; }
.lb-podium[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 380px; }

.lb-pod {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 0;
  animation: lb-rise .42s var(--ease) backwards;
}
.lb-pod--1 { animation-delay: .06s; }
.lb-pod--2 { animation-delay: 0s; }
.lb-pod--3 { animation-delay: .12s; }
@keyframes lb-rise { from { opacity: 0; transform: translateY(14px); } }

.lb-pod__medal { font-size: 22px; line-height: 1; }
.lb-pod--1 .lb-pod__medal { font-size: 28px; filter: drop-shadow(0 0 12px rgba(251, 191, 36, .55)); }

.lb-pod__ava { width: 48px; height: 48px; font-size: 16px; }
.lb-pod--1 .lb-pod__ava {
  width: 58px; height: 58px; font-size: 19px;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, .45), 0 8px 22px rgba(251, 191, 36, .28);
}

.lb-pod__name {
  font-weight: 700; font-size: 13.5px;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb-pod--1 .lb-pod__name { font-size: 15px; }
.lb-pod__score {
  font-weight: 800; font-size: 13px; color: var(--cyan);
  font-variant-numeric: tabular-nums;
}
.lb-pod--1 .lb-pod__score { font-size: 16px; color: var(--gold); }

.lb-pod__plinth {
  width: 100%;
  height: var(--h, 100px);
  border-radius: 14px 14px 0 0;
  display: grid; place-items: start center;
  padding-top: 10px;
  font-size: 20px; font-weight: 900;
  color: rgba(255, 255, 255, .5);
  background: linear-gradient(180deg, rgba(139, 92, 246, .42), rgba(139, 92, 246, .05));
  border: 1px solid rgba(139, 92, 246, .22);
  border-bottom: 0;
}
.lb-pod--1 .lb-pod__plinth {
  background: linear-gradient(180deg, rgba(251, 191, 36, .45), rgba(251, 191, 36, .05));
  border-color: rgba(251, 191, 36, .3);
  color: rgba(255, 255, 255, .8);
}
.lb-pod--3 .lb-pod__plinth {
  background: linear-gradient(180deg, rgba(217, 119, 6, .35), rgba(217, 119, 6, .04));
  border-color: rgba(217, 119, 6, .22);
}

.lb-podium__skel {
  height: 132px;
  border-radius: 14px 14px 0 0;
  align-self: end;
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02));
  animation: lb-shimmer 1.1s linear infinite;
  background-size: 100% 200%;
}
.lb-podium__skel:nth-child(1) { height: 104px; }
.lb-podium__skel:nth-child(3) { height: 84px; }

/* =============================== toolbar ================================= */
.lb-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.lb-segs {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .04);
  gap: 2px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}
.lb-segs::-webkit-scrollbar { display: none; }
.lb-seg {
  flex: 0 0 auto;
  padding: 7px 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px; font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: color .16s var(--ease), background .16s var(--ease);
}
.lb-seg:hover { color: #fff; }
.lb-seg.is-active { background: var(--grad); color: #0b0c14; }
.lb-seg:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.lb-toolbar #lbRefresh { margin-left: auto; }

/* ========================== the player's position ========================
   Shown whenever the signed-in or locally-named player is on this board, in
   or out of the visible rows, so "where am I" never needs scrolling for.
   ======================================================================= */
.lb-you {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg, 16px);
  border: 1px solid rgba(108, 76, 255, .45);
  background:
    radial-gradient(420px 120px at 0% 0%, rgba(108, 76, 255, .22), transparent 70%),
    rgba(108, 76, 255, .1);
  animation: lb-rise .32s var(--ease);
}
.lb-you[hidden] { display: none; }
.lb-you__k {
  font-size: 10px; font-weight: 800; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted);
}
.lb-you__rank {
  font-size: 24px; font-weight: 900; line-height: 1;
  font-variant-numeric: tabular-nums;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lb-you__who { min-width: 0; }
.lb-you__score {
  font-size: 18px; font-weight: 900; color: var(--cyan);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ============================== responsive =============================== */
@media (max-width: 720px) {
  .lb-podium { gap: 8px; }
  .lb-pod__plinth { height: calc(var(--h, 100px) * .74); font-size: 16px; }
  .lb-pod__ava { width: 42px; height: 42px; font-size: 14px; }
  .lb-pod--1 .lb-pod__ava { width: 50px; height: 50px; font-size: 16px; }
  .lb-pod__name { font-size: 12px; }
  .lb-pod--1 .lb-pod__name { font-size: 13px; }
  .lb-pod__score { font-size: 12px; }
  .lb-pod--1 .lb-pod__score { font-size: 14px; }
  .lb-hero .stats-row { gap: 14px; margin-bottom: 18px; }
}
@media (max-width: 520px) {
  .lb-toolbar #lbRefresh { margin-left: 0; }
  .lb-you {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "k k k" "rank who score";
    gap: 10px 12px;
  }
  .lb-you__k { grid-area: k; }
  .lb-you__rank { grid-area: rank; }
  .lb-you__who { grid-area: who; }
  .lb-you__score { grid-area: score; }
  .lb-pick__name { max-width: 108px; }
}

@media (prefers-reduced-motion: reduce) {
  .lb-pod, .lb-you { animation: none; }
  .lb-podium__skel, .lb-pick { animation: none; transition: none; }
}
