/**
 * Tournament plugin CSS — public Tournament Section (.tn-*)
 *
 * Only loaded on /tournament.php. Header (org identity + champion badge +
 * prev/next), the playoff bracket (vertical pyramid: Final -> Semifinals ->
 * Quarterfinals, widening downward), the Legends Swiss-stage banner, and the
 * empty state.
 */

.tn-page { position: relative; z-index: 2; max-width: 72rem; margin: 0 auto; padding: 48px 24px 80px; }

/* Header — a slim, centered title bar: prev/next Majors flank the tournament
   name at the page edges, thin divider below (Berno). Compact chrome pulls the
   champion crown up; the event logo is celebrated beside it (.tn-event-logo). */
.tn-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.06); margin-bottom: 24px; }
.tn-header-side { display: flex; align-items: center; }
.tn-header-side--prev { justify-self: start; }
.tn-header-side--next { justify-self: end; }
.tn-name { font-family: 'Righteous', sans-serif; font-size: 21px; color: #e5e7eb; letter-spacing: 2px; text-align: center; }

.tn-nav-arrow { display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.12); color: #c4b5fd; font-size: 28px; line-height: 1; text-decoration: none; transition: background 0.2s, border-color 0.2s; flex-shrink: 0; }
.tn-nav-arrow:hover { background: rgba(139,92,246,0.15); border-color: rgba(139,92,246,0.4); }
.tn-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Bracket — elimination tree with org-chart connector lines (PDF style):
   champion on top, finalists, semifinal pairs, quarterfinal pairs. Lines are
   drawn by li::before/::after borders; ul::before drops the vertical stub
   from a parent node down to its children's horizontal rail. */
/* Bracket section anchors the floating event logo into the top-left whitespace
   beside the champion crown (Berno — logo lives with the champion, bigger). */
.tn-bracket-section { position: relative; }
.tn-event-logo { position: absolute; top: 32px; left: 0; width: 200px; max-width: 20%; z-index: 1; pointer-events: none; }
.tn-event-logo img { width: 100%; height: auto; object-fit: contain; }
.tn-bracket-scroll { overflow-x: auto; padding-bottom: 8px; }
.tn-tree, .tn-tree ul { display: flex; justify-content: center; list-style: none; margin: 0; padding: 0; }
/* `safe center` centres the tree when it fits (desktop) but falls back to
   start-alignment when it overflows (phone), so the left half never lands in
   the unreachable scroll gutter that plain center-alignment creates. */
.tn-tree { justify-content: safe center; min-width: 720px; padding: 0 32px; }
.tn-tree ul { position: relative; padding-top: 26px; }
.tn-tree ul::before { content: ''; position: absolute; top: 0; left: 50%; width: 2px; height: 13px; background: rgba(196,181,253,0.45); }
.tn-tree li { display: flex; flex-direction: column; align-items: center; position: relative; padding: 13px 8px 0; }
.tn-tree > li { padding-top: 0; }
.tn-tree li::before, .tn-tree li::after { content: ''; position: absolute; top: 0; right: 50%; width: 50%; height: 13px; border-top: 2px solid rgba(196,181,253,0.45); }
.tn-tree li::after { right: auto; left: 50%; border-left: 2px solid rgba(196,181,253,0.45); }
.tn-tree li:only-child::before, .tn-tree li:only-child::after { display: none; }
.tn-tree li:first-child::before { border: 0 none; }
.tn-tree li:last-child::after { border: 0 none; }
.tn-tree li:last-child::before { border-right: 2px solid rgba(196,181,253,0.45); border-radius: 0 8px 0 0; }
.tn-tree li:first-child::after { border-radius: 8px 0 0 0; }

/* Frameless logos sized by round (final > sf > qf). Fixed-width slots keep both
   halves mirror-equal so the champion sits mid-page and score pills mid-rail.
   Names: vertical upright letter-stack on Final/Semis, label below on QF. */
.tn-node { position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px; width: 96px; }
.tn-node-box { display: flex; align-items: center; justify-content: center; border-radius: 12px; transition: transform 0.18s, filter 0.18s; }
.tn-node-box img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 8px rgba(0,0,0,0.45)); }
.tn-node-box[data-tn-pop] { cursor: pointer; }
.tn-node-box[data-tn-pop]:hover { transform: translateY(-2px); }
.tn-node--final .tn-node-box { width: 74px; height: 74px; }
.tn-node--sf .tn-node-box { width: 58px; height: 58px; }
.tn-node--qf .tn-node-box { width: 46px; height: 46px; }
.tn-node-letter { font-size: 16px; font-weight: 900; color: #c4b5fd; }
/* QF: plain label centred under the logo (keeps the 8-team base compact). */
.tn-node-name { max-width: 92px; font-size: 11px; font-weight: 600; color: #aca6c6; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Final + Semis: name sits horizontally on the OUTER side of the logo — left
   team to the left, right team to the right — vertically centred on the logo. */
.tn-node--final .tn-node-name, .tn-node--sf .tn-node-name { position: absolute; top: 50%; transform: translateY(-50%); max-width: none; overflow: visible; color: #d8d3ef; font-weight: 700; }
/* Anchor the name to the LOGO edge (node centre ± logo half + a small gap), not
   the wider slot edge, so it sits snug beside the logo instead of drifting off. */
.tn-node--final[data-tn-side="l"] .tn-node-name { right: 50%; margin-right: 45px; text-align: right; }
.tn-node--final[data-tn-side="r"] .tn-node-name { left: 50%; margin-left: 45px; text-align: left; }
.tn-node--sf[data-tn-side="l"] .tn-node-name { right: 50%; margin-right: 37px; text-align: right; }
.tn-node--sf[data-tn-side="r"] .tn-node-name { left: 50%; margin-left: 37px; text-align: left; }
.tn-node--final .tn-node-name { font-size: 13px; font-weight: 800; }
.tn-node--sf .tn-node-name { font-size: 12px; }
/* Match score pill — absolutely positioned at the first pair-sibling's
   top-right corner = the exact midpoint of the connector rail. Solid
   background so the line doesn't show through. */
.tn-rail-score { position: absolute; top: 0; right: 0; transform: translate(50%, -50%); z-index: 2; display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 8px; background: #1b1340; border: 1px solid rgba(196,181,253,0.35); font-size: 12px; font-weight: 800; line-height: 1.3; box-shadow: 0 4px 12px rgba(0,0,0,0.35); transition: border-color 0.2s, background 0.2s; }
.tn-rail-score[data-tn-pop]:hover { border-color: rgba(139,92,246,0.7); background: #241a4d; }
.tn-rail-score .tn-rs-win { color: #2fd07a; }
.tn-rail-score .tn-rs-lose { color: #ef5f6b; }
.tn-rail-score .tn-rs-n { color: #c4b5fd; }
.tn-rail-score .tn-rs-sep { color: #8b87a8; font-weight: 600; }
/* TBD slot keeps a faint dashed frame so an empty side still reads as a slot. */
.tn-node.tn-tbd .tn-node-box { background: #241a4d; border: 1px dashed rgba(255,255,255,0.2); opacity: 0.4; }
/* Champion crown at the top of the tree: MAJOR CHAMPION label over a big
   gold-ringed logo — the tree flows directly into it (Berno). */
.tn-node--champion { width: auto; }
.tn-node--champion .tn-node-box--gold { width: 112px; height: 112px; border: 1px solid rgba(245,196,81,0.6); border-radius: 20px; box-shadow: 0 0 36px rgba(245,196,81,0.35); background: rgba(245,196,81,0.08); overflow: hidden; }
.tn-node--champion .tn-node-box--gold img { width: 80%; height: 80%; }
.tn-node--champion .tn-node-letter { font-size: 28px; }
/* Champion crown — the big gold-ringed logo flanked by two matching gold
   plaques: "Major Champion + team" (left) and "Major MVP + player" (right),
   the title plaque a touch bigger (Berno). The logo is the only in-flow child
   so it stays dead-centre over the final rail; plaques are absolute. */
.tn-champion-crown { position: relative; display: flex; justify-content: center; }
.tn-champion-plaque { position: absolute; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 16px; border-radius: 14px; background: rgba(245,196,81,0.1); border: 1px solid rgba(245,196,81,0.4); white-space: nowrap; text-align: center; }
.tn-champion-plaque--title { right: 100%; margin-right: 22px; padding: 13px 19px; }
.tn-champion-plaque--mvp { left: 100%; margin-left: 22px; }
.tn-champion-eyebrow { font-size: 10px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; color: #f5c451; }
.tn-champion-value { font-family: 'Righteous', sans-serif; letter-spacing: 0.5px; color: #fde68a; line-height: 1.1; }
.tn-champion-plaque--title .tn-champion-eyebrow { font-size: 11px; }
.tn-champion-plaque--title .tn-champion-value { font-size: 21px; }
.tn-champion-plaque--mvp .tn-champion-value { font-size: 16px; }
/* Champion team name -> team page, MVP name -> profile (gold, hover-brighten). */
.tn-champion-value-link { text-decoration: none; cursor: pointer; transition: color 0.15s; }
.tn-champion-value-link:hover { color: #fff8e1; text-decoration: underline; text-decoration-color: rgba(245,196,81,0.6); }
.tn-champion-value-link:focus-visible { outline: 2px solid #f5c451; outline-offset: 3px; border-radius: 4px; }
.tn-champion-arrow { font-size: 0.7em; margin-left: 3px; opacity: 0.7; vertical-align: baseline; }
.tn-mvp-star { color: #f5c451; }
.tn-no-matches { text-align: center; color: #6b7280; font-size: 14px; padding: 40px 0; }

/* Legends banner */
.tn-legends { margin-top: 56px; }
.tn-legends-title { font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: #6b7280; margin-bottom: 20px; text-align: center; }
.tn-legends-buckets { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.tn-bucket { flex: 1 1 200px; max-width: 260px; padding: 16px; border-radius: 12px; text-align: center; border: 1px solid rgba(255,255,255,0.08); }
.tn-bucket--green { background: rgba(47,208,122,0.08); border-color: rgba(47,208,122,0.3); }
.tn-bucket--green-wide { background: rgba(47,208,122,0.05); border-color: rgba(47,208,122,0.2); }
.tn-bucket--red-wide { background: rgba(239,95,107,0.05); border-color: rgba(239,95,107,0.2); }
.tn-bucket--red { background: rgba(239,95,107,0.08); border-color: rgba(239,95,107,0.3); }
.tn-bucket-teams { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 32px; }
.tn-bucket-chip { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,0.05); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tn-bucket-chip img { width: 100%; height: 100%; object-fit: contain; }
.tn-bucket-letter { font-size: 13px; font-weight: 900; color: #c4b5fd; }
.tn-bucket-label { margin-top: 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.5px; color: #9ca3af; }

/* Empty state */
.tn-empty { text-align: center; padding: 100px 24px; }
.tn-empty-title { font-family: 'Righteous', sans-serif; font-size: 24px; color: #e5e7eb; margin-bottom: 12px; }
.tn-empty-body { font-size: 14px; color: #9ca3af; max-width: 32rem; margin: 0 auto; }

/* Popover triggers (team boxes, matchups, legends chips) */
[data-tn-pop] { cursor: pointer; }
[data-tn-pop]:focus-visible { outline: 2px solid #8b5cf6; outline-offset: 2px; border-radius: 8px; }

/* Roster / map-score popovers */
.tn-pop { position: fixed; z-index: 60; max-width: 280px; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; background: linear-gradient(180deg, #1b1340, #150f30); border: 1px solid rgba(139,92,246,0.35); border-radius: 12px; padding: 14px 16px; box-shadow: 0 12px 32px rgba(0,0,0,0.5); }
.tn-pop-title { font-size: 12px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: #c4b5fd; margin-bottom: 10px; }
/* Popover title doubles as a link to the team page when the team is published. */
.tn-pop-title-link { display: inline-flex; align-items: center; gap: 3px; text-decoration: none; cursor: pointer; transition: color 0.15s; }
.tn-pop-title-link:hover { color: #ddd6fe; }
.tn-pop-title-link:focus-visible { outline: 2px solid #8b5cf6; outline-offset: 2px; border-radius: 4px; }
.tn-pop-title-arrow { font-size: 0.9em; opacity: 0.7; }
.tn-pop-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; color: #e5e7eb; }
.tn-pop-role { flex-shrink: 0; min-width: 44px; text-align: center; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; padding: 2px 6px; border-radius: 4px; background: rgba(139,92,246,0.18); color: #c4b5fd; }
.tn-pop-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Player/coach name links straight through to their PRO/Legend profile. */
.tn-pop-link { color: #e5e7eb; text-decoration: none; cursor: pointer; border-radius: 3px; transition: color 0.15s; }
.tn-pop-link:hover { color: #c4b5fd; text-decoration: underline; }
.tn-pop-link:focus-visible { outline: 2px solid #8b5cf6; outline-offset: 2px; }
.tn-pop-flag { width: 16px; height: 12px; object-fit: cover; border-radius: 2px; flex-shrink: 0; }
.tn-standin-badge { flex-shrink: 0; font-size: 9px; font-weight: 700; text-transform: uppercase; padding: 1px 5px; border-radius: 4px; background: rgba(245,196,81,0.2); color: #f5c451; }
.tn-pop-coach { border-top: 1px solid rgba(255,255,255,0.08); margin-top: 6px; padding-top: 8px; }
.tn-pop-maprow { display: flex; align-items: center; justify-content: space-between; }
.tn-pop-mapname { color: #9ca3af; }
.tn-pop-mapscore .tn-pop-win { color: #2fd07a; font-weight: 700; }

/* Below the wide desktop the left gutter disappears — reflow the event logo
   into normal flow, centered above the bracket, so it never overlaps the tree. */
@media (max-width: 1024px) {
    .tn-event-logo { position: static; width: 150px; max-width: 60%; margin: 0 auto 24px; }
}

@media (max-width: 768px) {
    .tn-name { font-size: 20px; }
    /* Mobile keeps the exact desktop bracket — side names, flanking champion
       plaques — and simply scrolls it horizontally (tn-bracket-scroll), with
       tournament.js centering the champion into view on load. */
    .tn-bucket { flex: 1 1 45%; }
}

@media (max-width: 480px) {
    .tn-bucket { flex: 1 1 100%; }
}
