/* A single elimination bracket (FEAT-127, APP-69): the portal's Leagues > Tournaments, a division's Brackets view (p/Division)
   and the league's public Bracket page. Core_User.ProgramBracketHtml writes the markup, laid out as the league's old site laid
   it out (the owner, 2026-10-16): a grid with a column for each round, which share the width so the bracket fits its page
   without scrolling sideways, a row for each first-round place, and each game in the rows between the two games that feed it
   (its grid-column and grid-row are set on it). The round sections and their lists take no box of their own (display:
   contents), so their titles and games are the grid's items. Colours come from Bootstrap's variables and the round titles
   from the league site's heading font, so it follows each site's look. Only a bracket too wide for a phone scrolls sideways,
   inside its own box. */

.bk-scroll {
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.bk-bracket {
    display: grid;
    grid-template-columns: repeat(var(--bk-columns, 4), minmax(9rem, 1fr));
    column-gap: 1rem;
    row-gap: 0.75rem;
}

.bk-round,
.bk-games {
    display: contents;
}

.bk-games {
    list-style: none;
}

.bk-round-title {
    grid-row: 1;
    margin: 0 0 0.15rem;
    font-family: var(--lm-heading-font, inherit);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--bs-emphasis-color, #000);
}

/* The portal has no heading font of its own: its round titles are small capitals, as its other labels are */
.bk-portal .bk-round-title {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color, #6c757d);
}

.bk-game {
    align-self: center;
    min-width: 0;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.6rem;
    background: var(--bs-body-bg, #fff);
    overflow: hidden;
    font-size: 0.85rem;
    line-height: 1.25;
}

/* A division with more than one bracket picks one with these pills (p/Division), in the league site's own menu colours rather than
   Bootstrap's blue: the bracket shown on the menu bar's black, the others as plain links */
.bk-pills {
    gap: 0.5rem;
}

.bk-pills .nav-link {
    color: var(--bs-body-color, #212529);
    border: 1px solid var(--bs-border-color, #dee2e6);
    background: var(--bs-body-bg, #fff);
}

.bk-pills .nav-link:hover {
    border-color: var(--lm-nav-bg, #000);
}

.bk-pills .nav-link.active {
    color: var(--lm-nav-fg, #fff);
    background: var(--lm-nav-bg, #000);
    border-color: var(--lm-nav-bg, #000);
}

/* On the public site a scheduled game's whole card is one link to its game page (the owner, 2026-10-16): it lifts under the pointer */
.bk-game-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.bk-game-link:hover,
.bk-game-link:focus-visible {
    color: inherit;
    background: var(--bs-tertiary-bg, #f8f9fa);
}

.bk-game-link:focus-visible {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: -2px;
}

.bk-game:has(> .bk-game-link) {
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.bk-game:has(> .bk-game-link):hover {
    box-shadow: 0 0.35rem 0.9rem rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

/* The day and time (in the portal a link to the game) on the left, the game's number on the right */
.bk-head {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem 0.2rem;
    font-size: 0.8rem;
}

.bk-when {
    flex: 1;
    min-width: 0;
    font-weight: 700;
}

.bk-when a {
    color: inherit;
    text-decoration: none;
}

.bk-when a:hover,
.bk-when a:focus-visible {
    text-decoration: underline;
}

.bk-number {
    flex: 0 0 auto;
    color: var(--bs-secondary-color, #6c757d);
}

.bk-team {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
}

/* The portal shows each team's seed before its name */
.bk-seed {
    flex: 0 0 1.2rem;
    text-align: right;
    font-size: 0.75rem;
    color: var(--bs-secondary-color, #6c757d);
}

.bk-name {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.bk-name a {
    color: inherit;
    text-decoration: none;
}

.bk-name a:hover,
.bk-name a:focus-visible {
    text-decoration: underline;
}

.bk-score {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
}

.bk-win .bk-name,
.bk-win .bk-score {
    font-weight: 700;
}

.bk-out .bk-name,
.bk-out .bk-score {
    color: var(--bs-secondary-color, #6c757d);
}

.bk-tbd {
    color: var(--bs-secondary-color, #6c757d);
}

/* The field, the game's status, and in the portal the place's Schedule or Change link */
.bk-meta {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    color: var(--bs-secondary-color, #6c757d);
    border-top: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.1));
}

.bk-team + .bk-team {
    padding-bottom: 0.4rem;
}

.bk-problem {
    color: var(--bs-danger-text-emphasis, #b02a37);
}

/* The champion (APP-507): a badge above the bracket at the right, not a column of the grid, so it takes no width from the rounds */
.bk-champion-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

.bk-champion {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    border: 2px solid var(--bs-warning, #ffc107);
    border-radius: 0.6rem;
    padding: 0.5rem 1rem;
    text-align: center;
    font-weight: 700;
    overflow-wrap: anywhere;
    background: var(--bs-body-bg, #fff);
}

.bk-champion-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bs-secondary-color, #6c757d);
}

/* On a phone the badge takes the whole width above the bracket */
@media (max-width: 575.98px) {
    .bk-champion-row {
        justify-content: stretch;
    }

    .bk-champion {
        width: 100%;
    }
}

.bk-champion a {
    color: inherit;
}

/* League staff's Score button under a game they may score (APP-458, Assets/js/bracket-score.js): a full-width strip at the foot of
   the card, outside its link, in the league site's menu colours */
.bk-score-button {
    display: block;
    width: 100%;
    padding: 0.3rem 0.6rem;
    border: 0;
    border-top: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.1));
    background: var(--lm-nav-bg, #000);
    color: var(--lm-nav-fg, #fff);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

.bk-score-button:hover,
.bk-score-button:focus-visible {
    opacity: 0.85;
}

.bk-score-button:focus-visible {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: -2px;
}

/* A bracket in parts (APP-233): pool play shows its pools, double elimination its winners' and losers' brackets and its final. Each
   part has a heading and a grid of its own; a pool has its standings and its games in rows of cards */
.bk-part-title {
    margin: 1.5rem 0 0.5rem;
    font-family: var(--lm-heading-font, inherit);
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--bs-emphasis-color, #000);
}

.bk-champion-row + .bk-part-title,
.bk-part-title:first-child,
.bk-pool:first-child .bk-part-title {
    margin-top: 0;
}

.bk-pool-table {
    width: auto;
    min-width: min(100%, 22rem);
    font-size: 0.85rem;
}

.bk-pool-games {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.75rem;
}
