/* ─────────────────────────────────────────────────────────────
   brackets.css — the Brackets page.

   Loaded after briefing.css (tokens, masthead, edition bar, serif h1,
   .tools/.filters, footer, dark-mode tokens) and desk.css (.card,
   .kicker). Class names here are the contract with brackets.js.
   ───────────────────────────────────────────────────────────── */

.bracket-leagues { max-width: 100%; }
.bracket-leagues button { display: inline-flex; align-items: center; gap: 7px; }
.league-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; }
.league-dot.is-live { background: #d4452f; box-shadow: 0 0 0 3px rgba(212, 69, 47, .18); }
.league-dot.is-race { background: var(--green); }
.league-dot.is-complete { background: #b58a1b; }

.bracket-root { display: grid; gap: 34px; margin-bottom: 56px; }
/* Grid items default to min-width:auto, which let the wide bracket stretch the
   whole page on phones instead of scrolling inside .bracket-rounds. */
.bracket-root > *, .bracket-sides > *, .race-grid > * { min-width: 0; }
.bracket-empty { color: var(--muted); padding: 40px 0; }

/* ── Hero ───────────────────────────────────────────────────── */

.bracket-hero {
  background: var(--ink);
  color: white;
  border-radius: 8px;
  padding: 28px 30px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 1fr);
  gap: 28px;
  align-items: start;
}
.bracket-hero .kicker { color: var(--accent); }
.bracket-hero h2 {
  font-family: Georgia, serif;
  font-size: clamp(28px, 3.4vw, 42px);
  letter-spacing: -1px;
  line-height: 1.1;
  margin: 0 0 12px;
}
.bracket-hero p { margin: 0 0 8px; color: #d4e0da; }
.hero-champion { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.hero-champion img { width: 64px; height: 64px; object-fit: contain; background: white; border-radius: 50%; padding: 6px; }
.hero-stats { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 16px; }
.hero-stat strong { display: block; font-size: 28px; line-height: 1.1; color: var(--accent); }
.hero-stat span { font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: #b9c9c2; }
.hero-side h3 { font-size: 12px; letter-spacing: .8px; text-transform: uppercase; color: #b9c9c2; margin: 0 0 10px; }
.hero-games { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hero-games a, .hero-games li > span {
  display: block;
  background: rgba(255, 255, 255, .07);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
}
.hero-games a:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }
.hero-games small { display: block; color: #b9c9c2; font-size: 12px; margin-top: 2px; }
.phase-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-radius: 20px;
  padding: 3px 10px;
  margin-left: 8px;
  vertical-align: 2px;
  background: rgba(255, 255, 255, .14);
  color: white;
}
.phase-pill.is-live { background: #d4452f; }

/* ── Primer for newer fans ──────────────────────────────────── */

.bracket-primer { background: white; border: 1px solid var(--line); border-radius: 7px; padding: 14px 18px; }
.bracket-primer summary { cursor: pointer; font-weight: 750; }
.bracket-primer p { color: var(--muted); margin: 12px 0; max-width: 760px; }
.bracket-primer dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; max-width: 820px; font-size: 14px; }
.bracket-primer dt { font-weight: 750; }
.bracket-primer dd { margin: 0; color: var(--muted); }
@media (max-width: 650px) { .bracket-primer dl { grid-template-columns: 1fr; } .bracket-primer dd { margin-bottom: 6px; } }

/* ── Race tables ────────────────────────────────────────────── */

.race-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.race-card { background: white; border: 1px solid var(--line); border-radius: 7px; padding: 18px 18px 10px; }
.race-card h3 { font-size: 17px; margin: 0 0 10px; letter-spacing: -.2px; }
.race-list { list-style: none; margin: 0; padding: 0; }
.race-row {
  display: grid;
  grid-template-columns: 26px 24px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.race-row:first-child { border-top: 0; }
.race-row.is-out { color: var(--muted); }
.race-row.is-favorite { background: rgba(197, 239, 120, .28); border-radius: 4px; }
.race-place { font-weight: 800; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.race-row img, .matchup-team img { width: 22px; height: 22px; object-fit: contain; }
.race-name { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.race-record { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.race-status {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .3px;
  border-radius: 20px;
  padding: 3px 9px;
  white-space: nowrap;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #eef2ee;
  color: var(--ink);
}
.race-status.is-clinched { background: var(--green); color: white; }
.race-status.is-in { background: #dcefd0; color: #1f4d15; }
.race-status.is-playin { background: #fff0c7; color: #6b4a00; }
.race-status.is-chasing { background: #fde3dc; color: #8a2a16; }
.race-status.is-eliminated { background: transparent; color: var(--muted); }
.race-line {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #b0391f;
  padding: 6px 0;
}
.race-line::before, .race-line::after { content: ""; flex: 1; border-top: 2px dashed #e3a494; }
.race-line.is-playin { color: #8a6500; }
.race-line.is-playin::before, .race-line.is-playin::after { border-color: #e7c66b; }
.race-more { background: none; border: 0; color: var(--green); font-weight: 700; padding: 10px 4px; font-size: 13px; }

/* ── Bracket ────────────────────────────────────────────────── */

.bracket-section > .section-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.bracket-sides { display: grid; gap: 26px; }
.bracket-side h3 { font-size: 13px; letter-spacing: 1px; text-transform: uppercase; margin: 0 0 10px; color: var(--green); }
.bracket-rounds {
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
}
.bracket-round {
  flex: 0 0 236px;
  display: flex;
  flex-direction: column;
  scroll-snap-align: start;
  padding-right: 22px;
}
.bracket-round h4 {
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
  white-space: nowrap;
}
.round-dates { font-size: 12px; color: var(--muted); margin: -6px 0 10px; font-variant-numeric: tabular-nums; }
.bracket-final .round-dates { margin: -6px 0 12px; }

.matchup-schedule { border-top: 1px solid var(--line); font-size: 12px; }
.matchup-schedule summary {
  cursor: pointer;
  padding: 6px 10px;
  color: var(--green);
  font-weight: 700;
  list-style-position: inside;
}
.matchup-schedule ol { list-style: none; margin: 0; padding: 0 0 6px; }
.matchup-schedule li > a, .matchup-schedule li > span {
  display: grid;
  grid-template-columns: 26px 92px minmax(0, 1fr);
  gap: 6px;
  padding: 4px 10px;
  color: var(--ink);
}
.matchup-schedule li > a:hover { background: var(--paper); text-decoration: none; }
.game-number { font-weight: 800; color: var(--muted); }
.game-day { white-space: nowrap; }
.game-detail { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bracket-round-body { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 12px; }

.matchup {
  position: relative;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
.bracket-round:not(:last-child) .matchup::after {
  content: "";
  position: absolute;
  right: -22px;
  top: 50%;
  width: 21px;
  z-index: -1;
  border-top: 2px solid var(--line);
}
.bracket-round:not(:last-child) .matchup { overflow: visible; }
.bracket-round-body { isolation: isolate; }
.matchup.is-live { border-color: #d4452f; box-shadow: 0 0 0 2px rgba(212, 69, 47, .14); }
.matchup.is-projected { border-style: dashed; }
.matchup-team {
  display: grid;
  grid-template-columns: 20px 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 14px;
}
.matchup-team + .matchup-team { border-top: 1px solid var(--line); }
.matchup-team.is-winner { font-weight: 800; }
.matchup-team.is-loser { color: var(--muted); }
.matchup-team.is-loser img { opacity: .5; }
.matchup-team.is-tbd { color: var(--muted); font-style: italic; font-size: 13px; }
.matchup-team.is-tbd .matchup-name { white-space: normal; line-height: 1.3; }
.matchup-team picture, .race-row picture { display: block; width: 22px; height: 22px; }
.matchup-team.is-favorite { box-shadow: inset 3px 0 0 var(--accent); }
.matchup-seed { font-size: 11px; font-weight: 800; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.matchup-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matchup-name small { font-weight: 700; font-style: normal; font-size: 10px; letter-spacing: .5px; color: #8a6500; margin-left: 5px; }
.matchup-wins { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 14px; text-align: right; }
.matchup-foot {
  display: block;
  font-size: 12px;
  color: var(--muted);
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 0 0 7px 7px;
}
a.matchup-foot:hover { color: var(--ink); }
.matchup-foot .is-live-text { color: #d4452f; font-weight: 800; }

.bracket-final-wrap { display: flex; justify-content: center; }
.bracket-final { width: min(100%, 360px); text-align: center; }
.bracket-final h3 { font-family: Georgia, serif; font-size: 24px; letter-spacing: -.4px; margin: 0 0 12px; }
.bracket-final .matchup { text-align: left; border: 2px solid var(--ink); }
.bracket-final .matchup-team { font-size: 16px; padding: 11px 14px; }
.bracket-note { font-size: 13px; color: var(--muted); margin: 14px 0 0; }

@media (max-width: 900px) {
  .bracket-hero { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  .bracket-hero { padding: 22px 20px; }
  .race-grid { grid-template-columns: 1fr; }
  .race-row { grid-template-columns: 22px 22px minmax(0, 1fr) auto; }
  .race-record { display: none; }
  .race-status { max-width: 130px; }
  .bracket-round { flex-basis: 210px; }
}

@media (prefers-color-scheme: dark) {
  .bracket-hero { background: #203b34; }
  .race-card, .matchup, .bracket-primer { background: #1a2824; }
  .matchup-foot { background: #15211e; }
  .matchup-schedule li > a:hover { background: #15211e; }
  .race-status { background: #26342f; color: var(--ink); }
  .race-status.is-clinched { background: #2f7d62; }
  .race-status.is-in { background: #28422a; color: #cdeebb; }
  .race-status.is-playin { background: #4a3d12; color: #f3d98a; }
  .race-status.is-chasing { background: #4a241b; color: #ffb9a6; }
  .race-row.is-favorite { background: rgba(197, 239, 120, .12); }
  .bracket-final .matchup { border-color: var(--accent); }
  .filters button[aria-pressed=true] .league-dot.is-race { background: #172c2b; }
}
