/* ============================================================
   Climatle — leaderboard page.
   Re-uses the climatle design tokens for cohesion with the game,
   then layers on a podium, live stat strip, and motion.
============================================================ */

.climatle-leaderboard {
    max-width: 780px;
    position: relative;
}

/* ── Aurora accent behind the board ─────────────────────────── */
.climatle-lb__aurora {
    position: absolute;
    inset: -40px -10% auto -10%;
    height: 340px;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(38% 60% at 20% 20%, rgba(255, 107, 74, 0.20), transparent 70%),
        radial-gradient(40% 65% at 80% 10%, rgba(26, 107, 255, 0.18), transparent 70%),
        radial-gradient(45% 70% at 55% 60%, rgba(255, 179, 71, 0.16), transparent 70%);
    filter: blur(24px);
    opacity: 0.9;
    animation: cl-lb-aurora 16s ease-in-out infinite alternate;
}
@keyframes cl-lb-aurora {
    0%   { transform: translate3d(-3%, 0, 0) scale(1);    }
    50%  { transform: translate3d(3%, 2%, 0) scale(1.06); }
    100% { transform: translate3d(2%, -1%, 0) scale(1.02);}
}
.climatle-leaderboard > *:not(.climatle-lb__aurora) { position: relative; z-index: 1; }

/* ── Headings ───────────────────────────────────────────────── */
.climatle-lb__headings { min-width: 0; }
.climatle-lb__subtitle {
    margin: 2px 0 0;
    font-family: var(--cl-font-ui);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--cl-mute);
    line-height: 1.35;
}

.climatle-lb__back {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    margin-bottom: 6px;
    font-family: var(--cl-font-ui);
    font-weight: 600;
    font-size: 13px;
    color: var(--cl-accent);
    text-decoration: none;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1.5px solid var(--cl-accent-3);
    background: var(--cl-card);
    transition: background .18s var(--cl-ease), color .18s var(--cl-ease), transform .18s var(--cl-ease);
    flex-shrink: 0;
}
.climatle-lb__back:hover { background: var(--cl-accent-3); color: var(--cl-accent); transform: translateX(-2px); }

/* ── Controls row (tabs + live badge) ───────────────────────── */
.climatle-lb__controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 2px 0 4px;
}

.climatle-lb__tabs {
    position: relative;
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--cl-card);
    border: 1.5px solid var(--cl-line);
    border-radius: 999px;
    box-shadow: var(--cl-shadow-sm);
}
.climatle-lb__tab {
    position: relative;
    z-index: 1;
    appearance: none;
    border: none;
    background: transparent;
    font-family: var(--cl-font-ui);
    font-weight: 700;
    font-size: 13px;
    color: var(--cl-mute);
    padding: 8px 18px;
    border-radius: 999px;
    cursor: pointer;
    transition: color .2s var(--cl-ease);
}
.climatle-lb__tab:hover { color: var(--cl-ink); }
.climatle-lb__tab.is-active { color: #fff; }
/* Sliding pill that animates between active tabs (sized/placed by JS) */
.climatle-lb__tab-glow {
    position: absolute;
    top: 0;
    left: 0;
    height: 0;
    opacity: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--cl-primary), var(--cl-warm));
    box-shadow: 0 4px 12px rgba(255, 107, 74, 0.32);
    transition: transform .32s var(--cl-spring), width .32s var(--cl-spring), opacity .2s var(--cl-ease);
    z-index: 0;
    will-change: transform, width;
}

.climatle-lb__live {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--cl-font-ui);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cl-success);
}
.climatle-lb__live-dot {
    width: 8px; height: 8px;
    border-radius: 999px;
    background: var(--cl-success);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
    animation: cl-lb-pulse 2s var(--cl-ease-out) infinite;
}
@keyframes cl-lb-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    70%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ── Live stat strip ────────────────────────────────────────── */
.climatle-lb__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 4px;
}
.climatle-lb__stats:empty { display: none; }
.climatle-lb__stat {
    position: relative;
    overflow: hidden;
    background: var(--cl-card);
    border: 1.5px solid var(--cl-line);
    border-radius: var(--cl-radius);
    box-shadow: var(--cl-shadow-sm);
    padding: 14px 16px;
    animation: cl-lb-pop .5s var(--cl-spring) both;
}
.climatle-lb__stat::after {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--cl-primary), var(--cl-warm));
    opacity: 0.9;
}
.climatle-lb__stat--cool::after { background: linear-gradient(90deg, var(--cl-accent), var(--cl-cold)); }
.climatle-lb__stat--good::after { background: linear-gradient(90deg, var(--cl-success), var(--cl-success-2)); }
.climatle-lb__stat-value {
    font-family: var(--cl-font-display);
    font-weight: 800;
    font-size: 26px;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--cl-ink);
    font-variant-numeric: tabular-nums;
}
.climatle-lb__stat-value .cl-lb-unit {
    font-size: 13px;
    font-weight: 700;
    color: var(--cl-mute);
    margin-left: 3px;
    letter-spacing: 0;
}
.climatle-lb__stat-label {
    margin-top: 6px;
    font-family: var(--cl-font-ui);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--cl-mute);
}

/* ── Panel ──────────────────────────────────────────────────── */
.climatle-lb__panel {
    background: var(--cl-card);
    border: 1.5px solid var(--cl-line);
    border-radius: var(--cl-radius-lg);
    box-shadow: var(--cl-shadow-md);
    padding: 16px;
}

.climatle-lb__loading,
.climatle-lb__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 44px 16px;
    text-align: center;
    color: var(--cl-mute);
    font-size: 14px;
    font-family: var(--cl-font-ui);
    font-weight: 600;
}
/* An author `display` rule beats the UA [hidden]{display:none}, so restore it
   explicitly — otherwise the spinner/empty state can never be hidden. */
.climatle-lb__loading[hidden],
.climatle-lb__empty[hidden] { display: none; }
.climatle-lb__spinner {
    width: 18px; height: 18px;
    border-radius: 999px;
    border: 2.5px solid var(--cl-line-3);
    border-top-color: var(--cl-primary);
    animation: cl-lb-spin .8s linear infinite;
}
@keyframes cl-lb-spin { to { transform: rotate(360deg); } }

@keyframes cl-lb-pop {
    0%   { opacity: 0; transform: scale(0.8); }
    60%  { opacity: 1; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

/* ── Podium (top 3) ─────────────────────────────────────────── */
.climatle-lb__podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 10px;
    padding: 20px 4px 8px;
}
.climatle-lb__podium[hidden] { display: none; }

.climatle-lb__pod {
    flex: 1 1 0;
    max-width: 210px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.climatle-lb__pod--1 { order: 2; }
.climatle-lb__pod--2 { order: 1; }
.climatle-lb__pod--3 { order: 3; }

.climatle-lb__pod-badge {
    font-size: 20px;
    line-height: 1;
    margin-bottom: 4px;
    animation: cl-lb-float 3s ease-in-out infinite;
}
.climatle-lb__pod--1 .climatle-lb__pod-badge { font-size: 26px; }
@keyframes cl-lb-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

.climatle-lb__avatar {
    --sz: 52px;
    width: var(--sz); height: var(--sz);
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--cl-font-display);
    font-weight: 800;
    font-size: 22px;
    color: #fff;
    box-shadow: var(--cl-shadow-sm);
    position: relative;
    animation: cl-lb-pop .6s var(--cl-spring) both;
}
.climatle-lb__pod--1 .climatle-lb__avatar { --sz: 66px; font-size: 28px; }
.climatle-lb__avatar::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 999px;
    border: 2.5px solid transparent;
}
.climatle-lb__pod--1 .climatle-lb__avatar::after { border-color: #ffcf3f; box-shadow: 0 0 18px rgba(255, 200, 60, 0.6); }
.climatle-lb__pod--2 .climatle-lb__avatar::after { border-color: #c6cede; }
.climatle-lb__pod--3 .climatle-lb__avatar::after { border-color: #e0a765; }
.climatle-lb__pod.is-you .climatle-lb__avatar::after { border-color: var(--cl-accent); box-shadow: 0 0 16px rgba(26, 107, 255, 0.45); }

.climatle-lb__pod-name {
    margin-top: 9px;
    font-family: var(--cl-font-ui);
    font-weight: 700;
    font-size: 13.5px;
    color: var(--cl-ink);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.climatle-lb__pod-you {
    display: inline-block;
    margin-left: 4px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--cl-accent-3);
    color: var(--cl-accent);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
}
.climatle-lb__pod-metric {
    font-family: var(--cl-font-display);
    font-weight: 800;
    font-size: 17px;
    color: var(--cl-ink);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}
.climatle-lb__pod-metric small {
    font-size: 11px;
    font-weight: 700;
    color: var(--cl-mute);
    margin-left: 2px;
}
.climatle-lb__pod-sub {
    font-family: var(--cl-font-ui);
    font-size: 11px;
    font-weight: 600;
    color: var(--cl-mute);
    margin-top: 1px;
    min-height: 14px;
}

.climatle-lb__pedestal {
    width: 100%;
    margin-top: 12px;
    border-radius: var(--cl-radius) var(--cl-radius) 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10px;
    font-family: var(--cl-font-display);
    font-weight: 900;
    font-size: 22px;
    color: rgba(255, 255, 255, 0.95);
    transform-origin: bottom;
    animation: cl-lb-rise .55s var(--cl-ease) both;
}
.climatle-lb__pod--1 .climatle-lb__pedestal {
    height: 92px;
    background: linear-gradient(180deg, #ffd84a, #ffb347);
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), 0 8px 20px rgba(255, 179, 71, 0.35);
}
.climatle-lb__pod--2 .climatle-lb__pedestal {
    height: 66px;
    background: linear-gradient(180deg, #dce3ee, #aab2c0);
    color: #444a63;
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.5), 0 8px 18px rgba(120,130,150,0.25);
}
.climatle-lb__pod--3 .climatle-lb__pedestal {
    height: 48px;
    background: linear-gradient(180deg, #f0c485, #c39a4a);
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.35), 0 8px 18px rgba(180, 140, 80, 0.28);
}
@keyframes cl-lb-rise {
    0%   { transform: scaleY(0.2);  opacity: 0; }
    60%  { transform: scaleY(1.04); opacity: 1; }
    100% { transform: scaleY(1);    opacity: 1; }
}

/* Shine sweep across the winner's pedestal */
.climatle-lb__pod--1 .climatle-lb__pedestal {
    position: relative;
    overflow: hidden;
}
.climatle-lb__pod--1 .climatle-lb__pedestal::before {
    content: "";
    position: absolute;
    top: 0; left: -60%;
    width: 40%; height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,0.7), transparent);
    transform: skewX(-18deg);
    animation: cl-lb-shine 3.4s ease-in-out 0.6s infinite;
}
@keyframes cl-lb-shine {
    0%, 100% { left: -60%; }
    28%, 60% { left: 130%; }
}

/* ── Table (ranks 4+) ───────────────────────────────────────── */
.climatle-lb__table-wrap { width: 100%; overflow-x: auto; margin-top: 4px; }
.climatle-lb__table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--cl-font-ui);
}
.climatle-lb__th {
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cl-mute);
    padding: 10px 12px;
    border-bottom: 1.5px solid var(--cl-line);
}
.climatle-lb__th--rank   { width: 56px; }
.climatle-lb__th--num,
.climatle-lb__td--num    { text-align: right; width: 82px; }
.climatle-lb__th--player { width: auto; }

.climatle-lb__tr {
    border-bottom: 1px solid var(--cl-line-2);
    transition: background .15s var(--cl-ease);
    animation: cl-lb-row-in .45s var(--cl-ease) both;
}
.climatle-lb__tr:last-child { border-bottom: none; }
.climatle-lb__tr:hover      { background: var(--cl-card-soft); }
.climatle-lb__tr.is-you {
    background: linear-gradient(90deg, rgba(26, 107, 255, 0.08), rgba(26, 107, 255, 0.02));
    box-shadow: inset 3px 0 0 var(--cl-accent);
}
.climatle-lb__tr.is-you:hover { background: rgba(26, 107, 255, 0.12); }
@keyframes cl-lb-row-in {
    0%   { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

.climatle-lb__td {
    padding: 12px;
    font-size: 14px;
    color: var(--cl-ink-2);
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}
.climatle-lb__td--rank   { width: 56px; }
.climatle-lb__td--player { font-weight: 600; color: var(--cl-ink); }

.climatle-lb__rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px; height: 28px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--cl-card-soft);
    font-family: var(--cl-font-mono);
    font-weight: 600;
    font-size: 13px;
    color: var(--cl-mute);
}

.climatle-lb__td--player {
    display: flex;
    align-items: center;
    gap: 10px;
}
.climatle-lb__mini-avatar {
    flex-shrink: 0;
    width: 28px; height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--cl-font-display);
    font-weight: 800;
    font-size: 12px;
    color: #fff;
}
.climatle-lb__name {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}
.climatle-lb__you-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--cl-accent-3);
    color: var(--cl-accent);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
}

/* "Your position" panel below the main table */
.climatle-lb__you-wrap {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1.5px dashed var(--cl-line);
}
.climatle-lb__you-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cl-mute);
    margin: 0 0 8px 12px;
}
.climatle-lb__table--you .climatle-lb__td { padding-top: 10px; padding-bottom: 10px; }

/* ── About / how-it-works content ───────────────────────────── */
.climatle-lb__about { margin-top: 6px; }
.climatle-lb__about-title {
    font-family: var(--cl-font-display);
    font-weight: 800;
    font-size: 18px;
    color: var(--cl-ink);
    margin: 0 0 12px;
    letter-spacing: -0.01em;
}
.climatle-lb__about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}
.climatle-lb__about-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--cl-card);
    border: 1.5px solid var(--cl-line);
    border-radius: var(--cl-radius);
    box-shadow: var(--cl-shadow-xs);
    padding: 16px;
    transition: transform .2s var(--cl-ease), box-shadow .2s var(--cl-ease);
}
.climatle-lb__about-card:hover { transform: translateY(-2px); box-shadow: var(--cl-shadow-sm); }
.climatle-lb__about-icon { font-size: 22px; line-height: 1.1; flex-shrink: 0; }
.climatle-lb__about-card p {
    margin: 0;
    font-family: var(--cl-font-ui);
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--cl-ink-2);
}

.climatle-lb__cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    padding: 13px 24px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--cl-primary), var(--cl-warm));
    color: #fff;
    font-family: var(--cl-font-ui);
    font-weight: 800;
    font-size: 15px;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(255, 107, 74, 0.32);
    transition: transform .18s var(--cl-spring), box-shadow .18s var(--cl-ease);
}
.climatle-lb__cta:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 12px 26px rgba(255, 107, 74, 0.4); }
.climatle-lb__cta svg { transition: transform .2s var(--cl-ease); }
.climatle-lb__cta:hover svg { transform: translateX(3px); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 560px) {
    .climatle-leaderboard { padding-left: 10px; padding-right: 10px; }
    .climatle-lb__panel   { padding: 10px; }
    .climatle-lb__td      { padding: 10px 8px; font-size: 13px; }
    .climatle-lb__th      { padding: 8px; }
    .climatle-lb__name    { max-width: 120px; }
    .climatle-lb__tab     { padding: 7px 13px; font-size: 12px; }
    .climatle-lb__podium  { gap: 6px; padding: 14px 0 4px; }
    .climatle-lb__pod-name { font-size: 12px; }
    .climatle-lb__avatar  { --sz: 46px; font-size: 19px; }
    .climatle-lb__pod--1 .climatle-lb__avatar { --sz: 58px; font-size: 24px; }
    .climatle-lb__stat-value { font-size: 22px; }
    .climatle-lb__mini-avatar { display: none; }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .climatle-lb__aurora,
    .climatle-lb__live-dot,
    .climatle-lb__pod-badge,
    .climatle-lb__pod--1 .climatle-lb__pedestal::before,
    .climatle-lb__spinner { animation: none; }
    .climatle-lb__stat,
    .climatle-lb__avatar,
    .climatle-lb__pedestal,
    .climatle-lb__tr { animation-duration: .01ms; animation-delay: 0ms !important; }
    .climatle-lb__tab-glow { transition: none; }
}
