/*
 * Game Pulse: the cross-game hubs (includes/hubs.php): the game colours, the game switcher in a section's hero, the
 * hub pages' hero band, the /population/ chart and table and the /news/ feed. The header's Games menu is styled by the
 * theme (games.css, section 6).
 *
 * Each game keeps one colour wherever it appears (the chart's lines, the swatches, the badges): the eight hues of a
 * colour-blind-checked categorical palette in a fixed order, a lighter step for the dark scheme. Text never wears a
 * game colour: the colour is on the swatch or the badge's edge, and every line also has its name next to it.
 */

/* 1. One colour per game ------------------------------------------------------------------------------------- */

.gp-hub-c--osrs { --gp-hub-colour: light-dark(#2A78D6, #3987E5); }
.gp-hub-c--rs3 { --gp-hub-colour: light-dark(#EB6834, #D95926); }
.gp-hub-c--poe { --gp-hub-colour: light-dark(#1BAF7A, #199E70); }
.gp-hub-c--poe2 { --gp-hub-colour: light-dark(#EDA100, #C98500); }
.gp-hub-c--brighter-shores { --gp-hub-colour: light-dark(#E87BA4, #D55181); }
.gp-hub-c--pirates { --gp-hub-colour: light-dark(#008300, #008300); }
.gp-hub-c--wow { --gp-hub-colour: light-dark(#6250D6, #9085E9); }
.gp-hub-c--hearthstone { --gp-hub-colour: light-dark(#E34948, #E66767); }

.gp-hub-line {
	stroke: var(--gp-hub-colour, #64748B);
}

.gp-hub-dot {
	fill: var(--gp-hub-colour, #64748B);
}

svg.gp-hub-icon {
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
}

img.gp-hub-icon {
	flex: none;
	object-fit: contain;
}

.gp-hub-icon--letter {
	display: inline-grid;
	flex: none;
	place-items: center;
	border-radius: 6px;
	font-size: 0.75rem;
	font-weight: 700;
	color: var(--wp--preset--color--surface);
	background: var(--wp--preset--color--muted);
}

.gp-hub-swatch {
	display: inline-block;
	flex: none;
	width: 1.6rem;
	height: 0;
	border-top: 3px solid var(--gp-hub-colour, #64748B);
	vertical-align: middle;
}

.gp-hub-swatch--steam {
	border-top-style: dashed;
}

.gp-hub-swatch--residents {
	border-top-style: dotted;
}

.gp-hub-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.15rem 0.55rem 0.15rem 0.45rem;
	border-left: 4px solid var(--gp-hub-colour, #64748B);
	border-radius: 6px;
	background: var(--wp--preset--color--surface);
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1.4;
	color: var(--wp--preset--color--ink);
	white-space: nowrap;
}

.gp-hub-note {
	font-size: 0.9rem;
	color: var(--wp--preset--color--muted);
}

/* 2. The game switcher in a section's hero ------------------------------------------------------------------ */

.gp-hero__titlebar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.5rem 1rem;
}

.gp-switch {
	font-size: 0.9rem;
	text-align: left;
}

/* The open list takes its own row under the title, so the title keeps its line. */
.gp-switch[open] {
	display: flex;
	flex-basis: 100%;
	flex-direction: column;
	align-items: center;
}

.gp-switch summary {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.3rem 0.8rem;
	border: 1px solid var(--gp-hero-pill, rgba(255, 255, 255, 0.3));
	border-radius: var(--gp-badge-radius, 999px);
	background: rgba(0, 0, 0, 0.3);
	color: var(--gp-hero-ink, #F4EAD0);
	cursor: pointer;
	list-style: none;
}

.gp-switch summary::-webkit-details-marker {
	display: none;
}

.gp-switch summary::after {
	content: "";
	width: 0.45rem;
	height: 0.45rem;
	margin-left: 0.2rem;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: translateY(-2px) rotate(45deg);
}

.gp-switch[open] summary::after {
	transform: translateY(2px) rotate(-135deg);
}

/* Without JavaScript the list opens in the band itself (the band clips anything that would float over it). */
.gp-switch__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
	gap: 0.25rem;
	width: min(40rem, 90vw);
	margin: 0.5rem 0 0;
	padding: 0.4rem;
	list-style: none;
	border: 1px solid var(--gp-hero-pill, rgba(255, 255, 255, 0.25));
	border-radius: 10px;
	background: rgba(0, 0, 0, 0.35);
}

.gp-switch__list a {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.35rem 0.5rem;
	border-radius: 6px;
	color: var(--gp-hero-ink, #F4EAD0);
	text-decoration: none;
}

.gp-switch__list a:hover,
.gp-switch__list a:focus-visible,
.gp-switch__list a[aria-current] {
	background: rgba(255, 255, 255, 0.12);
}

.gp-switch__name {
	font-weight: 650;
}

.gp-switch__tab {
	margin-left: auto;
	font-size: 0.8rem;
	opacity: 0.8;
}

/* With JavaScript: one <select> and its button. */
.gp-switch--select {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
}

.gp-switch--select select,
.gp-switch--select button {
	min-height: 2.25rem;
	padding: 0.3rem 0.8rem;
	border: 1px solid var(--gp-hero-pill, rgba(255, 255, 255, 0.3));
	border-radius: var(--gp-badge-radius, 999px);
	background: rgba(0, 0, 0, 0.35);
	color: var(--gp-hero-ink, #F4EAD0);
	font: inherit;
}

.gp-switch--select select {
	max-width: min(22rem, 70vw);
	color-scheme: dark;
}

.gp-switch--select button {
	cursor: pointer;
	font-weight: 650;
}

/* 3. The hub pages' hero band ------------------------------------------------------------------------------ */

.gp-hero--hub .gp-hero__icons li {
	color: var(--gp-hero-ink, #F4EAD0);
}

.gp-hero--hub .gp-hero__icons :is(img, svg) {
	padding: 2px;
}

/* 4. /population/: the chart ------------------------------------------------------------------------------- */

.gp-hub-chart {
	display: grid;
	gap: 0.75rem;
	margin: 0;
}

.gp-hub-chart__ranges {
	text-align: center;
}

.gp-hub-chart__ranges ul {
	margin-bottom: 0;
	flex-wrap: wrap;
	justify-content: center;
}

/* w15: the chart's parts may shrink to a phone's column (the range switch alone is 360 px wide unwrapped). */
.gp-hub-chart > * {
	min-width: 0;
	max-width: 100%;
}

.gp-hub-chart__controls {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: center;
	gap: 0.75rem 1.5rem;
}

.gp-hub-chart__controls fieldset {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.gp-hub-chart__controls legend {
	margin: 0 auto 0.35rem;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--wp--preset--color--muted);
}

.gp-hub-toggles ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.4rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.gp-hub-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.3rem 0.7rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 999px;
	background: var(--wp--preset--color--surface);
	font-size: 0.85rem;
	cursor: pointer;
}

.gp-hub-toggle input {
	margin: 0;
	accent-color: var(--wp--preset--color--primary);
}

.gp-hub-toggle:has(input:not(:checked)) {
	opacity: 0.6;
}

.gp-hub-toggle:has(input:not(:checked)) .gp-hub-swatch {
	border-top-color: var(--wp--preset--color--border);
}

.gp-hub-toggle__value {
	font-variant-numeric: tabular-nums;
}

/* 2.2: a series chip may wrap its name at 320 px instead of pushing the page sideways. */
.gp-hub-toggles li {
	max-width: 100%;
}

.gp-hub-toggle {
	max-width: 100%;
	flex-wrap: wrap;
	white-space: normal;
}

.gp-hub-scale label {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	margin-right: 0.75rem;
	font-size: 0.85rem;
	cursor: pointer;
}

.gp-hub-apply {
	padding: 0.4rem 1rem;
	border: 1px solid var(--wp--preset--color--primary);
	border-radius: 999px;
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--on-primary, #0B0F1A);
	font: inherit;
	font-weight: 650;
	cursor: pointer;
}

.gp-hub-chart.is-enhanced .gp-hub-apply {
	display: none;
}

.gp-hub-chart__plot {
	min-height: 12rem;
	padding: 0.5rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 10px;
	background: var(--wp--preset--color--surface);
}

.gp-hub-chart__plot :is(svg, canvas) {
	display: block;
	width: 100%;
}

.gp-hub-chart__svg {
	height: auto;
}

.gp-hub-chart__plot canvas {
	height: 300px;
}

.gp-hub-chart__grid {
	stroke: var(--wp--preset--color--border);
	stroke-width: 1;
}

.gp-hub-chart__ink {
	fill: var(--wp--preset--color--muted);
}

.gp-hub-chart__readout {
	min-height: 1.4em;
	margin: 0;
	font-size: 0.85rem;
	text-align: center;
	color: var(--wp--preset--color--ink);
	font-variant-numeric: tabular-nums;
}

.gp-hub-chart figcaption {
	font-size: 0.85rem;
	line-height: 1.5;
	text-align: center;
	color: var(--wp--preset--color--muted);
}

/* 5. /population/: the table ------------------------------------------------------------------------------- */

.gp-hub-table td small,
.gp-hub-table__what small {
	display: block;
	margin-top: 0.15rem;
	font-size: 0.75rem;
	line-height: 1.4;
	color: var(--wp--preset--color--muted);
}

.gp-hub-table td {
	font-variant-numeric: tabular-nums;
}

.gp-hub-table__what {
	min-width: 16rem;
}

.gp-hub-table__what strong {
	margin-left: 0.4rem;
}

.gp-hub-table__source {
	min-width: 12rem;
	font-size: 0.85rem;
}

.gp-hub-table__none td {
	color: var(--wp--preset--color--muted);
}

/* 6. /news/: the chips and the feed ------------------------------------------------------------------------ */

.gp-hub-news {
	display: grid;
	gap: 0.75rem;
}

.gp-hub-chips ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.4rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.gp-hub-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	min-height: 2.25rem;
	box-sizing: border-box;
	padding: 0.3rem 0.8rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 999px;
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--ink);
	font-size: 0.875rem;
	text-decoration: none;
}

.gp-hub-chip small {
	font-size: 0.75rem;
	color: var(--wp--preset--color--muted);
}

.gp-hub-chip:hover,
.gp-hub-chip:focus-visible {
	border-color: var(--wp--preset--color--primary);
}

.gp-hub-chip[aria-current] {
	border-color: var(--wp--preset--color--primary);
	background: var(--wp--preset--color--primary-soft);
	font-weight: 650;
}

.gp-hub-news__status {
	margin: 0;
	font-size: 0.85rem;
	text-align: center;
	color: var(--wp--preset--color--muted);
}

.gp-hub-feed {
	display: grid;
	margin: 0;
	padding: 0;
	list-style: none;
}

.gp-hub-item {
	display: grid;
	grid-template-columns: 11.5rem minmax(0, 1fr);
	gap: 0.2rem 1rem;
	margin: 0;
	padding: 0.75rem 0;
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.gp-hub-item[hidden] {
	display: none;
}

.gp-hub-item .gp-hub-badge {
	grid-row: span 2;
	align-self: start;
	justify-self: start;
}

.gp-hub-item__title {
	font-weight: 600;
	line-height: 1.4;
}

.gp-hub-item__meta {
	font-size: 0.8rem;
	color: var(--wp--preset--color--muted);
}

.gp-hub-item__source::before {
	content: "·";
	margin-right: 0.35rem;
}

.gp-hub-news__tabs {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: center;
	gap: 0.25rem 0.75rem;
	font-size: 0.85rem;
}

.gp-hub-news__tabs p {
	margin: 0;
	color: var(--wp--preset--color--muted);
}

.gp-hub-news__tabs ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 0.75rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (max-width: 640px) {
	.gp-hub-item {
		grid-template-columns: minmax(0, 1fr);
	}

	.gp-hub-item .gp-hub-badge {
		grid-row: auto;
	}
}

/* 7. r12: the population KPI strip, the series chips, the news filter bar and "new since your last visit" ------------ */

.gp-hub-kpis {
	margin-bottom: 0.25rem;
}

/* A series chip: the game's icon, its line style and its number; off is dimmed, never filled. */
.gp-hub-toggle.gp-chip,
.gp-hub-toggle.gp-chip:has(input:checked) {
	gap: 0.4rem;
	border: var(--gp-btn-border, 1px solid var(--wp--preset--color--border));
	border-bottom: 3px solid var(--gp-hub-colour, #64748B);
	background: var(--gp-btn-bg, var(--wp--preset--color--surface));
	color: var(--gp-btn-ink, var(--wp--preset--color--ink));
}

.gp-hub-toggle.gp-chip:has(input:not(:checked)) {
	border-bottom-color: var(--wp--preset--color--border);
	opacity: 0.55;
}

.gp-hub-toggle .gp-hub-icon {
	width: 18px;
	height: 18px;
}

.gp-hub-chart__plot canvas:focus-visible {
	outline: 2px solid var(--gp-accent, var(--wp--preset--color--primary));
	outline-offset: 2px;
}

.gp-hub-chips.gp-filters,
.gp-hub-chips .gp-chips__options {
	justify-content: center;
}

.gp-chip--new {
	border-style: dashed;
}

.gp-hub-new {
	display: inline-block;
	margin-right: 0.4rem;
	padding: 0 0.4rem;
	border-radius: 999px;
	background: var(--gp-accent, var(--wp--preset--color--primary));
	color: var(--gp-accent-ink, #FFFFFF);
	font-size: 0.68rem;
	font-weight: 750;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	vertical-align: 0.1em;
}

.gp-hub-item.is-new {
	padding-left: 0.6rem;
	box-shadow: inset 3px 0 0 var(--gp-accent, var(--wp--preset--color--primary));
}
