/* ============================================================
   public/css/ranking.css
   Public ranking page — editorial sports leaderboard aesthetic
   Fonts: Barlow Condensed (display/numbers) + Outfit (body)
   ============================================================ */

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
    --ink:          #0f1117;
    --ink-soft:     #3a3d4a;
    --ink-muted:    #8a8f9e;
    --surface:      #ffffff;
    --surface-dim:  #f4f5f8;
    --border:       #e4e6ed;

    --header-bg:    #0f1117;
    --header-text:  #ffffff;
    --header-sub:   rgba(255,255,255,0.55);
    --header-intro: rgba(255,255,255,0.75);

    --rank-num-color: rgba(15,17,23,0.07);

    --chip-bg:      #f4f5f8;
    --chip-active:  #0f1117;
    --chip-text:    #5a5f6e;
    --chip-active-text: #ffffff;

    --font-display: 'Barlow Condensed', sans-serif;
    --font-body:    'Outfit', sans-serif;

    --page-max:     760px;
    --page-pad:     clamp(1rem, 5vw, 2.5rem);

    --bar-radius:   3px;
    --anim-dur:     0.55s;
    --anim-ease:    cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Base ───────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--ink);
    background: var(--surface);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: clamp(2rem, 6vw, 3.5rem) var(--page-pad) clamp(1.5rem, 4vw, 2.5rem);
}

.header-inner {
    max-width: var(--page-max);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-icon {
    flex-shrink: 0;
}

.header-icon img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 10px;
}

.site-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 3.25rem);
    font-weight: 900;
    letter-spacing: -0.01em;
    line-height: 1;
    color: var(--header-text);
    text-transform: uppercase;
}

.site-subtitle {
    margin-top: 0.375rem;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    color: var(--header-sub);
    font-weight: 500;
    letter-spacing: 0.03em;
}

.header-intro {
    max-width: var(--page-max);
    margin: 1.25rem auto 0;
    font-size: 0.9375rem;
    color: var(--header-intro);
    line-height: 1.65;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ── Main ───────────────────────────────────────────────────── */
.site-main {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 var(--page-pad) 4rem;
}

/* ── Category Filter ────────────────────────────────────────── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1.5rem 0 0.5rem;
}

.filter-chip {
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    border: 1.5px solid var(--border);
    background: var(--chip-bg);
    color: var(--chip-text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
    letter-spacing: 0.06em;
    line-height: 1;
    text-transform: uppercase;
}

.filter-chip:hover {
    border-color: var(--ink-soft);
    color: var(--ink);
    transform: translateY(-1px);
}

.filter-chip-active {
    background: var(--chip-active);
    border-color: var(--chip-active);
    color: var(--chip-active-text);
}

/* ── Ranking Section ────────────────────────────────────────── */
.ranking-section {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── Rank Row ───────────────────────────────────────────────── */
.rank-row {
    display: grid;
    grid-template-columns: 56px 1fr;
    align-items: center;
    gap: 0;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    position: relative;
    transition: opacity 0.2s;
}

.rank-row:first-child {
    border-top: 1px solid var(--border);
}

/* Hidden rows during filtering */
.rank-row[data-hidden="true"],
.upcoming-item[data-hidden="true"] {
    display: none;
}

/* ── Rank Number ────────────────────────────────────────────── */
.rank-number {
    font-family: var(--font-display);
    font-size: 2.75rem;
    font-weight: 900;
    color: var(--rank-num-color);
    line-height: 1;
    padding-right: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    user-select: none;
}

/* Top 3 get a bit more presence */
.rank-row[data-rank="1"] .rank-number { color: rgba(15,17,23,0.12); }
.rank-row[data-rank="2"] .rank-number { color: rgba(15,17,23,0.09); }
.rank-row[data-rank="3"] .rank-number { color: rgba(15,17,23,0.07); }

.tie-badge {
    font-family: var(--font-body);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
    text-transform: uppercase;
    line-height: 1;
}

/* ── Rank Content ───────────────────────────────────────────── */
.rank-content {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 0;
}

/* ── Meta row: name + score ─────────────────────────────────── */
.rank-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-width: 0;
}

/* Group keeps ⓘ glued to the name text regardless of how long the name is */
.rank-name-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
}

.rank-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.rank-score {
    font-family: var(--font-display);
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--ink);
    flex-shrink: 0;
    letter-spacing: -0.01em;
    line-height: 1;
}

/* ── Bar ────────────────────────────────────────────────────── */
.bar-track {
    position: relative;
    height: 16px;
    background: var(--surface-dim);
    border-radius: var(--bar-radius);
    overflow: visible;
    display: flex;
    align-items: center;
}

.bar-fill {
    height: 100%;
    width: 0;          /* starts at 0, animates to --bar-pct via JS */
    border-radius: var(--bar-radius);
    background: var(--bar-color, #3498db);
    transition: width var(--anim-dur) var(--anim-ease);
    will-change: width;
}

/* ── Sheet trigger icons ────────────────────────────────────── */
.sheet-trigger {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    color: var(--ink-muted);
    transition: color 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    position: relative;
    top: -1px;
}

.sheet-trigger svg {
    width: 13px;
    height: 13px;
}

.sheet-trigger:hover,
.sheet-trigger:focus {
    color: var(--ink);
    outline: none;
}

/* ── Bar animation trigger ──────────────────────────────────── */
.bars-animated .bar-fill {
    width: var(--bar-pct);
    transition-delay: var(--anim-delay, 0ms);
}

/* ── Upcoming section ───────────────────────────────────────── */
.upcoming-section {
    margin-top: 2.5rem;
}

.upcoming-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-muted);
    margin-bottom: 1rem;
}

.upcoming-heading-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.upcoming-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.upcoming-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
    transition: opacity 0.2s;
}

.upcoming-item:first-child {
    border-top: 1px solid var(--border);
}

.upcoming-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.upcoming-name {
    font-size: 0.9375rem;
    color: var(--ink-soft);
    font-weight: 500;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-ranking {
    padding: 4rem 0;
    text-align: center;
    color: var(--ink-muted);
    font-size: 0.9375rem;
}

/* No results after filter */
.no-filter-results {
    padding: 2.5rem 0;
    text-align: center;
    color: var(--ink-muted);
    font-size: 0.9375rem;
    display: none;
}

.no-filter-results.visible {
    display: block;
}

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
    border-top: 1px solid var(--border);
    text-align: center;
    padding: 1.5rem var(--page-pad);
    font-size: 0.8rem;
    color: var(--ink-muted);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.footer-copyright {
    font-size: 0.75rem;
    color: var(--ink-muted);
    opacity: 0.7;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
    .rank-row {
        grid-template-columns: 44px 1fr;
    }

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

    .rank-name {
        font-size: 0.9375rem;
    }
}

/* ── Print ──────────────────────────────────────────────────── */
@media print {
    .filter-bar,
    .tooltip-trigger { display: none; }

    .bar-fill {
        width: var(--bar-pct) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .site-header {
        background: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ==========================================================================
   Bottom Sheet — Phase 3
   ========================================================================== */

/* ── Backdrop ────────────────────────────────────────────────── */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 200;
    pointer-events: none;
    transition: background 0.3s;
}

.sheet-backdrop-visible {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

/* ── Sheet container ─────────────────────────────────────────── */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(105%);
    width: min(480px, 100vw);
    max-height: 80vh;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    z-index: 201;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.14), 0 -1px 4px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.bottom-sheet[hidden] {
    display: none;
}

.bottom-sheet-open {
    transform: translateX(-50%) translateY(0);
}

/* Drag handle bar */
.sheet-drag-bar {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 99px;
    margin: 10px auto 0;
    flex-shrink: 0;
}

/* ── Sheet header ────────────────────────────────────────────── */
.sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem 0;
    flex-shrink: 0;
}

.sheet-header-main {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
    flex: 1;
}

.sheet-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    display: inline-block;
}

.sheet-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sheet-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--surface-dim);
    border-radius: 50%;
    cursor: pointer;
    color: var(--ink-soft);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    margin-top: -2px;
}

.sheet-close:hover {
    background: var(--border);
    color: var(--ink);
}

/* ── Category tags ───────────────────────────────────────────── */
.sheet-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0.5rem 1.25rem 0;
    flex-shrink: 0;
    min-height: 0;
}

.sheet-cat-tag {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.5rem;
    background: var(--surface-dim);
    border: 1px solid var(--border);
    border-radius: 9999px;
    color: var(--ink-muted);
}

/* ── Sheet body ──────────────────────────────────────────────── */
.sheet-body {
    overflow-y: auto;
    padding: 0.75rem 1.25rem 2rem;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.sheet-empty {
    color: var(--ink-muted);
    font-size: 0.875rem;
    padding: 0.5rem 0;
}

/* ── Score list ──────────────────────────────────────────────── */
.sheet-score-list {
    list-style: none;
    margin-bottom: 0.875rem;
}

.sheet-score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.sheet-score-row:last-child {
    border-bottom: none;
}

.sheet-score-name {
    color: var(--ink-soft);
    font-weight: 500;
}

.sheet-score-val {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.01em;
    flex-shrink: 0;
}

.sheet-score-avg {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.625rem 0.875rem;
    background: var(--ink);
    color: var(--surface);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
}

.sheet-score-avg-val {
    font-family: var(--font-display);
    font-size: 1.375rem;
    font-weight: 900;
    letter-spacing: -0.01em;
}

/* ── Picks list ──────────────────────────────────────────────── */
.sheet-picks-list {
    list-style: none;
}

.sheet-picks-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.sheet-picks-row:last-child {
    border-bottom: none;
}

.sheet-picks-medal {
    font-weight: 700;
    font-size: 0.875rem;
    white-space: nowrap;
    min-width: 5.5rem;
    flex-shrink: 0;
}

.sheet-picks-name {
    color: var(--ink-soft);
    font-weight: 500;
}

/* ── Prevent body scroll when sheet open ────────────────────── */
body.sheet-open {
    overflow: hidden;
}

/* ── Upcoming item layout (picks button) ────────────────────── */
.upcoming-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 480px) {
    .bottom-sheet {
        width: 100vw;
        border-radius: 16px 16px 0 0;
    }
}

/* ── View All Picks button ───────────────────────────────────── */
.view-all-picks-wrap {
    display: flex;
    justify-content: center;
    padding: 2rem 0 0;
}

.view-all-picks-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.375rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 9999px;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink-soft);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.1s;
    letter-spacing: 0.02em;
}

.view-all-picks-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.view-all-picks-btn:hover {
    border-color: var(--ink-soft);
    color: var(--ink);
    background: var(--surface-dim);
    transform: translateY(-1px);
}

.view-all-picks-btn:active {
    transform: translateY(0);
}

/* ── All-picks table (inside bottom sheet) ───────────────────── */
.picks-all-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.25rem;
}

.picks-all-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 340px;
}

.picks-all-table thead th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.picks-all-th-participant {
    min-width: 100px;
}

.picks-all-table tbody tr {
    border-bottom: 1px solid var(--border);
}

.picks-all-table tbody tr:last-child {
    border-bottom: none;
}

.picks-all-table tbody tr:hover td {
    background: var(--surface-dim);
}

.picks-all-participant {
    padding: 0.6rem 0.75rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    vertical-align: middle;
}

.picks-all-cell {
    padding: 0.6rem 0.75rem;
    vertical-align: middle;
    min-width: 120px;
}

.picks-all-cell {
    display: table-cell; /* ensure inline-flex children behave */
}

/* Color dot + name inside each cell */
.picks-all-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 0.4rem;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

.picks-all-name {
    color: var(--ink-soft);
    font-weight: 500;
    vertical-align: middle;
}

/* "upcoming" badge on unscored picks */
.picks-all-upcoming {
    display: inline-block;
    margin-left: 0.375rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-muted);
    background: var(--surface-dim);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.1rem 0.3rem;
    vertical-align: middle;
    line-height: 1.4;
}

/* Average score on ranked picks */
.picks-all-avg {
    display: inline-block;
    margin-left: 0.375rem;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--ink-muted);
    vertical-align: middle;
    letter-spacing: -0.01em;
}

.picks-all-empty {
    color: var(--border);
    font-size: 1rem;
    text-align: center;
}

/* Tighten sheet body padding for table */
.sheet-body .picks-all-table-wrap {
    margin-top: 0.25rem;
}
