/* ==========================================
   TEAMS — /teams team-picker grid
   Loaded alongside style.css.

   Layout note: style.css already puts `padding-top: calc(56px + 20px)`
   on <body> to clear the fixed .top-nav — this file must NOT add its
   own top margin/offset on top of that.

   Defensive containment: this page has previously broken when some
   upstream element rendered wider than the viewport (a stray asset,
   a mis-sized decoration, etc.) and dragged the whole document
   sideways — everything that looked "centered" ended up off in a
   scrollable no-man's-land. Below we clip at the page boundary
   instead of letting that happen again, regardless of the cause.

   Every var() below carries a fallback so this page still renders
   correctly even if a token from style.css is ever missing.

   Each .team-pick-card gets --card-primary / --card-secondary / --card-glow
   custom properties set inline by teams.js from data/team-brand.json,
   so the accent border + glow are per-team while everything else stays
   on the shared court-at-night tokens from style.css. Rim-orange stays
   the only *system* accent (search focus, buttons, result count) — the
   team color is data, not decoration.
   ========================================== */

/* ---------- Defensive containment ---------- */
body.teams-page {
  overflow-x: clip;
  width: 100%;
  display: block;
}

.teams-page img,
.teams-page svg {
  max-width: 100%;
  height: auto;
}

.teams-page * {
  box-sizing: border-box;
}

/* ---------- Header ---------- */
.teams-header {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 20px 0;
  text-align: center;
}

.teams-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  padding: 5px 14px;
  border: 1px solid var(--card-border, rgba(255, 255, 255, 0.1));
  border-radius: 999px;
  background: var(--card-bg, #14171d);
  font-family: var(--font-body, 'Manrope', sans-serif);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent, #ff7a45);
}

.teams-eyebrow i {
  width: 13px;
  height: 13px;
  stroke-width: 2.5;
}

.teams-title {
  font-family: var(--font-display, 'Bebas Neue', sans-serif);
  font-size: clamp(2rem, 5vw, 2.8rem);
  letter-spacing: 0.01em;
  line-height: 1.05;
  text-transform: uppercase;
  color: var(--text-primary, #f5f6f8);
  margin-bottom: 6px;
}

.teams-subtitle {
  color: var(--text-secondary, #9aa1ad);
  font-family: var(--font-body, 'Manrope', sans-serif);
  font-size: 0.98rem;
  line-height: 1.5;
}

/* ---------- Search bar ---------- */
.teams-search-bar {
  position: sticky;
  top: 56px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 20px 14px;
  margin-top: 18px;
  background: linear-gradient(var(--bg-color, #0a0c10) 60%, transparent);
}

.teams-search-row {
  position: relative;
  width: 100%;
  max-width: 420px;
  min-width: 0;
}

.teams-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-secondary, #9aa1ad);
  pointer-events: none;
}

.teams-search-input {
  width: 100%;
  padding: 13px 44px;
  border-radius: var(--radius, 14px);
  border: 1px solid var(--card-border, rgba(255, 255, 255, 0.1));
  background: var(--card-bg, #14171d);
  color: var(--text-primary, #f5f6f8);
  font-family: var(--font-body, 'Manrope', sans-serif);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-width: 0;
}

.teams-search-input::placeholder {
  color: var(--text-secondary, #9aa1ad);
}

.teams-search-input:focus {
  border-color: var(--accent, #ff5a1f);
  box-shadow: 0 0 0 3px var(--accent-glow, rgba(255, 90, 31, 0.25));
}

.teams-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary, #9aa1ad);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.teams-search-clear:hover {
  color: var(--text-primary, #f5f6f8);
  background: rgba(255, 255, 255, 0.06);
}

.teams-result-count {
  font-family: var(--font-body, 'Manrope', sans-serif);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary, #9aa1ad);
  min-height: 1.2em;
  font-variant-numeric: tabular-nums;
}

/* ---------- Grid ----------
   Fluid column count via clamp() instead of a stack of hand-tuned
   breakpoints: card width scales smoothly with viewport width, so the
   grid self-adjusts from a 2-up phone layout up through a wide desktop
   layout without any of the columns snapping or overflowing. */
.teams-grid-wrap {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 20px 64px;
}

.teams-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary, #9aa1ad);
  text-align: center;
  padding: 56px 20px;
}

.teams-empty-state i {
  width: 32px;
  height: 32px;
  stroke-width: 1.5;
  opacity: 0.6;
}

.teams-empty-state p {
  font-family: var(--font-body, 'Manrope', sans-serif);
  font-size: 0.95rem;
  max-width: 320px;
}

.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(92px, 24vw, 150px), 1fr));
  gap: clamp(10px, 2vw, 14px);
}

.team-pick-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--card-bg, #14171d);
  border: 1px solid var(--card-border, rgba(255, 255, 255, 0.1));
  border-top: 3px solid var(--card-border, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius, 14px);
  padding: 22px 10px 18px;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
  animation: team-card-in 0.36s ease backwards;
  animation-delay: calc(min(var(--i, 0), 14) * 20ms);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.team-pick-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--card-glow, transparent) 0%, transparent 65%);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.team-pick-card:hover,
.team-pick-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--card-primary, var(--accent, #ff5a1f));
  border-top-color: var(--card-primary, var(--accent, #ff5a1f));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.team-pick-card:hover::before,
.team-pick-card:focus-visible::before {
  opacity: 1;
}

.team-pick-card:active {
  transform: translateY(-3px) scale(0.97);
}

.team-pick-logo {
  position: relative;
  width: 60px;
  height: 60px;
  object-fit: contain;
  transition: transform 0.18s ease;
}

.team-pick-card:hover .team-pick-logo,
.team-pick-card:focus-visible .team-pick-logo {
  transform: scale(1.06);
}

.team-pick-name {
  position: relative;
  font-family: var(--font-body, 'Manrope', sans-serif);
  font-weight: 700;
  font-size: 0.86rem;
  line-height: 1.25;
  color: var(--text-primary, #f5f6f8);
}

.team-pick-abbr {
  position: relative;
  font-family: var(--font-body, 'Manrope', sans-serif);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--card-primary, var(--accent, #ff7a45));
}

@keyframes team-card-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Loading skeleton ---------- */
.teams-grid-skeleton {
  margin-top: 0;
}

.team-skeleton-card {
  height: 128px;
  border-radius: var(--radius, 14px);
  border: 1px solid var(--card-border, rgba(255, 255, 255, 0.1));
  background: linear-gradient(100deg, var(--card-bg, #14171d) 30%, var(--card-bg-hover, #1c2027) 50%, var(--card-bg, #14171d) 70%);
  background-size: 200% 100%;
  animation: teams-skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes teams-skeleton-shimmer {
  0% { background-position: 150% 0; }
  100% { background-position: -50% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .team-skeleton-card {
    animation: none;
    background: var(--card-bg-hover, #1c2027);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
  .teams-search-bar {
    top: 48px;
    padding: 14px 16px 10px;
  }

  .teams-search-row {
    max-width: 100%;
  }

  .teams-search-input {
    font-size: 0.95rem;
    padding: 12px 40px;
  }

  .team-pick-card {
    padding: 16px 6px 14px;
  }

  .team-pick-logo {
    width: 46px;
    height: 46px;
  }

  .team-pick-name {
    font-size: 0.76rem;
  }

  .team-skeleton-card {
    height: 104px;
  }
}

@media (max-width: 380px) {
  .teams-title {
    font-size: 1.8rem;
  }

  .teams-search-row {
    max-width: 100%;
  }

  .teams-search-input {
    font-size: 0.9rem;
    padding: 11px 38px;
  }

  .teams-eyebrow {
    font-size: 0.66rem;
    padding: 4px 12px;
  }

  .team-pick-card {
    padding: 14px 4px 12px;
    gap: 8px;
  }

  .team-pick-logo {
    width: 40px;
    height: 40px;
  }

  .team-pick-name {
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .team-pick-card,
  .team-pick-logo {
    transition: none;
    animation: none;
  }

  .team-pick-card:hover,
  .team-pick-card:focus-visible {
    transform: none;
  }

  .team-pick-card:hover .team-pick-logo,
  .team-pick-card:focus-visible .team-pick-logo {
    transform: none;
  }
}