/* Player stats block. The table itself takes the theme's `.wp-block-table`
   look; this file adds only the controls above it and what a wide, sortable
   table needs. Colours come from the theme presets, with fallbacks so the
   block stays readable under another theme. */

.wps-stats {
	--wps-stats-pine: var(--wp--preset--color--pine, #085832);
	--wps-stats-ink: var(--wp--preset--color--ink, #14241b);
	--wps-stats-muted: var(--wp--preset--color--muted, #5d6b63);
	--wps-stats-line: var(--wps-line, rgba(8, 88, 50, .14));
	min-width: 0;
}

.wps-stats__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 14px 18px;
}
.wps-stats__bar[hidden] { display: none; }

.wps-stats__pick,
.wps-stats__search {
	position: relative;
	flex: 0 1 300px;
	min-width: 0;
}

.wps-stats__label {
	display: block;
	margin-bottom: 6px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--wps-stats-muted);
}

.wps-stats__toggle,
.wps-stats__q,
.wps-stats__find {
	box-sizing: border-box;
	width: 100%;
	min-height: 46px;
	margin: 0;
	padding: 10px 14px;
	border: 1px solid rgba(8, 88, 50, .32);
	border-radius: 8px;
	background: #fff;
	color: var(--wps-stats-ink);
	font: inherit;
	font-size: 16px;
	line-height: 1.3;
}
.wps-stats__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	text-align: left;
	font-weight: 600;
	cursor: pointer;
}
.wps-stats__toggle svg { flex: none; color: var(--wps-stats-pine); }
.wps-stats__single {
	display: flex;
	align-items: center;
	min-height: 46px;
	margin: 0;
	color: var(--wps-stats-ink);
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
}
.wps-stats__toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.wps-stats__toggle:focus-visible,
.wps-stats__q:focus-visible,
.wps-stats__find:focus-visible,
.wps-stats__sort:focus-visible,
.wps-stats__table:focus-visible {
	outline: 2px solid var(--wps-stats-pine);
	outline-offset: 2px;
}

.wps-stats__pop {
	position: absolute;
	z-index: 20;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	padding: 8px;
	border: 1px solid var(--wps-stats-line);
	border-radius: 10px;
	background: #fff;
	box-shadow: 0 18px 40px -18px rgba(6, 30, 18, .45);
}
.wps-stats__pop[hidden] { display: none; }

.wps-stats__find { min-height: 40px; padding: 8px 12px; }

.wps-stats__options {
	list-style: none;
	margin: 8px 0 0;
	padding: 0;
	max-height: 264px;
	overflow-y: auto;
}
.wps-stats__option {
	margin: 0;
	padding: 9px 12px;
	border-radius: 6px;
	color: var(--wps-stats-ink);
	font-size: 15px;
	line-height: 1.35;
	cursor: pointer;
}
.wps-stats__option.is-active { background: rgba(8, 88, 50, .09); }
.wps-stats__option[aria-selected="true"] { font-weight: 700; color: var(--wps-stats-pine); }
.wps-stats__option.is-none { color: var(--wps-stats-muted); cursor: default; }

.wps-stats__count {
	flex: 1 1 auto;
	margin: 0;
	padding-bottom: 12px;
	text-align: right;
	font-size: 14px;
	color: var(--wps-stats-muted);
	white-space: nowrap;
}

.wps-stats__noscript { font-weight: 600; margin: 0; }

/* The table scrolls inside its own box at every width: seven columns do not
   fit a phone, and an extra pasted column must never widen the page. */
.wps-stats .wps-stats__table {
	overflow-x: auto;
	max-width: 100%;
	margin: 18px 0 0;
}
.wps-stats__table table {
	width: 100%;
	min-width: 620px;
	border-collapse: collapse;
}
.wps-stats__table th,
.wps-stats__table td { white-space: nowrap; }
.wps-stats__table th.is-num,
.wps-stats__table td.is-num {
	text-align: right;
	font-variant-numeric: tabular-nums;
}
/* First and last name read as one label. */
.wps-stats__table td:nth-child(2) {
	font-weight: 600;
	color: var(--wps-stats-ink);
}

/* With the script running, the heading is a button filling the whole cell. */
.wps-stats__table th:has(.wps-stats__sort) { padding: 0; }
.wps-stats__sort {
	display: flex;
	align-items: center;
	gap: 6px;
	width: 100%;
	margin: 0;
	padding: 11px 12px;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	text-transform: inherit;
	text-align: left;
	cursor: pointer;
}
.wps-stats__table th.is-num .wps-stats__sort { justify-content: flex-end; }
.wps-stats__sort:hover { background: rgba(255, 255, 255, .12); }
.wps-stats__sort:focus-visible { outline-color: #fff; outline-offset: -3px; }
.wps-stats__arrow {
	flex: none;
	width: 12px;
	font-family: system-ui, sans-serif;
	font-size: 15px;
	font-weight: 700;
	line-height: 1;
	text-align: center;
}
.wps-stats__arrow.is-idle {
	font-size: 13px;
	font-weight: 400;
	opacity: .55;
}
.wps-stats__table th[aria-sort] { background: #033e22; }
.wps-stats__sort:hover .wps-stats__arrow.is-idle { opacity: 1; }

.wps-stats__table td.wps-stats__none {
	padding: 22px 12px;
	text-align: center;
	font-weight: 400;
	color: var(--wps-stats-muted);
}

.wps-stats__updated {
	margin: 10px 0 0;
	font-size: 13px;
	color: var(--wps-stats-muted);
}

@media (max-width: 640px) {
	.wps-stats__pick,
	.wps-stats__search { flex: 1 1 100%; }
	.wps-stats__count { padding-bottom: 0; text-align: left; }
}

/* Heading row pinned by the script while the table is scrolled past. */
.wps-stats__table thead th {
	position: relative;
	z-index: 2;
}
.wps-stats__table.is-pinned thead th { box-shadow: 0 6px 12px -6px rgba(6, 30, 18, .45); }
