/* ============================================================
   COMPONENTS-LEAGUE.CSS — Thirsk Squash Club
   Mini-league + standings + league-page surfaces.
   Loaded after components.css; depends on tokens in base.css.
   ============================================================ */

/* ── RANK BADGES (league positions) ────────────────────────── */
.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 500;
}
.rank-gold   { background: #fff3cd; color: #856404; }
.rank-silver { background: #e9ecef; color: #495057; }
.rank-bronze { background: #fde3cc; color: #8a3800; }
.rank-other  { background: var(--bl); color: var(--bm); }

/* ── DIVISION HEADER ───────────────────────────────────────── */
.div-header {
  background: var(--bd);
  color: #fff;
  padding: 7px 9px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-top: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 3px solid var(--bm);
}
.div-header span {
  font-size: 10px;
  color: rgba(255,255,255,.45);
}

/* ── RESULT ROWS (mini-league pending + history) ──────────── */
.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem;
  border: 0.5px solid var(--br);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  font-size: 12px;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.result-score {
  font-family: var(--font-stats);
  font-size: 18px;
  letter-spacing: 2px;
}
.result-score.win  { color: var(--gn); }
.result-score.loss { color: var(--rd); }

/* Per-row team result line on the league page */
.result-opp { font-weight: 500; font-size: 13px; }
.result-score-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.result-outcome {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
}
.result-outcome.win  { color: var(--gn); }
.result-outcome.loss { color: #999; }

/* ── CONFIRM / DISPUTE BUTTONS (pending results) ───────────── */
.result-actions { display: flex; gap: 0.4rem; width: 100%; }
.result-actions button {
  flex: 1;
  padding: 5px;
  font-size: 11px;
  cursor: pointer;
  border-radius: 5px;
  font-family: var(--font-body);
  border: 0.5px solid;
}
.btn-confirm {
  background: var(--gl);
  color: var(--gn);
  border-color: var(--gn);
}
.btn-dispute {
  background: var(--rl);
  color: var(--rd);
  border-color: var(--rd);
}

/* ── STANDINGS ROW TINTS ──────────────────────────────────── */
.standings-row-promote { background: #f0fff6; }
.standings-row-demote  { background: #fff5f5; }

/* Empty division-slot row — subtle gold highlight so it reads as
   an invitation rather than missing data. League.joinMiniLeague
   routes by caller state (anon → register, unpaid → membership,
   paid → skill flow). */
.standings-row-open td {
  background: rgba(245, 158, 11, 0.06);
  border-top: 0.5px dashed rgba(245, 158, 11, 0.35);
}
.standings-row-open:hover td {
  background: rgba(245, 158, 11, 0.14);
}

/* Live-update pulse — plays after a Supabase Realtime event
   repaints standings. Subtle emerald border flash so members
   see "this just updated" without distraction. */
@keyframes standings-flash-anim {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153,0); }
  20%  { box-shadow: 0 0 0 4px rgba(52, 211, 153,0.65); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153,0); }
}
.standings-flash {
  animation: standings-flash-anim 1.6s ease-out;
}

/* ── LEAGUE TABS (Mini League · Ladder · Tournaments · Honours) */
.league-tab {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--br);
  font-size: 12px;
  cursor: pointer;
  background: var(--wh);
  transition: all 0.2s;
  font-family: var(--font-body);
}
.league-tab.active {
  background: var(--bd);
  color: var(--bm);
  border-color: var(--bd);
}
.league-section { display: none; }
.league-section.active { display: block; }

/* ── LEAGUE PAGE TOP GRID (divisions left, signup hero right) */
.league-top-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.2rem;
  margin-bottom: 1rem;
  align-items: start;
}
.league-divisions-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

/* "Your matches" panel — sits above the divisions list when the signed-in
   user is in this round. Same emerald accent as primary CTAs so it reads
   as an action-required surface, not a passive info card. */
.my-round-panel {
  background: linear-gradient(135deg, #f0fbf5 0%, #ffffff 100%);
  border: 0.5px solid var(--br);
  border-left: 3px solid var(--bm);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem 1.2rem;
}
.my-round-kicker {
  font-family: var(--font-editorial);
  font-style: italic;
  font-size: 11px;
  color: var(--bm2);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  font-weight: 600;
}
.my-round-title {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.2;
  color: var(--bd);
  margin-bottom: 0.5rem;
  font-weight: 400;
}
.my-round-body {
  font-size: 13px;
  color: var(--mu);
  line-height: 1.6;
}
.league-signup-col {
  position: sticky;
  top: 72px; /* clear the sticky header */
  align-self: start;
}
@media (max-width: 960px) {
  .league-top-grid { grid-template-columns: 1fr; }
  .league-signup-col { position: static; }
  .league-divisions-stack { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}

/* ============================================================
   LEAGUE-PAGE SIGNUP CARD
   State-aware hero: kicker + big title + dynamic sub + primary
   CTA, with a live progress widget on the right.
   ============================================================ */
.league-signup-card {
  display: grid;
  /* Stack body + progress vertically — card lives in a 360px right
     column on the league page, so side-by-side doesn't fit. */
  grid-template-columns: 1fr;
  gap: 1.2rem;
  align-items: stretch;
  background: linear-gradient(135deg, var(--bd) 0%, #1a221d 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.7rem;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
  border-left: 4px solid var(--bm);
}
.league-signup-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 85% 20%, rgba(0, 208, 132,0.12) 0%, transparent 55%),
    radial-gradient(circle at 15% 85%, rgba(0, 208, 132,0.10) 0%, transparent 55%);
}
.league-signup-body {
  position: relative;
  z-index: 1;
  min-width: 0;
}
.league-signup-kicker {
  font-family: var(--font-editorial);
  font-style: italic;
  font-size: 12px;
  background: linear-gradient(90deg, #9a7a1f 0%, #d4af37 50%, #9a7a1f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.5rem;
}
.league-signup-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 3.4vw, 40px);
  color: #fff;
  letter-spacing: 2px;
  line-height: 1.1;
  margin-bottom: 0.6rem;
  font-weight: 400;
}
.league-signup-sub {
  font-size: 14px;
  color: var(--lav);
  line-height: 1.65;
  max-width: 560px;
  margin-bottom: 1.15rem;
}
.league-signup-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  align-items: center;
}
.btn-signup-primary {
  font-size: 14px;
  padding: 10px 22px;
}
.btn-signup-secondary {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}
.btn-signup-secondary:hover { border-color: var(--bm); color: var(--bm); }
.btn-signup-wa {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--wa);
  color: #fff;
  font-size: 12px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 500;
  white-space: nowrap;
}
.btn-signup-wa:hover { opacity: 0.9; text-decoration: none; }

/* Right-hand progress widget */
.league-signup-progress {
  position: relative;
  z-index: 1;
  text-align: center;
  min-width: 180px;
  padding: 1.1rem 1.4rem 1.2rem;
  background: rgba(8, 10, 9, 0.4);
  border: 1px solid rgba(0, 208, 132, 0.4);
  border-radius: var(--radius-md);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.league-signup-count {
  font-family: var(--font-stats);
  font-size: clamp(40px, 4.4vw, 54px);
  color: var(--bm);
  letter-spacing: 2px;
  line-height: 1;
}
.league-signup-count-slash {
  color: rgba(255,255,255,0.45);
  font-size: 0.7em;
  letter-spacing: 1px;
}
.league-signup-of {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  letter-spacing: 1.8px;
  text-transform: uppercase;
  margin: 0.45rem 0 0.7rem;
}
.league-signup-bar-wrap {
  background: rgba(255,255,255,0.18);
  border-radius: 6px;
  height: 10px;
  overflow: hidden;
  width: 100%;
}
.league-signup-bar {
  /* Match the homepage hero widget — red → amber → green gradient
     painted on the fill so the colour shifts as the bar grows. */
  background: linear-gradient(90deg, #d42b2b 0%, #f59e0b 40%, #10b981 85%, #34d399 100%);
  background-size: 220px 100%;
  background-repeat: no-repeat;
  height: 100%;
  border-radius: 6px;
  width: 0%;
  transition: width 0.8s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}
.league-signup-hint {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.6px;
  color: rgba(255,255,255,0.85);
  margin-top: 0.6rem;
  line-height: 1.4;
}
.league-signup-draw-eta {
  display: inline-block;
  margin-top: 0.55rem;
  padding: 3px 10px;
  background: rgba(0, 208, 132, 0.15);
  border: 1px solid rgba(0, 208, 132, 0.4);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 1.4px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--bml);
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.5);
}

@media (max-width: 680px) {
  .league-signup-card {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 1.4rem 1.3rem;
  }
  .league-signup-progress {
    width: 100%;
    min-width: 0;
  }
}

/* ============================================================
   LEAGUE — HOMEPAGE CTA + PLAYER CARDS
   Cross-page bits: homepage league CTA buttons, in-league flag,
   and the messaging widgets used in the Your Division card.
   ============================================================ */

/* Outlined emerald button for "Sign In" homepage action */
.btn-outline-blue {
  background: none;
  border: 1px solid var(--bm2);
  color: var(--bm2);
}
.btn-outline-blue:hover { background: var(--bl); }

/* Solid plum button for "Join" / "Rejoin" homepage actions */
.btn-plum {
  background: var(--bd);
  color: #fff;
  border: none;
}
.btn-plum:hover { background: #1a221d; }

.in-league-flag {
  font-size: 11px;
  color: var(--gn);
  font-weight: 500;
}

/* Unread red dot on player-card message button */
.unread-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rd);
  border: 2px solid var(--wh);
}

/* Message preview under player-card chat bubble */
.msg-preview {
  font-size: 11px;
  color: var(--mu);
  margin-top: 2px;
}
.msg-preview.is-unread {
  color: var(--bd);
  font-weight: 600;
}

/* Chat thread rounded corner overrides */
.chat-bubble {
  margin-bottom: 0.6rem;
  padding: 0.5rem 0.8rem;
  max-width: 80%;
}
.chat-bubble-me    { border-radius: 12px 12px 4px 12px; }
.chat-bubble-other { border-radius: 12px 12px 12px 4px; }
.chat-bubble-time {
  font-size: 10px;
  margin-top: 3px;
  opacity: 0.6;
}

/* ============================================================
   ADMIN — DIVISION MANAGEMENT
   ============================================================ */
.admin-unassigned-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.3rem;
  background: var(--al);
  border: 0.5px solid #ffe082;
  border-radius: var(--radius-sm);
  font-size: 12px;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.admin-unassigned-row > span { font-weight: 500; }
.admin-unassigned-row > div { display: flex; flex-wrap: wrap; gap: 4px; }

.division-card-title {
  font-weight: 500;
  font-size: 13px;
  color: var(--bd);
}
.division-player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-bottom: 0.5px solid var(--br);
  font-size: 12px;
}
.division-player-row:last-child { border-bottom: none; }

/* ============================================================
   PROFILE — MY LEAGUE JOURNEY (dashboard card)
   ============================================================ */
.journey-headline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.journey-headline-item { text-align: center; }
.journey-headline-num {
  font-family: var(--font-stats);
  font-size: clamp(18px, 4vw, 26px);
  letter-spacing: 1.5px;
  color: #fff;
  line-height: 1.1;
}
.journey-headline-num.journey-green { color: var(--bm); }
.journey-headline-num.journey-red   { color: #ff6b6b; }
.journey-headline-num.journey-gold  { color: var(--ac); }
.journey-headline-lbl {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin-top: 3px;
}

.journey-streak {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  text-align: center;
}
.streak-win  { background: rgba(0,208,132,0.18); color: var(--bml); }
.streak-loss { background: rgba(255,107,107,0.15); color: #ffb2b2; }

.journey-section { margin-top: 0.9rem; }
.journey-label {
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  margin-bottom: 0.5rem;
}
.journey-form-row {
  display: flex;
  gap: 5px;
}
.journey-form-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-body);
  color: #fff;
  cursor: help;
}
.journey-form-dot.win  { background: var(--bm); }
.journey-form-dot.loss { background: #ff6b6b; }

.journey-opp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
  font-size: 13px;
  color: rgba(255,255,255,0.9);
}
.journey-opp-row:last-child { border-bottom: none; }
.journey-tag-win  { background: var(--bm); color: #05080a; font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 700; }
.journey-tag-loss { background: #ff6b6b; color: #05080a; font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 700; }
.journey-tag-pend { background: rgba(255,255,255,0.1); color: var(--ac); font-size: 10px; padding: 2px 8px; border-radius: 10px; }
.journey-tag-todo { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7); font-size: 10px; padding: 2px 8px; border-radius: 10px; }

.journey-round-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.journey-round-pill {
  font-size: 10px;
  letter-spacing: 0.5px;
  background: rgba(0,208,132,0.15);
  color: var(--bml);
  padding: 3px 8px;
  border-radius: 10px;
}

.journey-h2h-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  border-bottom: 0.5px solid rgba(255,255,255,0.06);
}
.journey-h2h-row:last-child { border-bottom: none; }
.journey-h2h-win  { color: var(--bm); font-weight: 600; }
.journey-h2h-loss { color: #ff6b6b;   font-weight: 600; }
.journey-h2h-even { color: rgba(255,255,255,0.55); font-weight: 500; }
/* Default collapsed state — hide rows past the 5th. Toggling
   .is-expanded on the parent list reveals them in one paint. */
.journey-h2h-list .journey-h2h-extra { display: none; }
.journey-h2h-list.is-expanded .journey-h2h-extra { display: flex; }
.journey-h2h-toggle {
  margin-top: 0.55rem;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.85);
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.journey-h2h-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.4);
}

.journey-footer {
  margin-top: 0.9rem;
  padding-top: 0.6rem;
  border-top: 0.5px solid rgba(255,255,255,0.08);
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.3px;
}

/* ============================================================
   HONOURS PAGE — season champions + history
   ============================================================ */
.honours-season {
  padding: 0.75rem 0;
  border-bottom: 0.5px solid var(--br);
}
.honours-season:last-child { border-bottom: none; }
.honours-season-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
  gap: 0.5rem;
}
.honours-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.honours-table th {
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--mu);
  font-weight: 500;
  text-align: left;
  padding: 6px 8px 4px;
  border-bottom: 0.5px solid var(--br);
}
.honours-table td {
  padding: 6px 8px;
  border-bottom: 0.5px solid var(--br);
}
.honours-table tr:last-child td { border-bottom: none; }
.honours-table td:first-child { width: 80px; color: var(--mu); }
.honours-table td:last-child  { text-align: right; font-weight: 600; color: var(--bm); width: 60px; }
