/*
 * Live Stats — Portal-native styles.
 *
 * Everything here is scoped under `.live-stats-app` (the <main> wrapper in
 * live-stats/base.twig) so the app's custom component classes coexist with
 * Bootstrap 5.3 instead of colliding the way the classic standalone CSS did
 * (it styled bare `body`/`table`/`h1`). Generic chrome — groups, tables,
 * buttons, forms, tabs, banners — comes from Bootstrap + the portal kit; this
 * file only adds the genuinely Live-Stats-specific bits (the fight-detail
 * matchup art, the comparison-table label column, the bot-search box, the
 * events picker).
 *
 * The .stat-section / .stat-row / .stat-val family that used to live here is
 * gone (2026-08-15): it was a bordered box with an accent title BAR and
 * light-dark-light banded rows, which is a card where the section wanted a
 * group plus the zebra the contract bans. Those pages are groups + kit rows or
 * real tables now, and the service stopped computing a stripe.
 *
 * Colors go exclusively through Bootstrap tokens (var(--bs-*)) and Portal tokens
 * (var(--portal-*)); the two Live-Stats accents below map onto Portal brand
 * tokens so both light and dark themes work with no hard-coded values.
 */

.live-stats-app {
    /* Teal is the Live Stats accent (fills, headers). As TEXT it's too light on
       a white canvas, so --ls-accent-text swaps to brand purple in light mode. */
    --ls-accent: var(--portal-accent-teal);
    --ls-accent-text: var(--portal-accent-teal);
    --ls-accent-soft: color-mix(in srgb, var(--portal-accent-teal) 14%, transparent);
    --ls-magenta: var(--portal-accent);
    /* Ink on a teal fill. Was a fixed #212529 "same in both themes", which
       was only ever right for the dark theme: the light theme accent is a much
       darker teal, so near-black ink on it is unreadable. The kit token knows
       both — near-black on dark, white on light. */
    --ls-on-accent: var(--portal-c-on-accent);

    padding-block: 1.5rem;
}

:root[data-bs-theme="light"] .live-stats-app {
    --ls-accent-text: var(--portal-nhrl-purple);
}

.live-stats-app .live-stats-subnav { gap: 0.25rem; }

/* Rank / points movement.
 *
 * The direction comes from the view-model (LiveStatsPageService returns
 * up | down | new | flat) and the color is decided HERE, from the theme's
 * semantic tokens. Until 2026-08-14 the service returned hex literals that the
 * template wrote into style="color: …" — six of them, invisible to the "no hex
 * in page CSS" review grep because they were in PHP, and fixed against a page
 * that has a light theme. One attribute selector replaces all of that.
 *
 * `new` takes the accent rather than a status color: a bot appearing for the
 * first time is not good or bad news, it is new. */
.live-stats-app .ls-delta[data-dir="up"] {
    color: var(--portal-c-badge-success-color);
}
.live-stats-app .ls-delta[data-dir="down"] {
    color: var(--portal-c-badge-danger-color);
}
.live-stats-app .ls-delta[data-dir="new"] {
    color: var(--portal-c-accent);
}
.live-stats-app .ls-delta[data-dir="flat"] {
    color: var(--portal-c-text-muted);
}

.live-stats-app .ls-rank-col {
    width: 3rem;
    color: var(--bs-secondary-color);
}
.live-stats-app .ls-muted {
    color: var(--bs-secondary-color);
}

/* ===== Fight Detail: matchup header ===== */
.live-stats-app .matchup-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 1.75rem 1.25rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.live-stats-app .matchup-bot {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 300px;
}

.live-stats-app .bot-image-wrap {
    width: 140px;
    height: 140px;
    border-radius: var(--bs-border-radius);
    overflow: hidden;
    background: var(--bs-tertiary-bg);
    border: 2px solid var(--bs-border-color);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.live-stats-app .matchup-bot-left .bot-image-wrap {
    border-color: var(--ls-magenta);
    box-shadow: 0 0 16px color-mix(in srgb, var(--ls-magenta) 35%, transparent);
}

.live-stats-app .matchup-bot-right .bot-image-wrap {
    border-color: var(--ls-accent);
    box-shadow: 0 0 16px color-mix(in srgb, var(--ls-accent) 35%, transparent);
}

.live-stats-app .bot-image-wrap img {
    height: 100%;
    width: 100%;
    object-fit: cover;
}

.live-stats-app .bot-name {
    font-size: var(--portal-text-xl);
    text-transform: uppercase;
    color: var(--bs-body-color);
    text-align: center;
    letter-spacing: 0.5px;
}

.live-stats-app .bot-driver {
    font-size: var(--portal-text-md);
    color: var(--bs-secondary-color);
    margin-top: 4px;
    text-align: center;
}

.live-stats-app .matchup-vs {
    font-size: 3rem;
    font-weight: var(--portal-weight-strong);
    color: var(--ls-magenta);
    text-shadow: 0 0 20px color-mix(in srgb, var(--ls-magenta) 40%, transparent);
    flex-shrink: 0;
    padding: 0 10px;
}


/* Tournament-ID fields (settings page). The width used to be an inline
   style="max-width:260px" on the markup; sizing belongs in the stylesheet, and
   the two fields disagreed by 20px for no reason anyone recorded. */
.live-stats-app .ls-tid-input {
    max-width: 280px;
}

/* Fight-detail comparison tables.
 *
 * Replaces the .stat-section / .stat-row / .stat-val family, which was a
 * bordered box with a teal title BAR and light-dark-light banded rows — a card
 * where the section wanted a group, plus the zebra the contract bans. The rows
 * read across (left bot | attribute | right bot), so they are a real table
 * inside a group now, and the bot names head the two value columns.
 *
 * Only the middle column needs a rule: it is the row's LABEL, so it takes the
 * quiet centered treatment while the two value columns ride the global skin.
 *
 * Fixed layout so the two bot columns stay mirror-equal (40/20/40) no matter
 * how long one side's text runs — under auto layout a long Fun Fact let one
 * bot's column swallow the width and pushed the Stat column off-center. */
.live-stats-app .ls-compare {
    table-layout: fixed;
}

.live-stats-app .ls-compare .ls-compare-label {
    width: 20%;
    text-align: center;
    color: var(--bs-secondary-color);
    font-weight: var(--portal-weight-medium);
    white-space: nowrap;
}

/* Bot names head the two value columns; center them over the centered values. */
.live-stats-app .ls-compare thead th,
.live-stats-app .ls-compare td {
    text-align: center;
}

/* Side-by-side list columns (today's fights, #1 finishes) */
.live-stats-app .stat-list-columns { display: flex; gap: 0; }
.live-stats-app .stat-list-col { flex: 1; min-width: 0; }

.live-stats-app .stat-list-col-left {
    border-right: 1px solid var(--bs-border-color);
    box-shadow: inset 3px 0 0 var(--ls-magenta);
}
.live-stats-app .stat-list-col-right {
    box-shadow: inset -3px 0 0 var(--ls-accent);
}

.live-stats-app .stat-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: var(--portal-text-md);
    color: var(--bs-body-color);
}

.live-stats-app .stat-list-result {
    font-size: var(--portal-text-sm);
    letter-spacing: 0.5px;
    width: 20px;
    flex-shrink: 0;
    text-align: center;
    font-weight: var(--portal-weight-label);
}
.live-stats-app .stat-list-result-w { color: var(--bs-success-text-emphasis); }
.live-stats-app .stat-list-result-l { color: var(--bs-danger-text-emphasis); }

.live-stats-app .stat-list-detail {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-stats-app .stat-list-annotation {
    font-size: var(--portal-text-xs);
    color: var(--bs-secondary-color);
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Bot search (available fights) ===== */
.live-stats-app .bot-search-wrap { position: relative; max-width: 520px; }

.live-stats-app .bot-search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-top: none;
    border-radius: 0 0 var(--bs-border-radius) var(--bs-border-radius);
    max-height: 240px;
    overflow-y: auto;
    /* No fallback: the site stack always loads before page CSS, so the
       literal was dead weight carrying a colour the palette owns. */
    box-shadow: var(--bs-box-shadow);
}

.live-stats-app .bot-search-option {
    padding: 8px 14px;
    cursor: pointer;
    font-size: var(--portal-text-md);
    color: var(--bs-body-color);
}
.live-stats-app .bot-search-option:hover,
.live-stats-app .bot-search-option.active {
    background: var(--ls-accent);
    color: var(--ls-on-accent);
}
.live-stats-app .bot-search-option .ls-dupe { color: var(--bs-secondary-color); }

/* ===== Events picker (select event for bracket) ===== */
.live-stats-app .events-table-wrap {
    max-width: 640px;
    max-height: 70vh;
    overflow: auto;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}
.live-stats-app .events-table-wrap .events-choose { width: 2.5rem; text-align: center; }
.live-stats-app .events-table-wrap .events-date {
    width: 120px;
    font-variant-numeric: tabular-nums;
    color: var(--bs-secondary-color);
}
.live-stats-app .events-table-wrap label { cursor: pointer; display: block; margin: 0; }

/* The rankings tables ride the global table skin now — no .ls-rank-table.
 *
 * That class centered every cell, tinted the headers teal, and left-aligned the
 * bot name by POSITION (td:nth-child(3)), which silently pointed at the wrong
 * column whenever the two tables' column sets diverged — and they had. Cells
 * now say what they are: .portal-col-num for figures, .portal-truncate for the
 * name. Note the old rules also out-specified .portal-col-num
 * (.live-stats-app .ls-rank-table td is 0-2-1 against a single class), so they
 * had to go for the numeric alignment to apply at all. */

/* ===== Rankings Tool: points-threshold mini-tables + log ===== */
.live-stats-app .ls-pts-input {
    width: 4rem;
    text-align: right;
    font-family: var(--portal-font-mono);
}

.live-stats-app .ls-log-box {
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    color: var(--bs-body-color);
    font-family: var(--portal-font-mono);
    font-size: var(--portal-text-xs);
    line-height: 1.5;
    padding: 0.75rem 1rem;
    max-height: 320px;
    overflow-y: auto;
    white-space: pre-wrap;
    margin: 0;
}

.live-stats-app .ls-new-badge {
    display: inline-block;
    background: var(--ls-accent-soft);
    color: var(--ls-accent-text);
    font-size: var(--portal-label-size-sm);
    padding: 1px 6px;
    border-radius: var(--bs-border-radius-sm);
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: var(--portal-label-tracking);
}

/* ===== Rankings explainer (about pages) ===== */
.live-stats-app .rkx-page { max-width: 820px; line-height: 1.55; }
/* A body heading, not a second page title.
 *
 * This was 1.35rem in the accent teal — 1.35rem is the PAGE TITLE's size
 * (portal-page-title), so every section heading was competing with the real h1
 * from page-header directly above it, and teal is the single INTERACTIVE
 * accent, spent here on something you cannot click. Sized below the title and
 * back on body ink; the outline (h2 > h3) is unchanged. */
.live-stats-app .rkx-page h2 {
    font-size: var(--portal-text-lg);
    font-weight: var(--portal-weight-strong);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}
.live-stats-app .rkx-page h3 {
    font-size: var(--portal-text-lg);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}
.live-stats-app .rkx-example {
    background: var(--ls-accent-soft);
    border-left: 3px solid var(--ls-accent);
    border-radius: 0 var(--bs-border-radius) var(--bs-border-radius) 0;
    padding: 0.75rem 1.25rem;
    margin: 1rem 0;
}
.live-stats-app .rkx-example strong { color: var(--ls-accent-text); }

/* ===== Tournament Settings: drag-and-drop reorder ===== */
.live-stats-app .tournament-drag-col {
    width: 32px;
    padding: 8px;
    vertical-align: middle;
    text-align: center;
}
.live-stats-app .tournament-drag-handle {
    cursor: grab;
    color: var(--bs-secondary-color);
    user-select: none;
    display: inline-block;
}
.live-stats-app .tournament-drag-handle:hover { color: var(--ls-accent-text); }
.live-stats-app .tournament-drag-handle:active { cursor: grabbing; }
.live-stats-app .tournament-row.tournament-dragging { opacity: 0.5; }
.live-stats-app .tournament-row.tournament-drop-before .tournament-drag-col {
    box-shadow: inset 0 3px 0 0 var(--ls-accent);
}
.live-stats-app .tournament-row.tournament-drop-after .tournament-drag-col {
    box-shadow: inset 0 -3px 0 0 var(--ls-accent);
}
