/* Playoff bracket — shared by the admin Playoffs page, the public /playoffs/
   page, the homepage section and dashboard cards. Uses design_tokens.css
   variables only, so it themes light/dark with the rest of the site, and is
   self-contained: app pages don't load public_pages.css, so every piece of
   geometry this partial needs has to live here. */

.iil-bracket {
  --bracket-gap: 1rem;
  font-family: var(--iil-font-body);
  color: var(--iil-text);
}

/* ----- Champion callout ----- */
.iil-bracket-champion {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  margin-bottom: var(--bracket-gap);
  border: 1px solid var(--iil-accent);
  border-radius: 12px;
  background: var(--iil-accent-wash);
}
.iil-bracket-champion-mark {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  color: #fff;
  font-family: var(--iil-font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.iil-bracket-champion-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.iil-bracket-champion-label {
  font-family: var(--iil-font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--iil-accent-strong);
}
.iil-bracket-champion-team {
  font-family: var(--iil-font-display);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--iil-accent-strong);
}

/* ----- Rounds: plain stack, the fallback for a bracket with no geometry ----- */
.iil-bracket-rounds {
  display: grid;
  gap: var(--bracket-gap);
  grid-template-columns: 1fr;
}
.iil-bracket-round { display: grid; gap: 0.75rem; align-content: start; }

.iil-bracket-round-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0;
  font-family: var(--iil-font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--iil-text-mute);
}
.iil-bracket-round-week {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--iil-text-dim);
}

/* ----- Tournament tree -----
   Rounds are columns left-to-right; every match is placed on a row span whose
   centre is the midpoint of the matches feeding it (services/playoffs.py
   computes the spans). Row tracks are equal `1fr`, which in an auto-height grid
   all resolve to the same height — that's what keeps the centring exact even
   though match cards vary in height. Row gap MUST stay 0: with a gap, row-line
   positions stop being proportional to a grid area's height and the connector
   percentages drift. Breathing room comes from the slot padding instead.

   The tree keeps its shape everywhere — a phone and a narrow dashboard column
   both scroll it sideways rather than getting a different layout, which is why
   the scroll container is unconditional. */
.iil-bracket-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.25rem;
}
.iil-bracket--tree .iil-bracket-rounds {
  --bracket-col: minmax(13rem, 1fr);
  --bracket-connector: 2.75rem;
  row-gap: 0;
  column-gap: 0;
  min-width: 46rem;
}
/* Promotes the slots to direct grid children while keeping the round grouping
   in the markup for the no-geometry fallback. */
.iil-bracket--tree .iil-bracket-round { display: contents; }
.iil-bracket--tree .iil-bracket-round-title {
  grid-row: 1;
  align-self: end;
  padding: 0 0.15rem 0.6rem;
}
.iil-bracket--tree .iil-bracket-slot {
  align-self: center;
  min-width: 0;
  padding-block: 0.4rem;
}

/* ----- Connectors -----
   The element spans the full block height of its feeders, so the inline
   percentages are exact fractions of its own height. Two in-stubs on the left
   half, a spine joining them, one out-stub on the right half at the downstream
   match's centre. The #1 bye gets its own Round 1 card, so every match is fed by
   two and every connector is the same elbow. (A lone feeder would collapse all
   four onto one straight line — still correct, just no longer reachable.) */
.iil-bracket-connector { position: relative; }
.iil-bracket-connector > span {
  position: absolute;
  background: var(--iil-hairline-2);
}
.iil-bracket-connector-in,
.iil-bracket-connector-out {
  width: 50%;
  height: 1px;
}
.iil-bracket-connector-in { left: 0; }
.iil-bracket-connector-out { left: 50%; }
.iil-bracket-connector-spine {
  left: 50%;
  width: 1px;
  top: var(--feed-a);
  height: calc(var(--feed-b) - var(--feed-a));
}

/* ----- Match card ----- */
.iil-bracket-match {
  border: 1px solid var(--iil-hairline);
  border-radius: 12px;
  background: var(--iil-bg-2);
  overflow: hidden;
}
.iil-bracket-match.is-complete { border-color: var(--iil-hairline-2); }

.iil-bracket-side {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
}
.iil-bracket-side + .iil-bracket-side { border-top: 1px solid var(--iil-hairline); }
/* Winner takes the accent: tinted row, solid accent bar, accent text. The
   losing side stays neutral. `inset` box-shadow so the bar costs no layout. */
.iil-bracket-side.is-winner {
  background: var(--iil-accent-wash);
  box-shadow: inset 3px 0 0 var(--iil-accent);
  color: var(--iil-accent-strong);
}
.iil-bracket-side.is-winner .iil-bracket-team { font-weight: 700; }
.iil-bracket-side.is-pending .iil-bracket-team {
  color: var(--iil-text-dim);
  font-style: italic;
}

.iil-bracket-team {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-size: 0.94rem;
  font-weight: 500;
}
.iil-bracket-team .iil-dot {
  flex: none;
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0;
  border-radius: 50%;
  /* Matches the ring public_pages.css gives .iil-dot, which app pages never load. */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.iil-bracket-bye {
  flex: none;
  padding: 1px 6px;
  border: 1px solid var(--iil-hairline-2);
  border-radius: 999px;
  font-family: var(--iil-font-display);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--iil-text-mute);
}

.iil-bracket-score {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.iil-bracket-score strong { font-size: 1rem; }
.iil-bracket-games {
  font-size: 0.74rem;
  color: var(--iil-text-mute);
  white-space: nowrap;
}

.iil-bracket-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 0.85rem;
  border-top: 1px solid var(--iil-hairline);
  background: var(--iil-bg-3);
}
.iil-bracket-tag {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--iil-text-mute);
}
.iil-bracket-tag.is-warn { color: var(--iil-accent-strong); }
.iil-bracket-note {
  font-size: 0.72rem;
  color: var(--iil-text-dim);
}

.iil-bracket-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  border-top: 1px solid var(--iil-hairline);
}
.iil-coinflip-form { flex: 1 1 100%; }

.iil-bracket-empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--iil-text-dim);
}

/* ----- The #1 seed's bye card -----
   A Round 1 card with no game behind it, so it carries the winner accent on the
   seed but no score. Dashed border marks it as the one card that isn't a played
   match; it must stay the same height rhythm as the rest, so no size overrides. */
.iil-bracket-match.is-bye { border-style: dashed; }
