/* brackets.css — bracket visualization (tokens from variables.css) */

:root {
    /* Bracket-specific shadows */
    --ambient-shadow-light: 0 8px 32px rgba(15, 43, 25, 0.06);
    --ambient-shadow-hover: 0 12px 64px rgba(15, 43, 25, 0.1);
}

.tournament-sub {
    text-align: center;
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: 0 0 1rem;
}

.containerResults {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* --- Navigation & Headings --- */
.back-link {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 1rem;
    transition: color 0.2s;
    font-size: 0.95rem;
}

.back-link:hover {
    color: var(--secondary-container);
}

.results-header-block {
    margin-bottom: 1rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.results-header-block h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-core);
    margin: 0;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.tournament-sub {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0 0;
}

/* --- Bracket Wrapper (The Arena) --- */
.bracket-wrapper {
    overflow-x: auto;
    padding: 1rem;
    background-color: var(--surface-container-low);
    border-radius: 1rem;
    min-height: 400px;
    
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--outline-variant) transparent;
}

.bracket-wrapper::-webkit-scrollbar {
    height: 8px;
}
.bracket-wrapper::-webkit-scrollbar-thumb {
    background-color: var(--outline-variant);
    border-radius: 4px;
}

.bracket-container {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-width: max-content; /* ensure it stretches */
}

/* --- Round Columns --- */
.bracket-round {
    display: flex;
    flex-direction: column;
    width: 240px;
    margin-right: 40px;
    position: relative;
}

.bracket-round:last-child {
    margin-right: 0;
}

.round-title {
    background: linear-gradient(135deg, rgba(0, 48, 22, 0.9), rgba(26, 71, 42, 0.85));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.7rem;
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 1rem 0;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.match-list {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex-grow: 1;
    position: relative;
}

/* --- Match Card Wrapper --- */
.match-card-wrapper {
    position: relative;
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    flex: 1 1 0;
}

/* --- Match Cards --- */
.match-card {
    background: var(--surface-container-lowest);
    border-radius: 0.75rem;
    width: 100%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    box-shadow: var(--ambient-shadow-light);
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* important for border radius clipping */
}

/* Ghost border via pseudo element for ambient feel */
.match-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid var(--outline-variant);
    opacity: 0.2;
    pointer-events: none;
    z-index: 5;
}

.match-card-link:hover .match-card {
    transform: translateY(-4px);
    box-shadow: var(--ambient-shadow-hover);
}

/* Bye State */
.match-card.is-bye {
    background: var(--surface);
    box-shadow: none;
}

.match-card.is-bye::before {
    border: 1px dashed var(--outline);
    opacity: 0.4;
}

.match-card.is-bye .score {
    color: var(--outline-variant);
}

/* Card Header (Meta) */
.match-meta {
    padding: 0.3rem 0.75rem;
    font-size: 0.55rem;
    font-family: var(--font-body);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: var(--surface-container-lowest);
    border-bottom: 1px solid rgba(0,0,0,0.03);
}

.match-card.is-bye .match-meta {
    background: transparent;
}


/* --- Competitors --- */
.competitor {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.75rem;
    min-height: 32px;
    background: var(--surface-container-lowest);
    position: relative;
}

/* Shift background for bottom competitor to create depth without lines */
.competitor:last-child {
    background: var(--surface-container);
}

.match-card.is-bye .competitor {
    background: transparent;
}

/* Winner State - 4px solid left border */
.competitor.winner {
    background: var(--surface-container-lowest);
}

.competitor.winner::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--primary-container);
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.competitor.winner .ath-name {
    font-weight: 700;
    color: var(--primary-core);
}

.competitor.winner .score {
    color: var(--primary-core);
}


/* Name Block & Badges */
.name-block {
    display: flex;
    align-items: center;
    overflow: hidden;
}

.flag-code {
    font-family: var(--font-tech);
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--surface-container-lowest);
    background: var(--outline);
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    margin-right: 0.5rem;
    min-width: 26px;
    text-align: center;
}

/* Give the winner flag a primary color tint */
.competitor.winner .flag-code {
    background: var(--primary-container);
}

.ath-name {
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}

/* Score - The Data Hero */
.score {
    font-family: var(--font-tech);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--on-surface);
    padding-left: 0.5rem;
    text-align: right;
    min-width: 30px;
}

.tie-arrow {
    display: block;
    font-family: var(--font-body);
    font-size: 0.55rem;
    color: var(--secondary-core);
    font-weight: 600;
    margin-top: -2px;
}

/* --- Connectors --- */
/* Right exit line */
.bracket-round:not(:last-child) .match-card-wrapper::after {
    content: '';
    position: absolute;
    right: -20px;
    top: calc(50% - 1px);
    width: 20px;
    height: 2px;
    background: var(--outline-variant);
    opacity: 0.5;
    z-index: 1;
}

/* Left entrance line */
.bracket-round:not(:first-child) .match-card-wrapper::before {
    content: '';
    position: absolute;
    left: -20px;
    top: calc(50% - 1px);
    width: 20px;
    height: 2px;
    background: var(--outline-variant);
    opacity: 0.5;
    z-index: 1;
}

/* Vertical bracket lines */
.connector-line {
    position: absolute;
    right: -21px;
    width: 2px;
    background: var(--outline-variant);
    opacity: 0.5;
    z-index: 1;
}

.match-card-wrapper:nth-child(odd) .connector-line {
    top: 50%;
    height: 100%;
}

.match-card-wrapper:nth-child(even) .connector-line {
    bottom: 50%;
    height: 100%;
}

/* --- Highlights & Medals --- */
.gold-match {
    border: 2px solid #d4af37 !important;
    box-shadow: 0 8px 32px rgba(212, 175, 55, 0.2) !important;
}
.gold-match .match-meta {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), transparent) !important;
    color: #b8860b !important;
}
.gold-match::before { border: none !important; }

.bronze-match {
    border: 2px solid #cd7f32 !important;
    box-shadow: 0 8px 32px rgba(205, 127, 50, 0.2) !important;
}
.bronze-match .match-meta {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.15), transparent) !important;
    color: #a0522d !important;
}
.bronze-match::before { border: none !important; }

.bracket-round.phase-0 .round-title {
    background: linear-gradient(135deg, #d4af37, #b8860b);
    color: #fff;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.bronze-section .round-title {
    background: linear-gradient(135deg, #cd7f32, #a0522d);
    color: #fff;
    box-shadow: 0 4px 15px rgba(205, 127, 50, 0.3);
}

/* --- Bronze Section --- */
.bronze-section {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 2px dashed var(--outline-variant);
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.bronze-section .round-title {
    background: linear-gradient(135deg, var(--secondary-core), var(--secondary-container));
    color: #ffffff;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    .containerResults {
        padding: 0.5rem;
    }
    
    .results-header-block h1 {
        font-size: 1.1rem;
    }
    
    .bracket-wrapper {
        padding: 0.5rem;
        border-radius: 0.75rem;
    }

    .bracket-round {
        width: 200px;
        margin-right: 25px;
    }
    
    .match-card-wrapper::after {
        right: -12px;
        width: 12px;
    }
    
    .ath-name {
        max-width: 100px;
        font-size: 0.6rem;
    }

    .score {
        font-size: 0.8rem;
    }
}