/**
 * Origins Leaderboard Styles
 * Same Axie theme as Card Explorer
 */

/* ====================================
   CSS Variables (same as card-explorer)
   ==================================== */
:root {
    --axie-bg-dark:       #2a1810;
    --axie-bg-medium:     #3d2518;
    --axie-bg-light:      #5a3a28;
    --axie-accent-gold:   #f4d03f;
    --axie-accent-orange: #e67e22;
    --axie-text-light:    #f5e6d3;
    --axie-text-muted:    #c4a882;
    --axie-border:        rgba(244, 208, 63, 0.3);
    --axie-shadow:        rgba(0, 0, 0, 0.4);
}

/* ====================================
   Page Base
   ==================================== */
.leaderboard-page {
    min-height: 100vh;
    background-color: var(--axie-bg-dark);
}

/* ====================================
   Hero
   ==================================== */
.leaderboard-hero {
    position: relative;
    height: 280px;
    background-image: url('../images/card-explorer/Axie Background4.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.leaderboard-hero .hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(42, 24, 16, 0.4) 0%,
        rgba(42, 24, 16, 0.7) 70%,
        rgba(42, 24, 16, 1) 100%
    );
}

.leaderboard-hero .hero-content {
    position: relative;
    z-index: 2;
    padding: 0 20px;
}

.leaderboard-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.2rem;
    color: var(--axie-accent-gold);
    text-shadow:
        3px 3px 0 var(--axie-bg-dark),
        -1px -1px 0 var(--axie-accent-orange);
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.leaderboard-description {
    font-family: 'Inter', sans-serif;
    font-size: 1.05rem;
    color: var(--axie-text-light);
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.6;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* ====================================
   Filters Bar
   ==================================== */
.lb-filters-section {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(180deg, var(--axie-bg-medium) 0%, var(--axie-bg-dark) 100%);
    border-bottom: 3px solid var(--axie-accent-gold);
    padding: 18px 0;
    box-shadow: 0 4px 20px var(--axie-shadow);
}

.lb-filters-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: flex-end;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.65rem;
    color: var(--axie-accent-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.filter-input {
    background: var(--axie-bg-light);
    border: 2px solid var(--axie-border);
    border-radius: 8px;
    padding: 10px 40px 10px 15px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: var(--axie-text-light);
    min-width: 260px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.filter-input::placeholder { color: var(--axie-text-muted); }

.filter-input:focus {
    outline: none;
    border-color: var(--axie-accent-gold);
    box-shadow: 0 0 10px rgba(244, 208, 63, 0.3);
}

.search-wrapper { position: relative; }

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--axie-text-muted);
    pointer-events: none;
}

.lb-counter-inline {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.65rem;
    color: var(--axie-text-muted);
    padding-bottom: 12px;
    margin-left: auto;
}

.lb-counter-inline span {
    color: var(--axie-accent-gold);
    font-size: 0.8rem;
}

/* ====================================
   Separator (reuse card-explorer pattern)
   ==================================== */
.axie-separator {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.separator-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--axie-border), transparent);
}

.separator-icon {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 8px rgba(244,208,63,0.6));
}

/* ====================================
   Leaderboard Section
   ==================================== */
.lb-section {
    padding: 0 20px 60px;
}

.lb-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ====================================
   Loading / Error States
   ==================================== */
.lb-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--axie-text-muted);
    gap: 20px;
}

.lb-loading p {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.75rem;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--axie-bg-light);
    border-top-color: var(--axie-accent-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.lb-error {
    text-align: center;
    padding: 60px 20px;
    color: var(--axie-text-muted);
}

.lb-error .error-icon { font-size: 3rem; margin-bottom: 16px; }

.lb-error h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.9rem;
    color: var(--axie-accent-orange);
    margin-bottom: 12px;
}

.lb-error p {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    margin-bottom: 24px;
}

.retry-btn {
    background: linear-gradient(135deg, var(--axie-accent-orange), #c0392b);
    border: none;
    border-radius: 8px;
    padding: 12px 28px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.65rem;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.retry-btn:hover { opacity: 0.85; }

/* ====================================
   Table
   ==================================== */
.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Inter', sans-serif;
    table-layout: fixed; /* enforce column widths */
}

.lb-table thead tr {
    background: var(--axie-bg-medium);
    border-bottom: 2px solid var(--axie-accent-gold);
}

.lb-table th {
    padding: 16px 20px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.65rem;
    color: var(--axie-accent-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: left;
    white-space: nowrap;
}

/* Fixed widths — team col gets whatever remains (~640px at 1200px container) */
.lb-table th.col-rank  { width: 90px;  text-align: center; }
.lb-table th.col-player{ width: 230px; }
.lb-table th.col-team  { text-align: center; }
.lb-table th.col-vstar { width: 180px; text-align: right; }

.lb-table tbody tr {
    border-bottom: 1px solid rgba(244, 208, 63, 0.08);
    transition: background 0.2s ease;
}

.lb-table tbody tr.lb-row-clickable { cursor: pointer; }
.lb-table tbody tr:hover      { background: rgba(244, 208, 63, 0.06); }
.lb-table tbody tr.row-top3   { background: rgba(244, 208, 63, 0.08); }
.lb-table tbody tr.row-top3:hover { background: rgba(244, 208, 63, 0.13); }

.lb-table td {
    padding: 10px 20px;
    color: var(--axie-text-light);
    font-size: 1rem;
    vertical-align: middle;
    overflow: hidden;
}

/* Rank column */
.lb-table td.col-rank {
    text-align: center;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.85rem;
}

.rank-medal { font-size: 1.8rem; line-height: 1; }

.rank-num {
    display: inline-block;
    min-width: 36px;
    text-align: center;
}

.rank-top10  { color: var(--axie-accent-gold); }
.rank-normal { color: var(--axie-text-muted); }

/* Player column */
.col-player .player-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--axie-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Victory Stars column */
.lb-table td.col-vstar {
    text-align: right;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.85rem;
    color: var(--axie-accent-gold);
    white-space: nowrap;
}

.vstar-icon { margin-left: 6px; font-size: 1rem; }

/* Team column */
.lb-table td.col-team {
    padding: 8px 12px;
    text-align: center;
}

/* Group wrapper (replaces skeletons after load) */
.team-axies-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.team-axies {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Each unit: level badge + axie card side by side */
.axie-unit {
    display: flex;
    align-items: center;
    gap: 5px;
}

.team-level-badge {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.45rem;
    color: var(--axie-accent-gold);
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(244, 208, 63, 0.35);
    border-radius: 3px;
    padding: 3px 5px;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Skeleton loaders */
.team-skeleton {
    width: 160px;
    height: 160px;
    border-radius: 8px;
    background: linear-gradient(90deg,
        var(--axie-bg-light) 25%,
        var(--axie-bg-medium) 50%,
        var(--axie-bg-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.team-empty {
    color: var(--axie-text-muted);
    font-size: 1.3rem;
}

.axie-card-link {
    display: inline-block;
    text-decoration: none;
    flex-shrink: 0;
}

/* Each axie wrapper */
.axie-card-wrap {
    position: relative;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

.axie-sprite {
    width: 160px;
    height: 160px;
    object-fit: contain;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.6));
    transition: transform 0.2s ease;
}

.axie-card-wrap:hover .axie-sprite {
    transform: scale(1.08);
}


/* Runes overlay — top-left of each axie */
.axie-runes {
    position: absolute;
    top: 4px;
    left: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    width: 46px;
    z-index: 2;
}

.rune-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.6);
    background: var(--axie-bg-dark);
    object-fit: cover;
}

.rune-dot {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--axie-accent-gold);
    border: 1px solid rgba(0,0,0,0.4);
}

/* Player tier badge */
.player-tier {
    display: inline-block;
    font-size: 0.65rem;
    font-family: 'Press Start 2P', cursive;
    color: var(--axie-accent-orange);
    opacity: 0.85;
    margin-top: 4px;
}

/* Empty row */
.lb-empty-row {
    text-align: center;
    padding: 40px;
    color: var(--axie-text-muted);
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
}

/* ====================================
   Pagination
   ==================================== */
.lb-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 30px 0 10px;
}

.lb-page-btn {
    background: var(--axie-bg-medium);
    border: 2px solid var(--axie-border);
    border-radius: 8px;
    padding: 10px 22px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.6rem;
    color: var(--axie-text-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

.lb-page-btn:hover:not(:disabled) {
    border-color: var(--axie-accent-gold);
    color: var(--axie-accent-gold);
}

.lb-page-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.lb-page-label {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.65rem;
    color: var(--axie-text-muted);
}

/* ====================================
   Responsive
   ==================================== */
@media (max-width: 768px) {
    .leaderboard-title { font-size: 1.3rem; }

    .lb-table th.col-team,
    .lb-table td.col-team { display: none; }

    .lb-table th, .lb-table td { padding: 10px 10px; }

    .filter-input { min-width: 100%; }

    .lb-counter-inline { margin-left: 0; }
}
