/*
 * Game Pulse: the Puzzle Pirates section. Sea-green, sand, rope-brown and parchment, as --gp-* overrides under
 * [data-game="pirates"] and .is-game-pirates (the shared components in pulse.css read them), plus the section's own
 * pieces (.gp-pp-*). Colours use light-dark(), so the light and dark schemes come from one declaration.
 */

[data-game="pirates"],
.is-game-pirates {
	--wp--preset--color--primary: light-dark(#0F766E, #5EEAD4);
	--wp--preset--color--primary-soft: light-dark(#E6F2EE, #0F2A27);
	--wp--preset--color--primary-bright: light-dark(#14B8A6, #99F6E4);
	--wp--preset--color--on-primary: light-dark(#FFFFFF, #071A18);
	--wp--preset--color--accent: light-dark(#8A5A2B, #E3B47C);
	--wp--preset--color--ink: light-dark(#2B2118, #EFE6D2);
	--wp--preset--color--muted: light-dark(#6B5B45, #B8AC93);
	--wp--preset--color--surface: light-dark(#FBF5E6, #0E1B1A);
	--wp--preset--color--surface-alt: light-dark(#F3E8CC, #142624);
	--wp--preset--color--border: light-dark(#D6C29A, #2E4A45);
	--gp-pp-sea: light-dark(#0F766E, #2DD4BF);
	--gp-pp-sand: light-dark(#E9D8A6, #6B5B3A);
	--gp-pp-rope: light-dark(#8A5A2B, #C8955A);
	--gp-pp-parchment: light-dark(#FBF3DE, #18201E);
	--gp-tone: var(--gp-pp-rope);
	--gp-radius: 10px;
	--gp-radius-sm: 6px;
	--gp-head-font: Georgia, "Times New Roman", serif;
	--gp-panel-border: light-dark(#C9AE7A, #3B5A54);
	--gp-panel-bg:
		radial-gradient(130% 100% at 0% 0%, light-dark(rgba(255, 255, 255, 0.55), rgba(45, 212, 191, 0.06)), transparent 55%),
		repeating-linear-gradient(97deg, light-dark(rgba(138, 90, 43, 0.035), rgba(255, 255, 255, 0.02)) 0 1px, transparent 1px 5px),
		var(--gp-pp-parchment);
	--gp-panel-alt-bg:
		repeating-linear-gradient(97deg, light-dark(rgba(138, 90, 43, 0.04), rgba(255, 255, 255, 0.02)) 0 1px, transparent 1px 5px),
		light-dark(#F4EAD0, #142624);
	--gp-panel-shadow: 0 1px 0 light-dark(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.04)) inset, 0 12px 26px -20px rgba(7, 26, 24, 0.55);
	--gp-bar: linear-gradient(90deg, #0F766E, #14B8A6 60%, #E9D8A6);
	--gp-bar-track: light-dark(#E8DBBB, #1E3431);
	--gp-live-bg: light-dark(#0F766E, #5EEAD4);
	--gp-live-ink: light-dark(#FFFFFF, #071A18);
	--gp-ink: light-dark(#6B5B45, #B8AC93);
	--gp-grid: light-dark(#E2D3AE, #24403B);
	--gp-series-1: light-dark(#0F766E, #2DD4BF);
	--gp-series-2: light-dark(#B45309, #F59E0B);
	--gp-series-3: light-dark(#7C4A1E, #D6A06A);
	--gp-series-4: light-dark(#1D4ED8, #93C5FD);
	--gp-series-5: light-dark(#9F1239, #FDA4AF);
	--gp-series-6: light-dark(#4D7C0F, #BEF264);
	color: var(--wp--preset--color--ink);
}

.gp-pp {
	display: grid;
	grid-template-columns: minmax(0, 1fr);   /* wide tables scroll inside their wrapper instead of widening the page */
	gap: var(--wp--preset--spacing--40, 1.5rem);
}

.gp-pp > *,
.gp-pp .gp-grid > * {
	min-width: 0;
}

.gp-pp .gp-panel,
.gp-pp-ocean,
.gp-pp-board {
	padding: var(--wp--preset--spacing--40, 1.25rem);
	border: 1px solid var(--gp-panel-border);
	border-radius: var(--gp-radius);
	background: var(--gp-panel-bg);
	box-shadow: var(--gp-panel-shadow);
}

.gp-pp h3,
.gp-pp h4,
.gp-pp-title {
	font-family: var(--gp-head-font);
	margin: 0 0 0.5rem;
}

.gp-pp .gp-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
	gap: var(--wp--preset--spacing--30, 1rem);
}

.gp-pp-icon {
	width: 1.2em;
	height: 1.2em;
	margin-right: 0.35em;
	vertical-align: -0.2em;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
	color: var(--gp-pp-sea);
}

/* Nameplate: a rope-bordered parchment band with the compass. */
.gp-pp-nameplate {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 1rem 1.25rem;
	border: 2px solid var(--gp-pp-rope);
	outline: 1px dashed color-mix(in srgb, var(--gp-pp-rope) 55%, transparent);
	outline-offset: -7px;
	border-radius: var(--gp-radius);
	background:
		radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--gp-pp-sea) 16%, transparent), transparent 60%),
		var(--gp-pp-parchment);
}

.gp-pp-nameplate > .gp-pp-icon {
	width: 3rem;
	height: 3rem;
	margin: 0;
	flex: none;
}

.gp-pp-kicker {
	margin: 0;
	font-size: 0.8rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--gp-pp-rope);
}

.gp-pp-title {
	font-size: clamp(1.4rem, 3vw, 2rem);
}

.gp-pp-subtitle,
.gp-pp-muted,
.gp-pp-read,
.gp-pp-kind {
	margin: 0.25rem 0;
	color: var(--wp--preset--color--muted);
	font-size: 0.9rem;
}

.gp-pp-tabs ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.gp-pp-tabs a {
	display: inline-block;
	padding: 0.35rem 0.8rem;
	border: 1px solid var(--gp-panel-border);
	border-radius: 999px;
	background: var(--gp-pp-parchment);
	color: var(--wp--preset--color--ink);
	text-decoration: none;
	font-size: 0.9rem;
}

.gp-pp-tabs a[aria-current="page"] {
	background: var(--gp-pp-sea);
	border-color: var(--gp-pp-sea);
	color: var(--wp--preset--color--on-primary);
}

.gp-pp-oceans {
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.gp-pp-ocean {
	border-top: 4px solid var(--gp-pp-sea);
}

.gp-pp-stats {
	margin: 0.5rem 0;
	padding: 0;
	list-style: none;
}

.gp-pp-stats li {
	padding: 0.2rem 0;
}

.gp-pp-chip {
	display: inline-block;
	padding: 0.05rem 0.5rem;
	border-radius: 999px;
	background: color-mix(in srgb, var(--gp-pp-sand) 70%, transparent);
	color: var(--wp--preset--color--ink);
	font-size: 0.78rem;
	font-weight: 600;
	white-space: nowrap;
}

.gp-pp-countdown {
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	color: var(--gp-pp-sea);
}

.gp-pp-countdown.is-soon {
	color: var(--gp-pp-rope);
}

.gp-pp-winner {
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	color: var(--gp-pp-sea);
}

.gp-pp-upcoming ol {
	margin: 0;
	padding-left: 1.25rem;
}

.gp-pp-upcoming li {
	padding: 0.35rem 0;
	border-bottom: 1px dashed var(--gp-panel-border);
}

.gp-pp .gp-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.92rem;
}

.gp-pp .gp-table th,
.gp-pp .gp-table td {
	padding: 0.45rem 0.6rem;
	border-bottom: 1px solid var(--gp-panel-border);
	text-align: left;
	vertical-align: top;
}

.gp-pp .gp-table thead th {
	background: color-mix(in srgb, var(--gp-pp-sand) 55%, transparent);
	font-family: var(--gp-head-font);
}

.gp-pp .gp-table-wrap {
	overflow-x: auto;
}

/* Fame levels: nine steps from sand to sea. */
.gp-pp-tiers {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	margin: 0 0 0.5rem;
	padding: 0;
	list-style: none;
}

.gp-pp-tier {
	display: inline-block;
	padding: 0.1rem 0.55rem;
	border-radius: var(--gp-radius-sm);
	background: color-mix(in srgb, var(--gp-pp-sea) calc(var(--gp-pp-tier, 0) * 11%), var(--gp-pp-sand));
	color: var(--wp--preset--color--ink);
	font-weight: 600;
}

.gp-pp-tier--0 { --gp-pp-tier: 0; }
.gp-pp-tier--1 { --gp-pp-tier: 1; }
.gp-pp-tier--2 { --gp-pp-tier: 2; }
.gp-pp-tier--3 { --gp-pp-tier: 3; }
.gp-pp-tier--4 { --gp-pp-tier: 4; }
.gp-pp-tier--5 { --gp-pp-tier: 5; }
.gp-pp-tier--6 { --gp-pp-tier: 6; color: var(--wp--preset--color--on-primary); }
.gp-pp-tier--7 { --gp-pp-tier: 7; color: var(--wp--preset--color--on-primary); }
.gp-pp-tier--8 { --gp-pp-tier: 8; color: var(--wp--preset--color--on-primary); }

.gp-pp-move {
	font-size: 0.75rem;
	font-weight: 700;
}

.gp-pp-move--up,
.gp-pp-move--new {
	color: var(--gp-pp-sea);
}

.gp-pp-move--down {
	color: var(--gp-pp-rope);
}

/* The pirate lookup, laid out like the game's pirate info: affiliations, reputation, holdings, familiars and hearties
   on the left; the name, the framed portrait and the trophies in the middle; the standings on the right. Phones stack
   the portrait first. Official images sit over the section's drawn icon for their slot (see gamepulse_pirates_art()). */
.gp-pp-card__cols {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 15rem) minmax(0, 1fr);
	gap: var(--wp--preset--spacing--40, 1.5rem);
	align-items: start;
}

.gp-pp-card__left,
.gp-pp-card__right {
	display: grid;
	gap: 1rem;
	align-content: start;
	min-width: 0;
}

.gp-pp-card__centre {
	display: grid;
	justify-items: center;
	gap: 0.6rem;
	text-align: center;
	min-width: 0;
}

.gp-pp .gp-pp-card__name {
	margin: 0;
	font-size: clamp(1.35rem, 2.4vw, 1.75rem);
	text-align: center;
}

.gp-pp-card__ocean {
	margin: 0;
}

.gp-pp-frame {
	display: grid;
	place-items: center;
	padding: 8px;
	border: 3px double var(--gp-pp-rope);
	border-radius: var(--gp-radius-sm);
	background:
		repeating-linear-gradient(97deg, light-dark(rgba(138, 90, 43, 0.06), rgba(255, 255, 255, 0.03)) 0 1px, transparent 1px 5px),
		light-dark(#E9DDBA, #1A2A27);
	box-shadow: 0 1px 0 light-dark(rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.05)) inset, 0 10px 22px -16px rgba(7, 26, 24, 0.6);
	max-width: 100%;
}

.gp-pp-art {
	position: relative;
	display: inline-grid;
	place-items: center;
	flex: none;
	width: calc(var(--gp-pp-w, 28) * 1px);
	max-width: 100%;
	aspect-ratio: var(--gp-pp-w, 28) / var(--gp-pp-h, 28);
	vertical-align: middle;
}

.gp-pp-art > img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.gp-pp-art > img + .gp-pp-icon {
	visibility: hidden;   /* the drawn icon waits behind the official image */
}

.gp-pp-art > .gp-pp-icon {
	width: 72%;
	height: 72%;
	margin: 0;
}

.gp-pp-art.is-drawn {
	border: 1px dashed var(--gp-panel-border);
	border-radius: var(--gp-radius-sm);
	background: color-mix(in srgb, var(--gp-pp-sand) 35%, transparent);
}

.gp-pp-portrait.is-drawn > .gp-pp-icon {
	width: 55%;
	height: 55%;
}

/* An image that did not answer, before (or without) the script: a labelled box, never an empty one. Browsers draw
   these pseudo-elements only for an image that failed to load. */
.gp-pp-art > img::before {
	content: "";
	position: absolute;
	inset: 0;
	border: 1px dashed var(--gp-panel-border);
	border-radius: var(--gp-radius-sm);
	background: var(--gp-pp-parchment);
}

.gp-pp-art > img::after {
	content: attr(alt);
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 2px;
	overflow: hidden;
	font-size: 0.6rem;
	line-height: 1.1;
	text-align: center;
	color: var(--wp--preset--color--muted);
}

.gp-pp-block h4 {
	display: flex;
	justify-content: center;
	align-items: center;
	margin: 0 0 0.5rem;
	padding-bottom: 0.3rem;
	border-bottom: 1px dashed var(--gp-panel-border);
	font-size: 1rem;
	color: var(--gp-pp-sea);
	text-align: center;
}

.gp-pp-lines,
.gp-pp-rows,
.gp-pp-badges,
.gp-pp-trophies {
	margin: 0;
	padding: 0;
	list-style: none;
}

.gp-pp-lines {
	display: grid;
	gap: 0.45rem;
}

.gp-pp-lines li {
	display: grid;
	grid-template-columns: 30px minmax(0, 1fr);
	gap: 0.6rem;
	align-items: center;
	font-size: 0.92rem;
	text-align: left;
}

.gp-pp-lines li > .gp-pp-icon {
	justify-self: center;
	margin: 0;
}

.gp-pp-rows {
	display: grid;
	gap: 0.35rem;
}

.gp-pp-rows li {
	display: grid;
	grid-template-columns: 2.4rem minmax(0, 1fr) auto;
	grid-template-areas: "art name value" "art bar bar" "art note note";
	column-gap: 0.6rem;
	align-items: center;
	font-size: 0.92rem;
	text-align: left;
}

.gp-pp-rows li > .gp-pp-art {
	grid-area: art;
	justify-self: center;
}

.gp-pp-rows__name {
	grid-area: name;
	font-weight: 600;
}

.gp-pp-rows__value {
	grid-area: value;
	text-align: right;
	white-space: nowrap;
}

.gp-pp-rows__note {
	grid-area: note;
	font-size: 0.78rem;
	color: var(--wp--preset--color--muted);
}

.gp-pp-xp {
	color: var(--wp--preset--color--muted);
}

.gp-pp-standing {
	font-weight: 700;
}

/* The standing bar: the rating's place among the nine standing words. */
.gp-pp-bar {
	grid-area: bar;
	height: 4px;
	margin: 2px 0;
	border-radius: 2px;
	background: linear-gradient(90deg, var(--gp-pp-sea) calc(var(--gp-pp-standing, 0) * 100%), var(--gp-bar-track) 0);
}

.gp-pp-badges,
.gp-pp-trophies {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 4px;
	margin-top: 0.4rem;
}

.gp-pp-trophies {
	max-width: 13rem;
}

.gp-pp-hearties {
	margin: 0;
	font-size: 0.9rem;
	line-height: 1.7;
	text-align: center;
}

.gp-pp-credit {
	margin: 1rem 0 0;
	padding-top: 0.6rem;
	border-top: 1px dashed var(--gp-panel-border);
	font-size: 0.85rem;
	color: var(--wp--preset--color--muted);
	text-align: center;
}

@media (max-width: 960px) {
	.gp-pp-card__cols {
		grid-template-columns: minmax(0, 1fr);
	}

	.gp-pp-card__centre {
		order: -1;
	}

	.gp-pp-card__left,
	.gp-pp-card__right {
		width: min(100%, 32rem);
		margin-inline: auto;
	}
}

.gp-pp-facts,
.gp-pp-reputation,
.gp-pp-news {
	margin: 0.5rem 0;
	padding: 0;
	list-style: none;
}

.gp-pp-facts li,
.gp-pp-news li {
	padding: 0.25rem 0;
}

.gp-pp-reputation {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.25rem;
}

.gp-pp-lookup {
	display: flex;
	flex-wrap: wrap;
	align-items: end;
	gap: 0.75rem;
}

.gp-pp-lookup label {
	display: grid;
	gap: 0.25rem;
	font-weight: 600;
}

.gp-pp-lookup input,
.gp-pp-lookup select {
	padding: 0.45rem 0.6rem;
	border: 1px solid var(--gp-panel-border);
	border-radius: var(--gp-radius-sm);
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--ink);
	font: inherit;
}

.gp-pp-lookup button {
	padding: 0.5rem 1rem;
	border: 0;
	border-radius: var(--gp-radius-sm);
	background: var(--gp-pp-sea);
	color: var(--wp--preset--color--on-primary);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.gp-pp-lookup .gp-pp-muted {
	flex-basis: 100%;
}

.gp-pp-chart {
	margin: 0;
	padding: 1rem;
	border: 1px solid var(--gp-panel-border);
	border-radius: var(--gp-radius);
	background: var(--gp-panel-alt-bg);
}

.gp-pp-chart figcaption {
	margin-bottom: 0.5rem;
	font-family: var(--gp-head-font);
	font-weight: 600;
}

.gp-pp-chart canvas {
	display: block;
	width: 100%;
	height: 220px;
}

.gp-pp-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 1rem;
	margin: 0.5rem 0 0;
	padding: 0;
	list-style: none;
	font-size: 0.85rem;
}

.gp-pp-swatch {
	display: inline-block;
	width: 1.5rem;
	margin-right: 0.35rem;
	vertical-align: middle;
	border-top: 3px solid;
}

.gp-pp-readout {
	min-height: 1.2em;
	margin: 0.25rem 0 0;
	font-size: 0.85rem;
	color: var(--wp--preset--color--muted);
}

.gp-pp-sources {
	margin: 0;
	font-size: 0.82rem;
	color: var(--wp--preset--color--muted);
}

@media (max-width: 600px) {
	.gp-pp-nameplate {
		align-items: flex-start;
	}

	.gp-pp-nameplate > .gp-pp-icon {
		width: 2.25rem;
		height: 2.25rem;
	}

	.gp-pp .gp-table th,
	.gp-pp .gp-table td {
		padding: 0.35rem 0.4rem;
	}
}

/* r12: filtered rows and cards leave the page (the filter bar sets "hidden"; nothing in the section may show them). */
.gp-pp [hidden] {
	display: none !important;
}

.gp-pp-go {
	padding: 0.35rem 0.9rem;
	font: inherit;
}

.gp-pp-empty {
	margin: 0.5rem 0 0;
	font-style: italic;
	color: var(--wp--preset--color--muted);
}

.gp-pp-more {
	margin: 0.75rem 0 0;
	font-weight: 600;
}

.gp-pp-quiet {
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 0.9rem;
	color: var(--wp--preset--color--muted);
}

.gp-pp-leaders .gp-pp-muted {
	margin-top: 0.75rem;
}

.gp-pp-lookup {
	display: block;
}

.gp-pp-lookup fieldset {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.gp-pp-lookup__row {
	display: flex;
	flex-wrap: wrap;
	align-items: end;
	gap: 0.75rem;
}

.gp-pp-lookup__row .gp-search {
	display: grid;
	gap: 0.25rem;
	flex: 1 1 16rem;
	max-width: 26rem;
	font-weight: 600;
}

.gp-pp-lookup__row .gp-search input {
	padding-left: 0.7rem;
}

.gp-pp-recent {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.35rem;
	margin: 0.75rem 0 0;
	padding: 0;
	list-style: none;
	font-size: 0.9rem;
}

.gp-pp-lookup__about {
	margin-top: 0.75rem;
	font-size: 0.9rem;
}

.gp-pp-lookup__about summary {
	cursor: pointer;
	color: var(--wp--preset--color--muted);
}

/* The preview: portrait left, lines right (the shared popover holds it). */
.gp-pp-peek {
	display: flex;
	gap: 0.75rem;
	align-items: flex-start;
	max-width: 22rem;
	font-size: 0.9rem;
}

.gp-pp-peek p,
.gp-pp-peek ul {
	margin: 0 0 0.35rem;
}

.gp-pp-peek ul {
	padding: 0;
	list-style: none;
}

.gp-pp-peek__best li {
	display: flex;
	justify-content: space-between;
	gap: 0.75rem;
}

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

.gp-pp-peek__more {
	font-weight: 700;
}

/* The pop the section's script draws until the shared one is there (pulse.js .gp-pop). */
.gp-pop.gp-pp-pop {
	position: absolute;
	z-index: 1000;
	max-width: min(24rem, calc(100vw - 1rem));
	padding: 0.75rem;
}

/* Tables become cards on phones: each row a card of two columns, each cell under its column's name. */
@media (max-width: 640px) {
	.gp-pp .gp-board thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
	}

	.gp-pp .gp-board,
	.gp-pp .gp-board tbody {
		display: block;
		width: auto;
	}

	.gp-pp .gp-board tr {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		margin: 0 0 0.6rem;
		border: 1px solid var(--gp-panel-border);
		border-radius: var(--gp-radius-sm);
		overflow: hidden;
	}

	.gp-pp .gp-board tr[hidden] {
		display: none;
	}

	.gp-pp .gp-board th[scope="row"] {
		grid-column: 1 / -1;
	}

	.gp-pp .gp-board th,
	.gp-pp .gp-board td {
		display: block;
		padding: 0.35rem 0.6rem;
		border-bottom: 1px dashed var(--gp-panel-border);
	}

	.gp-pp .gp-board td::before {
		content: attr(data-label);
		display: block;
		font-weight: 700;
		font-size: 0.72rem;
		letter-spacing: 0.04em;
		text-transform: uppercase;
		color: var(--wp--preset--color--muted);
	}

	.gp-pp .gp-board td:last-child:nth-child(even) {
		grid-column: 1 / -1;
	}
}