/*
 * Chesselo – leaderboard and player profile.
 *
 * Text uses the theme's own font and colour. To restyle, override the custom properties on .chesselo, e.g.
 *   .chesselo { --chesselo-accent: #0b5ed7; }
 */

.chesselo {
	--chesselo-accent: #ffcc00;
	--chesselo-line: rgba(127, 127, 127, 0.28);
	--chesselo-soft: rgba(127, 127, 127, 0.08);
	--chesselo-up: #1a7f37;
	--chesselo-down: #b3261e;
	--chesselo-same: #6b7280;
	--chesselo-on-accent: #111111;
	--chesselo-graph-fill: #ffcc00;
	--chesselo-graph-line: currentColor;
	--chesselo-graph-line-width: 2.5;
	--chesselo-graph-node: var(--chesselo-accent);
	--chesselo-graph-node-stroke: var(--chesselo-on-accent);
	--chesselo-gold: #ffcc00;
	--chesselo-silver: #aeb4bd;
	--chesselo-bronze: #cd8f5d;
	--chesselo-radius: 10px;

	box-sizing: border-box;
	margin: 1.5em 0;
	font: inherit;
	color: inherit;
	line-height: 1.5;
}

.chesselo *,
.chesselo *::before,
.chesselo *::after {
	box-sizing: inherit;
}

/* Tabs --------------------------------------------------------------- */

.chesselo__tabs {
	display: flex;
	gap: 0.25rem;
	margin: 0 0 1rem;
	border-bottom: 1px solid var(--chesselo-line);
	overflow-x: auto;
	overflow-y: hidden;
	white-space: nowrap;
	scrollbar-width: thin;
}

.chesselo__tabs[hidden],
.chesselo__panel[hidden],
.chesselo__empty[hidden],
.chesselo__more[hidden],
.chesselo__back[hidden],
.chesselo__ranges[hidden],
.chesselo__chart-view[hidden] {
	/* !important: some themes set "section { display: block !important }", which otherwise shows every
	   format's details and graph at once (the profile looks duplicated). */
	display: none !important;
}

.chesselo .chesselo__tab {
	appearance: none;
	margin: 0 0 -1px;
	padding: 0.65em 1.1em;
	border: 0;
	border-bottom: 3px solid transparent;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	line-height: 1.2;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	opacity: 0.7;
}

.chesselo .chesselo__tab:hover {
	opacity: 1;
	background: var(--chesselo-soft);
}

.chesselo .chesselo__tab[aria-selected="true"] {
	border-bottom-color: var(--chesselo-accent);
	font-weight: 700;
	opacity: 1;
	background: none;
}

.chesselo .chesselo__tab:focus-visible,
.chesselo .chesselo__load:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Leaderboard table ---------------------------------------------------- */

.chesselo__scroll {
	max-width: 100%;
	overflow-x: hidden;
	padding: 1px;
}

.chesselo .chesselo__table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	font-size: inherit;
	font-variant-numeric: tabular-nums;
}

.chesselo .chesselo__caption {
	padding: 0 0 0.6em;
	text-align: left;
	font-weight: 700;
	font-size: 1.1em;
	caption-side: top;
}

.chesselo--tabs .chesselo__caption {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.chesselo .chesselo__table th,
.chesselo .chesselo__table td {
	padding: 0.7em 0.9em;
	border: 0;
	border-bottom: 1px solid var(--chesselo-line);
	background: none;
	text-align: left;
	vertical-align: middle;
}

.chesselo .chesselo__table thead th {
	border-bottom-width: 2px;
	font-size: 0.85em;
	font-weight: 600;
	opacity: 0.75;
}

.chesselo .chesselo__table tbody tr:hover td {
	background: var(--chesselo-soft);
}

.chesselo__c--rank {
	width: 6em;
	white-space: nowrap;
	font-weight: 700;
}

.chesselo__c--rating,
.chesselo__c--games {
	text-align: right !important;
}

.chesselo__c--rating {
	font-weight: 700;
}

.chesselo__c--name a {
	color: inherit;
	text-decoration: underline;
	text-decoration-color: var(--chesselo-line);
	text-underline-offset: 3px;
}

.chesselo__c--name a:hover,
.chesselo__c--name a:focus-visible {
	text-decoration-color: currentColor;
}

.chesselo__c--gender {
	width: 4.5em;
	text-align: center;
}

.chesselo .chesselo__gender-icon {
	display: inline-block;
	width: 1.35em;
	height: 1.35em;
	max-width: none;
	vertical-align: middle;
	border: 0;
	box-shadow: none;
	background: transparent;
}

/* Top three: a coloured bar on the left edge of the row. */
.chesselo__row--p1 { --chesselo-medal: var(--chesselo-gold); }
.chesselo__row--p2 { --chesselo-medal: var(--chesselo-silver); }
.chesselo__row--p3 { --chesselo-medal: var(--chesselo-bronze); }

.chesselo__row--podium td:first-child {
	box-shadow: inset 5px 0 0 var(--chesselo-medal);
}

/* Load more ---------------------------------------------------------- */

.chesselo__more {
	margin: 1.25rem 0 0;
	text-align: center;
}

.chesselo .chesselo__load {
	appearance: none;
	padding: 0.6em 1.6em;
	border: 2px solid currentColor;
	border-radius: 999px;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	font-weight: 600;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
}

.chesselo .chesselo__load:hover {
	background: var(--chesselo-accent);
	border-color: var(--chesselo-accent);
	color: var(--chesselo-on-accent);
}

.chesselo .chesselo__load[aria-busy="true"] {
	opacity: 0.55;
	cursor: progress;
}

/* Notices ------------------------------------------------------------ */

.chesselo__empty,
.chesselo__notice {
	margin: 1rem 0;
	padding: 1em 1.25em;
	border-radius: var(--chesselo-radius);
	background: var(--chesselo-soft);
}

/* Player profile ------------------------------------------------------- */

.chesselo__back {
	margin: 0 0 0.5rem;
	font-size: 0.9em;
}

.chesselo__back a {
	color: inherit;
}

/* Icon in column 1; the name and the state/country line share column 2, so location lines up with the name. */
.chesselo .chesselo__identity {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	column-gap: 0.35em;
	align-items: center;
	margin: 0 0 1rem;
	font-size: clamp(1.5rem, 4vw, 2.1rem);
	line-height: 1.2;
}

.chesselo .chesselo__identity .chesselo__player {
	grid-column: 2;
	grid-row: 1;
	min-width: 0;
	margin: 0;
	font-size: 1em;
	line-height: inherit;
}

.chesselo .chesselo__identity .chesselo__player-icon {
	grid-column: 1;
	grid-row: 1;
	display: block;
	width: 50px;
	height: 50px;
	max-width: none;
	object-fit: contain;
	margin: 0;
	border: 0;
	box-shadow: none;
	background: transparent;
}

.chesselo .chesselo__format-name {
	margin: 1.5rem 0 0.75rem;
	font-size: 1.15rem;
}

.chesselo__summary {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0.75rem 2.5rem;
	margin: 0 0 1.25rem;
	padding: 1.1rem 1.25rem;
	border-left: 6px solid var(--chesselo-accent);
	border-radius: 0 var(--chesselo-radius) var(--chesselo-radius) 0;
	background: var(--chesselo-soft);
}

.chesselo .chesselo__current {
	display: flex;
	flex-direction: column;
	margin: 0;
}

.chesselo__current-label {
	font-size: 0.85em;
	opacity: 0.75;
}

.chesselo__current-value {
	font-size: clamp(2.4rem, 7vw, 3.6rem);
	font-weight: 800;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

.chesselo .chesselo__facts {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 0.95em;
}

.chesselo .chesselo__facts li {
	margin: 0;
	padding: 0;
}

.chesselo__chart-wrap {
	margin: 0 0 1rem;
}

.chesselo .chesselo__chart {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	overflow: visible;
}

.chesselo__grid line {
	stroke: var(--chesselo-line);
	stroke-width: 1;
}

.chesselo__grid text,
.chesselo__axis text {
	fill: currentColor;
	opacity: 0.7;
	font-size: 11px;
	font-family: inherit;
}

.chesselo__area {
	fill: var(--chesselo-graph-fill);
	stroke: none;
}

.chesselo__line {
	stroke: var(--chesselo-graph-line);
	stroke-width: var(--chesselo-graph-line-width);
	stroke-linejoin: round;
	stroke-linecap: round;
}

.chesselo__dots circle {
	fill: var(--chesselo-graph-node);
	stroke: var(--chesselo-graph-node-stroke);
	stroke-width: 1.5;
}

/* Node style "Solid circle" (Settings > Rating graph): fill only, no outline. */
.chesselo__dots--solid circle {
	stroke: none;
}

/* Graph period buttons (All time, 5 years, ...) */
.chesselo__ranges {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin: 0 0 0.75rem;
}

.chesselo .chesselo__range {
	appearance: none;
	margin: 0;
	padding: 0.35em 0.9em;
	border: 1px solid var(--chesselo-line);
	border-radius: 999px;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	font-size: 0.9em;
	line-height: 1.3;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	opacity: 0.8;
}

.chesselo .chesselo__range:hover {
	opacity: 1;
	background: var(--chesselo-soft);
}

.chesselo .chesselo__range[aria-pressed="true"] {
	border-color: var(--chesselo-accent);
	background: var(--chesselo-accent);
	color: var(--chesselo-on-accent);
	font-weight: 700;
	opacity: 1;
}

.chesselo .chesselo__range:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.chesselo__details {
	margin: 0 0 1rem;
}

.chesselo__details summary {
	padding: 0.5em 0;
	cursor: pointer;
	font-weight: 600;
}

.chesselo__up {
	color: var(--chesselo-up);
	font-weight: 700;
}

.chesselo__down {
	color: var(--chesselo-down);
	font-weight: 700;
}

.chesselo__same {
	color: var(--chesselo-same);
	font-weight: 700;
}

/* Rating change (+15.3) after a rating, and rank change (up 2) after a rank. */
.chesselo__delta,
.chesselo__rc {
	display: inline-block;
	margin-left: 0.35em;
	font-size: 0.8em;
	font-weight: 600;
	white-space: nowrap;
}

.chesselo__delta--up,
.chesselo__rc--up {
	color: var(--chesselo-up);
}

.chesselo__delta--down,
.chesselo__rc--down {
	color: var(--chesselo-down);
}

.chesselo__delta--same,
.chesselo__rc--same {
	color: var(--chesselo-same);
}

.chesselo__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* State and country (with flag), under the player's name and lined up with it. */
.chesselo .chesselo__identity .chesselo__meta {
	grid-column: 2;
	grid-row: 2;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 1.25rem;
	margin: 0.2rem 0 0;
	font-size: 1rem;
	line-height: 1.4;
	opacity: 0.85;
}

.chesselo__country {
	white-space: nowrap;
}

.chesselo .chesselo__flag {
	display: inline-block;
	width: 1.25em;
	height: auto;
	margin: 0 0 0 0.15em;
	vertical-align: -0.15em;
	border-radius: 2px;
	box-shadow: 0 0 0 1px var(--chesselo-line);
}

.chesselo__current-line {
	display: flex;
	align-items: baseline;
	gap: 0.25rem;
}

.chesselo__current-line .chesselo__delta {
	margin-left: 0.5em;
	font-size: 1.15rem;
}

.chesselo--admin .chesselo__panel {
	margin: 0 0 2rem;
}

@media (max-width: 520px) {
	.chesselo .chesselo__table th,
	.chesselo .chesselo__table td {
		padding: 0.6em 0.5em;
	}

	.chesselo__c--rank {
		width: 3em;
	}

	.chesselo__summary {
		gap: 0.75rem 1.5rem;
	}
}
