/* Class leaderboard (public/js/leaderboard.js) — the board, its week /
   all-time tabs, and the dialog. Used on the Learn English page, the
   student's homework page and the teacher's students page. */

.lb-tabs {
  display: flex;
  gap: 6px;
  width: fit-content;
  margin: 0 auto 12px;
  padding: 4px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--white);
}

.lb-tab {
  padding: 6px 16px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.lb-tab[aria-selected="true"] {
  background: var(--memyellow);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.lb-tab:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 14px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--white);
  color: var(--ink);
}

.lb-row.is-me {
  background: var(--memyellow);
  box-shadow: 3px 4px 0 0 var(--ink);
}

.lb-rank {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #eef3f6;
  font-size: 1.05rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.lb-row.is-rank-1 .lb-rank {
  width: 40px;
  height: 40px;
  border-width: 3px;
  background: #ffd23f;
  font-size: 1.2rem;
}

.lb-row.is-rank-2 .lb-rank {
  background: #d7dee6;
}

.lb-row.is-rank-3 .lb-rank {
  background: #f0b27a;
}

.lb-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-me {
  display: inline-block;
  margin-inline-start: 4px;
  padding: 1px 9px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--white);
  font-size: 0.82rem;
  font-weight: 900;
  vertical-align: 2px;
}

.lb-points {
  flex-shrink: 0;
  font-size: 1.12rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lb-gap {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 0.6;
  color: var(--muted);
}

.lb-empty {
  margin: 0 0 10px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--ink);
}

.lb-rules {
  font-size: 0.98rem;
  color: var(--ink);
}

.lb-rules summary {
  width: fit-content;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.lb-rules ul {
  margin: 8px 0 0;
  padding-inline-start: 20px;
  line-height: 1.55;
}

.lb-rules li + li {
  margin-top: 3px;
}

/* ── Dialog ── */

.lb-dialog {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2200 !important;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) 16px max(12px, env(safe-area-inset-bottom, 0px));
}

.lb-dialog.hidden {
  display: none !important;
}

body.lb-open {
  overflow: hidden;
}

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.lb-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(520px, 100%);
  max-height: 100%;
  padding: 18px 20px 20px;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: var(--clean-bg-how, #b8fff5);
  color: var(--ink);
  box-shadow: var(--shadow-candy, 8px 10px 0 0 rgba(0, 0, 0, 0.95));
  animation: lb-pop 0.22s ease;
}

@keyframes lb-pop {
  0% { transform: scale(0.9); }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.lb-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lb-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--memyellow);
}

.lb-icon svg {
  width: 28px;
  height: 28px;
}

.lb-dialog .lb-title {
  flex: 1;
  margin: 0;
  font-family: var(--font-sans), system-ui, sans-serif;
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1.2;
  color: var(--ink);
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.lb-close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}

.lb-close svg {
  width: 20px;
  height: 20px;
}

/* Only the list scrolls, so the tabs and the rules stay in view. */
.lb-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.lb-body .lb-board {
  min-height: 0;
  overflow-y: auto;
  padding: 2px 6px 6px 2px;
  scrollbar-width: thin;
}

@media (max-width: 480px) {
  .lb-card {
    gap: 10px;
    padding: 14px 14px 16px;
  }

  .lb-row {
    gap: 10px;
    min-height: 48px;
    padding: 6px 10px;
  }

  .lb-name,
  .lb-points {
    font-size: 1.02rem;
  }
}
