/* sportperspective — Stats page. Tokens only; shared components are styled in site.css. */

/* Page head + controls ------------------------------------------------------ */
.stats-head { padding-bottom: var(--s-5); }

.stats-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3) var(--s-5);
  margin-top: var(--s-6);
}
.stats-controls .controls { min-width: 0; max-width: 100%; }
.stats-controls__tabs { min-width: 0; max-width: 100%; }

.stats-updated {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin: 0;
  white-space: nowrap;
}
.stats-updated__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--league);
  flex: none;
}
.stats-updated__dot--stale { background: var(--accent); }
.stats-updated time { color: var(--text); }

/* Panel ---------------------------------------------------------------------- */
.stats-panel {
  border-top: 1px solid var(--line-strong);
  padding-top: var(--s-5);
  padding-bottom: var(--s-8);
}

.stats-toolbar:not(:empty) { margin-bottom: var(--s-5); }
.stats-toolbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3) var(--s-5);
  min-height: 42px;
}

.stats-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  max-width: 80ch;
  margin: 0;
  line-height: 1.4;
}
.stats-legend__lead { color: var(--text); font-weight: 600; }
.stats-legend__item { display: inline-flex; align-items: center; gap: var(--s-2); }
.stats-legend__note { flex-basis: 100%; }
@media (min-width: 1100px) { .stats-legend__note { flex-basis: auto; } }

/* Playoff picture: tinted rows + a seed tag beside the team name. */
.stand-table tr.is-playoff > * { background: color-mix(in srgb, var(--league) 9%, var(--table-bg)); }
.stand-table tr.is-playoff--wc > * { background: color-mix(in srgb, var(--league) 5%, var(--table-bg)); }
.stand-table tr.is-playoff > th:first-child { box-shadow: inset 3px 0 0 var(--league); }
.stand-table tr.is-playoff--wc > th:first-child { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--league) 55%, transparent); }
.stand-table.data-table tr > :first-child { padding-left: var(--s-3); }
.card .stand-table.data-table tr > :first-child { padding-left: var(--s-4); }
.stats-legend__line {
  width: 28px;
  flex: none;
  border-top: 2px dashed var(--league);
}

.stats-notice:not(:empty) { margin-bottom: var(--s-4); }
.stats-stale { flex-wrap: wrap; align-items: center; column-gap: var(--s-3); }
.stats-stale__retry {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.stats-region {
  min-height: 360px;
  transition: opacity var(--t-fast) var(--ease);
}
.stats-region:focus { outline: none; }
.stats-region[data-pending] { opacity: .5; }
.stats-region .empty-state,
.stats-region .error-state { max-width: 640px; }

/* Standings ------------------------------------------------------------------- */
.stand-conf + .stand-conf { margin-top: var(--s-7); }

.stand-conf__title {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 32px;
  margin-bottom: var(--s-4);
  font-size: 1.375rem;
  font-stretch: 110%;
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.stand-conf__title::before {
  content: "";
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 2px;
  background: var(--league);
  transform: rotate(45deg) scale(.8);
}

.stand-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-6) var(--s-6);
}
/* JS adds --two only when every column fits side by side (see fitDivisionGrid). */
@media (min-width: 1100px) {
  .stand-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--s-5); }
}

.stand-stack { display: grid; gap: var(--s-7); }

.stand-block { min-width: 0; }
.stand-block__title {
  display: flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: var(--s-2);
  font-size: .75rem;
  font-weight: 650;
  font-stretch: 100%;
  letter-spacing: .12em;
  text-transform: uppercase;
  line-height: 1.3;
  color: var(--league-ink);
}
.standings--conference .stand-block__title,
.standings--league .stand-block__title,
.stand-block__title--h3 {
  min-height: 32px;
  margin-bottom: var(--s-3);
  font-size: 1.375rem;
  font-stretch: 110%;
  font-weight: 750;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--text);
}

/* Team column: keep it from collapsing, but let numbers stay tight. */
.stand-table .col-team { min-width: 0; }
.stand-table td.col-rec { font-weight: 500; color: var(--muted); }
.stand-table td.col-rec.is-key { color: var(--text); font-weight: 700; }

/* Fixed numeric column widths so stacked tables line up column for column;
   the team column absorbs the remaining width. */
@media (min-width: 760px) {
  .stand-table th.num { width: 4.25rem; }
  .stand-table th.num.col-rec { width: 4.75rem; }
}

/* Side-by-side division tables: tighter numeric columns, nicknames only. */
.stand-grid--two .stand-table th:not(:first-child),
.stand-grid--two .stand-table td { padding-inline: calc(var(--s-1) * 1.5); }
.stand-grid--two .stand-table th.num { width: auto; }
.stand-grid--two .stand-table th:last-child,
.stand-grid--two .stand-table td:last-child { padding-right: 0; }
.stand-grid--two .team-cell { gap: var(--s-2); }
.stand-grid--two .team-cell__full { display: none; }
.stand-grid--two .team-cell__nick { display: inline; }

/* fitDivisionGrid() measures synchronously; no transitions while it does. */
.standings.is-measuring,
.standings.is-measuring * { transition: none !important; }

/* Skeleton titles occupy the same box as the headings they stand in for. */
.stats-sk-title { height: 12px; }
.stand-block__title--h3 .stats-sk-title,
.stats-sk-conf { height: 18px; }
.standings.is-skeleton .stand-block__title,
.standings.is-skeleton .stand-conf__title { color: transparent; }
.standings.is-skeleton .stand-conf__title::before { background: var(--surface-2); }

/* Leaders --------------------------------------------------------------------- */
.leaders-grid { row-gap: var(--s-7); }
@media (min-width: 760px) {
  .leaders-grid { column-gap: var(--s-6); }
}

/* Scores ---------------------------------------------------------------------- */
.stats-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}
.stats-nav__step {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.stats-step {
  width: 34px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}
.stats-step span { display: block; transform: translateY(-1px); }
.stats-nav__label {
  display: grid;
  justify-items: center;
  min-width: 132px;
  padding-inline: var(--s-2);
  text-align: center;
}
.stats-nav__kicker { font-size: .6875rem; color: var(--league-ink); }
.stats-nav__title {
  font-size: 1.25rem;
  font-stretch: 110%;
  font-weight: 750;
  line-height: 1.15;
  letter-spacing: -0.01em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.stats-nav__summary {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-4);
  margin: 0;
}
.stats-nav__live {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text);
}

.score-grid,
.scores-skeleton .skeleton-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 172px), 1fr));
  gap: var(--s-3);
}
.score-grid .score-chip,
.scores-skeleton .skeleton-chip { width: auto; }
.scores-skeleton .skeleton-chip { height: auto; min-height: 92px; }

.scores-day + .scores-day { margin-top: var(--s-6); }
.scores-day__title { margin-bottom: var(--s-3); }

/* Small screens --------------------------------------------------------------- */
@media (max-width: 599px) {
  .stats-controls { margin-top: var(--s-5); }
  .stats-controls .controls { width: 100%; }
  .stats-controls__tabs { flex: 1 1 auto; }
  .stats-controls__tabs .tabs { display: flex; width: 100%; }
  .stats-controls__tabs .tabs .seg__btn { flex: 1 1 0; padding-inline: var(--s-3); }
  .stats-view-switch { width: 100%; }
  .stats-view-switch .seg__btn { flex: 1 1 0; padding-inline: var(--s-2); }
  .stats-nav { width: 100%; justify-content: space-between; }
  .stats-nav__label { min-width: 0; flex: 1 1 auto; }
  .stats-nav__step { flex: 1 1 auto; justify-content: space-between; }
  .stand-conf__title,
  .standings--conference .stand-block__title,
  .standings--league .stand-block__title,
  .stand-block__title--h3 { font-size: 1.1875rem; }
}

/* Motion (gated; reduced motion keeps only the static states) ------------------ */
@media (prefers-reduced-motion: no-preference) {
  .stats-enter { animation: stats-in var(--t) var(--ease) both; }
}
@keyframes stats-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
