/* PickleBoard — division detail view styles.
 *
 * Used by:
 *   public/b.html        Dedicated /b/<id> page
 *   public/live.html     Spectator view's Divisions tab
 *
 * The HTML these styles target is produced by public/division-render.js
 * (single source of truth for the division rendering logic). Loading
 * the script without loading this CSS gets you correct semantic
 * markup but no styling; loading both gets you the broadcast-quality
 * read-only view.
 *
 * CSS-variable contract — consumers must define on :root or body:
 *   --bg, --fg, --muted, --accent
 *   --card                     base card background
 *   --card-elev                slightly lighter for nested cards
 *                              (match within round; round within section).
 *                              Falls back to --card if not defined.
 *   --border                   subtle outline
 *   --winner                   color for the winning team (defaults to --accent)
 *   --live                     color for the LIVE indicator (defaults to a red)
 *   --font-display, --font-mono, --font-body  optional, all fall back
 *                              to sans-serif/monospace/sans-serif respectively
 *
 * All selectors namespaced under .pb-* so they can't collide with
 * other surfaces' utility classes.
 */

/* Title block — tournament name + division name + format/size/best-of */
.pb-title-block { margin-bottom: 28px; }
.pb-tournament {
  font-family: var(--font-mono, monospace); font-size: 11px;
  letter-spacing: 0.2em; color: var(--muted); text-transform: uppercase;
  margin-bottom: 8px;
}
/* 0.66.0: duprGrouping chip under the tournament name in the division header. */
.pb-duprGrouping {
  display: inline-block; margin-bottom: 8px;
  font-family: var(--font-mono, monospace); font-size: 11px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: #38bdf8; background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.34); border-radius: 999px; padding: 3px 12px;
}
.pb-title {
  font-family: var(--font-display, sans-serif);
  font-weight: 800; font-size: 32px; line-height: 1.1;
  margin-bottom: 6px;
}
.pb-subtitle {
  color: var(--muted); font-size: 14px;
}
.pb-subtitle .dot { margin: 0 8px; opacity: 0.4; }

/* Champion banner — shown when division.status === 'complete'. */
.pb-champion {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent) 20%, var(--card)),
    var(--card));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 26px;
  display: flex; align-items: center; gap: 16px;
}
.pb-champion-trophy { font-size: 36px; line-height: 1; }
.pb-champion-label {
  font-family: var(--font-mono, monospace); font-size: 11px;
  letter-spacing: 0.22em; color: var(--accent); text-transform: uppercase;
  margin-bottom: 4px;
}
.pb-champion-name {
  font-family: var(--font-display, sans-serif);
  font-weight: 800; font-size: 26px;
}

/* Sections — pool standings, pool matches, knockout rounds */
.pb-section { margin-bottom: 32px; }
.pb-section-head {
  font-family: var(--font-mono, monospace); font-size: 11px;
  letter-spacing: 0.22em; color: var(--muted); text-transform: uppercase;
  margin-bottom: 12px;
}

/* Pool standings table */
.pb-standings {
  width: 100%; border-collapse: collapse;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden;
}
.pb-standings thead th {
  text-align: left; padding: 12px 16px;
  font-family: var(--font-mono, monospace); font-size: 10px;
  letter-spacing: 0.18em; color: var(--muted); text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.pb-standings td {
  padding: 14px 16px; border-top: 1px solid var(--border);
  font-size: 15px;
}
.pb-standings tbody tr:first-child td { border-top: none; }
.pb-standings .rank { font-family: var(--font-mono, monospace); width: 36px; color: var(--muted); }
.pb-standings .name { font-weight: 600; }
.pb-standings .wl, .pb-standings .diff {
  font-family: var(--font-mono, monospace); color: var(--muted); width: 80px;
}
.pb-standings .advancing .rank,
.pb-standings .advancing .name { color: var(--accent); }
.pb-standings .advancing .adv {
  display: inline-block; margin-left: 6px; font-size: 11px;
  color: var(--accent);
}

/* 0.78.1: large-duprGrouping (groups_playoff) — groups grid + final standings. */
.pb-groups {
  display: grid; gap: 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .pb-groups { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .pb-groups { grid-template-columns: repeat(3, 1fr); }
}
.pb-group {
  padding: 12px; border-radius: 12px;
  background: rgba(255,255,255,0.02); border: 1px solid var(--border, rgba(255,255,255,0.1));
}
.pb-group-head {
  font-weight: 700; margin-bottom: 8px; color: var(--fg);
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 13px;
}
.pb-group .pb-round { margin-top: 10px; }
.pb-final-standings {
  display: grid; gap: 4px 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .pb-final-standings { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .pb-final-standings { grid-template-columns: repeat(3, 1fr); }
}
.pb-fs-row { display: flex; gap: 10px; align-items: baseline; padding: 3px 0; }
.pb-fs-place {
  font-family: var(--font-mono, monospace); color: var(--accent); font-weight: 700;
  min-width: 42px; text-align: right;
}
.pb-fs-name { color: var(--fg); }

/* Rounds grid — single column on mobile, multi-column on desktop. */
.pb-rounds {
  display: grid; gap: 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .pb-rounds.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .pb-rounds.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .pb-rounds.cols-4 { grid-template-columns: repeat(4, 1fr); }
}
.pb-round {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.pb-round-head {
  font-family: var(--font-mono, monospace); font-size: 11px;
  letter-spacing: 0.22em; color: var(--muted); text-transform: uppercase;
  margin-bottom: 12px;
}
/* 1.150.0: Swiss "Round N" separators within the Matches section. */
.pb-swiss-round {
  font-family: var(--font-mono, monospace); font-size: 10.5px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
  margin: 12px 0 6px; opacity: 0.85;
}
.pb-swiss-round:first-child { margin-top: 0; }

/* Match card */
.pb-match {
  background: var(--card-elev, var(--card));
  border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 10px;
  position: relative;
}
.pb-match:last-child { margin-bottom: 0; }
.pb-match.live {
  border-color: color-mix(in srgb, var(--live, #ff5436) 60%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--live, #ff5436) 30%, transparent),
              0 0 22px color-mix(in srgb, var(--live, #ff5436) 18%, transparent);
}
.pb-match.live::before {
  content: 'LIVE';
  position: absolute; top: -8px; right: 10px;
  background: var(--live, #ff5436); color: #fff;
  font-family: var(--font-mono, monospace); font-size: 9px;
  letter-spacing: 0.18em; padding: 2px 7px; border-radius: 3px;
  font-weight: 700;
  animation: pb-pulse 1.6s ease-in-out infinite;
}
@keyframes pb-pulse { 50% { opacity: 0.4; } }
.pb-team-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
}
.pb-team-row + .pb-team-row { border-top: 1px solid var(--border); }
.pb-team-name {
  flex: 1; font-weight: 600; font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pb-team-name.tbd { color: var(--muted); font-weight: 500; font-style: italic; }
.pb-team-row.winner .pb-team-name { color: var(--winner, var(--accent)); }
.pb-team-row.loser .pb-team-name { color: var(--muted); }
.pb-team-row.winner::before {
  content: '▶'; color: var(--winner, var(--accent));
  font-size: 10px; flex-shrink: 0;
}
.pb-team-row.loser::before { content: ''; width: 10px; flex-shrink: 0; }
.pb-team-row:not(.winner):not(.loser)::before { content: ''; width: 10px; flex-shrink: 0; }
.pb-team-score {
  font-family: var(--font-mono, monospace); font-size: 14px;
  color: var(--fg); font-weight: 600; flex-shrink: 0;
  min-width: 20px; text-align: right;
}
.pb-team-row.loser .pb-team-score { color: var(--muted); }

.pb-match-status {
  font-family: var(--font-mono, monospace); font-size: 10px;
  letter-spacing: 0.18em; color: var(--muted); text-transform: uppercase;
  text-align: center; padding: 4px 0; margin-top: 6px;
  border-top: 1px dashed var(--border);
}
.pb-match.pending .pb-match-status {
  color: color-mix(in srgb, var(--accent) 70%, var(--muted));
}
.pb-match.waiting .pb-match-status {
  color: var(--muted); opacity: 0.5;
}

/* 0.10.41: rematch badge — spectator surfaces. Amber tint marks it
   as "informational, worth knowing" without conflicting with the
   pending/done state colors. Below the match status row. */
.pb-match-rematch {
  font-family: var(--font-mono, monospace);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffaa33;
  text-align: center;
  padding: 3px 0;
  border-top: 1px dashed color-mix(in srgb, #ffaa33 30%, transparent);
}
.pb-match.has-rematch {
  box-shadow: 0 0 0 1px color-mix(in srgb, #ffaa33 26%, transparent);
}

/* Empty / error states */
.pb-empty {
  text-align: center; padding: 60px 20px;
  color: var(--muted);
}
.pb-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.pb-empty-title {
  font-family: var(--font-display, sans-serif); font-weight: 700;
  font-size: 22px; margin-bottom: 8px; color: var(--fg);
}
.pb-empty-detail {
  font-size: 14px; max-width: 360px; margin: 0 auto; line-height: 1.5;
}

/* 0.12.10: scheduled court + start-time on upcoming matches. */
.pb-match-sched {
  margin-top: 4px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--accent, #c8ff3a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 1.14.x: Teams tie — two teams of four over four doubles lines (spectator/OBS). */
.pb-teams-tie { margin: 14px 0 6px; }
.pb-tie-teams {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px;
  padding: 12px 16px; margin-bottom: 12px;
  border: 1px solid var(--pb-border, rgba(255,255,255,0.12)); border-radius: 12px;
  background: var(--pb-panel, rgba(255,255,255,0.03));
}
.pb-tie-team { font-size: 20px; font-weight: 800; }
.pb-tie-team:first-child { text-align: right; }
.pb-tie-team.won { color: var(--pb-good, #5fcb7a); }
.pb-tie-tally { display: flex; align-items: center; gap: 8px; font-size: 28px; font-weight: 900; }
.pb-tie-tally-sep { opacity: 0.4; }
.pb-tie-lines { display: flex; flex-direction: column; gap: 8px; }
.pb-tie-line {
  display: grid; grid-template-columns: 110px 1fr 1fr; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--pb-border, rgba(255,255,255,0.08));
  background: var(--pb-panel, rgba(255,255,255,0.02));
}
.pb-tie-line.decided { border-color: var(--pb-accent-dim, rgba(108,198,255,0.35)); }
/* 1.151.0: DreamBreaker decider row — set apart from the four lines. */
.pb-tie-line.pb-tie-db { margin-top: 8px; border-style: dashed; }
.pb-tie-line.pb-tie-db .pb-tie-line-label { color: var(--pb-gold, #ffd84d); }
.pb-tie-line-label { font-weight: 700; opacity: 0.85; }
.pb-tie-side { display: flex; align-items: center; gap: 10px; }
.pb-tie-side:nth-child(2) { justify-content: flex-end; }
.pb-tie-side:nth-child(3) { justify-content: flex-start; }
.pb-tie-side .pb-tie-pair { color: var(--pb-muted, rgba(255,255,255,0.7)); font-size: 14px; }
.pb-tie-side .pb-tie-num { font-size: 20px; font-weight: 800; min-width: 26px; text-align: center; }
.pb-tie-side.won .pb-tie-num, .pb-tie-side.won .pb-tie-pair { color: var(--pb-good, #5fcb7a); }
.pb-tie-foot { margin-top: 10px; text-align: center; color: var(--pb-muted, rgba(255,255,255,0.65)); font-size: 13.5px; }
