/* =========================================================================
   stats.css — statistical tables, season grids and stat cards.
   Used by the player and coach pages (and any future module rendering
   season-by-season stats).

   Three sub-modules:
     - .stats-season-* : per-season table + chart + ad column (used by player)
     - .stats-grid / .stat-card : square stat tile grid (used by player/coach)
     - .season-table : season-history table (used by player/coach)
   ========================================================================= */

/* ---------------------------------------------------------------------------
   Stats season module: table + chart + ad
   --------------------------------------------------------------------------- */
.stats-season-module {
  padding: 24px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.stats-season-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(220px, 1fr);
  gap: 20px;
  align-items: start;
}

.stats-season-column {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stats-season-column h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px 0;
  color: #000;
  text-shadow: 1px 0 0 currentColor;
}

.stats-season-empty {
  color: var(--ink-faint);
  font-size: 13px;
  padding: 12px 0;
}

.stats-section-title {
  margin-bottom: 4px;
}

/* Filter hint (mobile / desktop variants) */
.filter-hint {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #64748b;
  margin-top: 4px;
  text-shadow: none;
  font-style: italic;
}

.filter-hint--mobile  { display: none; }
.filter-hint--desktop { display: inline-block; }

@media (max-width: 768px) {
  .filter-hint--mobile  { display: block; }
  .filter-hint--desktop { display: none; }
}

/* Stats season table */
.stats-season-table-container {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.stats-season-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-season-table thead th {
  background-color: var(--surface);
  border: 0;
  border-bottom: 1px solid #f97316;
  padding: 5px;
  font-weight: 700;
  font-size: 11px;
  text-align: center;
}

.stats-season-table thead th:first-child {
  text-align: left;
}

.stats-season-table td {
  padding: 5px;
  border: 0;
  text-align: center;
  vertical-align: middle;
  font-size: 14px;
}

.stats-season-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: #000;
  text-shadow: 1px 0 0 currentColor;
}

.stats-season-table tbody tr {
  border-bottom: 1px solid #ffb4439c;
  cursor: pointer;
  transition: background-color 0.2s;
}

.stats-season-table tbody tr:hover,
.stats-season-table tbody tr.active-filter {
  background-color: rgb(255 176 67 / 10%);
}

.stats-season-table tbody tr.active-filter {
  box-shadow: inset 4px 0 0 #f97316;
}

/* Stats season header + toggles */
.stats-season-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.stats-season-toggle {
  display: flex;
  gap: 8px;
}

.season-stats-toggle-btn {
  border: 1px solid rgba(148, 163, 184, 0.8);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  background: #f8fafc;
  color: var(--ink-strong);
  cursor: pointer;
  transition: all 0.2s ease;
}

.season-stats-toggle-btn.active {
  background: #f97316;
  border-color: #f97316;
  color: #fff;
}

.season-stats-toggle-btn:focus-visible {
  outline: 2px solid #f97316;
  outline-offset: 2px;
}

/* Stats season chart panel */
.stats-season-chart {
  min-height: 260px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 12px;
  background: var(--surface);
  position: relative;
}

.stats-season-chart canvas {
  width: 100%;
  height: 220px;
}

.stats-season-chart-empty {
  position: absolute;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  font-size: 12px;
  text-align: center;
  padding: 0 10px;
}

/* Stats module ad (dark sky in stats area) */
.stats-module-ad {
  width: 300px;
  height: 600px;
  min-width: 300px;
  max-width: 300px;
  min-height: 600px;
  max-height: 600px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.4), transparent 45%),
    linear-gradient(145deg, #111827, #1f2937);
  border: 1px solid rgba(156, 163, 175, 0.4);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.stats-season-ad-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 300px;
  min-width: 300px;
  max-width: 300px;
}

/* Player-page tweaks for the stats grids */
body.page-player .stats-season-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1.1fr) 220px;
}

body.page-player .stats-season-column,
body.page-player .stats-season-chart-column {
  min-width: 0;
}

body.page-player .career-stats-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

body.page-player .career-ad-column {
  display: none;
}

body.page-player .stats-season-ad-column {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
}

body.page-player .stats-module-ad {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  height: 520px;
  min-height: 520px;
  max-height: 520px;
}

@media (max-width: 1280px) {
  body.page-player .stats-season-grid,
  body.page-player .career-stats-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  body.page-player .stats-season-ad-column,
  body.page-player .stats-module-ad,
  body.page-player .career-ad-column {
    display: none;
  }
}

@media (max-width: 1024px) {
  body.page-player .stats-season-grid,
  body.page-player .career-stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .stats-season-module {
    padding: 16px;
  }

  .stats-season-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-season-toggle {
    width: 100%;
  }

  .season-stats-toggle-btn {
    flex: 1 1 0;
    text-align: center;
  }

  .stats-season-chart {
    min-height: 220px;
  }

  .stats-season-chart canvas {
    height: 180px;
  }

  .stats-season-grid {
    gap: 14px;
  }

  .stats-season-table-container,
  body.page-player .career-table-container {
    margin: 0 -4px;
    padding: 0 4px 4px;
  }

  .stats-season-table {
    min-width: 640px;
  }

  body.page-player .career-table-container table {
    min-width: 420px;
  }
}

@media (max-width: 480px) {
  .stats-season-module {
    padding: 14px;
  }

  .stats-season-table {
    min-width: 600px;
  }
}

/* ---------------------------------------------------------------------------
   Square stat tiles (used by coach/player intro blocks)
   --------------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}

.stat-card {
  background: rgba(249, 115, 22, 0.08);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid rgba(249, 115, 22, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9aa8bf;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #f97316;
}

.stat-description {
  font-size: 10px;
  color: #64748b;
  margin-top: 4px;
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------------------------------------------------------------------------
   Season history table (per-season summary list)
   --------------------------------------------------------------------------- */
.season-history {
  margin-top: 24px;
}

.season-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.season-table thead {
  background: rgba(249, 115, 22, 0.1);
}

.season-table th {
  padding: 12px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9aa8bf;
  font-weight: 600;
  border-bottom: 2px solid rgba(249, 115, 22, 0.3);
}

.season-table td {
  padding: 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.season-table tbody tr:hover {
  background: rgba(249, 115, 22, 0.05);
}

.season-table .season-name {
  font-weight: 600;
  color: #e6eef8;
}

.season-table .team-name {
  color: #9aa8bf;
  font-size: 13px;
}

.season-table .stat-number {
  font-weight: 600;
  color: #e6eef8;
}

@media (max-width: 768px) {
  .season-table {
    font-size: 12px;
  }

  .season-table th,
  .season-table td {
    padding: 8px 6px;
  }
}
