/* The leaderboard's styling.
 *
 * Moved out of templates/leaderboard.html on 2026-08-31 (2 blocks,
 * concatenated in source order). It was inline in the HTML, so no
 * browser could cache a byte of it and it was re-sent on every
 * request. url_for('static', ...) stamps this URL with the file's own
 * CONTENT hash and serves it immutable for a year.
 *
 * Byte-for-byte the blocks that were there; only the address moved.
 */

    .lb-page { max-width: 100%; margin: 2rem auto; padding: 0; }
    .lb-page h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
    .lb-page .subtitle { color: var(--text-secondary); margin-bottom: 1.5rem; }

    /* tabs use global .page-tabs / .page-tab from style.css */

    /* Search */
    .lb-search {
        margin-bottom: 1rem; position: relative;
    }
    .lb-search input {
        width: 100%; padding: 0.6rem 0.8rem 0.6rem 2.2rem;
        background: var(--bg-card); border: 1px solid var(--border);
        border-radius: 10px; color: var(--text-heading); font-size: 0.85rem;
        outline: none; transition: border-color 0.2s;
        box-sizing: border-box;
    }
    .lb-search input:focus { border-color: var(--accent); }
    .lb-search input::placeholder { color: var(--text-muted); }
    .lb-search .search-icon {
        position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%);
        color: var(--text-muted); font-size: 0.85rem; pointer-events: none;
    }

    /* Ranked table dressed toward the .a-* kit look: rows read as list
       rows on a card surface, hover lift, kit radii. Table structure is
       preserved (infinite-scroll JS appends <tr>/<td>). */
    .lb-table-card {
        background: var(--bg-card); border: 1px solid var(--border);
        border-radius: var(--r, 14px); box-shadow: var(--shadow);
        padding: 0.25rem 1rem; margin-top: 0.25rem;
    }
    .lb-table { width: 100%; border-collapse: collapse; }
    .lb-table th {
        text-align: left; color: var(--text-muted); padding: 0.6rem 0.5rem;
        border-bottom: 1px solid var(--border-subtle); font-weight: 700;
        font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
    }
    .lb-table td { padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--border-subtle); }
    .lb-table tbody tr:last-child td { border-bottom: none; }
    .lb-table tbody tr { transition: background 0.15s ease; }
    .lb-table tbody tr:hover td { background: color-mix(in srgb, var(--scheme-primary) 5%, transparent); }

    .lb-rank {
        width: 40px; font-weight: 900; font-size: 1.05rem;
        font-variant-numeric: tabular-nums; color: var(--text-muted);
    }
    .lb-rank.gold { color: var(--gold); }
    .lb-rank.silver { color: var(--text-secondary); }
    .lb-rank.bronze { color: var(--orange); }

    /* Bar logo chip — kit .a-row .ic shape, used in the podium + (optionally)
       reused vocabulary. The table keeps its inline .icon span. */
    .lb-logo {
        width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
        display: grid; place-items: center; font-size: 19px;
        background: var(--bg-inset); border: 1px solid var(--border-subtle);
    }

    /* Movement pill (rank delta) — kit .a-pill flavour, rendered inline
       in the metric cell. Up = green, flat = neutral, down = red. */
    .lb-move {
        display: inline-flex; align-items: center; gap: 4px; font-size: 0.68rem;
        font-weight: 700; padding: 3px 9px; border-radius: 999px;
        white-space: nowrap; vertical-align: middle;
        background: var(--bg-inset); color: var(--text-secondary);
        border: 1px solid var(--border-subtle);
    }
    .lb-move.up { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); border-color: color-mix(in srgb, var(--green) 34%, transparent); }
    .lb-move.down { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); border-color: color-mix(in srgb, var(--red) 34%, transparent); }

    /* Player's own row highlight — mockup .me (outline). Kept distinct from
       the existing pinned .lb-you-row treatment. */
    .lb-table tbody tr.me td { background: color-mix(in srgb, var(--scheme-primary) 7%, transparent); }
    .lb-table tbody tr.me td:first-child { box-shadow: inset 3px 0 0 var(--scheme-primary); }
    .lb-you-chip {
        display: inline-flex; align-items: center; font-size: 0.6rem;
        font-weight: 800; padding: 2px 8px; border-radius: 999px;
        letter-spacing: 0.05em; vertical-align: middle; margin-left: 0.3rem;
        background: color-mix(in srgb, var(--scheme-primary) 16%, transparent);
        color: var(--scheme-primary);
        border: 1px solid color-mix(in srgb, var(--scheme-primary) 34%, transparent);
    }

    /* ---- Top-3 podium (built from the first 3 server-rendered rows) ---- */
    .lb-podium {
        display: grid; grid-template-columns: repeat(3, 1fr);
        gap: 14px; margin: 0.5rem 0 1.25rem; align-items: end;
    }
    .lb-podium-card {
        background: var(--bg-card); border: 1px solid var(--border);
        border-radius: var(--r, 14px); box-shadow: var(--shadow);
        padding: 16px 14px; text-align: center; text-decoration: none;
        display: block; transition: transform 0.15s ease;
    }
    .lb-podium-card:hover { transform: translateY(-2px); }
    .lb-podium-card .lb-logo { width: 48px; height: 48px; margin: 0 auto; font-size: 22px; }
    .lb-podium-card .lb-pod-name {
        font-weight: 800; color: var(--text-heading); margin-top: 8px;
        font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .lb-podium-card .lb-pod-metric { font-variant-numeric: tabular-nums; margin-top: 2px; font-size: 0.85rem; }
    .lb-podium-card .lb-pod-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
    .lb-podium-card.first {
        border-color: color-mix(in srgb, var(--gold) 45%, var(--border));
        transform: translateY(-8px);
    }
    .lb-podium-card.first:hover { transform: translateY(-10px); }
    .lb-podium-card.first .lb-logo { width: 56px; height: 56px; font-size: 24px; }
    .lb-podium-card.first .lb-pod-name { font-size: 1.05rem; font-weight: 900; }
    .lb-podium-card.first .lb-pod-metric { color: var(--gold); font-weight: 800; }
    .lb-pod-rankbadge {
        display: inline-flex; align-items: center; justify-content: center;
        font-size: 0.7rem; font-weight: 800; color: var(--text-muted);
        font-variant-numeric: tabular-nums; letter-spacing: 0.04em;
    }
    .lb-podium-card.first .lb-pod-rankbadge { color: var(--gold); }
    @media (max-width: 600px) {
        .lb-podium { gap: 8px; margin: 0.25rem 0 1rem; }
        .lb-podium-card { padding: 12px 8px; }
        .lb-podium-card .lb-pod-name { font-size: 0.8rem; }
        .lb-table-card { padding: 0.1rem 0.5rem; }
    }

    .lb-bar { display: flex; align-items: center; gap: 0.75rem; }
    .lb-bar .icon { font-size: 1.3rem; }
    .lb-bar .name { font-weight: 700; color: var(--text-heading); }
    .lb-bar .owner { font-size: 0.8rem; color: var(--text-secondary); }

    .lb-metric { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
    .lb-days { color: var(--text-secondary); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

    .empty-lb { text-align: center; padding: 3rem; color: var(--text-secondary); }

    /* No horizontal scroll — let the table contract (table-layout: auto
       + column rules below do the work). A horizontal scrollbar across
       the whole board at narrow desktop widths looks broken. */
    .table-scroll { overflow-x: hidden; }
    .lb-table { table-layout: auto; }
    /* Trend sparkline + day-count are the first columns to shrink on
       narrow desktops — the Bar column stays priority. */
    @media (max-width: 1000px) {
        .lb-table th:nth-child(5), .lb-table td:nth-child(5),
        .lb-table th:nth-child(6), .lb-table td:nth-child(6) {
            white-space: nowrap;
        }
        .lb-table th:nth-child(3), .lb-table td:nth-child(3) {
            display: none;   /* hide "Best day" on ≤1000px so Metric fits */
        }
    }

    /* Bell button — inline with bar name */
    .bell-btn {
        background: none; border: 1px solid rgba(255, 215, 0, 0.27); border-radius: 50%;
        width: 32px; height: 32px; font-size: 1rem; cursor: pointer;
        transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center;
        padding: 0; flex-shrink: 0;
    }
    .bell-btn:hover { background: rgba(255, 215, 0, 0.15); border-color: var(--gold); transform: scale(1.15); }
    .bell-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
    .bell-rang { font-size: 1rem; opacity: 0.5; }
    .bell-sent {
        display: inline-flex; align-items: center; gap: 0.3rem;
        font-size: 0.7rem; color: var(--green); font-weight: 600;
        flex-shrink: 0;
    }
    .bell-cell { display: flex; align-items: center; }

    /* Flag-rival button — inline with bar name, purple to match the ⚔️ rivalry theme */
    .lb-rival-btn {
        background: none; border: 1px solid rgba(142, 68, 173, 0.32); border-radius: 50%;
        width: 32px; height: 32px; font-size: 0.9rem; cursor: pointer; color: #8e44ad;
        transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center;
        padding: 0; flex-shrink: 0;
    }
    .lb-rival-btn:hover { background: rgba(142, 68, 173, 0.14); border-color: #8e44ad; transform: scale(1.15); }
    .lb-rival-btn:disabled { opacity: 0.75; cursor: default; transform: none; }

    /* Infinite scroll */
    .lb-loading {
        text-align: center; padding: 1.5rem; color: var(--text-muted);
    }
    .lb-loading .spinner {
        display: inline-block; width: 20px; height: 20px;
        border: 2px solid var(--border); border-top-color: var(--accent);
        border-radius: 50%; animation: lb-spin 0.6s linear infinite;
        margin-right: 0.5rem; vertical-align: middle;
    }
    @keyframes lb-spin { to { transform: rotate(360deg); } }
    .lb-end { text-align: center; padding: 1rem; color: #3a3a5a; font-size: 0.8rem; }

    /* Pinned "your bar" row */
    .lb-table tr.lb-you-row td,
    .lb-table tr.lb-you-row-inline td {
        background: color-mix(in srgb, var(--accent) 10%, transparent);
        border-bottom: 2px solid var(--accent);
    }
    .lb-table tr.lb-you-row td:first-child,
    .lb-table tr.lb-you-row-inline td:first-child { border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
    .lb-table tr.lb-you-row td:last-child,
    .lb-table tr.lb-you-row-inline td:last-child { border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
    .lb-you-badge {
        display: inline-block; font-size: 0.6rem; font-weight: 800;
        background: var(--accent); color: #111; padding: 0.1rem 0.4rem;
        border-radius: 10px; margin-right: 0.35rem; letter-spacing: 0.05em;
        vertical-align: middle;
    }
    .lb-you-label {
        font-size: 0.68rem; color: var(--text-muted); font-weight: 600;
        margin-top: 0.15rem;
    }
    .lb-gap-pill {
        display: inline-block; font-size: 0.68rem; font-weight: 700;
        padding: 0.15rem 0.55rem; border-radius: 20px;
        background: color-mix(in srgb, var(--gold) 12%, transparent);
        color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
        margin-top: 0.2rem; white-space: nowrap;
    }
    .lb-gap-pill.at-top {
        background: color-mix(in srgb, var(--green) 12%, transparent);
        color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, transparent);
    }

    /* Sparkline */
    .lb-spark {
        width: 60px; height: 20px; vertical-align: middle;
        overflow: visible;
    }
    .lb-spark polyline {
        fill: none; stroke: var(--accent); stroke-width: 1.5;
        stroke-linecap: round; stroke-linejoin: round;
        opacity: 0.85;
    }
    .lb-spark circle { fill: var(--accent); }
    .lb-spark-empty {
        display: inline-block; width: 60px; height: 20px;
        color: var(--text-muted); font-size: 0.7rem; text-align: center;
        line-height: 20px;
    }

    @media (max-width: 600px) {
        .lb-page h1 { font-size: 1.4rem; }
        .table-scroll { overflow-x: hidden; }
        /* `table-layout: auto` lets the browser allocate width by content —
           but we still cap the rank/trend/days columns so the Bar column
           keeps the bulk of the row. Previously we had `table-layout: fixed`
           with no column widths, which stripped the Bar name down to a
           column so narrow it wrapped character-by-character vertically. */
        .lb-table { min-width: 0; width: 100%; font-size: 0.75rem; table-layout: auto; }
        .lb-table th, .lb-table td { padding: 0.35rem 0.2rem; vertical-align: middle; }
        .lb-table th:first-child, .lb-table td:first-child { padding-left: 0.25rem; }
        .lb-rank { width: 28px; padding-left: 0.15rem !important; font-size: 0.95rem; }
        /* Bar is the priority column — give it every available pixel. */
        .lb-table th:nth-child(2), .lb-table td:nth-child(2) { width: auto; }
        /* Metric columns: shrink-to-fit, nowrap so numbers don't split. */
        .lb-table th:nth-child(3), .lb-table td:nth-child(3),
        .lb-table th:nth-child(4), .lb-table td:nth-child(4) {
            width: 1%; white-space: nowrap;
        }
        /* Trend sparkline + Days — fixed narrow. */
        .lb-table th:nth-child(5), .lb-table td:nth-child(5) { width: 60px; }
        .lb-table th:nth-child(6), .lb-table td:nth-child(6) { width: 32px; }
        .lb-bar { gap: 0.4rem; flex-wrap: nowrap; min-width: 0; }
        .lb-bar .icon { font-size: 0.9rem; flex-shrink: 0; }
        /* `overflow-wrap: anywhere` was breaking long names one character
           per line whenever the column got squeezed. `break-word` only
           breaks at natural word boundaries, falls back to character
           breaks only when a single word is longer than the cell. */
        .lb-bar .name {
            font-size: 0.75rem;
            white-space: normal;
            overflow-wrap: break-word;
            word-break: normal;
            min-width: 0;
        }
        .lb-bar .owner { white-space: normal; overflow-wrap: break-word; min-width: 0; }
        .lb-metric { white-space: nowrap; }
        .bell-btn { width: 28px; height: 28px; font-size: 0.85rem; min-width: 28px; flex-shrink: 0; }
        .bell-sent { font-size: 0.65rem; }
    }

    @media (max-width: 600px) {
        /* On non-yesterday tabs, Best Day duplicates the yesterday view's
           drinks column and pushes the primary Metric column into a sliver
           too narrow for the header label (e.g. 'Team Va' clipped). Hide
           it on mobile so the tab the user actually picked gets full width. */
        .lb-table[data-tab]:not([data-tab="yesterday"]) th:nth-child(3),
        .lb-table[data-tab]:not([data-tab="yesterday"]) td:nth-child(3) {
            display: none;
        }
        /* With Best Day gone, the metric column can wrap its header if the
           label is long (e.g. 'Team Value', 'Avg/Day'). Numbers still nowrap. */
        .lb-table[data-tab]:not([data-tab="yesterday"]) th:nth-child(4) { white-space: normal; }
    }

    @media (max-width: 400px) {
        .lb-table th:nth-child(5), .lb-table td:nth-child(5) { display: none; } /* Trend */
        .lb-table th:nth-child(6), .lb-table td:nth-child(6) { display: none; } /* Days */
        .lb-rank { width: 26px; padding-left: 0.15rem !important; }
        .lb-table th, .lb-table td { padding: 0.3rem 0.15rem; }
        /* Keep the bell button visible on narrow phones — it's the whole
           reason people come to the leaderboard. Shrink it instead of
           hiding it (previously display:none, which made the bell
           genuinely unreachable on ≤400px screens). */
        .bell-btn { width: 22px; height: 22px; font-size: 0.7rem; min-width: 22px; }
        .bell-sent { font-size: 0.55rem; }
    }


    .lb-dropdown { position: relative; display: inline-block; }
    .lb-dropdown-menu {
        display: none; position: absolute; top: calc(100% + 4px); left: 0;
        min-width: 180px; background: var(--bg-card-solid);
        border: 1px solid var(--border); border-radius: 10px;
        padding: 0.35rem; z-index: 20;
        box-shadow: 0 4px 14px rgba(0,0,0,0.3);
    }
    .lb-dropdown.open .lb-dropdown-menu { display: block; }
    .lb-dropdown-menu a {
        display: block; padding: 0.5rem 0.8rem;
        color: var(--text-primary); text-decoration: none;
        border-radius: 6px; font-size: 0.85rem;
    }
    .lb-dropdown-menu a:hover { background: var(--accent-hover-bg); }
    .lb-dropdown-menu a.active { color: var(--scheme-primary); font-weight: 700; }
    #lbSocialFilter.active { border-color: var(--scheme-primary); color: var(--scheme-primary); background: color-mix(in srgb, var(--scheme-primary) 10%, transparent); }
    