/* ================================================================
   NHL Playoff Bracket — Modern Dark Theme
   ================================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Colours */
  --bg-page:       #07090f;
  --bg-card:       #0f1523;
  --bg-card-2:     #141b2e;
  --bg-hover:      #1c2540;
  --border:        #1e2d4f;
  --border-bright: #2a3f6a;
  --gold:          #FFB81C;
  --gold-dim:      #c8901566;
  --navy:          #041E42;
  --green:         #37b653;
  --green-dim:     #37b65333;
  --red:           #e63946;
  --red-dim:       #e6394622;
  --text-hi:       #eaf0fb;
  --text-mid:      #94a3c0;
  --text-lo:       #4a5a7a;
  --live:          #ff3b3b;
  --connector:     #1e3060;
  --connector-hl:  #FFB81C88;

  /* Sizes */
  --card-w:        170px;
  --card-gap:      12px;
  --slot-h:        140px;   /* height of one R1 slot */
  --col-gap:       36px;
  --connector-w:   24px;    /* half-width of connector arm */
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Barlow', sans-serif;
  background: var(--bg-page);
  color: var(--text-hi);
  min-height: 100vh;
  overflow-x: auto;
}

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(135deg, #020b1a 0%, #041e42 60%, #071530 100%);
  border-bottom: 1px solid var(--gold-dim);
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(6px);
}

.header-inner {
  max-width: 1800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-brand { display: flex; align-items: center; gap: 14px; }

.nhl-shield {
  width: 52px;
  height: auto;
  filter: drop-shadow(0 2px 8px #FFB81C55);
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: var(--text-hi);
  text-transform: uppercase;
}
.brand-year {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 1.6rem;
  color: var(--gold);
  letter-spacing: 0.06em;
  line-height: 1;
}

.header-meta { display: flex; align-items: center; gap: 20px; }

.live-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #e6394618;
  border: 1px solid #e6394655;
  border-radius: 20px;
  padding: 5px 12px;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}
.live-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--live);
}

.update-info { display: flex; flex-direction: column; align-items: flex-end; font-size: 0.72rem; }
.update-label { color: var(--text-lo); text-transform: uppercase; letter-spacing: 0.06em; }
.update-time  { color: var(--text-mid); font-weight: 600; }

/* ---------- Main ---------- */
.main-content {
  padding: 28px 16px 48px;
  max-width: 1900px;
  margin: 0 auto;
}

/* ---------- States (loading / error) ---------- */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 60vh;
  color: var(--text-mid);
}
.state-icon { font-size: 3rem; }
.state-title { font-size: 1.3rem; font-weight: 600; color: var(--text-hi); }
.state-text  { font-size: 0.95rem; color: var(--text-mid); }

.spinner {
  width: 52px;
  height: 52px;
  border: 4px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.retry-btn {
  margin-top: 8px;
  padding: 10px 28px;
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 6px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: opacity 0.2s;
}
.retry-btn:hover { opacity: 0.85; }

/* ---------- Conference Banners ---------- */
.bracket-inner {
  min-width: fit-content;
}

.conf-banners {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.conf-banner {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 8px 16px;
  border-radius: 6px;
  text-align: center;
}
.conf-banner.west {
  background: linear-gradient(90deg, #041E4244 0%, transparent 100%);
  border: 1px solid #041e4266;
  color: #7baaf0;
}
.conf-banner.east {
  background: linear-gradient(270deg, #041E4244 0%, transparent 100%);
  border: 1px solid #041e4266;
  color: #7baaf0;
}
.conf-banner.scf {
  min-width: 130px;
  text-align: center;
  background: linear-gradient(180deg, #1a1200 0%, #291c00 100%);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-size: 0.75rem;
  line-height: 1.3;
  padding: 8px 10px;
}

/* ---------- Bracket Scroll Wrapper ---------- */
.bracket-scroll-wrap {
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 12px;
  /* custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) var(--bg-page);
}
.bracket-scroll-wrap::-webkit-scrollbar { height: 6px; }
.bracket-scroll-wrap::-webkit-scrollbar-track { background: var(--bg-page); }
.bracket-scroll-wrap::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }

/* ---------- Bracket Grid ---------- */
.bracket-grid {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  min-width: fit-content;
  position: relative;
}

/* ---------- Bracket Column ---------- */
.bracket-col {
  display: flex;
  flex-direction: column;
  position: relative;
}

.col-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 0 calc(var(--connector-w) / 2);
}

/* Column widths */
.bracket-col { width: calc(var(--card-w) + var(--connector-w) * 2); }
.bracket-col.col-scf { width: calc(var(--card-w) + 20px); }

/* Round label at top */
.round-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-lo);
  text-align: center;
  padding: 4px 0 8px;
  white-space: nowrap;
}

/* ---------- Series Slots ---------- */
.slots {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.slot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  position: relative;
  min-height: var(--slot-h);
}
/* R2 slots are 2× taller, CF slots 4×, SCF 8× */
.bracket-col.round-2 .slot { min-height: calc(var(--slot-h) * 2); }
.bracket-col.round-3 .slot { min-height: calc(var(--slot-h) * 4); }
.bracket-col.round-4 .slot { min-height: calc(var(--slot-h) * 8); }

/* Connector arms on slots (drawn via CSS borders) */

/* --- West side: connectors on the RIGHT of each card --- */
.bracket-col.conf-west.round-1 .slot::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  width: var(--connector-w);
  height: 1px;
  background: var(--connector);
}

.bracket-col.conf-west.round-1 .slot.top-of-pair::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  width: 2px;
  background: var(--connector);
  /* height set by JS */
}

.bracket-col.conf-west.round-2 .slot::after,
.bracket-col.conf-west.round-3 .slot::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  width: var(--connector-w);
  height: 1px;
  background: var(--connector);
}

/* --- East side: connectors on the LEFT --- */
.bracket-col.conf-east.round-1 .slot::after,
.bracket-col.conf-east.round-2 .slot::after,
.bracket-col.conf-east.round-3 .slot::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: var(--connector-w);
  height: 1px;
  background: var(--connector);
}

/* SCF receives from both sides */
.bracket-col.col-scf .slot::before,
.bracket-col.col-scf .slot::after { display: none; }

/* ---------- SVG connector canvas ---------- */
.connector-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
}

/* ---------- Series Card ---------- */
.series-card {
  width: var(--card-w);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  cursor: default;
  position: relative;
}
.series-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-bright);
  box-shadow: 0 6px 24px #00000066, 0 0 0 1px var(--border-bright);
  z-index: 10;
}

.series-card.series-complete {
  border-color: #1e3040;
  opacity: 0.85;
}
.series-card.series-complete .team-row.loser {
  opacity: 0.45;
}

.series-card.series-live {
  border-color: var(--live);
  box-shadow: 0 0 0 1px var(--live), 0 4px 18px #ff3b3b33;
  animation: live-pulse 2s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--live), 0 4px 18px #ff3b3b33; }
  50%       { box-shadow: 0 0 0 2px var(--live), 0 6px 28px #ff3b3b55; }
}

/* ---- Team Rows ---- */
.team-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  position: relative;
  transition: background 0.15s;
}
.team-row + .team-row {
  border-top: 1px solid var(--border);
}
.team-row.winner {
  background: var(--green-dim);
}
.team-row.loser {
  /* no special bg — just dimmed via parent .series-complete */
}

.team-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 3px #00000088);
}

.team-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  color: var(--text-hi);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-row.loser .team-name { color: var(--text-lo); }

.team-seed {
  font-size: 0.65rem;
  color: var(--text-lo);
  font-weight: 400;
}

.team-wins {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 1.2rem;
  min-width: 18px;
  text-align: right;
  color: var(--text-mid);
}
.team-wins.wins-leader {
  color: var(--green);
}
.team-wins.wins-champion {
  color: var(--gold);
}

/* ---- Series Footer (status / next game) ---- */
.series-footer {
  background: var(--bg-card-2);
  border-top: 1px solid var(--border);
  padding: 5px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.series-status {
  font-size: 0.68rem;
  color: var(--text-mid);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.series-status.status-champion { color: var(--gold); }

.next-game-info {
  font-size: 0.63rem;
  color: var(--text-lo);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.next-game-info.live-game {
  color: var(--live);
  font-weight: 700;
  font-size: 0.68rem;
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.5; } }

.last-score {
  font-size: 0.63rem;
  color: var(--gold);
  line-height: 1.4;
}

/* ---- Empty / TBD card ---- */
.series-card.series-tbd {
  background: var(--bg-card-2);
  border-style: dashed;
  border-color: var(--border);
}
.tbd-label {
  width: 100%;
  text-align: center;
  padding: 28px 10px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: var(--text-lo);
  text-transform: uppercase;
}

/* ---- SCF special styling ---- */
.bracket-col.col-scf .series-card {
  border-color: var(--gold-dim);
  box-shadow: 0 0 32px #FFB81C22;
  background: linear-gradient(180deg, #0f1523 0%, #1a1200 100%);
}
.bracket-col.col-scf .series-card:hover {
  border-color: var(--gold);
  box-shadow: 0 0 40px #FFB81C44, 0 8px 32px #00000088;
}

/* ---------- Connector SVG lines ---------- */
.connector-line {
  stroke: var(--connector);
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
}
.connector-line.active {
  stroke: var(--connector-hl);
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 16px;
  font-size: 0.75rem;
  color: var(--text-lo);
  border-top: 1px solid var(--border);
}

/* ---------- Series card — clickable variant ---------- */
.series-card.series-clickable {
  cursor: pointer;
}

/* ---------- Series Detail Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: modal-fade-in 0.18s ease;
}
@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px #00000099;
  animation: modal-slide-in 0.18s ease;
  overflow: hidden;
}
@keyframes modal-slide-in {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-card-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  color: var(--text-hi);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-mid);
  font-size: 1rem;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--text-hi); background: var(--bg-hover); }

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) var(--bg-card);
}
.modal-body::-webkit-scrollbar       { width: 5px; }
.modal-body::-webkit-scrollbar-track { background: var(--bg-card); }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }

.modal-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
}

.modal-empty {
  text-align: center;
  color: var(--text-lo);
  font-size: 0.88rem;
  padding: 20px 0;
}

/* ---- Individual game block ---- */
.modal-game {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.modal-game-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.game-num {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mid);
  flex-shrink: 0;
}

.game-live-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--live);
  background: #e6394618;
  border: 1px solid #e6394655;
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.game-score {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-hi);
}

/* ---- Period block ---- */
.modal-period {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-period:last-child { border-bottom: none; }

.modal-period-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-lo);
  margin-bottom: 5px;
}

/* ---- Goal row ---- */
.modal-goal {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  font-size: 0.83rem;
  flex-wrap: wrap;
  line-height: 1.4;
}

.goal-time {
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--text-lo);
  min-width: 34px;
  flex-shrink: 0;
}

.goal-team {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--text-mid);
  background: var(--bg-hover);
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
}

.goal-scorer {
  color: var(--text-hi);
  font-weight: 600;
}

.goal-assists {
  color: var(--text-lo);
  font-size: 0.78rem;
}
.goal-assists::before { content: '· '; }

.goal-unassisted { font-style: italic; }

/* ---------- Responsive tweaks ---------- */
@media (max-width: 768px) {
  :root {
    --card-w: 140px;
    --slot-h: 120px;
    --connector-w: 16px;
  }
  .brand-title { font-size: 1rem; }
  .brand-year  { font-size: 1.3rem; }
  .nhl-shield  { width: 40px; }
  .conf-banner { font-size: 0.8rem; }
}
