/*
 * OPPOSITUM — Event Leaderboard Styles (leaderboard.html)
 *
 * Same look as history.css / landing.css:
 * Carved Obsidian · Bioluminescent Amethyst · Smoldering Copper
 * Self-contained on top of style.css so edits to other pages do not move this one.
 */

:root {
    --indigo-deep: #0d0a2e;
    --copper: #c2723a;
    --copper-light: #e8914c;
    --amethyst: #b44fff;
    --carved-shadow: inset 0 2px 8px rgba(0,0,0,0.9),
                     inset 0 -1px 0px rgba(180,79,255,0.15);
    --copper-glow: 0 0 18px rgba(194,114,58,0.35);
    --text-muted: rgba(243,244,246,0.62);
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ─── Header / Navegación ─── */
.lb-header {
    padding: 16px 32px;
    padding-top: max(16px, env(safe-area-inset-top));
    background: linear-gradient(180deg, #0b0710 0%, rgba(13,10,46,0.97) 100%);
    border-bottom: 1px solid rgba(180, 79, 255, 0.2);
    box-shadow: 0 4px 24px rgba(0,0,0,0.8), 0 1px 0 rgba(180,79,255,0.12);
    position: sticky;
    top: 0;
    z-index: 100;
}

.lb-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 1000px;
    margin: 0 auto;
}

.lb-nav h1 {
    font-size: 1.5rem;
    letter-spacing: 0.08em;
    margin: 0 0 0 auto;
}

.btn-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;                /* override global button width:100% */
    min-height: 44px;
    padding: 8px 18px;
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--text-secondary);
    border: 1px solid rgba(139,92,246,0.3);
    border-radius: 4px;
    background: rgba(124,58,237,0.08);
    box-shadow: var(--carved-shadow);
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-nav:hover {
    color: var(--text-gold);
    border-color: rgba(251,191,36,0.5);
    background: rgba(251,191,36,0.06);
    box-shadow: var(--carved-shadow), 0 0 14px rgba(251,191,36,0.2);
    transform: translateY(-1px);
}

.btn-nav:focus-visible,
.btn-link:focus-visible,
.lb-rules summary:focus-visible {
    outline: 2px solid var(--text-gold);
    outline-offset: 2px;
}

.btn-primary-nav {
    color: #ffffff !important;
    border-color: var(--copper) !important;
    background: linear-gradient(135deg, #8b3a0f 0%, var(--copper) 55%, #e8914c 100%) !important;
    box-shadow: 0 2px 0 #4a1a05, var(--copper-glow) !important;
}

.btn-primary-nav:hover {
    background: linear-gradient(135deg, var(--copper) 0%, var(--copper-light) 100%) !important;
    box-shadow: 0 3px 0 #4a1a05, 0 0 20px rgba(232,145,76,0.5) !important;
}

/* ─── Main ─── */
.lb-main {
    flex: 1;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 28px 20px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* ─── Intro: event window + rules ─── */
.lb-intro {
    width: 100%;
    max-width: 760px;
    text-align: center;
}

.lb-intro-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.lb-phase {
    font-family: 'Cinzel', serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 20px;
    color: var(--text-secondary);
    border: 1px solid rgba(139,92,246,0.4);
    background: rgba(124,58,237,0.12);
    white-space: nowrap;
}

.lb-phase.is-live {
    color: #6ee7b7;
    border-color: rgba(16,185,129,0.45);
    background: rgba(16,185,129,0.12);
}

.lb-phase.is-live::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    vertical-align: 1px;
}

.lb-phase.is-closed {
    color: var(--copper-light);
    border-color: rgba(194,114,58,0.45);
    background: rgba(194,114,58,0.12);
}

.lb-window {
    font-size: 14px;
    color: var(--text-muted);
}

.lb-rules {
    margin: 14px auto 0;
    max-width: 560px;
    text-align: left;
    border: 1px solid rgba(139,92,246,0.2);
    border-radius: 4px;
    background: linear-gradient(160deg, rgba(26,15,46,0.7) 0%, rgba(13,10,30,0.8) 100%);
    box-shadow: var(--carved-shadow);
}

.lb-rules summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--copper-light);
    cursor: pointer;
    list-style: none;
}

.lb-rules summary::-webkit-details-marker {
    display: none;
}

.lb-rules summary::after {
    content: '▾';
    margin-left: 8px;
    transition: transform 0.2s ease;
}

.lb-rules[open] summary::after {
    transform: rotate(180deg);
}

.lb-rules ul {
    margin: 0;
    padding: 0 18px 14px 34px;
    font-size: 14px;
    line-height: 1.6;
    color: rgba(243,244,246,0.8);
}

.lb-rules li + li {
    margin-top: 4px;
}

.lb-rules strong {
    color: var(--text-gold);
}

/* ─── Estados (loading, error, vacío) ─── */
.state-container {
    width: 100%;
    max-width: 500px;
    padding: 32px 24px;
    text-align: center;
    background: linear-gradient(160deg, rgba(26,15,46,0.9) 0%, rgba(13,10,30,0.95) 100%);
    border: 1px solid rgba(139,92,246,0.2);
    border-radius: 4px;
    box-shadow: var(--carved-shadow), 0 8px 32px rgba(0,0,0,0.6);
    animation: lbFadeIn 0.3s ease-out;
}

.state-container p {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.state-container p + p {
    margin-top: 8px;
}

#lb-loading p {
    font-family: 'Cinzel', serif;
    letter-spacing: 0.1em;
    color: var(--copper-light);
}

.lb-error-text {
    color: var(--danger) !important;
    font-weight: 600;
}

.lb-hint {
    font-size: 13px !important;
    color: var(--text-muted) !important;
}

#lb-retry {
    margin-top: 18px;
}

.lb-spinner {
    display: block;
    width: 28px;
    height: 28px;
    margin: 0 auto 14px;
    border-radius: 50%;
    border: 3px solid rgba(180,79,255,0.2);
    border-top-color: var(--amethyst);
    animation: lbSpin 0.9s linear infinite;
}

/* ─── Tabla ─── */
.lb-board {
    width: 100%;
    max-width: 760px;
    background: linear-gradient(160deg, rgba(26,15,46,0.9) 0%, rgba(13,10,30,0.95) 100%);
    border: 1px solid rgba(139,92,246,0.22);
    border-radius: 4px;
    box-shadow: var(--carved-shadow), 0 8px 32px rgba(0,0,0,0.6);
    overflow: hidden;
    animation: lbFadeIn 0.3s ease-out;
}

/* Stands above the table or the empty card, whichever was last loaded. */
.lb-stale {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 12px;
    max-width: 100%;
    padding: 8px 14px;
    font-size: 13px;
    text-align: center;
    color: #fca5a5;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.35);
    border-radius: 4px;
}

.btn-link {
    width: auto;
    min-height: 40px;
    padding: 6px 10px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-gold);
    background: transparent;
    border: 1px solid rgba(251,191,36,0.4);
    border-radius: 4px;
    box-shadow: none;
}

.btn-link:hover {
    background: rgba(251,191,36,0.08);
    border-color: var(--text-gold);
    box-shadow: none;
    transform: none;
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.lb-table th,
.lb-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(139,92,246,0.12);
}

.lb-table thead th {
    font-family: 'Cinzel', serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: rgba(11,7,16,0.55);
    border-bottom: 1px solid rgba(139,92,246,0.3);
    white-space: nowrap;
}

.lb-table tbody tr:nth-child(even) {
    background: rgba(124,58,237,0.045);
}

.lb-table tbody tr:last-child th,
.lb-table tbody tr:last-child td {
    border-bottom: none;
}

.lb-table .col-rank {
    width: 3.6em;
    text-align: center;
}

.lb-table tbody .col-name {
    font-weight: 600;
    color: var(--text-primary);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.lb-table .col-num {
    width: 1%;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.lb-table td.col-num {
    color: var(--text-muted);
}

.lb-table td.col-points {
    color: var(--text-gold);
    font-weight: 700;
    font-size: 1.05em;
}

.lbl-short {
    display: none;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2em;
    height: 2em;
    padding: 0 0.35em;
    border-radius: 999px;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 0.95em;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.rank-1 .rank-badge {
    color: #1a1205;
    background: linear-gradient(135deg, #fde68a 0%, #fbbf24 55%, #b45309 100%);
    box-shadow: 0 0 12px rgba(251,191,36,0.45);
}

.rank-2 .rank-badge {
    color: #0f172a;
    background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 55%, #64748b 100%);
    box-shadow: 0 0 10px rgba(203,213,225,0.3);
}

.rank-3 .rank-badge {
    color: #1c0a02;
    background: linear-gradient(135deg, #f3c49b 0%, var(--copper) 55%, #7c2d12 100%);
    box-shadow: 0 0 10px rgba(194,114,58,0.4);
}

.rank-1 .col-name {
    color: var(--text-gold) !important;
}

.lb-footnote {
    padding: 10px 14px 12px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid rgba(139,92,246,0.12);
}

.lb-updated {
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-align: center;
}

/* ─── Footer ─── */
.lb-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(139,92,246,0.1);
    background: rgba(11,7,16,0.9);
}

#version-label {
    font-family: 'Cinzel', serif;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(167,139,250,0.3);
}

@keyframes lbFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@media (prefers-reduced-motion: reduce) {
    .state-container,
    .lb-board {
        animation: none;
    }
    .lb-spinner {
        animation-duration: 3s;
    }
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .lb-header {
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .lb-nav {
        gap: 8px;
    }

    .lb-nav h1 {
        order: 3;
        width: 100%;
        margin: 4px 0 0;
        text-align: center;
        font-size: 1.1rem;
        letter-spacing: 0.06em;
    }

    .lb-nav .btn-nav {
        flex: 1 1 0;
    }

    .lb-main {
        padding: 20px 12px 36px;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .lb-table {
        font-size: 14px;
    }

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

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

    .lb-table th:last-child,
    .lb-table td:last-child {
        padding-right: 12px;
    }

    .lb-table .col-rank {
        width: 2.8em;
    }

    .lb-table thead th {
        letter-spacing: 0.06em;
    }

    .lbl-long {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .lbl-short {
        display: inline;
    }
}

/* Phones in landscape: keep the table on screen instead of a sticky header. */
@media (max-height: 500px) and (orientation: landscape) {
    .lb-header {
        position: static;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .lb-main {
        padding-top: 16px;
        gap: 14px;
    }

    .lb-table th,
    .lb-table td {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .lb-header,
    .lb-main,
    .lb-footer {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
}
