/**
 * Statistikportal frontend.
 *
 * Design tokens follow the site template instead of inventing a second visual
 * language. The earlier stylesheet introduced its own blue (#005ea8) and its own
 * radii, which read as a foreign widget dropped into the page. The template's
 * own accent is the Schwabach yellow it defines as --sw-primary, its headings
 * and links are black, and its buttons and images are strongly rounded.
 *
 * The yellow only ever carries black text: it is far too light to sit behind
 * white type, and far too light to serve as a focus indicator on its own, so
 * focus rings are black with the yellow as a companion.
 */

.com-statisticsportal {
	--sp-accent: var(--sw-primary, #fed501);
	--sp-ink: #1a1d21;
	--sp-muted: #55606b;
	/**
	 * Two border tokens with different jobs.
	 *
	 * --sp-border draws decorative separation: a card at rest, a panel edge, a
	 * table rule. Decoration carries no contrast requirement.
	 *
	 * --sp-border-strong is the boundary of anything a visitor operates - a chip,
	 * the search field, a button. That is a user interface component and WCAG
	 * 1.4.11 asks 3:1 for it. #7d8894 reaches 3.5:1 on white; the #b3bcc5 used
	 * before managed 1.9:1, so the chips had no perceivable edge.
	 */
	--sp-border: #d5dbe1;
	--sp-border-strong: #7d8894;
	--sp-surface: #f5f7f9;
	--sp-surface-raised: #fff;
	--sp-radius: 16px;
	--sp-radius-sm: 10px;
	--sp-radius-pill: 999px;
	--sp-gap: 1rem;
	--sp-focus: #000;
	color: var(--sp-ink);
}

/* The template fades every link to opacity .7 on hover, which washes out a
   whole card. Cards signal hover with their border and shadow instead. */
.com-statisticsportal a:hover,
.com-statisticsportal a:focus {
	opacity: 1;
}

.com-statisticsportal :focus-visible {
	outline: 3px solid var(--sp-focus);
	outline-offset: 2px;
}

/* ---------------------------------------------------------------- page head */

.com-statisticsportal .sp-head {
	border-bottom: 1px solid var(--sp-border);
	margin-bottom: 1.5rem;
	padding-bottom: 1.25rem;
}

.com-statisticsportal .sp-kicker {
	color: var(--sp-muted);
	font-size: .9rem;
	letter-spacing: .04em;
	margin: 0 0 .4rem;
	text-transform: uppercase;
}

.com-statisticsportal .sp-title {
	font-size: clamp(1.9rem, 1.2rem + 2.4vw, 2.75rem);
	font-weight: 700;
	line-height: 1.1;
	margin: 0;
}

.com-statisticsportal .sp-intro {
	font-size: 1.05rem;
	line-height: 1.55;
	margin: .8rem 0 0;
	max-width: 62ch;
}

.com-statisticsportal .sp-head-meta {
	color: var(--sp-muted);
	display: flex;
	flex-wrap: wrap;
	font-size: .92rem;
	gap: .35rem 1.5rem;
	margin: .9rem 0 0;
}

.com-statisticsportal .sp-back {
	margin: 0 0 .75rem;
}

.com-statisticsportal .sp-back a {
	font-size: .95rem;
}

/* ------------------------------------------------------- buttons and search */

.com-statisticsportal .sp-button {
	background: var(--sp-accent);
	border: 1px solid var(--sp-accent);
	border-radius: var(--sp-radius-pill);
	color: #000;
	cursor: pointer;
	display: inline-block;
	font: inherit;
	font-weight: 600;
	line-height: 1.3;
	padding: .6rem 1.35rem;
	text-decoration: none;
}

.com-statisticsportal .sp-button:hover,
.com-statisticsportal .sp-button:focus-visible {
	background: #ffe867;
	border-color: #000;
	color: #000;
}

.com-statisticsportal .sp-button-quiet {
	background: transparent;
	border-color: var(--sp-border-strong);
	font-weight: 400;
}

.com-statisticsportal .sp-button-quiet:hover,
.com-statisticsportal .sp-button-quiet:focus-visible {
	background: var(--sp-accent);
	border-color: #000;
}

.com-statisticsportal .sp-actions {
	align-items: baseline;
	display: flex;
	flex-wrap: wrap;
	gap: .5rem .9rem;
	margin: 1.1rem 0 0;
}

.com-statisticsportal .sp-actions-hint {
	color: var(--sp-muted);
	font-size: .85rem;
}

.com-statisticsportal .sp-toolbar {
	align-items: flex-end;
	display: flex;
	flex-wrap: wrap;
	gap: .75rem 1rem;
	margin-bottom: .5rem;
}

.com-statisticsportal .sp-search {
	display: grid;
	flex: 1 1 20rem;
	gap: .3rem;
}

.com-statisticsportal .sp-search-label {
	font-size: .9rem;
	font-weight: 600;
}

.com-statisticsportal .sp-search-input {
	background: var(--sp-surface-raised);
	border: 1px solid var(--sp-border-strong);
	border-radius: var(--sp-radius-pill);
	color: var(--sp-ink);
	font: inherit;
	padding: .6rem 1.1rem;
	width: 100%;
}

.com-statisticsportal .sp-search-input:focus-visible {
	border-color: #000;
}

.com-statisticsportal .sp-search-status {
	color: var(--sp-muted);
	font-size: .9rem;
	margin: 0 0 1rem;
	min-height: 1.4em;
}

/* -------------------------------------------------------------- sections */

.com-statisticsportal .sp-sections {
	display: grid;
	gap: .85rem;
}

.com-statisticsportal .sp-section {
	background: var(--sp-surface-raised);
	border: 1px solid var(--sp-border);
	border-radius: var(--sp-radius);
	overflow: hidden;
}

.com-statisticsportal .sp-section-summary {
	align-items: center;
	cursor: pointer;
	display: flex;
	gap: .75rem;
	list-style: none;
	padding: .9rem 1.1rem;
	position: relative;
}

/* The default triangle cannot be styled and sits at a different size in every
   browser, so it is replaced with a chevron drawn from a border. */
.com-statisticsportal .sp-section-summary::-webkit-details-marker {
	display: none;
}

.com-statisticsportal .sp-section-summary::before {
	border-right: 2px solid var(--sp-ink);
	border-bottom: 2px solid var(--sp-ink);
	content: '';
	flex: 0 0 auto;
	height: .55rem;
	margin-left: .15rem;
	transform: rotate(-45deg);
	transition: transform .15s ease;
	width: .55rem;
}

.com-statisticsportal .sp-section[open] > .sp-section-summary::before {
	transform: rotate(45deg);
}

.com-statisticsportal .sp-section-summary:hover {
	background: var(--sp-surface);
}

.com-statisticsportal .sp-section-summary:focus-visible {
	outline: 3px solid var(--sp-focus);
	outline-offset: -3px;
}

/* A section is only a heading plus its accent bar; the yellow marks the topic
   without colouring text, which the yellow is too light to do. */
.com-statisticsportal .sp-section-title {
	align-items: baseline;
	color: var(--sp-ink);
	display: flex;
	flex-wrap: wrap;
	font-size: 1.3rem;
	font-weight: 700;
	gap: .25rem .75rem;
	line-height: 1.25;
	margin: 0;
}

.com-statisticsportal .sp-section-title::before {
	background: var(--sp-accent);
	border-radius: var(--sp-radius-pill);
	content: '';
	height: 1.1em;
	margin-right: .25rem;
	width: .3rem;
}

.com-statisticsportal .sp-section-count {
	color: var(--sp-muted);
	font-size: .85rem;
	font-weight: 400;
}

/* ----------------------------------------------------------------- cards */

.com-statisticsportal .sp-cards {
	border-top: 1px solid var(--sp-border);
	display: grid;
	gap: var(--sp-gap);
	/**
	 * auto-fill, not auto-fit.
	 *
	 * auto-fit collapsed the empty tracks, so a section holding two datasets
	 * stretched them to half the page while a section of four kept them at a
	 * quarter - the same kind of card came out at two different sizes on one
	 * page. auto-fill keeps the track width constant across all sections.
	 */
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
	list-style: none;
	margin: 0;
	padding: 1.1rem;
}

.com-statisticsportal .sp-card {
	background: var(--sp-surface-raised);
	border: 1px solid var(--sp-border);
	border-radius: var(--sp-radius-sm);
	/**
	 * The footer is pinned to the bottom of the card.
	 *
	 * The grid stretches every card in a row to the tallest one. Without this
	 * the shorter cards left a large void under their content while the meta
	 * line floated in the middle of the box.
	 */
	display: grid;
	grid-template-rows: auto 1fr auto;
	padding: .95rem 1rem;
	position: relative;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.com-statisticsportal .sp-card:hover,
.com-statisticsportal .sp-card:focus-within {
	border-color: var(--sp-border-strong);
	box-shadow: 0 .5rem 1.1rem rgb(26 29 33 / 10%);
}

.com-statisticsportal .sp-card-title {
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.3;
	margin: 0 0 .45rem;
}

.com-statisticsportal .sp-card-title a {
	color: var(--sp-ink);
	text-decoration: none;
}

/* The link is stretched over the whole card so the entire box is clickable,
   while the accessible name stays just the dataset title instead of the title
   plus every key figure, period and source concatenated. */
.com-statisticsportal .sp-card-title a::after {
	content: '';
	inset: 0;
	position: absolute;
}

.com-statisticsportal .sp-card-title a:hover,
.com-statisticsportal .sp-card-title a:focus-visible {
	text-decoration: underline !important;
	text-decoration-thickness: .09em;
	text-underline-offset: .16em;
}

.com-statisticsportal .sp-card:focus-within {
	outline: 3px solid var(--sp-focus);
	outline-offset: 2px;
}

.com-statisticsportal .sp-card-title a:focus-visible {
	outline: 0;
}

/* Clamped to two lines: one long key-figure name must not set the height of
   every card in the row. */
.com-statisticsportal .sp-card-topics {
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	color: var(--sp-muted);
	display: -webkit-box;
	font-size: .92rem;
	line-height: 1.4;
	margin: 0 0 .6rem;
	overflow: hidden;
}

.com-statisticsportal .sp-card-meta {
	align-items: baseline;
	align-self: end;
	display: flex;
	flex-wrap: wrap;
	gap: .2rem .7rem;
	margin: 0;
}

.com-statisticsportal .sp-card-period {
	background: var(--sp-surface);
	border-radius: var(--sp-radius-pill);
	font-size: .85rem;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	padding: .12rem .6rem;
}

.com-statisticsportal .sp-card-figures {
	color: var(--sp-muted);
	font-size: .85rem;
}

.com-statisticsportal .sp-card-source {
	color: var(--sp-muted);
	font-size: .82rem;
	margin: .45rem 0 0;
}

/* ------------------------------------------------------------ chip filter */

.com-statisticsportal .sp-chipbar {
	display: flex;
	flex-wrap: wrap;
	gap: .4rem;
	margin: 0 0 .5rem;
}

.com-statisticsportal .sp-chip {
	background: var(--sp-surface-raised);
	border: 1px solid var(--sp-border-strong);
	border-radius: var(--sp-radius-pill);
	color: var(--sp-ink);
	cursor: pointer;
	font: inherit;
	font-size: .9rem;
	line-height: 1.2;
	padding: .4rem .8rem;
}

.com-statisticsportal .sp-chip:hover {
	border-color: #000;
}

/* Selection is carried by the yellow fill and a heavier weight, not by colour
   alone, so it survives a greyscale print and colour-vision deficiency. */
.com-statisticsportal .sp-chip[aria-pressed="true"] {
	background: var(--sp-accent);
	border-color: #000;
	font-weight: 700;
}

/* Used instead of the chip row where a dataset carries more key figures than a
   row of buttons can show without dwarfing the chart. */
.com-statisticsportal .sp-seriespicker {
	display: grid;
	gap: .3rem;
	margin: 0 0 .75rem;
	max-width: 34rem;
}

.com-statisticsportal .sp-seriespicker-label {
	font-size: .9rem;
	font-weight: 600;
}

.com-statisticsportal .sp-seriespicker-select {
	background: var(--sp-surface-raised);
	border: 1px solid var(--sp-border-strong);
	border-radius: var(--sp-radius-pill);
	color: var(--sp-ink);
	font: inherit;
	max-width: 100%;
	padding: .5rem 1rem;
}

.com-statisticsportal .sp-chip-status {
	color: var(--sp-muted);
	font-size: .88rem;
	margin: 0 0 1rem;
	min-height: 1.3em;
}

/* ------------------------------------------------------- panels and charts */

.com-statisticsportal .sp-detail-grid {
	display: grid;
	gap: var(--sp-gap);
	grid-template-columns: minmax(0, 1.45fr) minmax(15rem, .55fr);
	margin: 1.25rem 0;
}

.com-statisticsportal .sp-chart-column {
	align-content: start;
	display: grid;
	gap: var(--sp-gap);
	min-width: 0;
}

.com-statisticsportal .sp-panel {
	background: var(--sp-surface-raised);
	border: 1px solid var(--sp-border);
	border-radius: var(--sp-radius);
	min-width: 0;
	padding: 1rem 1.1rem 1.1rem;
}

.com-statisticsportal .sp-panel-title {
	font-size: 1rem;
	font-weight: 700;
	margin: 0 0 .8rem;
}

.com-statisticsportal .sp-chart {
	background: var(--sp-surface);
	border: 1px solid var(--sp-border);
	border-radius: var(--sp-radius-sm);
	/**
	 * Height in vh as well as rem.
	 *
	 * A fixed 24rem box does not fit on the screen at 400% zoom, where the
	 * viewport is a few hundred CSS pixels tall (WCAG 1.4.10). Whichever of the
	 * two is smaller wins, with a floor so the chart never collapses.
	 */
	height: min(24rem, 60vh);
	min-height: 14rem;
	overflow: hidden;
	padding: .85rem;
	position: relative;
}

.com-statisticsportal .sp-chart canvas {
	display: block;
	height: 100% !important;
	width: 100% !important;
}

.com-statisticsportal .sp-chart-fallback {
	font-size: .88rem;
	margin: .65rem 0 0;
}

.com-statisticsportal .sp-empty-chart {
	align-items: center;
	color: var(--sp-muted);
	display: flex;
	height: 100%;
	justify-content: center;
	padding: 1rem;
	text-align: center;
}

/* -------------------------------------------------------- latest values */

.com-statisticsportal .sp-latest-panel {
	align-self: start;
}

.com-statisticsportal .sp-latest {
	display: grid;
	gap: .6rem;
	margin: 0;
}

.com-statisticsportal .sp-latest-item {
	border-bottom: 1px solid var(--sp-border);
	padding-bottom: .6rem;
}

.com-statisticsportal .sp-latest-item:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.com-statisticsportal .sp-latest-label {
	color: var(--sp-muted);
	font-size: .85rem;
	font-weight: 400;
	line-height: 1.3;
	margin: 0;
}

.com-statisticsportal .sp-latest-value {
	font-size: 1.3rem;
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	line-height: 1.2;
	margin: .1rem 0 0;
}

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

.com-statisticsportal .sp-table-toolbar {
	align-items: baseline;
	display: flex;
	flex-wrap: wrap;
	gap: .4rem 1rem;
	justify-content: space-between;
	margin: 1.5rem 0 .6rem;
}

.com-statisticsportal .sp-table-title {
	font-size: 1.2rem;
	font-weight: 700;
	margin: 0;
	scroll-margin-top: 2rem;
}

.com-statisticsportal .sp-table-count {
	color: var(--sp-muted);
	font-size: .9rem;
}

.com-statisticsportal .sp-table-scroll {
	border: 1px solid var(--sp-border);
	border-radius: var(--sp-radius-sm);
	max-height: 34rem;
	overflow: auto;
}

.com-statisticsportal .sp-table-scroll:focus-visible {
	outline: 3px solid var(--sp-focus);
	outline-offset: -3px;
}

.com-statisticsportal .sp-table {
	margin: 0;
}

/* A long value table scrolls inside its own box, so the column headings have to
   travel with it or the numbers lose their meaning halfway down. */
.com-statisticsportal .sp-table thead th {
	background: var(--sp-surface);
	border-bottom: 2px solid var(--sp-border-strong);
	position: sticky;
	top: 0;
	z-index: 1;
}

.com-statisticsportal .sp-table th,
.com-statisticsportal .sp-table td {
	padding: .5rem .75rem;
	vertical-align: top;
}

.com-statisticsportal .sp-table .sp-cell-indicator {
	font-weight: 400;
}

/* Right-aligned and tabular so the digits line up in columns and magnitudes are
   comparable down the page. */
.com-statisticsportal .sp-table .sp-cell-number {
	font-variant-numeric: tabular-nums;
	text-align: right;
	white-space: nowrap;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 900px) {
	.com-statisticsportal .sp-detail-grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 520px) {
	.com-statisticsportal .sp-cards {
		padding: .85rem;
	}

	.com-statisticsportal .sp-table-scroll {
		max-height: none;
	}
}

/* Motion is decoration here; nothing depends on it. */
@media (prefers-reduced-motion: reduce) {
	.com-statisticsportal *,
	.com-statisticsportal *::before,
	.com-statisticsportal *::after {
		transition-duration: .01ms !important;
	}
}

/* ---------------------------------------------------------------- print */

@media print {
	.com-statisticsportal .sp-toolbar,
	.com-statisticsportal .sp-search-status,
	.com-statisticsportal .sp-chipbar,
	.com-statisticsportal .sp-chip-status,
	.com-statisticsportal .sp-back,
	.com-statisticsportal .sp-actions,
	.com-statisticsportal .sp-chart-fallback {
		display: none !important;
	}

	/* A collapsed section would print as a bare heading, and a scroll box would
	   print only its first screen. On paper everything is shown in full. */
	.com-statisticsportal .sp-section:not([open]) > *:not(summary) {
		display: block !important;
	}

	.com-statisticsportal .sp-section-summary::before {
		display: none;
	}

	.com-statisticsportal .sp-cards {
		display: block !important;
	}

	.com-statisticsportal .sp-card {
		break-inside: avoid;
		margin-bottom: .4cm;
	}

	.com-statisticsportal .sp-table-scroll {
		max-height: none !important;
		overflow: visible !important;
	}

	.com-statisticsportal .sp-section,
	.com-statisticsportal .sp-panel,
	.com-statisticsportal .sp-card {
		border-color: #999;
		box-shadow: none !important;
	}

	.com-statisticsportal .sp-chart {
		height: auto;
		min-height: 0;
	}
}
