/* CSS used exclusively on the stats pages (views/stats/) */

/* ── Stats layout (left nav + content) ────────────────────────── */
.stats-layout {
  display: flex;
  align-items: stretch;
  gap: 24px;
  margin: 16px 25px;
  min-height: calc(100vh - 32px); /* 32px = top + bottom margin */
}

.stats-nav {
  flex: 0 0 160px;
  border-right: 1px solid var(--color-border);
  padding-right: 16px;
  padding-top: 4px;
}

.stats-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stats-nav ul li {
  margin-bottom: 6px;
}

.stats-nav ul li a {
  display: block;
  padding: 2px 4px;
}

.stats-nav-divider {
  height: 1px;
  background: var(--color-border);
  margin: 8px 0 !important;
}

.stats-content {
  flex: 1 1 auto;
  min-width: 0;
}

/* ── Shared stats components ───────────────────────────────── */
.stats-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.stats-label {
  font-size: var(--font-size-s);
  color: var(--color-hint);
  white-space: nowrap;
}

.stats-hint {
  font-size: var(--font-size-s);
  color: var(--color-hint);
  margin-bottom: 8px;
}

.stats-pct {
  color: gray;
  font-size: 0.85em;
}

.stats-table-sm {
  max-width: 480px;
}

.size-switcher {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ── Stats: board size switcher buttons ────────────────────────── */
.size-btn {
  font-family: var(--font-stack);
  font-size: var(--font-size-s);
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  background: var(--color-odd-row);
  color: var(--color-text);
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s, color 0.15s;
}

.size-btn:hover {
  background: var(--color-even-row);
}

.size-btn-active {
  background: var(--color-header);
  border-color: var(--color-link);
  color: var(--color-text);
  font-weight: 600;
  cursor: default;
}

/* ── Number of Pegs stats page ─────────────────────────────── */
.pegs-controls {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.pegs-control-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.pegs-checkbox {
  width: 15px;
  height: 15px;
}

.pegs-color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1.5px solid;
  border-radius: 3px;
  flex-shrink: 0;
}

.pegs-chart-wrap {
  max-width: 900px;
}

#pegs-stats {
  margin-top: 10px;
  font-size: var(--font-size-s);
  color: #444;
}

/* ── First Moves stats page ─────────────────────────────────────── */
.fm-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  font-size: var(--font-size-s);
  color: #555;
}

.fm-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: middle;
  border-radius: 2px;
}

.fm-legend-swatch-under {
  background: rgba(52, 152, 219, 0.8);
  border: 1px solid #888;
}

.fm-legend-swatch-expected {
  background: #f0f0f0;
  border: 1px solid #bbb;
}

.fm-legend-swatch-over {
  background: rgba(231, 76, 60, 0.8);
  border: 1px solid #888;
}

.fm-legend-note {
  padding: 1px 5px;
  font-size: var(--font-size-xs);
}

.fm-heading {
  margin-bottom: 6px;
}

.fm-scroll-wrap {
  overflow-x: auto;
}

.fm-heatmap {
  font-size: var(--font-size-xs);
  border-collapse: collapse;
}

/* Horizontal row separator lines */
.fm-heatmap td.main {
  border-bottom: 1px solid var(--color-border);
}

.fm-heatmap .fm-corner,
.fm-heatmap .fm-col-header {
  text-align: center;
  font-weight: bold;
  color: var(--color-heading);
  background: var(--color-odd-row);
  padding: 3px 6px;
}

.fm-heatmap .fm-row-header {
  text-align: right;
  font-weight: bold;
  color: var(--color-heading);
  background: var(--color-odd-row);
  padding: 3px 8px 3px 6px;
  white-space: nowrap;
}

.fm-cell {
  text-align: center;
  padding: 4px 5px;
  min-width: 54px;
  cursor: default;
  vertical-align: middle;
}

.fm-cell:hover {
  outline: 2px solid var(--color-link);
  outline-offset: -2px;
  position: relative;
  z-index: 1;
}

.fm-cell-empty {
  background: #f7f7f7 !important;
}

.fm-cell-sparse {
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(128, 128, 128, 0.2) 10px,
    rgba(128, 128, 128, 0.2) 20px
  );
}

.fm-cell-mid {
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(128, 128, 128, 0.2) 10px,
    rgba(128, 128, 128, 0.2) 11px
  );
}

.fm-cell-move {
  font-family: var(--font-for-moves);
  font-weight: bold;
  font-size: var(--font-size-xs);
  color: #333;
  line-height: 1.2;
}

.fm-cell-residual {
  font-size: var(--font-size-xs);
  font-weight: bold;
  line-height: 1.2;
  margin-top: 1px;
}

.fm-cell-swap {
  font-size: 0.68rem;
  color: #777;
  line-height: 1.2;
  margin-top: 1px;
}

.fm-th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.fm-th-sortable:hover {
  background: var(--color-even-row);
}

.fm-cell-empty .fm-cell-move {
  color: #ccc;
}

.fm-notes {
  margin-top: 6px;
  font-size: var(--font-size-xs);
  color: #777;
}

.fm-ranked-heading {
  margin-top: 24px;
  margin-bottom: 4px;
}

#fm-ranked-table {
  max-width: 520px;
}

.fm-rank-num {
  color: #777;
}

.fm-move-cell {
  font-family: var(--font-for-moves);
  font-weight: bold;
  padding-left: 8px;
}

.fm-move-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1px solid #999;
  border-radius: 2px;
  margin-right: 5px;
  margin-left: 3px;
  vertical-align: middle;
}

.fm-ranked td {
  white-space: nowrap;
}

/* ── Player stats page ─────────────────────────────────────── */
.ps-form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.ps-input-wrap {
  position: relative;
  display: inline-block;
}

.ps-status {
  font-size: var(--font-size-xs);
  color: var(--color-hint);
}

.ps-info-text {
  font-size: var(--font-size-s);
}

.ps-hint-text {
  font-size: var(--font-size-s);
  color: var(--color-hint);
}

#board-size-filter {
  margin-bottom: 8px;
}

.ps-th-sort {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.ps-th-sort:hover {
  background: var(--color-even-row);
}

.ps-player-input {
  width: 280px;
  font-size: var(--font-size-s);
  font-family: var(--font-stack);
  border: 1px solid var(--color-border);
  padding: 3px 6px;
}

.ps-player-listbox {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  min-width: 100%;
  max-width: 380px;
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  z-index: 200;
  box-shadow: 0 3px 8px rgba(0,0,0,0.18);
}

.ps-view-btn {
  font-size: var(--font-size-s);
  font-family:var(--font-stack);
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  background: var(--color-odd-row);
  cursor: pointer;
}
