/* A category's bracket (bracketHtml in src/tournament.ts), on the public page
   and in the TV mode: a grid with a column per round and a row per first-round
   game; a later game spans the two it comes from, so the lines between them
   (::before / ::after of the cells) meet at its middle. The page's tokens
   (--card, --line, --text, --muted, --live, --a-ink or --a, --mine, --soft)
   give both themes; the sizes are in em, so the TV's larger type scales it. */
.tp-bracket {
  --bw: 11em;
  --bmax: 17em;
  --bgap: 2.2em;
  --bl: var(--bline, var(--line));
  --bpath: var(--a-ink, var(--a));
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(var(--bw), var(--bmax)));
  grid-template-rows: auto repeat(var(--rows, 1), 1fr);
  column-gap: var(--bgap);
  /* Sideways only when it does not fit (a phone); never a vertical scrollbar. */
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 10px;
  font-size: 0.9rem;
  line-height: 1.3;
  scroll-snap-type: x proximity;
}
.tp-bracket .tp-bhead {
  grid-row: 1;
  margin: 0 0 4px;
  padding: 0;
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  scroll-snap-align: start;
}
.tp-bcell { position: relative; display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 0.45em 0; }

/* The lines: out of a game to the middle of the gap, down (the upper of two) or up (the lower) to where they meet, into the next game. */
.tp-bdown::after, .tp-bup::after, .tp-bfin::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  width: calc(var(--bgap) / 2 + 1px);
  border-top: 2px solid var(--bl);
}
.tp-bfin::after { width: var(--bgap); }
.tp-bdown::before, .tp-bup::before {
  content: "";
  position: absolute;
  left: calc(100% + var(--bgap) / 2 - 1px);
  border-left: 2px solid var(--bl);
}
.tp-bdown::before { top: 50%; bottom: 0; }
.tp-bup::before { top: 0; bottom: 50%; }
.tp-bin > .tp-bmatch::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  width: calc(var(--bgap) / 2);
  border-top: 2px solid var(--bl);
}

/* A game: when and where, its two sides with the score (the winner bold), «En juego». */
.tp-bmatch { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.35em 0.65em; }
.tp-bmatch[data-state="live"] { border-color: var(--live); box-shadow: inset 3px 0 0 var(--live); }
.tp-bbye { opacity: 0.75; }
.tp-bmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.3em; margin: 0 0 0.2em; font-size: 0.75em; color: var(--muted); font-variant-numeric: tabular-nums; }
.tp-bmeta .tp-badge { margin-left: auto; font-size: 0.9em; }
.tp-bside { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5em; padding: 0.15em 0; }
.tp-bside + .tp-bside { border-top: 1px solid var(--line); }
.tp-bname { min-width: 0; overflow-wrap: anywhere; }
.tp-bside.tp-won { font-weight: 800; }
.tp-bscore { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.tp-bpens { margin-left: 0.2em; font-size: 0.8em; font-weight: 600; color: var(--muted); }
.tp-bcode { font-weight: 700; font-style: normal; color: var(--text); }
.tp-bside.tp-prov { font-style: normal; color: var(--text); }
.tp-provtag { display: inline-block; padding: 0 0.4em; border: 1px dashed var(--muted); border-radius: 999px; font-size: 0.72em; color: var(--muted); white-space: nowrap; vertical-align: 0.1em; }
.tp-bside.tp-mine { background: var(--mine); margin: 0 -0.65em; padding-left: 0.65em; padding-right: 0.65em; }

/* The third-place game under the final; the champion after it. */
.tp-bthird { justify-content: flex-start; padding-top: 1em; }
.tp-bthird-title { margin: 0 0 0.25em; font-size: 0.8em; font-weight: 700; color: var(--muted); }
.tp-champ { text-align: center; padding: 0.8em 0.6em; border-radius: 12px; border: 2px solid #eab308; background: var(--card); }
.tp-trophy { display: block; font-size: 2em; line-height: 1.1; }
.tp-champ-name { display: block; margin: 0.15em 0 0.3em; font-size: 1.15em; overflow-wrap: anywhere; }
.tp-champ-line { margin: 0.15em 0 0; font-size: 0.82em; color: var(--muted); overflow-wrap: anywhere; }
.tp-champ-line span:last-child { color: var(--text); font-weight: 600; }
.tp-champ [data-team].tp-mine { background: var(--mine); border-radius: 4px; padding: 0 0.2em; }

/* «Mi equipo»: its games outlined and the lines it went along (public/tournament.js). */
.tp-bcell.tp-onpath > .tp-bmatch { border-color: var(--bpath); box-shadow: 0 0 0 1px var(--bpath); }
.tp-bcell.tp-pathout::after, .tp-bcell.tp-pathout::before { border-color: var(--bpath); }
.tp-bcell.tp-onpath.tp-bin > .tp-bmatch::before { border-color: var(--bpath); }
.tp-bchamp.tp-onpath .tp-champ { box-shadow: 0 0 0 2px var(--bpath); }
