/* Knockout brackets (sports/bracket.js): rounds left to right, 1 px lines between them.
   Slots are whole pixels (64 px, doubling each round), so a joining line meets its cell exactly
   on the rule between the cell's two lines. */

.bk {
  --bk-rule: var(--line-strong);
  --bk-gap: 32px;   /* between rounds; even, so the lines meet halfway */
  --bk-slot: 64px;  /* a first-round match's share of the height; even */
  --bk-cell: 52px;  /* a match: two 25 px lines and its border */
  --bk-w: 176px;
  --bk-w-max: 264px;
  --bk-cw: 128px;
  --bk-cw-max: 220px;
  --bk-seed: 22px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 12px 14px 14px;
}
.bk.is-unseeded { --bk-seed: 2px; }
.bk.has-cap { --bk-slot: 84px; }

.bk-grid {
  display: grid;
  grid-template-rows: auto 1fr;
  column-gap: var(--bk-gap);
  min-width: min-content;
}
.bk-h {
  padding: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bk-body { display: flex; flex-direction: column; min-width: 0; }
.bk-slot {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-height: var(--bk-slot);
}

/* The lines: each match draws half of the bracket that joins it to its partner, and a later
   round's match the stub that reaches back to it. */
.bk-body.has-next > .bk-slot::after,
.bk-body.has-prev > .bk-slot::before {
  content: "";
  position: absolute;
  border: 0 solid var(--bk-rule);
  pointer-events: none;
}
.bk-body.has-next > .bk-slot::after { right: calc(var(--bk-gap) / -2); width: calc(var(--bk-gap) / 2); }
.bk-body.has-next > .bk-slot:nth-child(odd)::after { top: 50%; bottom: 0; border-width: 1px 1px 0 0; }
.bk-body.has-next > .bk-slot:nth-child(even)::after { top: 0; bottom: calc(50% - 1px); border-width: 0 1px 1px 0; }
.bk-body.has-next.is-last > .bk-slot::after { right: calc(var(--bk-gap) * -1); width: var(--bk-gap); bottom: auto; height: 0; border-width: 1px 0 0; }
.bk-body.has-prev > .bk-slot::before { left: calc(var(--bk-gap) / -2); width: calc(var(--bk-gap) / 2); top: 50%; height: 0; border-width: 1px 0 0; }
/* A bye draws no lines: its partner's half runs alone, and a match after two byes has no stub. */
.bk-body > .bk-slot.is-bye::after, .bk-body > .bk-slot.is-bye::before, .bk-body > .bk-slot.is-first::before { content: none; }

/* A match */
.bk-m {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: var(--bk-cell);
  border: 1px solid var(--bk-rule);
  border-radius: 6px;
  background: var(--surface);
}
.bk-a {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-radius: 5px;
  color: inherit;
  text-decoration: none;
}
a.bk-a:hover, .bk-m.is-open > .bk-a { background: var(--surface-2); }
a.bk-a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.bk-p {
  display: grid;
  grid-template-columns: var(--bk-seed) minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 6px;
  box-sizing: border-box;
  height: 25px;
  padding-right: 6px;
  font-size: 14px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.bk-p + .bk-p { border: 0 solid var(--line); border-width: 1px 0 0; }
.bk-seed { font-size: 11px; color: var(--muted); text-align: right; }
.bk-n { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bk-p.is-win .bk-n { font-weight: 700; }
.bk-p.is-loss .bk-n { color: var(--muted); }
.bk-sm { display: none; }
.bk-note { margin-left: 5px; font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.bk-tbd { color: var(--faint); }
.bk-p.is-bye { background: var(--surface-2); }
.bk-sc { display: flex; white-space: nowrap; }
.bk-cap {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 3px;
  overflow: hidden;
  font-size: 11px;
  line-height: 13px;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Logos and team links (entries with logo, href). A cell whose sides link has its own link as an
   empty cover under the lines; the lines let clicks through to it except on a name. */
.bk-logo { display: inline-block; margin-right: 6px; vertical-align: -4px; object-fit: contain; }
a.bk-t { color: inherit; text-decoration: none; }
a.bk-t:hover { text-decoration: underline; text-underline-offset: 2px; }
a.bk-t:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-radius: 2px; }
.bk-cover { position: absolute; inset: 0; z-index: 1; border-radius: 5px; }
.bk-m.has-sides > .bk-a { position: relative; z-index: 2; pointer-events: none; }
.bk-m.has-sides a.bk-t { pointer-events: auto; }
a.bk-cover:hover + .bk-a { background: var(--surface-2); }
a.bk-cover:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

/* The champion */
.bk-champ { min-width: var(--bk-cw); }
.bk-champ .bk-slot { padding-left: 10px; }
/* A champion's name is never broken onto two lines: its column is at least as wide as the name
   (bracket.js sizes it max-content), and the bracket scrolls sideways where the page is narrower. */
.bk-cn { font: 700 24px/1.05 var(--display); white-space: nowrap; }
.bk-cn.is-tbd { font-weight: 500; color: var(--faint); }
.bk-cn.has-logo { display: inline-flex; align-items: center; gap: 8px; }
.bk-cn.has-logo .bk-logo { flex: none; margin: 0; }

@media (max-width: 600px) {
  .bk { --bk-gap: 24px; --bk-w: 196px; --bk-w-max: 196px; --bk-cw: 120px; --bk-cw-max: 150px; --bk-seed: 16px; padding: 10px 12px 12px; }
  .bk.is-unseeded { --bk-seed: 2px; }
  .bk-p { font-size: 13px; column-gap: 5px; }
  .bk-lg { display: none; }
  .bk-sm { display: inline; }
  .bk-cn { font-size: 21px; }
}
