/* Public league microsite styles. Shared by the SSR Cloud Function (ssrLeagueSite,
   functions/src/ssr.ts) and the client hydration script (app.js). Served as a
   static file by Firebase Hosting, so the /leagues/** rewrite never touches it. */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0a0a0f;
  --panel: rgba(255,255,255,0.04);
  --panel-border: rgba(255,255,255,0.08);
  --text: #f5f6fa;
  --muted: rgba(255,255,255,0.45);
  --faint: rgba(255,255,255,0.28);
  --blue: #3b6ef5;
  --blue-soft: rgba(59,110,245,0.14);
  --blue-text: #93b8ff;
  --green: #4ade80;
  --green-soft: rgba(74,222,128,0.12);
  --amber: #f59e0b;
}
html, body {
  background: var(--bg); color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, Arial, sans-serif;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}
body { padding-bottom: env(safe-area-inset-bottom); }
a { color: inherit; text-decoration: none; }

/* ---- Overlay (loading / not-found, client paths only) ---- */
#overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); text-align: center; padding: 24px;
}
#overlay[hidden] { display: none; }
#overlay h1 { font-size: 1.1rem; font-weight: 800; }
#overlay p { color: var(--muted); font-size: 0.9rem; max-width: 28rem; }
#overlay a { color: var(--blue-text); font-weight: 700; }
#spinner {
  width: 30px; height: 30px;
  border: 3px solid rgba(255,255,255,0.12); border-top-color: rgba(255,255,255,0.5);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Server-rendered not-found / message block */
.overlay-msg { text-align: center; padding: 60px 16px; }
.overlay-msg h1 { font-size: 1.3rem; font-weight: 800; margin-bottom: 8px; }
.overlay-msg p { color: var(--muted); font-size: 0.92rem; max-width: 30rem; margin: 0 auto; }
.overlay-msg a { color: var(--blue-text); font-weight: 700; }

/* ---- Top brand bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(10,10,15,0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--panel-border);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.topbar[hidden] { display: none; }
.topbar .inner { max-width: 920px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -0.01em; }
.brand img { width: 22px; height: 22px; }
.brand .name { font-size: 0.95rem; }
.brand .name b { color: var(--blue-text); }
.topbar .cta { font-size: 0.72rem; font-weight: 700; color: var(--muted); border: 1px solid var(--panel-border); border-radius: 999px; padding: 6px 12px; }

.wrap { max-width: 920px; margin: 0 auto; padding: 18px 16px 48px; }
.wrap[hidden] { display: none; }

/* ---- Homepage masthead (SSR) ---- */
.home-hero { text-align: center; padding: 18px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.home-hero h1 { font-size: clamp(1.7rem, 6vw, 2.6rem); font-weight: 900; letter-spacing: -0.025em; line-height: 1.05; }
.home-hero .hero-sub { color: var(--blue-text); font-weight: 700; font-size: clamp(0.95rem, 3vw, 1.1rem); }
.season-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 5px 12px; border-radius: 999px;
}
.season-pill.live { background: var(--green-soft); color: var(--green); }
.season-pill.soon { background: var(--blue-soft); color: var(--blue-text); }
.season-pill.done { background: rgba(255,255,255,0.06); color: var(--muted); }
.hero-cta {
  margin-top: 4px; background: var(--blue); color: #fff; font-weight: 800; font-size: 0.92rem;
  padding: 11px 22px; border-radius: 12px; transition: transform 0.12s;
}
.hero-cta:active { transform: scale(0.97); }
.stat-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; }
.stat {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 10px 16px; min-width: 84px;
}
.stat b { font-size: 1rem; font-weight: 900; }
.stat span { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }

.home-about { margin-top: 22px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; padding: 16px 18px; }
.home-about h2 { font-size: 0.95rem; font-weight: 800; margin-bottom: 8px; }
.home-about p { color: rgba(255,255,255,0.7); font-size: 0.9rem; line-height: 1.6; white-space: pre-line; }

.home-week { margin-top: 18px; }
.home-week h2 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 800; margin-bottom: 10px; padding-left: 2px; }
.week-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.week-game { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; padding: 12px 14px; }
.week-game .wg-when { font-size: 0.7rem; color: var(--muted); font-weight: 700; }
.week-game .wg-teams { font-weight: 800; font-size: 0.95rem; margin-top: 4px; }
.week-game .wg-teams span { color: var(--faint); font-weight: 600; font-size: 0.8rem; }
.week-game .wg-field { font-size: 0.68rem; color: var(--faint); margin-top: 5px; }

/* ---- Directory hub ---- */
.dir-group { margin-top: 26px; }
.dir-group h2 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 800; margin-bottom: 10px; padding-left: 2px; }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.dir-card { display: flex; flex-direction: column; gap: 3px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; padding: 14px 16px; transition: border-color 0.15s; }
.dir-card:hover { border-color: rgba(59,110,245,0.4); }
.dir-card .dir-name { font-weight: 800; font-size: 0.95rem; }
.dir-card .dir-place { color: var(--muted); font-size: 0.76rem; }

/* ---- League header (legacy client header; kept for demo/direct paths) ---- */
.league-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.league-head h1 { font-size: clamp(1.5rem, 5vw, 2.1rem); font-weight: 900; letter-spacing: -0.02em; line-height: 1.1; }
.league-head .updated { color: var(--faint); font-size: 0.72rem; margin-top: 6px; }
.season-select {
  background: var(--panel); color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 9px 12px; font-size: 0.85rem; font-weight: 600; font-family: inherit; outline: none; min-width: 0;
}
.season-select[hidden] { display: none; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; padding: 5px; margin: 22px 0 18px; }
.tabs button {
  flex: 1; padding: 9px 8px; border: none; border-radius: 10px; cursor: pointer; font-family: inherit;
  font-size: 0.82rem; font-weight: 700; color: var(--muted); background: transparent; transition: background 0.15s, color 0.15s;
}
.tabs button.active { background: var(--blue); color: #fff; }

.tabpane { display: none; flex-direction: column; gap: 18px; }
.tabpane.active { display: flex; }
.empty { color: var(--faint); font-size: 0.85rem; text-align: center; padding: 28px 0; }

/* ---- Schedule ---- */
.day-group h2 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 800; margin-bottom: 8px; padding-left: 2px; }
.game {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
}
.game .when { font-size: 0.74rem; color: var(--muted); font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.game .teams { min-width: 0; }
.game .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game .tname { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game .tname.win { color: #fff; }
.game .tname.lose { color: var(--muted); }
.game .sc { font-weight: 900; font-size: 1rem; font-variant-numeric: tabular-nums; flex: none; }
.game .field { font-size: 0.68rem; color: var(--faint); margin-top: 5px; }
.game .right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.badge { font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.final { background: var(--green-soft); color: var(--green); }
.badge.sched { background: rgba(255,255,255,0.06); color: var(--muted); }
.badge.off { background: rgba(239,68,68,0.12); color: #fca5a5; }
.watch { display: inline-flex; align-items: center; gap: 5px; font-size: 0.68rem; font-weight: 800; color: var(--blue-text); background: var(--blue-soft); border: 1px solid rgba(59,110,245,0.3); border-radius: 999px; padding: 5px 10px; white-space: nowrap; }
.watch .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* ---- Standings ---- */
.table-wrap { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 8px; text-align: center; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
th { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 800; border-bottom: 1px solid var(--panel-border); }
td { border-bottom: 1px solid rgba(255,255,255,0.04); }
tr:last-child td { border-bottom: none; }
.team-cell { text-align: left; display: flex; align-items: center; gap: 9px; font-weight: 700; }
.team-cell .rank { color: var(--faint); font-size: 0.72rem; width: 16px; flex: none; text-align: right; }
.team-cell .chip { width: 10px; height: 10px; border-radius: 3px; flex: none; }
th.lead, td.lead { text-align: left; padding-left: 14px; }

/* ---- Teams ---- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.team-card { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; padding: 13px; }
.team-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; background: rgba(255,255,255,0.06); flex: none; }
.team-logo.ph { display: flex; align-items: center; justify-content: center; font-weight: 900; color: rgba(255,255,255,0.5); font-size: 1rem; }
.team-card .meta { min-width: 0; }
.team-card .tn { font-weight: 800; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-card .rec { color: var(--muted); font-size: 0.74rem; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---- Footer ---- */
.foot { max-width: 920px; margin: 0 auto; padding: 26px 16px calc(26px + env(safe-area-inset-bottom)); border-top: 1px solid var(--panel-border); text-align: center; }
.foot[hidden] { display: none; }
.foot .pw { color: var(--muted); font-size: 0.78rem; }
.foot .pw b { color: var(--blue-text); font-weight: 800; }
.foot .get { margin-top: 8px; font-size: 0.74rem; color: var(--faint); }
.foot .get a { color: var(--blue-text); font-weight: 700; }

@media (prefers-reduced-motion: reduce) { #spinner { animation: none; } }
