/*
 * Reputation leaderboard.
 *
 * The podium used to be three 100px cards centred in a 1400px band, which
 * left most of the width empty; it now spans the container with the winner
 * raised. The list used to carry only a level and a score, so every row had a
 * wide empty gutter between the name and the numbers - it now shows the stats
 * the API actually populates (badges, playtime, s&box score) as real columns.
 */

.lb-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

/* ---- podium ------------------------------------------------------------ */

.lb-podium {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-md);
    align-items: end;
    margin-bottom: var(--space-xl);
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: var(--space-lg) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    text-align: center;
}

/* the winner sits higher and heavier than the two beside it */
.podium-gold {
    padding-block: var(--space-xl);
    border-color: rgb(251 191 36 / 35%);
    background:
        linear-gradient(180deg, rgb(251 191 36 / 10%) 0%, transparent 60%),
        var(--bg-card);
}

.podium-avatar-wrap {
    position: relative;
    display: inline-flex;
}

.podium-avatar {
    width: 72px;
    height: 72px;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    object-fit: cover;
}

.podium-gold .podium-avatar {
    width: 104px;
    height: 104px;
    border-color: var(--highlight-gold);
}

.podium-silver .podium-avatar {
    border-color: #c7ccd6;
}

.podium-bronze .podium-avatar {
    border-color: #c98a52;
}

/*
 * A plain numeral, not a medal glyph: workspace_premium and military_tech both
 * turn to mush at this size, and the number says the same thing clearly.
 */
.podium-medal {
    position: absolute;
    right: -4px;
    bottom: -4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 3px solid var(--bg-primary);
    border-radius: 50%;
    background: #b6bcc8;
    color: #10141c;
    font-size: var(--fs-small);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.podium-gold .podium-medal {
    right: -2px;
    bottom: 2px;
    width: 34px;
    height: 34px;
    background: var(--highlight-gold);
    font-size: var(--fs-title);
}

.podium-bronze .podium-medal {
    background: #c98a52;
}

.podium-name {
    max-width: 100%;
    overflow: hidden;
    color: var(--text-primary);
    font-size: var(--fs-title);
    font-weight: 700;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium-gold .podium-name {
    font-size: var(--fs-lead);
}

.podium-name:hover {
    color: var(--primary-ink);
}

.podium-score {
    color: var(--text-primary);
    font-size: var(--fs-figure);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: var(--lh-tight);
}

.podium-gold .podium-score {
    color: var(--highlight-gold);
    font-size: var(--fs-hero);
}

.podium-level {
    color: var(--text-muted);
    font-size: var(--fs-tiny);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}

.podium-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.35rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--hairline);
    width: 100%;
    color: var(--text-muted);
    font-size: var(--fs-tiny);
    font-variant-numeric: tabular-nums;
}

.podium-meta span {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

.podium-meta .material-symbols-rounded {
    font-size: 1.15em;
}

/* ---- list -------------------------------------------------------------- */

.lb-list {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    overflow: hidden;
}

/*
 * One column template shared by the header and every row, so the numbers line
 * up under their labels instead of drifting.
 */
.lb-head,
.lb-row {
    display: grid;
    grid-template-columns:
        3.25rem 32px minmax(0, 1fr)
        5rem 6.5rem 6rem 6.5rem;
    gap: 0.75rem;
    align-items: center;
    padding: 0.4rem 0.9rem;
}

.lb-head {
    border-bottom: 1px solid var(--border);
    background: rgb(var(--tint) / 2%);
    color: var(--text-tertiary);
    font-size: var(--fs-micro);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}

/* the rank column and every numeric column align right, headers included */
.lb-head span:first-child,
.lb-head span:nth-child(n + 4),
.lb-row > .lb-stat,
.lb-row > .lb-score {
    text-align: right;
}

.lb-row {
    border-top: 1px solid var(--surface-line);
    color: var(--text-secondary);
    font-size: var(--fs-small);
    font-variant-numeric: tabular-nums;
    transition: background var(--transition-fast);
}

.lb-row:first-of-type {
    border-top: 0;
}

.lb-row:hover {
    background: var(--bg-hover);
}

.lb-row--top1 {
    background: rgb(251 191 36 / 6%);
}

.lb-row--top2,
.lb-row--top3 {
    background: rgb(var(--tint) / 3%);
}

.lb-rank {
    color: var(--text-muted);
    font-size: var(--fs-tiny);
    font-weight: 600;
    text-align: right;
}

.lb-row--top1 .lb-rank {
    color: var(--highlight-gold);
}

.lb-row--top2 .lb-rank,
.lb-row--top3 .lb-rank {
    color: var(--text-secondary);
}

.lb-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.lb-user {
    min-width: 0;
}

.lb-name {
    display: block;
    overflow: hidden;
    color: var(--text-primary);
    font-size: var(--fs-small);
    font-weight: 600;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-name:hover {
    color: var(--primary-ink);
}

.lb-level {
    color: var(--text-secondary);
    font-size: var(--fs-tiny);
    font-weight: 600;
}

.lb-stat {
    color: var(--text-muted);
    font-size: var(--fs-tiny);
}

.lb-stat--empty {
    color: var(--text-disabled);
}

.lb-score {
    color: var(--text-primary);
    font-weight: 700;
}

.lb-score small {
    margin-left: 0.15rem;
    color: var(--text-muted);
    font-size: var(--fs-micro);
    font-weight: 400;
}

.lb-info-section {
    margin-top: var(--space-3xl);
    padding-top: var(--space-2xl);
    border-top: 1px solid var(--border);
}

/* ---- narrow ------------------------------------------------------------ */

@media (width <= 1100px) {
    .lb-head,
    .lb-row {
        grid-template-columns: 3rem 32px minmax(0, 1fr) 5rem 6.5rem;
    }

    /* s&box score and badges are the first to go when space runs out */
    .lb-head span:nth-child(4),
    .lb-head span:nth-child(6),
    .lb-row > .lb-stat--badges,
    .lb-row > .lb-stat--sbox {
        display: none;
    }
}

@media (width <= 720px) {
    .lb-podium {
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
    }

    .podium-gold {
        order: -1;
    }

    .lb-head {
        display: none;
    }

    .lb-row {
        grid-template-columns: 2.5rem 32px minmax(0, 1fr) auto;
        row-gap: 0.15rem;
    }

    .lb-row > .lb-stat,
    .lb-row > .lb-level {
        display: none;
    }
}
