/* ============================================================
   Atomify · v2 · leaderboard (page)
   ------------------------------------------------------------
   Gamified · 2nd page in the gamified track. Stats grid +
   filter row + scope tabs + podium for top-3 + hairline table.
   ============================================================ */

/* ─── 1 · Personal stats grid ───────────────────────── */
.lb-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  overflow: hidden;
  background: var(--paper-2);
}
.lb-stat {
  position: relative;
  padding: 1.2rem 1.3rem 1.25rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.lb-stat:last-child { border-right: 0; }
@media (min-width: 720px) {
  .lb-stat { border-bottom: 0; }
}
.lb-stat-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.lb-stat-value {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.5rem, 2.8vw, 2.1rem);
  letter-spacing: -0.022em;
  line-height: 1;
  color: var(--ink);
}
.lb-stat-value .num {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
}
.lb-stat-value--accent { color: var(--green-deep); }
[data-theme="dark"] .lb-stat-value--accent,
body.dark-mode .lb-stat-value--accent { color: var(--green); }
.lb-stat-value--gold { color: var(--gold); }
[data-theme="dark"] .lb-stat-value--gold,
body.dark-mode .lb-stat-value--gold { color: var(--gold-bright); }
.lb-stat-aux {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}

.lb-stats-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  border: 1px dashed var(--line);
  border-radius: var(--r-3);
  background: var(--paper-2);
}

/* ─── 2 · Filter row (quiz + class selects) ─────────── */
.lb-filters {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.lb-filter {
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.lb-filter-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.lb-select {
  width: 100%;
  padding: 0.7rem 0.95rem;
  padding-right: 2.5rem;
  font-family: var(--font-body);
  font-size: 0.94rem;
  color: var(--ink);
  background-color: var(--paper-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-3);
  cursor: pointer;
  appearance: none;
  outline: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234A5568' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  transition: border-color 180ms, box-shadow 180ms, background-color 180ms;
}
.lb-select:focus {
  border-color: var(--green-deep);
  box-shadow: var(--focus-ring);
  background-color: var(--paper);
}
[data-theme="dark"] .lb-select:focus,
body.dark-mode .lb-select:focus { border-color: var(--green); }
[data-theme="dark"] .lb-select,
body.dark-mode .lb-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239BA2AE' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
}

/* ─── 3 · Scope tabs (Global · Național · Clasă) ────── */
.lb-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  width: max-content;
  max-width: 100%;
}
.lb-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 1rem;
  border: 0;
  background: transparent;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
}
.lb-tab svg { width: 14px; height: 14px; }
.lb-tab:hover { background: var(--paper); color: var(--ink); }
.lb-tab.is-active {
  background: var(--ink);
  color: var(--paper);
}
[data-theme="dark"] .lb-tab.is-active,
body.dark-mode .lb-tab.is-active {
  background: var(--green);
  color: #0B1220;
}
.lb-tab[hidden] { display: none; }

/* ─── 4 · Country / scope banner ────────────────────── */
.lb-scope-banner {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--green-deep);
  border-radius: var(--r-3);
  background: var(--paper-2);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}
.lb-scope-banner strong {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink);
  letter-spacing: -0.005em;
}
[data-theme="dark"] .lb-scope-banner,
body.dark-mode .lb-scope-banner { border-left-color: var(--green); }

/* ─── 5 · Podium (top 3) ────────────────────────────── */
.lb-podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  align-items: end;
}
.lb-podium-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.15rem 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  background: var(--paper-2);
  text-align: center;
  align-items: center;
  overflow: hidden;
}
.lb-podium-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.4;
  background: linear-gradient(180deg, var(--medal-tint, transparent) 0%, transparent 60%);
}
.lb-podium-card--1 { order: 2; padding-top: 1.4rem; padding-bottom: 1.4rem; --medal-tint: var(--gold-tint); border-color: transparent; border-top: 2px solid var(--gold); }
.lb-podium-card--2 { order: 1; --medal-tint: rgba(155, 162, 174, 0.18); border-top: 2px solid var(--ink-3); border-color: transparent; }
.lb-podium-card--3 { order: 3; --medal-tint: var(--amber-tint); border-top: 2px solid var(--amber); border-color: transparent; }

.lb-medal {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--line-strong);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  position: relative;
  z-index: 1;
}
.lb-medal--1 { background: var(--gold); color: #FFFFFF; border-color: var(--gold); }
.lb-medal--2 { background: #F4F1E7; color: var(--ink-2); border-color: var(--ink-3); }
[data-theme="dark"] .lb-medal--2,
body.dark-mode .lb-medal--2 { background: var(--ink-3); color: #0B1220; border-color: var(--ink-3); }
.lb-medal--3 { background: var(--amber); color: #FFFFFF; border-color: var(--amber); }

.lb-podium-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  z-index: 1;
}
.lb-podium-card--1 .lb-podium-avatar {
  width: 76px; height: 76px; font-size: 2rem;
  border: 2px solid var(--gold);
  background: var(--gold-tint);
}
[data-theme="dark"] .lb-podium-card--1 .lb-podium-avatar,
body.dark-mode .lb-podium-card--1 .lb-podium-avatar {
  color: var(--gold-bright);
}

.lb-podium-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.2;
  z-index: 1;
  word-break: break-word;
}
.lb-podium-card--1 .lb-podium-name { font-size: 1.1rem; }
.lb-podium-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  z-index: 1;
}
.lb-podium-pct {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-weight: 500;
  font-size: 1.15rem;
  color: var(--green-deep);
  line-height: 1;
}
.lb-podium-card--1 .lb-podium-pct { font-size: 1.45rem; color: var(--gold); }
[data-theme="dark"] .lb-podium-card--1 .lb-podium-pct,
body.dark-mode .lb-podium-card--1 .lb-podium-pct { color: var(--gold-bright); }
[data-theme="dark"] .lb-podium-pct,
body.dark-mode .lb-podium-pct { color: var(--green); }
.lb-podium-time {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: 0.74rem;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}

@media (max-width: 720px) {
  .lb-podium {
    grid-template-columns: 1fr;
  }
  .lb-podium-card--1,
  .lb-podium-card--2,
  .lb-podium-card--3 { order: initial; }
  .lb-podium-card--1 { order: -1; }
}

/* ─── 6 · Leaderboard table ─────────────────────────── */
.lb-table {
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  background: var(--paper-2);
  overflow: hidden;
}
.lb-table-head,
.lb-table-row {
  display: grid;
  grid-template-columns: 60px 1.6fr 1fr 0.9fr 1.3fr 1fr 1fr;
  gap: 0.85rem;
  align-items: center;
  padding: 0.85rem 1.25rem;
}
.lb-table-head {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.lb-table-row {
  border-bottom: 1px solid var(--line-soft);
  transition: background-color 150ms;
}
.lb-table-row:last-child { border-bottom: 0; }
.lb-table-row:hover { background: var(--paper); }

/* Highlight current user's row */
.lb-table-row--you {
  background: var(--green-tint);
  border-left: 3px solid var(--green-deep);
  padding-left: calc(1.25rem - 3px);
}
.lb-table-row--you:hover { background: var(--green-tint); }
[data-theme="dark"] .lb-table-row--you,
body.dark-mode .lb-table-row--you { border-left-color: var(--green); }

.lb-rank {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink-2);
}
.lb-rank--1 { color: var(--gold); font-weight: 600; }
[data-theme="dark"] .lb-rank--1,
body.dark-mode .lb-rank--1 { color: var(--gold-bright); }
.lb-rank--2 { color: var(--ink-2); font-weight: 600; }
.lb-rank--3 { color: var(--amber); font-weight: 600; }

.lb-user {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}
.lb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  flex-shrink: 0;
}
.lb-username {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.94rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.lb-username-you {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green-deep);
  background: transparent;
  border: 1px solid var(--green-deep);
  border-radius: 999px;
}
[data-theme="dark"] .lb-username-you,
body.dark-mode .lb-username-you { color: var(--green); border-color: var(--green); }

.lb-country {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.lb-score {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: 0.92rem;
  color: var(--ink-2);
  white-space: nowrap;
}
.lb-score-correct {
  color: var(--ink);
  font-weight: 500;
}
.lb-score-of {
  color: var(--ink-muted);
  margin: 0 0.15em;
}

.lb-pct {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.lb-pct-bar {
  flex: 1;
  height: 4px;
  background: var(--paper-3);
  border-radius: 2px;
  overflow: hidden;
  max-width: 100px;
  min-width: 24px;
}
.lb-pct-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  background: linear-gradient(90deg, var(--green-deep), var(--green));
  transition: width 600ms var(--ease-out);
}
.lb-pct--low .lb-pct-bar::after {
  background: linear-gradient(90deg, var(--amber), var(--amber-bright));
}
.lb-pct-num {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: 0.85rem;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
}
.lb-pct--low .lb-pct-num { color: var(--amber); }

.lb-time,
.lb-date {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: 0.82rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* Mobile collapse */
@media (max-width: 920px) {
  .lb-table-head { display: none; }
  .lb-table-row {
    grid-template-columns: 44px 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.4rem 0.75rem;
    padding: 0.85rem 1.1rem;
  }
  .lb-table-row .lb-rank { grid-row: 1 / span 2; align-self: center; }
  .lb-table-row .lb-user { grid-column: 2; grid-row: 1; }
  .lb-table-row .lb-pct  { grid-column: 3; grid-row: 1; justify-self: end; }
  .lb-table-row .lb-country,
  .lb-table-row .lb-score,
  .lb-table-row .lb-time,
  .lb-table-row .lb-date {
    grid-column: 2 / -1;
    grid-row: 2;
    font-size: 0.74rem;
    display: inline;
    margin-right: 0.85rem;
  }
  .lb-table-row .lb-country::before { content: ''; }
  .lb-pct-bar { max-width: 60px; }
}

/* ─── 7 · Empty + error states ──────────────────────── */
.lb-empty {
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: var(--ink-muted);
  background: var(--paper-2);
}
.lb-empty-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.5rem;
}
.lb-empty-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.15rem;
  color: var(--ink-2);
  margin-bottom: 0.4rem;
}
.lb-empty-body {
  font-size: 0.92rem;
  color: var(--ink-soft);
  max-width: 50ch;
  margin: 0 auto;
  line-height: 1.5;
}

/* ─── 8 · Auth-required (same shape as chestionare) ─── */
.lb-auth-required {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1.6rem 1.75rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-4);
  background: var(--gold-tint);
  margin-top: 0.5rem;
}
.lb-auth-required-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}
[data-theme="dark"] .lb-auth-required-eyebrow,
body.dark-mode .lb-auth-required-eyebrow { color: var(--gold-bright); }
.lb-auth-required-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0;
}
.lb-auth-required-body {
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0;
  max-width: 60ch;
}
