/* Linked by the pages that use it; the layer keeps its old place in the
   cascade, from when core/main.css imported it. */
@layer components {
/* Leaderboard Component Styles */

/* ================================
   Section Wrapper
   ================================ */
.leaderboard-section {
    margin-bottom: 48px;
}

/* ================================
   Header Section
   ================================ */
.dashboard-header {
    text-align: center;
    margin: 32px 0 0 0;
}

.tournament-badge {
    display: inline-block;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    padding: 10px 28px;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12),
                0 2px 4px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.tournament-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.tournament-badge:hover::before {
    left: 100%;
}

.tournament-badge h2 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--warning) 0%, var(--warning) 50%, var(--warning) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    filter: drop-shadow(0 2px 4px rgba(251, 191, 36, 0.3));
}

.header-subtitle {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    /* darker slate: #64748b on the cream band read at 3.8 to 1 */
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ================================
   Leaderboard Container
   ================================ */
.leaderboard-container {
    max-width: 1400px;
    margin: 0 auto;
    background: linear-gradient(to bottom, var(--surface), #f8fafc);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05),
                0 10px 25px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

/* ================================
   Table Structure
   ================================ */
.leaderboard-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    font-size: 0.9rem;
}

.leaderboard-table thead {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    position: relative;
}

.leaderboard-table thead::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #fbbf24, #f59e0b, #fbbf24);
}

.leaderboard-table th {
    padding: 16px 12px;
    font-weight: 700;
    text-align: center;
    font-size: 0.875rem;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    white-space: nowrap;
}

.rank-column {
    width: 80px;
    padding-left: 20px !important;
    text-align: center !important;
}

.player-column {
    text-align: left !important;
    padding-left: 20px !important;
    min-width: 180px;
}

.match-column {
    width: 70px;
}

.total-column {
    min-width: 120px;
    background: rgba(255, 255, 255, 0.15);
}

/* ================================
   Table Rows
   ================================ */
.leaderboard-row {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.leaderboard-row:hover {
    background: linear-gradient(90deg, #f1f5f9 0%, #f8fafc 100%);
    transform: scale(1.005);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.leaderboard-row:not(:last-child) {
    border-bottom: 1px solid #e2e8f0;
}

/* Top 3 Players Special Styling */
.leaderboard-row.top-player.rank-1 {
    background: linear-gradient(90deg, #fef9e7 0%, #fffbeb 100%);
}

.leaderboard-row.top-player.rank-1:hover {
    background: linear-gradient(90deg, var(--surface) 0%, #fef9e7 100%);
    border-left: 4px solid var(--warning);
}

.leaderboard-row.top-player.rank-2 {
    background: linear-gradient(90deg, #f1f5f9 0%, #f8fafc 100%);
}

.leaderboard-row.top-player.rank-2:hover {
    background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 100%);
}

.leaderboard-row.top-player.rank-3 {
    background: linear-gradient(90deg, #fef9e7 0%, #fffef9 100%);
}

.leaderboard-row.top-player.rank-3:hover {
    background: linear-gradient(90deg, #fef3cd 0%, #fef9e7 100%);
}

/* ================================
   Table Cells
   ================================ */
.leaderboard-table td {
    padding: 14px 12px;
    text-align: center;
}

/* Rank Cell */
.rank-cell {
    text-align: center;
    padding-left: 20px !important;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-weight: 700;
    transition: all 0.3s ease;
}

.rank-badge.rank-1 {
    background: transparent;
    box-shadow: none;
}

.rank-badge.rank-2 {
    background: transparent;
    box-shadow: none;
}

.rank-badge.rank-3 {
    background: transparent;
    box-shadow: none;
}

.rank-badge:not(.rank-1):not(.rank-2):not(.rank-3) {
    background: linear-gradient(135deg, var(--surface-3) 0%, var(--accent-teal) 100%);
    color: var(--bg-footer);
    font-size: 0.95rem;
}

.rank-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.rank-number {
    font-size: 1.1rem;
    color: #1e293b;
}

/* Player Name Cell */
.player-name-cell {
    text-align: left;
    padding-left: 20px !important;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1e293b;
    letter-spacing: 0.3px;
}

.leaderboard-row.rank-1 .player-name {
    color: #b45309;
}

.leaderboard-row.rank-2 .player-name {
    color: #475569;
}

.leaderboard-row.rank-3 .player-name {
    color: #92400e;
}

/* Score Cells */
.score-cell {
    font-weight: 500;
    color: #475569;
    font-variant-numeric: tabular-nums;
}

/* Total Cell */
.total-cell {
    background: linear-gradient(135deg, #eff6ff 0%, var(--surface) 100%);
    font-weight: 700;
    padding: 14px 16px !important;
    border-left: 4px solid var(--accent-teal);
}

.total-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    letter-spacing: 0.5px;
    font-variant-numeric: tabular-nums;
}

.leaderboard-row.rank-1 .total-score {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #78350f;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.4);
}

.leaderboard-row.rank-2 .total-score {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.4);
}

.leaderboard-row.rank-3 .total-score {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}

/* ================================
   Actions Section
   ================================ */
.leaderboard-actions {
    margin-top: 4px;
    display: flex;
    justify-content: center;
    gap: 16px;
}

.button-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 28px;
    background: linear-gradient(135deg, var(--accent-teal) 0%, var(--accent-teal) 100%);
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    border: none;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.button-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
    background: linear-gradient(135deg, var(--accent-teal-dark) 0%, var(--accent-teal-dark) 100%);
}

.button-link:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.button-icon {
    font-size: 1rem;
}

.button-text {
    font-size: 0.9rem;
}

/* ================================
   Empty State
   ================================ */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    background: linear-gradient(to bottom, #f8fafc, var(--surface));
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.6;
}

.no-results {
    font-size: 1.1rem;
    color: #64748b;
    font-weight: 600;
    margin: 8px 0;
}

.no-results-subtitle {
    font-size: 0.9rem;
    color: #94a3b8;
    margin: 4px 0;
}

/* ================================
   Responsive Design
   ================================ */
@media (max-width: 768px) {
    .tournament-badge h2 {
        font-size: 1.5rem;
    }

    .leaderboard-container {
        padding: 16px;
        border-radius: 12px;
    }

    .leaderboard-table {
        font-size: 0.875rem;
    }

    .leaderboard-table th {
        padding: 12px 8px;
        font-size: 0.875rem;
    }

    .leaderboard-table td {
        padding: 10px 6px;
    }

    .rank-column {
        width: 60px;
        padding-left: 12px !important;
    }

    .player-column {
        min-width: 120px;
        padding-left: 12px !important;
    }

    .match-column {
        width: 55px;
    }

    .rank-badge {
        width: 36px;
        height: 36px;
    }

    .rank-icon {
        font-size: 1.6rem;
    }

    .player-name {
        font-size: 0.875rem;
    }

    .total-score {
        padding: 4px 12px;
        font-size: 0.9rem;
    }

    .button-link {
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .dashboard-header {
        margin: 20px 0;
    }

    .tournament-badge {
        padding: 8px 20px;
    }

    .tournament-badge h2 {
        font-size: 1.3rem;
        letter-spacing: 1px;
    }

    .header-subtitle {
        font-size: 0.875rem;
        letter-spacing: 1.5px;
    }

    .leaderboard-container {
        padding: 4px 2px;
        border-radius: 8px;
    }

    .leaderboard-table {
        font-size: 0.875rem;
    }

    .leaderboard-table th {
        padding: 6px 2px;
        font-size: 0.875rem;
        letter-spacing: 0;
        /* At the floor size a one-line heading runs over its neighbour on a
           phone, so here a heading wraps and the columns carry its width. */
        white-space: normal;
    }

    .leaderboard-table td {
        padding: 6px 2px;
    }

    .rank-column {
        width: 46px;
        padding-left: 2px !important;
    }

    .player-column {
        min-width: 0;
        width: auto;
        padding-left: 4px !important;
    }

    .match-column {
        width: 48px;
        padding: 6px 2px !important;
    }

    .total-column {
        min-width: 0;
        width: 64px;
        padding: 6px 2px !important;
    }

    .rank-cell {
        padding-left: 2px !important;
        padding-right: 1px !important;
    }

    .player-name-cell {
        padding-left: 4px !important;
        padding-right: 2px !important;
    }

    .rank-badge {
        width: 24px;
        height: 24px;
        border-radius: 5px;
    }

    .rank-icon {
        font-size: 1.2rem;
    }

    .rank-number {
        font-size: 0.875rem;
    }

    .player-name {
        font-size: 0.875rem;
    }

    .score-cell {
        font-size: 0.875rem;
    }

    .total-cell {
        padding: 6px 2px !important;
    }

    .total-score {
        padding: 2px 5px;
        font-size: 0.875rem;
        border-radius: 5px;
    }

    .leaderboard-actions {
        margin-top: 16px;
    }

    .button-link {
        padding: 2px 12px;
        font-size: 0.875rem;
        gap: 6px;
    }

    .empty-state {
        padding: 60px 16px;
    }

    .empty-icon {
        font-size: 3rem;
    }
}

/* 480 -- space is gold: the shell gives its padding back to the content. */
@media (max-width: 480px) {
  .leaderboard-container { padding-left: 4px; padding-right: 4px; }
}

}

/* Champions: the month beside the title, once written on the tag. Outside
   the layer, as a tag's own style outranked every layer. */
.header-subtitle.header-subtitle--bold { font-weight: 700; }

/* Champions: a free cup's name in its leaderboard title (games'
   includes/cup_leaderboard.html), once written on the tag. */
.leaderboard-title .lb-cup-name { font-size: 1rem; }
