/* ============================================================
   ChukkaTimer Live — Stylesheet
   ============================================================ */

/* ----- Custom Properties ----------------------------------- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121c;
  --bg-card: #181826;
  --bg-card-hover: #1f1f32;
  --bg-timer: #10101a;

  --text-primary: #eaeaf0;
  --text-secondary: #9999aa;
  --text-muted: #606070;

  --accent-green: #22d66a;
  --accent-amber: #f5a623;
  --accent-red: #e84040;
  --accent-grey: #666680;

  --border-subtle: #2a2a3a;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --max-width: 720px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--text-primary);
  text-decoration: none;
}

/* ----- Layout ---------------------------------------------- */
.page-wrapper {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
  flex: 1;
}

/* ----- Header ---------------------------------------------- */
.site-header {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-header__title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.site-header__title span {
  color: var(--accent-green);
}

.site-header__home {
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: color 0.2s;
}

.site-header__home:hover {
  color: var(--text-primary);
}

/* ----- Footer ---------------------------------------------- */
.site-footer {
  text-align: center;
  padding: 2rem 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.site-footer a {
  color: var(--text-secondary);
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--accent-green);
}

/* ----- Status Badge ---------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge--live {
  background: rgba(34, 214, 106, 0.15);
  color: var(--accent-green);
}

.badge--paused {
  background: rgba(245, 166, 35, 0.15);
  color: var(--accent-amber);
}

.badge--finished {
  background: rgba(102, 102, 128, 0.15);
  color: var(--accent-grey);
}

.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge--live .badge__dot {
  animation: pulse-dot 1.8s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ----- Stale Warning Banner -------------------------------- */
.stale-banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 1.5rem;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.4s ease, max-height 0.4s ease, padding 0.4s ease,
    margin 0.4s ease;
}

.stale-banner.visible {
  opacity: 1;
  max-height: 80px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.stale-banner:not(.visible) {
  padding: 0 1rem;
  margin-bottom: 0;
}

.stale-banner--warn {
  background: rgba(245, 166, 35, 0.12);
  border: 1px solid rgba(245, 166, 35, 0.3);
  color: var(--accent-amber);
}

.stale-banner--error {
  background: rgba(232, 64, 64, 0.12);
  border: 1px solid rgba(232, 64, 64, 0.3);
  color: var(--accent-red);
}

/* ----- Team Scores ----------------------------------------- */
.scores {
  margin-bottom: 1rem;
}

.team-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
}

.team-row + .team-row {
  border-top: 1px solid var(--border-subtle);
}

.team-color {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.team-name {
  font-size: 1.3rem;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-score {
  font-size: 1.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.team-score__handicap {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 0.3rem;
}

.vs-divider {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.15rem 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.handicap-info {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.5rem 0 0;
}

/* ----- Timer ----------------------------------------------- */
.timer-container {
  text-align: center;
  padding: 2rem 0;
  margin: 1rem 0;
  background: var(--bg-timer);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.timer-display {
  font-family: var(--font-mono);
  font-size: 5.5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}

.timer-display--running {
  color: var(--accent-green);
}

.timer-display--extra {
  color: var(--accent-amber);
}

.timer-display--paused {
  color: var(--accent-grey);
}

.timer-display--ended {
  color: var(--accent-red);
}

.timer-phase {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* ----- Chukka Progress ------------------------------------- */
.chukka-progress {
  text-align: center;
  padding: 1.25rem 0;
}

.chukka-progress__label {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.chukka-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.chukka-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--accent-grey);
  background: transparent;
  transition: all 0.3s;
}

.chukka-dot--played {
  background: var(--accent-grey);
  border-color: var(--accent-grey);
}

.chukka-dot--current {
  border-color: var(--accent-green);
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(34, 214, 106, 0.5);
  animation: pulse-chukka 2s ease-in-out infinite;
}

@keyframes pulse-chukka {
  0%, 100% { box-shadow: 0 0 8px rgba(34, 214, 106, 0.5); }
  50% { box-shadow: 0 0 16px rgba(34, 214, 106, 0.8); }
}

/* ----- Status Bar ------------------------------------------ */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.status-bar__separator {
  color: var(--border-subtle);
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.3rem;
  vertical-align: middle;
  transition: background 0.3s;
}

.connection-dot--connected {
  background: var(--accent-green);
}

.connection-dot--disconnected {
  background: var(--accent-red);
}

/* ----- Loading State --------------------------------------- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 0;
  gap: 1rem;
}

.loading__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading__text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ----- Error / Not Found ----------------------------------- */
.message-state {
  text-align: center;
  padding: 4rem 1rem;
}

.message-state__icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.message-state__title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.message-state__body {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.message-state__link {
  color: var(--accent-green);
  font-weight: 600;
  transition: opacity 0.2s;
}

.message-state__link:hover {
  opacity: 0.8;
}

/* ============================================================
   INDEX PAGE — Game Cards
   ============================================================ */

.game-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.game-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  transition: background 0.2s, border-color 0.2s;
}

.game-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.08);
}

.game-card__top {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.4rem;
}

.game-card__teams {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-card__score {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.game-card__bottom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.game-card__bottom .badge {
  font-size: 0.65rem;
}

.game-card__meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.game-card__meta-separator {
  color: var(--border-subtle);
}

.empty-state {
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-muted);
}

.empty-state__title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
}

.empty-state__body {
  font-size: 0.9rem;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 480px) {
  .timer-display {
    font-size: 3.5rem;
  }

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

  .team-score {
    font-size: 1.4rem;
  }

  .team-score__handicap {
    font-size: 0.85rem;
  }

  .timer-container {
    padding: 1.5rem 0;
    margin: 0.75rem 0;
  }

  .site-header__title {
    font-size: 0.95rem;
  }
}

@media (min-width: 800px) {
  .timer-display {
    font-size: 7rem;
  }

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

  .team-score {
    font-size: 2.2rem;
  }
}

@media (min-width: 1200px) {
  :root {
    --max-width: 800px;
  }

  .timer-display {
    font-size: 8.5rem;
  }
}
