/* Bracket Display - Public Websites */

.bracket-container {
    --bracket-connector-w: 20px;
    --bracket-line-color: #94a3b8;
    --bracket-line-width: 2px;
    overflow-x: auto;
    padding: 1rem 0;
}

/* Grid: rounds as columns, all same height */
.bracket-rounds {
    display: grid;
    column-gap: calc(var(--bracket-connector-w) * 2);
    align-items: stretch;
    min-width: fit-content;
}

/* Each round column */
.bracket-round {
    display: flex;
    flex-direction: column;
    overflow: visible;
}

/* Fixed-height round header for alignment across rounds */
.bracket-round-header {
    height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-bottom: 2px solid var(--color-darktone, #333);
    text-align: center;
    flex-shrink: 0;
}

/* Matchups container fills remaining height */
.bracket-matchups {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Each slot wraps one matchup card and takes equal vertical space.
   With flex:1, slots in round N with fewer matchups are taller,
   naturally centering the card between the two feeder matchups. */
.bracket-slot {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
    padding: 4px 0;
    overflow: visible;
}

/* The matchup card itself */
.bracket-matchup {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.15s ease;
}

.bracket-matchup:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.bracket-matchup--completed {
    border-color: #9ca3af;
}

/* Small info/header bars inside matchup card */
.bracket-matchup-info {
    display: flex;
    justify-content: center;
    padding: 0.125rem 0.5rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.bracket-matchup-header {
    display: flex;
    justify-content: flex-end;
    padding: 0.125rem 0.5rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

/* Team row inside matchup card */
.bracket-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.875rem;
    min-height: 2.25rem;
}

.bracket-team:last-child {
    border-bottom: none;
}

.bracket-team-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 0.5rem;
    color: var(--color-darktone, #333);
    font-weight: 500;
}

.bracket-team-score {
    font-weight: 700;
    min-width: 1.5rem;
    text-align: center;
    color: var(--color-darktone, #333);
}

/* Winner/Loser highlighting */
.bracket-team--winner {
    background-color: #ecfdf5;
}

.bracket-team--winner .bracket-team-name {
    color: #065f46;
    font-weight: 700;
}

.bracket-team--winner .bracket-team-score {
    color: #065f46;
}

.bracket-team--loser {
    background-color: #fef2f2;
}

.bracket-team--loser .bracket-team-name {
    color: #991b1b;
    opacity: 0.7;
}

.bracket-team--loser .bracket-team-score {
    color: #991b1b;
    opacity: 0.7;
}


/* ============================
   BRACKET CONNECTOR LINES
   ============================

   Slots are assigned explicit classes by the server:
     .pair-top    = top of a 2-game pair → horizontal right + vertical down
     .pair-bottom = bottom of a 2-game pair → horizontal right + vertical up
     .single      = standalone feeder (bye/seed for other team) → horizontal right only

   Together, each pair-top + pair-bottom forms the bracket arm ┐├┘ shape.
   Single slots draw only a straight horizontal line to the next round.

   Each slot in a non-first round draws an incoming horizontal via ::before.
*/

/* --- Outgoing: pair-top (top of a 2-game pair) --- */
/* Horizontal from matchup center going right + vertical going down to pair boundary */
.bracket-round:not(:last-child) .bracket-slot.pair-top::after {
    content: '';
    position: absolute;
    right: calc(var(--bracket-connector-w) * -1);
    top: 50%;
    bottom: 0;
    width: var(--bracket-connector-w);
    border-top: var(--bracket-line-width) solid var(--bracket-line-color);
    border-right: var(--bracket-line-width) solid var(--bracket-line-color);
}

/* --- Outgoing: pair-bottom (bottom of a 2-game pair) --- */
/* Horizontal from matchup center going right + vertical going up to pair boundary */
.bracket-round:not(:last-child) .bracket-slot.pair-bottom::after {
    content: '';
    position: absolute;
    right: calc(var(--bracket-connector-w) * -1);
    top: 0;
    bottom: 50%;
    width: var(--bracket-connector-w);
    border-bottom: var(--bracket-line-width) solid var(--bracket-line-color);
    border-right: var(--bracket-line-width) solid var(--bracket-line-color);
}

/* --- Placeholder slots: invisible spacers for bye/seed alignment --- */
/* Hide all connectors on placeholder slots */
.bracket-slot.placeholder::before,
.bracket-slot.placeholder::after {
    display: none !important;
}

/* --- Incoming: all slots in non-first rounds --- */
/* Horizontal from left (previous round junction) to matchup */
.bracket-round:not(:first-child) .bracket-slot::before {
    content: '';
    position: absolute;
    left: calc(var(--bracket-connector-w) * -1);
    top: 50%;
    width: var(--bracket-connector-w);
    height: 0;
    border-top: var(--bracket-line-width) solid var(--bracket-line-color);
}

/* Responsive */
@media (max-width: 640px) {
    .bracket-container {
        --bracket-connector-w: 12px;
        padding: 0.5rem 0;
    }

    .bracket-team {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    .bracket-team-name {
        max-width: 100px;
    }

    .bracket-round-header {
        height: 40px;
    }
}
