/* Mapa de eliminatórias (templates/includes/bracket.html) — usado no painel e no site.
   Cada ronda é uma coluna com a mesma altura; os jogos dividem-na em partes iguais,
   por isso cada jogo fica ao centro dos dois que o alimentam e as linhas acertam. */
.bk {
  --bk-ink: #14201b; --bk-muted: #5b6b64; --bk-rule: #dde5e0; --bk-line: #b8c7bf;
  --bk-night: #0d2b22; --bk-ball: #f5c518; --bk-court: #1a7a4c; --bk-surface: #fff;
  --bk-gap: 36px; --bk-slot-h: 92px;
  overflow-x: auto; padding: 4px 4px 12px; scrollbar-width: thin;
}
.bk:focus-visible { outline: 3px solid var(--bk-ball); outline-offset: 2px; }
.bk-rounds, .bk-slots { list-style: none; margin: 0; padding: 0; }
.bk-rounds { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(196px, 1fr); column-gap: var(--bk-gap); min-width: min-content; }
.bk-round { display: flex; flex-direction: column; min-width: 0; }
.bk-round-title {
  margin: 0 0 10px !important; font-size: .8rem !important; font-weight: 600 !important; color: var(--bk-muted);
  font-family: inherit !important; letter-spacing: 0; white-space: nowrap;
}
.bk-slots { display: flex; flex-direction: column; height: calc(var(--bk-first, 1) * var(--bk-slot-h)); }
.bk-slot { position: relative; flex: 1; display: flex; align-items: center; min-height: 0; }

/* Linhas: saída de cada jogo, junção dos pares e entrada na ronda seguinte. */
.bk-round:not(:last-child) .bk-slot::after {
  content: ""; position: absolute; right: calc(var(--bk-gap) / -2); top: 50%; width: calc(var(--bk-gap) / 2);
  border-top: 2px solid var(--bk-line);
}
.bk-round:not(:last-child) .bk-slot:nth-child(odd):not(:last-child)::before,
.bk-round:not(:last-child) .bk-slot:nth-child(even)::before {
  content: ""; position: absolute; right: calc(var(--bk-gap) / -2); height: 50%;
  border-right: 2px solid var(--bk-line);
}
.bk-round:not(:last-child) .bk-slot:nth-child(odd)::before { top: 50%; }
.bk-round:not(:last-child) .bk-slot:nth-child(even)::before { top: 0; }
.bk-round:not(:first-child) .bk-match::before, .bk-round:not(:first-child) .bk-champion::before {
  content: ""; position: absolute; left: calc(var(--bk-gap) / -2 - 1px); top: 50%; width: calc(var(--bk-gap) / 2 + 1px);
  border-top: 2px solid var(--bk-line);
}
.bk-slot.is-finished::after { border-top-color: var(--bk-court); }

.bk-match {
  position: relative; display: block; width: 100%;
  background: var(--bk-surface); border: 1px solid var(--bk-rule); border-radius: 8px;
  color: var(--bk-ink); text-decoration: none; overflow: visible;
  box-shadow: 0 1px 2px rgba(13, 43, 34, .06);
}
a.bk-match:hover { border-color: var(--bk-court); }
a.bk-match:focus-visible { outline: 3px solid var(--bk-ball); outline-offset: 2px; }
.bk-slot.is-empty .bk-match { background: transparent; border-style: dashed; box-shadow: none; }
.bk-meta { display: flex; justify-content: space-between; gap: 8px; padding: 5px 10px 0; font-size: .7rem; color: var(--bk-muted); }
.bk-when { display: inline-flex; gap: 6px; }
.bk-team { display: flex; align-items: center; gap: 8px; padding: 4px 10px; font-size: .85rem; line-height: 1.25; }
.bk-team + .bk-team { border-top: 1px solid var(--bk-rule); padding-bottom: 6px; }
.bk-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-team.is-pending .bk-name { color: var(--bk-muted); font-style: italic; font-size: .78rem; }
.bk-team.is-winner { font-weight: 700; }
.bk-sets {
  min-width: 22px; text-align: center; border-radius: 4px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: #edf2ef; color: var(--bk-muted);
}
.bk-team.is-winner .bk-sets { background: var(--bk-night); color: var(--bk-ball); }

.bk-champion {
  position: relative; width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 14px 12px; border-radius: 8px; background: var(--bk-night); color: rgba(255, 255, 255, .7); font-weight: 600;
}
.bk-champion .bi { color: rgba(245, 197, 24, .5); font-size: 1.2rem; }
.bk-champion.is-known { color: #fff; }
.bk-champion.is-known .bi { color: var(--bk-ball); }

/* Jogo do 3.º lugar: na coluna da final, logo abaixo do cartão da final (fora do fluxo,
   para a final continuar ao centro e as linhas do quadro não mudarem). */
.bk { --bk-third-offset: 58px; --bk-third-h: 128px; }
.bk-third { position: absolute; left: 0; right: 0; top: calc(50% + var(--bk-third-offset)); }
.bk-third .bk-round-title { margin-bottom: 6px !important; }
.bk-third .bk-match::before { content: none !important; }
.bk-third .bk-match { border-style: dashed; }
.bk-third a.bk-match, .bk-third .bk-match:has(.is-winner) { border-style: solid; }
/* Quadros pequenos (meias-finais + final): a coluna é baixa, por isso reserva-se espaço em baixo. */
.bk.has-third .bk-rounds {
  padding-bottom: max(0px, calc(var(--bk-third-offset) + var(--bk-third-h) - var(--bk-first, 1) * var(--bk-slot-h) / 2));
}
.bk.has-third:has(.bk-third .bk-schedule) { --bk-third-h: 164px; }  /* painel: botão "Marcar jogo (TBC)" */

/* Resumo do quadro, jornadas, isenções e o botão que marca os jogos de uma jornada. */
.bk-summary { margin: 0 0 14px; font-size: .85rem; color: #5b6b64; }
.bk-summary .bi { color: #1a7a4c; margin-right: 4px; }
.bk-jornada { display: block; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #1a7a4c; }
.bk-round-title { white-space: normal; }
.bk-schedule { margin: -4px 0 8px; }
.bk-schedule .btn { font-size: .72rem; padding: 2px 8px; }
.bk-slot.is-bye .bk-match { border-style: dashed; background: #f6faf8; }
.bk-slot.is-bye .bk-team + .bk-team .bk-name { font-style: normal; text-transform: uppercase; font-size: .68rem; letter-spacing: .05em; }
.bk-bye-tag { font-weight: 700; color: #1a7a4c; }

@media (max-width: 575.98px) {
  .bk { --bk-gap: 24px; --bk-slot-h: 88px; }
  .bk-rounds { grid-auto-columns: minmax(170px, 1fr); }
}
@media print {
  .bk { overflow: visible; }
}
