/*
 * Africa 360° base layer.
 *
 * Element defaults that no Bricks global class can own: document typography,
 * links, focus, motion, and the block-editor article body. Every value is a
 * token from the Bricks global variables; no literal colours or sizes here
 * apart from hairline widths carried by the border tokens.
 *
 * Bricks ships its own CSS inside cascade layers, so these unlayered rules win
 * without !important.
 */

/* Document */
html {
	color-scheme: light;
	-webkit-text-size-adjust: 100%;
}

/* Under the sticky article head, in-page links (contents list, #method, notes) land
   below the head instead of behind it. */
html:has(#brx-header.brx-sticky) {
	scroll-padding-block-start: var(--sticky-offset);
}

body {
	background: var(--color-bg-page);
	color: var(--color-text-primary);
	font-family: var(--font-reading);
	font-size: var(--text-body);
	line-height: var(--leading-body);
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
	color: inherit;
	font-family: var(--font-display);
	font-weight: var(--weight-semibold);
	text-wrap: balance;
}

p, li, figcaption {
	text-wrap: pretty;
}

img, svg, video {
	max-width: 100%;
	height: auto;
}

/* Links: no underline at rest in navigation and cards; accent red and underlined on
   hover (handover section 10). Links in running text stay underlined (.article-body). */
a {
	color: inherit;
	text-decoration: none;
	text-decoration-thickness: from-font;
	text-underline-offset: 0.2em;
}

a:hover {
	color: var(--color-text-accent);
	text-decoration: underline;
}

/* Focus: visible on every control; white ring on navy grounds */
:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-offset);
}

[data-dark] :focus-visible {
	outline: var(--focus-ring-inverse);
}

::selection {
	background: var(--color-accent-brand-tint);
	color: var(--color-text-primary);
}

/* Search-term highlight and the [hl] editorial highlight */
mark {
	background: var(--color-accent-brand-tint);
	color: inherit;
	padding-inline: 0.1em;
}

/* Skip link (output by Bricks) */
.skip-link {
	position: absolute;
	inset-block-start: var(--space-2);
	inset-inline-start: var(--space-2);
	z-index: 1000;
	padding: var(--space-3) var(--space-4);
	background: var(--color-bg-inverse);
	color: var(--color-text-inverse);
	font-family: var(--font-ui);
	font-size: var(--text-meta);
	transform: translateY(-200%);
}

.skip-link:focus-visible {
	transform: none;
	outline: var(--focus-ring-inverse);
}

/* Announced, not shown: script-made live regions (forms.js "Sending…"). The Bricks
   class .visually-hidden only reaches pages whose elements carry it. */
.a360-sr-only {
	position: absolute;
	width: var(--rule-hairline-width);
	height: var(--rule-hairline-width);
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Page behind the open menu panel does not scroll */
.has-menu-open {
	overflow: hidden;
}

/* Motion */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/*
 * Article body: block-editor content rendered by Bricks' Post Content element.
 * Editors write clean core blocks; the design comes from here, so every
 * article renders consistently without per-post styling.
 */
.article-body {
	max-width: var(--measure-body);
	min-width: 0;
	font-family: var(--font-reading);
	font-size: var(--text-body);
	line-height: var(--leading-body);
}

.article-body > * + * {
	margin-block-start: var(--space-6);
}

/* Drop cap without floats: initial-letter where supported, a plain first letter elsewhere. */
@supports (initial-letter: 3) or (-webkit-initial-letter: 3) {
	.article-body > p:first-of-type::first-letter {
		-webkit-initial-letter: 3;
		initial-letter: 3;
		margin-inline-end: var(--space-2);
		font-family: var(--font-display);
		font-weight: var(--weight-semibold);
		color: var(--color-text-primary);
	}
}

.article-body h2 {
	margin-block-start: var(--space-12);
	font-size: var(--text-crosshead);
	line-height: var(--leading-crosshead);
}

/* A body that opens on a cross-head (standard pages) starts level with its side column. */
.article-body > h2:first-child {
	margin-block-start: 0;
}

.article-body h3 {
	margin-block-start: var(--space-8);
	font-size: var(--text-headline-sm);
	line-height: var(--leading-headline-sm);
}

.article-body a {
	text-decoration: underline;
	text-decoration-color: var(--color-border-subtle);
}

.article-body a:hover {
	text-decoration-color: currentColor;
}

.article-body ul,
.article-body ol {
	padding-inline-start: var(--space-6);
}

.article-body li + li {
	margin-block-start: var(--space-2);
}

/* Pull-quote: a plain core Quote block in the body. Inline in the reading column by
   default (and always on phones), 4px brand-red left rule, display type 24/32 rising
   to 30/40. The [hl] highlight inside it is a <mark> (see mark above). */
.article-body blockquote {
	margin-inline: 0;
	padding-inline-start: var(--space-6);
	border-inline-start: var(--border-accent);
	font-family: var(--font-display);
	font-size: var(--text-pullquote);
	font-weight: var(--weight-semibold);
	line-height: var(--leading-pullquote);
	text-wrap: balance;
}

.article-body blockquote p {
	margin: 0;
}

.article-body blockquote cite {
	display: block;
	margin-block-start: var(--space-3);
	font-family: var(--font-ui);
	font-size: var(--text-meta);
	font-style: normal;
	font-weight: var(--weight-medium);
	line-height: var(--leading-meta);
	color: var(--color-text-secondary);
}

/*
 * Article layout: the template wraps the article in .article-layout (the query
 * container) > .article-layout__grid, which holds the side modules and the article
 * body (a container cannot restyle itself from its own query, hence two elements).
 * Where an open column of at least
 * --pullquote-min fits beside the 650px reading column (650 + 109 + 280 = 1039px),
 * the layout becomes a two-column grid and the body's blocks join it directly
 * (display: contents). Every block takes the text column; a pull-quote marked
 * .a360-quote--aside (a360-core body-layout.php decides which) takes the open
 * column, and the side stack (.article-layout__side) holds the first rows of it.
 * Grid auto-placement then sets the quote level with the paragraph
 * before it (its source position), spanning the next rows, so it sits beside the
 * text it relates to, never overlaps another side item, and needs no float, no
 * absolute positioning and no script. Below that width the body stays one column
 * and the quote returns inline after its paragraph.
 */
.article-layout {
	container: article / inline-size;
	min-width: 0;
}

@container article (min-width: 1039px) {
	.article-layout__grid {
		display: grid;
		grid-template-columns:
			[text-start] minmax(0, var(--measure-body)) [text-end]
			var(--article-column-gap)
			[aside-start] minmax(var(--pullquote-min), var(--article-aside-max)) [aside-end];
		align-items: start;
	}

	.article-layout__grid > .article-body {
		display: contents;
	}

	/* Grid items' margins do not collapse, so only the top margin spaces the flow. */
	.article-layout__grid > .article-body > * {
		grid-column: text;
		margin-block-end: 0;
	}

	.article-layout__side {
		grid-column: aside;
		grid-row: 1 / span 6; /* A360_SIDE_ROWS in body-layout.php */
		min-width: 0;
	}

	/* Top margin matches the paragraphs', so the quote lines up with its paragraph. */
	.article-layout__grid > .article-body > blockquote.a360-quote--aside,
	.article-layout__grid > .article-body > aside.a360-note--aside {
		grid-column: aside;
		grid-row: span 4; /* A360_QUOTE_SPAN in body-layout.php */
	}

	/* The reference draws a side note narrower than the column (240 to 302px). */
	.article-layout__grid > .article-body > aside.a360-note--aside {
		max-width: var(--hero-caption-basis);
	}

	/* Template modules in the reading column (Key takeaways; corrections and topics). */
	.article-layout__grid > .article-layout__text {
		grid-column: text;
	}
}

/* One column (phones, tablets): the reference wraps the side stack below the opening
   (Key takeaways and the paragraphs before the first cross-head), not above the text.
   The body joins the flow (display: contents) and order places the side stack
   between the opening and the first H2; the closing modules come last. */
@container article (max-width: 1038.98px) {
	.article-layout__grid {
		display: flex;
		flex-direction: column;
	}

	.article-layout__grid > .article-body {
		display: contents;
	}

	/* Flex items' margins do not collapse either: only the top margin spaces the flow. */
	.article-layout__grid > .article-body > * {
		max-width: var(--measure-body);
		margin-block-end: 0;
	}

	.article-layout__grid > .article-body > h2:first-of-type,
	.article-layout__grid > .article-body > h2:first-of-type ~ * {
		order: 2;
	}

	.article-layout__side {
		order: 1;
		margin-block-start: var(--space-8);
	}

	.article-layout__grid > .article-layout__text:last-child {
		order: 3;
	}
}

/* Reading-column modules placed by the template around the body. */
.article-layout__text {
	display: flex;
	flex-direction: column;
	gap: var(--space-6);
	min-width: 0;
	max-width: var(--measure-body);
}

.article-body + .article-layout__text {
	margin-block-start: var(--space-8);
}

/* Key takeaways come before the body: the opening paragraph keeps the 24px rhythm. */
.article-layout__text ~ .article-body > :first-child {
	margin-block-start: var(--space-6);
}

/*
 * Report layout (HANDOVER 9.5, reference-html/single-special-report.html): the single
 * special report template wraps the report in .report-layout (the query container) >
 * .report-layout__grid, holding in source order: .report-layout__text (Key findings),
 * .report-layout__side ("In this report" + Evidence sidebar), the Post Content
 * .article-body, and .report-layout__text (Method and sources, corrections, topics).
 *
 * Two columns (650 + 109 + 280 = 1039px): the reading modules stack in the text column
 * and the side column spans every row and stretches to the text's height, so the
 * evidence panel (position: sticky) has room to stick. Pull-quotes and notes stay
 * inline: the side column belongs to the evidence.
 *
 * One column: the evidence sits below the intro (HANDOVER 15), that is after Key
 * findings and the opening (the blocks before the first cross-head), as the article
 * layout wraps its side stack; then the rest of the body; the closing modules last.
 */
.report-layout {
	container: report / inline-size;
	min-width: 0;
}

.report-layout__text {
	display: flex;
	flex-direction: column;
	gap: var(--space-8);
	min-width: 0;
	max-width: var(--measure-body);
}

.report-layout__side {
	display: flex;
	flex-direction: column;
	gap: var(--space-8);
	min-width: 0;
	max-width: var(--article-aside-max);
}

@container report (min-width: 1039px) {
	.report-layout__grid {
		display: grid;
		grid-template-columns:
			[text-start] minmax(0, var(--measure-body)) [text-end]
			var(--article-column-gap)
			[aside-start] minmax(var(--pullquote-min), var(--article-aside-max)) [aside-end];
		grid-template-rows: repeat(3, auto); /* findings, body, closing modules */
		align-items: start;
	}

	.report-layout__grid > :not(.report-layout__side) {
		grid-column: text;
	}

	.report-layout__side {
		grid-column: aside;
		grid-row: 1 / -1;
		align-self: stretch;
	}

	.report-layout__text ~ .article-body,
	.article-body ~ .report-layout__text {
		margin-block-start: var(--space-8);
	}
}

@container report (max-width: 1038.98px) {
	.report-layout__grid {
		display: flex;
		flex-direction: column;
	}

	.report-layout__grid > .article-body {
		display: contents;
	}

	/* Flex items' margins do not collapse: only the top margin spaces the flow. */
	.report-layout__grid > .article-body > * {
		max-width: var(--measure-body);
		margin-block-end: 0;
	}

	.report-layout__text ~ .article-body > :first-child {
		margin-block-start: var(--space-8);
	}

	.report-layout__grid > .article-body > h2:first-of-type,
	.report-layout__grid > .article-body > h2:first-of-type ~ * {
		order: 2;
	}

	.report-layout__side {
		order: 1;
		margin-block-start: var(--space-8);
	}

	.report-layout__grid > .report-layout__text:last-child {
		order: 3;
		margin-block-start: var(--space-8);
	}
}

/* Method and sources: the report's sources table, printed by {a360_sources_table} into
   a keyboard-scrollable region. Shares the data table's cells, header tint and hairlines;
   the caption is the section's "Sources" label (evidence blue caps, no icon or rule). */
.a360-data--sources {
	overflow-x: auto;
}

.a360-data--sources caption {
	padding-block-end: var(--space-2);
	font-size: var(--text-kicker);
	line-height: var(--leading-kicker);
	font-weight: var(--weight-bold);
	letter-spacing: var(--tracking-kicker);
	text-transform: uppercase;
	text-align: start;
	color: var(--color-evidence);
}

.a360-data--sources tbody th {
	font-weight: var(--weight-semibold);
}

.a360-data--sources tbody th a {
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.a360-data--sources .a360-data__note {
	color: var(--color-text-secondary);
}

.article-body figure {
	margin-inline: 0;
}

.article-body figure img {
	display: block;
	width: 100%;
	aspect-ratio: var(--ratio-card);
	object-fit: cover;
}

.article-body figcaption {
	margin-block-start: var(--space-2);
	font-family: var(--font-ui);
	font-size: var(--text-caption);
	font-style: italic;
	line-height: var(--leading-caption);
	color: var(--color-text-secondary);
}

/* Note callout (block style "a360-note"): By the numbers, definitions, typologies */
.is-style-a360-note {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	min-width: 0;
	max-width: var(--measure-body);
	padding: var(--space-4) var(--space-6) var(--space-6);
	background: var(--color-bg-surface);
	border-block-start: var(--border-rule-strong);
	font-family: var(--font-ui);
	font-size: var(--text-meta);
	line-height: var(--leading-meta);
}

.article-body .is-style-a360-note > * + * {
	margin-block-start: 0;
}

.is-style-a360-note .a360-note__label {
	margin: 0;
	font-family: var(--font-ui);
	font-size: var(--text-kicker);
	font-weight: var(--weight-bold);
	line-height: var(--leading-kicker);
	letter-spacing: var(--tracking-kicker);
	text-transform: uppercase;
	color: var(--color-text-accent);
}

.is-style-a360-note .a360-note__stat {
	font-family: var(--font-display);
	font-size: var(--text-headline-lg);
	font-weight: var(--weight-semibold);
	line-height: var(--leading-headline-lg);
}

.is-style-a360-note .a360-note__source {
	font-size: var(--text-caption);
	font-style: italic;
	line-height: var(--leading-caption);
	color: var(--color-text-secondary);
}

/* Data table module (core Table blocks, normalised by a360-core tables.php):
   caption above (Data label + title), a keyboard-scrollable region with a 2px blue
   top rule, evidence-tint header row, hairline rows, row labels, right-aligned
   tabular numerals, and the source line beneath. Below --data-table-min the table
   keeps its columns and the region scrolls instead of squeezing them. */
.wp-block-table.a360-data {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	min-width: 0;
	margin-inline: 0;
	margin-block-end: 0; /* core adds 1em, which would push the source line away */
	overflow: visible;
	font-family: var(--font-ui);
}

.a360-data .a360-data__caption {
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
	margin: 0;
	font-family: var(--font-ui);
	font-style: normal;
	text-align: start; /* core centres .wp-element-caption */
	color: var(--color-text-primary);
}

.a360-data__label {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	font-size: var(--text-kicker);
	line-height: var(--leading-kicker);
	font-weight: var(--weight-bold);
	letter-spacing: var(--tracking-kicker);
	text-transform: uppercase;
	color: var(--color-evidence);
}

.a360-data__label::before {
	content: "";
	flex-shrink: 0;
	width: var(--icon-md);
	height: var(--icon-md);
	background-color: currentColor;
	-webkit-mask: var(--icon-chart) center / contain no-repeat;
	mask: var(--icon-chart) center / contain no-repeat;
}

.a360-data__title {
	font-size: var(--text-table-title);
	line-height: var(--leading-table-title);
	font-weight: var(--weight-bold);
}

.a360-data__scroll {
	min-width: 0;
	overflow-x: auto;
	border-block-start: var(--border-evidence-rule);
}

.a360-data table {
	width: 100%;
	min-width: var(--data-table-min);
	table-layout: auto;
	border-collapse: collapse;
	font-family: var(--font-ui);
	font-size: var(--text-ui);
	line-height: var(--leading-ui);
	text-align: start;
}

.a360-data thead {
	border: 0;
}

.a360-data thead tr {
	background-color: var(--color-evidence-tint);
}

.a360-data :is(th, td) {
	padding-block: var(--cell-padding-block);
	padding-inline: var(--space-3);
	border: 0;
	text-align: start;
	vertical-align: top;
}

.a360-data thead th {
	font-size: var(--text-card-meta);
	font-weight: var(--weight-bold);
}

.a360-data tbody tr {
	border-block-end: var(--border-hairline);
}

.a360-data tbody th {
	font-weight: var(--weight-medium);
}

.a360-data .is-numeric {
	text-align: end;
	font-variant-numeric: tabular-nums;
}

.a360-data :is(.has-text-align-right, [data-align="right"]) { text-align: end; }
.a360-data :is(.has-text-align-center, [data-align="center"]) { text-align: center; }

.a360-data__source {
	margin: 0;
	font-family: var(--font-ui);
	font-size: var(--text-caption);
	font-style: italic;
	line-height: var(--leading-caption);
	color: var(--color-text-secondary);
}

/* The source line belongs to the table above it: the module's 12px gap, not the
   body's paragraph spacing. */
.article-body > .wp-block-table + .a360-data__source {
	margin-block-start: var(--space-3);
}

/*
 * Page callouts (Editorial standards, HANDOVER 9.9): Group blocks in the page body.
 *   .a360-callout--evidence  "Shown on every special report": evidence tint, blue
 *                            document-icon heading (h3), bulleted list.
 *   .a360-callout--trust     "Seen an error?": trust tint, edit icon, green lead-in,
 *                            and the Report an error button (last paragraph's link).
 * [a360_recent_corrections] prints .a360-corrections: h3 over date + headline rows.
 */
.article-body .a360-callout {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	padding: var(--space-m) var(--space-6) var(--space-6);
	font-family: var(--font-ui);
	font-size: var(--text-ui);
	line-height: var(--leading-ui);
}

/* Classic themes wrap Group content in an inner container: let its children join
   the callout's own layout. */
.article-body .a360-callout > .wp-block-group__inner-container {
	display: contents;
}

.article-body .a360-callout > * > *,
.article-body .a360-callout > :not(.wp-block-group__inner-container) {
	margin: 0;
}

.article-body .a360-callout--evidence {
	background-color: var(--color-evidence-tint);
}

.article-body .a360-callout--evidence h3 {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	font-family: var(--font-ui);
	font-size: var(--text-kicker);
	line-height: var(--leading-kicker);
	font-weight: var(--weight-bold);
	letter-spacing: var(--tracking-kicker);
	text-transform: uppercase;
	color: var(--color-evidence);
}

.article-body .a360-callout--evidence h3::before {
	content: "";
	flex-shrink: 0;
	width: var(--icon-md);
	height: var(--icon-md);
	background-color: currentColor;
	-webkit-mask: var(--icon-document) center / contain no-repeat;
	mask: var(--icon-document) center / contain no-repeat;
}

.article-body .a360-callout--evidence li + li {
	margin-block-start: var(--space-1);
}

.article-body .a360-callout--trust {
	flex-direction: row;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3) var(--space-6);
	padding: var(--space-m) var(--space-6);
	background-color: var(--color-trust-tint);
}

.article-body .a360-callout--trust p:first-child {
	flex: 1 1 var(--pullquote-min);
	min-width: 0;
}

.article-body .a360-callout--trust p:first-child::before {
	content: "";
	display: inline-block;
	width: var(--icon-lg);
	height: var(--icon-lg);
	margin-inline-end: var(--space-3);
	vertical-align: middle;
	background-color: var(--color-trust);
	-webkit-mask: var(--icon-edit) center / contain no-repeat;
	mask: var(--icon-edit) center / contain no-repeat;
}

.article-body .a360-callout--trust strong {
	color: var(--color-trust);
}

.article-body .a360-callout--trust p:last-child a {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	min-height: var(--target-min);
	padding-inline: var(--space-4);
	border-radius: var(--radius-control);
	background-color: var(--color-trust);
	color: var(--color-text-inverse);
	font-weight: var(--weight-semibold);
	text-decoration: none;
}

.article-body .a360-callout--trust p:last-child a::after {
	content: "";
	width: var(--icon-md);
	height: var(--icon-md);
	background-color: currentColor;
	-webkit-mask: var(--icon-arrow-right) center / contain no-repeat;
	mask: var(--icon-arrow-right) center / contain no-repeat;
}

.article-body .a360-callout--trust p:last-child a:hover {
	text-decoration: underline;
}

.a360-corrections {
	display: flex;
	flex-direction: column;
	font-family: var(--font-ui);
	font-size: var(--text-ui);
	line-height: var(--leading-ui);
}

.article-body .a360-corrections h3 {
	margin: 0 0 var(--space-1);
	padding-block-end: var(--space-3);
	border-block-end: var(--border-rule);
	font-family: var(--font-ui);
	font-size: var(--text-kicker);
	line-height: var(--leading-kicker);
	font-weight: var(--weight-bold);
	letter-spacing: var(--tracking-kicker);
	text-transform: uppercase;
}

.a360-corrections__row {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-1) var(--space-6);
	padding-block: var(--space-3);
	border-block-end: var(--border-hairline);
}

.a360-corrections__row time {
	flex: 0 0 var(--corrections-date-basis);
	color: var(--color-text-secondary);
}

.a360-corrections__row > div {
	display: flex;
	flex-direction: column;
	flex: 999 1 var(--result-body-basis);
	min-width: 0;
}

.a360-corrections__row a {
	font-weight: var(--weight-semibold);
}

.a360-corrections__row span {
	color: var(--color-text-secondary);
}

/*
 * About: "What we cover" cards (owner: cards, easily identifiable). A Group
 * .a360-cover-grid of Groups .a360-cover-card (h3 section name, linked where the
 * section exists, + one paragraph). Two columns in the 650 measure, one on phones.
 */
.article-body .a360-cover-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--card-min)), 1fr));
	gap: var(--grid-gutter);
	margin-block: var(--space-8);
}

.article-body .a360-cover-grid > .wp-block-group__inner-container,
.article-body .a360-cover-card > .wp-block-group__inner-container {
	display: contents;
}

.article-body .a360-cover-card {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	min-width: 0;
	padding: var(--space-m) var(--space-6) var(--space-6);
	border-block-start: var(--border-accent);
	background-color: var(--color-bg-surface);
	font-family: var(--font-ui);
	font-size: var(--text-ui);
	line-height: var(--leading-ui);
}

.article-body .a360-cover-card h3,
.article-body .a360-cover-card p {
	margin: 0;
}

.article-body .a360-cover-card h3 {
	font-family: var(--font-display);
	font-size: var(--text-headline-sm);
	line-height: var(--leading-headline-sm);
	font-weight: var(--weight-semibold);
}

.article-body .a360-cover-card h3 a {
	color: inherit;
	text-decoration: none;
}

.article-body .a360-cover-card h3 a:hover {
	color: var(--color-text-accent);
	text-decoration: underline;
}

.article-body .a360-cover-card p {
	color: var(--color-text-secondary);
}
