/* ============================================================
   ChukkaTimer Live — Stylesheet
   Styled to match the ChukkaTimer app: warm paper, polo-field
   green, and a brass accent, with Fraunces + Hanken Grotesk.
   ============================================================ */
@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,500;0,9..144,600;0,9..144,700&family=Hanken+Grotesk:wght@400;500;600;700;800&display=swap");

/* ----- Custom Properties ----------------------------------- */
:root {
  --bg-primary: #faf7ef;     /* warm paper */
  --bg-secondary: #f1ecdf;
  --bg-card: #ffffff;
  --bg-card-hover: #fbf9f3;
  --bg-timer: #ffffff;

  --text-primary: #16201a;   /* near-black, faint green */
  --text-secondary: #515b54;
  --text-muted: #868f88;

  --accent-green: #1f7a52;    /* polo-field green */
  --accent-green-soft: #7fb79c;
  --accent-amber: #c79a3e;    /* brass */
  --accent-red: #c0392b;
  --accent-grey: #b3bbb4;

  --brand-deep: #0f3d28;
  --gold: #c79a3e;
  --gold-2: #e3c46f;

  --border-subtle: rgba(22, 32, 26, 0.10);
  --border-strong: rgba(22, 32, 26, 0.16);

  --font-sans: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-num: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: var(--font-num); /* alias: session.css uses --font-mono for numerals */

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;

  --shadow-sm: 0 1px 2px rgba(16, 40, 24, 0.06), 0 4px 14px -6px rgba(16, 40, 24, 0.14);
  --shadow-md: 0 12px 34px -14px rgba(16, 40, 24, 0.26);

  --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;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

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.1rem 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.75rem;
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.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-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

/* brass bell glyph before the wordmark */
.site-header__title::before {
  content: "";
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
  background:
    linear-gradient(155deg, #163f2c, #0f3122);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3.5a5.5 5.5 0 015.5 5.5c0 3.5 1 5 2 6.2.4.5 0 1.3-.7 1.3H5.2c-.7 0-1.1-.8-.7-1.3 1-1.2 2-2.7 2-6.2A5.5 5.5 0 0112 3.5z' fill='%23e3c46f'/%3E%3Cpath d='M10 19.5a2 2 0 004 0' stroke='%23e3c46f' stroke-width='2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E"),
    linear-gradient(155deg, #163f2c, #0f3122);
  background-size: 20px 20px, cover;
  background-position: center, center;
  background-repeat: no-repeat;
  box-shadow: 0 4px 10px -5px rgba(16, 49, 34, 0.8);
}

.site-header__title span {
  color: var(--accent-green);
  font-style: italic;
  font-weight: 500;
}

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

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

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

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

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

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

.badge--live {
  background: rgba(31, 122, 82, 0.14);
  color: var(--accent-green);
}

.badge--paused {
  background: rgba(199, 154, 62, 0.16);
  color: #9a7522;
}

.badge--finished {
  background: rgba(22, 32, 26, 0.08);
  color: var(--text-secondary);
}

.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(199, 154, 62, 0.14);
  border: 1px solid rgba(199, 154, 62, 0.34);
  color: #8a6a1e;
}

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

/* ----- Team Scores ----------------------------------------- */
.scores {
  margin-bottom: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

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

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

.team-color {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(22, 32, 26, 0.12);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.team-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-score {
  font-size: 1.9rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-num);
  letter-spacing: -0.02em;
}

.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.78rem;
  color: var(--text-muted);
  padding: 0.1rem 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}

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

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

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

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

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

.timer-display--paused {
  color: var(--text-muted);
}

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

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

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

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

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

.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-green-soft);
  border-color: var(--accent-green-soft);
}

.chukka-dot--current {
  border-color: var(--accent-green);
  background: var(--accent-green);
  box-shadow: 0 0 0 4px rgba(31, 122, 82, 0.18);
  animation: pulse-chukka 2s ease-in-out infinite;
}

@keyframes pulse-chukka {
  0%, 100% { box-shadow: 0 0 0 4px rgba(31, 122, 82, 0.18); }
  50% { box-shadow: 0 0 0 7px rgba(31, 122, 82, 0.10); }
}

/* ----- 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-strong);
}

.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-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  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: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.25s, border-color 0.2s;
}

.game-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.game-card__teams {
  flex: 1;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-card__score {
  font-family: var(--font-num);
  font-weight: 800;
  font-size: 1.1rem;
  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;
}

/* Club-chukka session card: no score, subtle "Club" tag instead. */
.game-card__score--session {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
}

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

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

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

.empty-state__title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  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.75rem;
  }

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

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

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

  .timer-container {
    padding: 1.75rem 0;
    margin: 0.85rem 0;
  }

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

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

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

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

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

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