/* ========================================================================
   Backgammon Live Scoreboard - Display Page Stylesheet
   TV-optimized dark theme for live pub display
   ======================================================================== */

/* ========================================================================
   Reset & Base Styles
   ======================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: #0f0f0f;
  color: #ffffff;
  line-height: 1.4;
  overflow: hidden;
}

/* ========================================================================
   Screen Management
   ========================================================================
   Only one .screen visible at a time. Default: display: none.
   The "active" class makes a screen visible.
   ======================================================================== */

.screen {
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background-color: #0f0f0f;
  z-index: 10;
}

.screen.active {
  display: flex;
}

/* ========================================================================
   Pairing Screen (State 1)
   ======================================================================== */

#pairing-screen {
  gap: 2rem;
}

.qr-code {
  width: 300px;
  height: 300px;
  background-color: #ffffff;
  border: 2px solid #f5a623;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 200px;
  min-height: 200px;
}

.pairing-message {
  font-size: 2.5rem;
  font-weight: 500;
  text-align: center;
  color: #ffffff;
  margin-top: 1rem;
}

.pairing-instruction {
  font-size: 1.5rem;
  text-align: center;
  color: #cccccc;
  margin-top: 0.5rem;
}

/* ========================================================================
   Scoreboard Screen (State 2)
   ======================================================================== */

#scoreboard-screen {
  align-items: stretch;
  justify-content: flex-start;
  padding: 2rem;
  gap: 1.5rem;
  overflow: hidden;
}

/* Team Scores (dominant visual element, SC-004: legible from 5m) */
.team-scores {
  display: grid;
  grid-template-columns: 1fr auto auto auto 1fr;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  padding: 2rem;
  background-color: rgba(245, 166, 35, 0.08);
  border: 2px solid #f5a623;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.team-name {
  font-size: 2rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-name.home-team-name {
  text-align: end;
  color: #f5a623;
}

.team-name.away-team-name {
  text-align: start;
  color: #64b5f6;
}

.team-score {
  font-size: clamp(4rem, 10vw, 14rem);
  font-weight: 700;
  color: #f5a623;
  text-align: center;
  line-height: 1;
  min-width: 2em;
}

.score-separator {
  font-size: clamp(2rem, 5vw, 6rem);
  font-weight: 300;
  color: #f5a623;
  margin: 0 0.5rem;
}

/* Team player colours — matches the home/away name colours in the scoreboard */
.team1-player {
  color: #f5a623;
}

.team2-player {
  color: #64b5f6;
}

/* Active Matches Section */
.active-matches {
  flex: 0 1 auto;
  width: 100%;
  padding: 1.5rem;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(245, 166, 35, 0.3);
  border-radius: 0.5rem;
}

.section-heading {
  font-size: 1.75rem;
  font-weight: 600;
  color: #f5a623;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.active-matches-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.active-matches-list li {
  padding: 1rem;
  background-color: rgba(255, 255, 255, 0.05);
  border-inline-start: 3px solid #f5a623;
  font-size: 1.5rem;
  color: #ffffff;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* player1: start-aligned, takes available space */
.active-matches-list li .match-players:nth-child(1) {
  flex: 1;
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* player2: end-aligned, takes available space */
.active-matches-list li .match-players:nth-child(3) {
  flex: 1;
  text-align: end;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.active-matches-list li .match-score {
  flex: 0 0 auto;
  color: #f5a623;
  font-weight: 700;
  text-align: center;
  min-width: 5rem;
}

.active-matches-list li .match-target {
  flex: 0 0 auto;
  font-size: 0.8em;
  color: #888888;
  white-space: nowrap;
}

/* Recent Games Feed (scrollable) */
.recent-games {
  flex: 1 1 auto;
  width: 100%;
  padding: 1.5rem;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(245, 166, 35, 0.3);
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.recent-games-list {
  list-style: none;
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-inline-end: 0.5rem;
}

/* Custom scrollbar styling for recent games */
.recent-games-list::-webkit-scrollbar {
  width: 0.5rem;
}

.recent-games-list::-webkit-scrollbar-track {
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 0.25rem;
}

.recent-games-list::-webkit-scrollbar-thumb {
  background-color: #f5a623;
  border-radius: 0.25rem;
}

.recent-games-list::-webkit-scrollbar-thumb:hover {
  background-color: #ffb84d;
}

.recent-games-list li {
  padding: 0.75rem 1rem;
  background-color: rgba(255, 255, 255, 0.05);
  border-inline-start: 3px solid #f5a623;
  font-size: 1.25rem;
  color: #ffffff;
  border-radius: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* ========================================================================
   No Event Screen (State 3)
   ======================================================================== */

#no-event-screen {
  gap: 1.5rem;
}

.no-event-message {
  font-size: 3rem;
  font-weight: 600;
  text-align: center;
  color: #ffffff;
}

.no-event-instruction {
  font-size: 1.75rem;
  text-align: center;
  color: #cccccc;
}

/* ========================================================================
   Expired Screen (State 4)
   ======================================================================== */

#expired-screen {
  gap: 2rem;
}

.expired-message {
  font-size: 2.5rem;
  font-weight: 500;
  text-align: center;
  color: #ffffff;
}

.reload-button {
  padding: 1.25rem 3rem;
  font-size: 1.75rem;
  font-weight: 600;
  color: #0f0f0f;
  background-color: #f5a623;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 150ms ease-in-out;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-height: 48px;
  min-width: 48px;
}

.reload-button:active {
  background-color: #ffb84d;
}

/* ========================================================================
   Connection Lost Overlay (FR-015)
   ========================================================================
   Fixed position overlay over entire screen when connection drops.
   Hidden by default, shown when .visible class is added.
   ======================================================================== */

.connection-lost-overlay {
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 100;
}

.connection-lost-overlay.visible {
  display: flex;
}

.connection-lost-message,
.reconnecting-message {
  font-size: 2rem;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  letter-spacing: 0.05em;
}

.connection-lost-message {
  color: #ff6b6b;
}

.reconnecting-message {
  font-size: 1.5rem;
  color: #cccccc;
  font-weight: 500;
}

/* ========================================================================
   Responsive Design
   ========================================================================
   Optimized for TV resolutions: 1080p (1920×1080), 4K (3840×2160).
   Also works on desktop/tablet browsers.
   ======================================================================== */

/* Small screens (mobile/tablet portrait) */
@media (max-width: 768px) {
  .screen {
    padding: 1.5rem;
  }

  .pairing-message {
    font-size: 1.5rem;
  }

  .pairing-instruction {
    font-size: 1rem;
  }

  .qr-code {
    width: 200px;
    height: 200px;
  }

  .team-scores {
    gap: 0.75rem;
    padding: 1.5rem;
  }

  .team-name {
    font-size: 1.25rem;
  }

  .section-heading {
    font-size: 1.25rem;
  }

  .active-matches-list li {
    font-size: 1rem;
    padding: 0.75rem;
    flex-wrap: wrap;
  }

  .recent-games-list li {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
  }

  .no-event-message {
    font-size: 1.75rem;
  }

  .no-event-instruction {
    font-size: 1rem;
  }

  .expired-message {
    font-size: 1.5rem;
  }

  .reload-button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
  }

  .connection-lost-message {
    font-size: 1.25rem;
  }

  .reconnecting-message {
    font-size: 1rem;
  }
}

/* Medium screens (tablet landscape) */
@media (min-width: 769px) and (max-width: 1200px) {
  .team-scores {
    padding: 1.75rem;
    gap: 1.25rem;
  }

  .section-heading {
    font-size: 1.5rem;
  }

  .active-matches-list li {
    font-size: 1.25rem;
  }

  .recent-games-list li {
    font-size: 1rem;
  }
}

/* Large screens (desktop/1080p TV and above) */
@media (min-width: 1201px) {
  .screen {
    padding: 3rem;
  }

  #scoreboard-screen {
    padding: 2.5rem;
  }

  .team-scores {
    padding: 2.5rem;
  }

  .section-heading {
    font-size: 1.75rem;
  }

  .active-matches-list li {
    font-size: 1.5rem;
    padding: 1.25rem;
  }

  .recent-games-list li {
    font-size: 1.25rem;
    padding: 0.875rem 1.25rem;
  }
}

/* ========================================================================
   Print & Accessibility
   ======================================================================== */

@media print {
  body {
    background-color: #ffffff;
    color: #000000;
  }

  .screen {
    background-color: #ffffff;
    color: #000000;
  }
}

/* Ensure sufficient color contrast for accessibility */
@media (prefers-contrast: more) {
  .team-score {
    color: #ffcc00;
  }

  .score-separator {
    color: #ffcc00;
  }

  .team-scores {
    border-color: #ffcc00;
    background-color: rgba(255, 204, 0, 0.1);
  }

  .section-heading {
    color: #ffcc00;
  }

  .active-matches-list li,
  .recent-games-list li {
    border-left-color: #ffcc00;
  }
}
