/*
 * MBC block pattern styles (front page hero and zigzag bands, and the
 * patterns that follow). Tokens only (css/tokens.css). Also loaded in the
 * block editor.
 */

/* ---- Hero ---- */
.mbc-hero {
	max-width: var(--mbc-content-width);
	margin: 0 auto;
	padding: var(--mbc-space-3xl) var(--mbc-gutter);
	background: var(--mbc-surface);
	text-align: center;
}

.mbc-hero h1 {
	margin-bottom: var(--mbc-space-s);
}

.mbc-hero__tagline {
	font-size: var(--mbc-step-2);
	line-height: var(--mbc-leading-heading);
}

.mbc-hero__buttons {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--mbc-space-s);
	margin: var(--mbc-space-xl) 0;
}

.mbc-hero__small {
	margin: 0;
	color: var(--mbc-text-muted);
	font-size: var(--mbc-step--1);
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

/* ---- Zigzag bands (core Media & Text) ---- */
.mbc-band {
	max-width: var(--mbc-content-width);
	margin: 0 auto;
	background: var(--mbc-surface);
	border-top: var(--mbc-border-width) solid var(--mbc-border);
	align-items: center;
}

.mbc-band .wp-block-media-text__content {
	padding: var(--mbc-space-xl) var(--mbc-gutter);
}

.mbc-band .wp-block-media-text__media {
	padding: var(--mbc-space-m);
}

.mbc-band .wp-block-media-text__media img {
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: var(--mbc-radius-md);
}

.mbc-band h2 {
	font-size: var(--mbc-step-4);
}

/* The slideshow band: a Group (text) beside a Gallery, laid out like the Media & Text bands. The
   Gallery stacks above the text below 600px and sits on the side set by the zigzag above that
   (core's own Media & Text stacking point). The slideshow itself is css/slideshow.css. */
.mbc-band--slides {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
}

/* Core wraps a Group's children in .wp-block-group__inner-container when it renders; flatten it so
   the text and the gallery are the grid's items. */
.mbc-band--slides > .wp-block-group__inner-container {
	display: contents;
}

.mbc-band--slides .wp-block-group__inner-container > .mbc-band__content {
	order: 2;
	padding: var(--mbc-space-xl) var(--mbc-gutter);
}

.mbc-band--slides .wp-block-group__inner-container > .wp-block-gallery {
	order: 1;
	margin: var(--mbc-space-m);
}

@media (min-width: 601px) {
	.mbc-band--slides {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.mbc-band--slides .wp-block-group__inner-container > .mbc-band__content {
		order: 1;
	}

	.mbc-band--slides .wp-block-group__inner-container > .wp-block-gallery {
		order: 2;
	}
}

/* Social icons take the text colour, not the brand colours core gives them. */
html body .mbc-band__social .wp-social-link,
html body .mbc-band__social .wp-social-link a {
	background: none;
	color: var(--mbc-text);
}

.mbc-band__social {
	margin-bottom: var(--mbc-space-m);
}

/* ---- Activity page ---- */
.mbc-activity__top {
	align-items: start;
	gap: var(--mbc-space-l);
}

/* Core centres both columns and insets the text column by 8%. */
.mbc-activity__top .wp-block-media-text__media,
.mbc-activity__top .wp-block-media-text__content {
	align-self: start;
	padding: 0;
}

.mbc-activity__top .wp-block-media-text__media img {
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: var(--mbc-radius-md);
}

.mbc-facts {
	padding: var(--mbc-space-m) var(--mbc-space-l);
	border: var(--mbc-border-width) solid var(--mbc-border);
	border-radius: var(--mbc-radius-md);
	background: var(--mbc-surface-alt);
}

.mbc-facts p {
	margin: 0 0 var(--mbc-space-s);
}

.mbc-facts p:last-child {
	margin-bottom: 0;
}

.mbc-facts strong {
	display: block;
	color: var(--mbc-text-muted);
	font-size: var(--mbc-step--1);
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

/* ---- Info page ---- */
.mbc-lead {
	color: var(--mbc-text-muted);
	font-size: var(--mbc-step-1);
}

.mbc-page__content .wp-block-image img {
	border-radius: var(--mbc-radius-md);
}

.mbc-cta {
	padding: var(--mbc-space-l);
	border: var(--mbc-border-width) solid var(--mbc-border);
	border-radius: var(--mbc-radius-md);
	background: var(--mbc-surface-alt);
}

.mbc-cta > :last-child {
	margin-bottom: 0;
}

/* Wide graphics (banners, panoramas) shown whole instead of cropped to 4:3. */
.mbc-image-contain .wp-block-media-text__media img {
	aspect-ratio: auto;
	object-fit: contain;
}

/* ---- Mission partner page ---- */
.mbc-partner__top {
	align-items: start;
	gap: var(--mbc-space-l);
}

.mbc-partner__top .wp-block-media-text__media,
.mbc-partner__top .wp-block-media-text__content {
	align-self: start;
	padding: 0;
}

/* Logos are shown whole, never cropped. */
.mbc-partner__top .wp-block-media-text__media img {
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: contain;
	padding: var(--mbc-space-m);
	border: var(--mbc-border-width) solid var(--mbc-border);
	border-radius: var(--mbc-radius-md);
	background: var(--mbc-surface-alt);
}

/* Info pages: a very tall image dominates; cap it. */
.mbc-page__content .wp-block-image img {
	width: 100%;
	max-height: 28rem;
	object-fit: cover;
}

/* ---- News listing (Query Loop cards) ---- */
.mbc-news .wp-block-post-template,
.mbc-nl__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
	gap: var(--mbc-space-l);
	margin: 0;
	padding: 0;
	list-style: none;
}

.mbc-card,
.mbc-card > .wp-block-group__inner-container {
	display: flex;
	flex-direction: column;
	gap: var(--mbc-space-xs);
	height: 100%;
}

.mbc-card {
	overflow: hidden;
	border: var(--mbc-border-width) solid var(--mbc-border);
	border-radius: var(--mbc-radius-md);
	background: var(--mbc-surface-alt);
}

/* Text sits inset; the featured image runs edge to edge. Group blocks may
   wrap their children in .wp-block-group__inner-container, so style by class. */
.mbc-card__date,
.mbc-card__title,
.mbc-card__excerpt {
	margin: 0;
	padding-inline: var(--mbc-space-m);
}

.mbc-card__image {
	margin: 0;
	padding: 0;
}

.mbc-card__image img {
	display: block;
	width: 100%;
}

.mbc-card__date {
	margin-top: var(--mbc-space-xs);
	color: var(--mbc-text-muted);
	font-size: var(--mbc-step--1);
}

.mbc-card__title {
	font-size: var(--mbc-step-1);
}

.mbc-card__title a {
	color: var(--mbc-text);
}

.mbc-card__excerpt {
	padding-bottom: var(--mbc-space-m);
}

.mbc-card__excerpt p {
	margin: 0 0 var(--mbc-space-xs);
}

.mbc-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--mbc-space-s);
	margin-top: var(--mbc-space-xl);
}

.mbc-pagination a {
	display: inline-flex;
	align-items: center;
	min-height: var(--mbc-tap-target);
	padding: 0 var(--mbc-space-s);
}

.mbc-pagination .page-numbers.current {
	font-weight: var(--mbc-weight-strong);
}

/* ---- Meet the team ---- */
.wp-block-media-text.mbc-team__minister {
	grid-template-columns: minmax(0, 30%) 1fr;
	align-items: start;
	gap: var(--mbc-space-l);
	margin-block: var(--mbc-space-l);
}

.mbc-team__minister .wp-block-media-text__media,
.mbc-team__minister .wp-block-media-text__content {
	align-self: start;
	padding: 0;
}

.mbc-team__minister .wp-block-media-text__media img {
	width: 100%;
	height: auto;
	border-radius: var(--mbc-radius-md);
}

.mbc-team__minister h2 {
	margin-top: 0;
}

.mbc-people-grid > .wp-block-group__inner-container,
.mbc-people-grid:not(:has(> .wp-block-group__inner-container)) {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
	gap: var(--mbc-space-l) var(--mbc-space-m);
	margin: 0 0 var(--mbc-space-m);
}

.mbc-person {
	margin: 0;
}

.mbc-person .wp-block-image {
	margin: 0 0 var(--mbc-space-xs);
}

.mbc-person img {
	display: block;
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	object-position: center 20%;
	border-radius: var(--mbc-radius-md);
}

.mbc-person__name {
	margin: 0;
	font-weight: var(--mbc-weight-strong);
}

/* ---- Newsletter issues: web version and archive ---- */
.mbc-nl__subtitle {
	margin: 0 0 var(--mbc-space-xs);
	color: var(--mbc-text-muted);
	font-size: var(--mbc-step-1);
}

.mbc-nl__intro {
	margin-bottom: var(--mbc-space-xl);
}

.mbc-nl__list {
	margin-top: var(--mbc-space-l);
}

.mbc-nl__list > .mbc-card > a.mbc-card__image {
	display: block;
}

.mbc-nl__list .mbc-card__image img {
	aspect-ratio: 3 / 2;
	object-fit: cover;
}

.mbc-nl__list .mbc-card__title:last-child {
	padding-bottom: var(--mbc-space-m);
}

/* ---- Newsletter web version: one centred column, posts as a single-column list ----
   The column is the page wrapper narrowed to the newsletter measure (it keeps the usual side
   padding on small screens). The archive keeps the card grid above (.mbc-nl__list). */
.mbc-page--newsletter {
	max-width: calc(var(--mbc-newsletter-measure) + 2 * var(--mbc-gutter));
}

.mbc-nl-issue .mbc-post__content {
	max-width: none;
}

/* Natural size, shrunk to fit the column, never enlarged. */
.mbc-nl-issue .mbc-post__figure img {
	width: auto;
	max-width: 100%;
	height: auto;
}

.mbc-nl-issue__list {
	container-type: inline-size;
	display: flex;
	flex-direction: column;
	gap: var(--mbc-space-m);
	margin: var(--mbc-space-l) 0 0;
	padding: 0;
	list-style: none;
}

.mbc-nl-item {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0;
	height: auto;
}

.mbc-nl-item--has-image {
	grid-template-columns: var(--mbc-newsletter-thumb) 1fr;
}

.mbc-nl-item .mbc-card__image {
	display: block;
	align-self: start; /* a fixed 3:2 box: never stretched to the row's height */
	aspect-ratio: 3 / 2;
	overflow: hidden;
}

.mbc-nl-item .mbc-card__image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.mbc-nl-item__body {
	display: flex;
	flex-direction: column;
	gap: var(--mbc-space-xs);
	min-width: 0;
	padding: var(--mbc-space-m);
}

.mbc-nl-item__body > * {
	padding-inline: 0;
}

.mbc-nl-item__body .mbc-card__date {
	margin-top: 0;
}

/* Below about 480px of column width the thumbnail goes on top (a container query, so it follows
   the column, not the viewport). */
@container (max-width: 30rem) {
	.mbc-nl-item--has-image {
		grid-template-columns: 1fr;
	}
}

.mbc-nl-issue__email {
	margin: var(--mbc-space-xl) 0 0;
}

/* ---- Section index ([mbc_section_index]): cards built from the menu ---- */
.mbc-section-index {
	margin: var(--mbc-space-m) 0;
}

.mbc-section-index__heading {
	margin-bottom: var(--mbc-space-m);
}

.mbc-section-index__notice {
	padding: var(--mbc-space-s) var(--mbc-space-m);
	border: var(--mbc-border-width) dashed var(--mbc-border);
	color: var(--mbc-text-muted);
	font-size: var(--mbc-step--1);
}

.mbc-section-cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
	gap: var(--mbc-space-m);
	margin: 0;
	padding: 0;
	list-style: none;
}

.mbc-section-card {
	position: relative;
	display: flex;
	flex-direction: column;
	margin: 0;
	overflow: hidden;
	border: var(--mbc-border-width) solid var(--mbc-border);
	border-radius: var(--mbc-radius-md);
	background: var(--mbc-surface-alt);
}

.mbc-section-card__media {
	aspect-ratio: var(--mbc-card-ratio);
	overflow: hidden;
	background: var(--mbc-border);
}

.mbc-section-card__media img,
.mbc-section-card__placeholder {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.mbc-section-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: var(--mbc-space-xs);
	padding: var(--mbc-space-m);
}

.mbc-section-card__title {
	margin: 0;
	font-size: var(--mbc-step-1);
}

.mbc-section-card__title a {
	display: inline-flex;
	align-items: center;
	gap: var(--mbc-space-xs);
	min-height: var(--mbc-tap-target);
	color: var(--mbc-text);
	text-decoration: none;
}

/* One link per card: the title link stretches over the whole card. */
.mbc-section-card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.mbc-section-card:hover {
	background: var(--mbc-hover-bg);
}

.mbc-section-card:hover .mbc-section-card__title a {
	text-decoration: underline;
}

.mbc-section-card:focus-within {
	outline: var(--mbc-focus-width) solid var(--mbc-focus);
	outline-offset: var(--mbc-space-3xs);
}

.mbc-section-card__title a:focus-visible {
	outline: none;
}

.mbc-section-card__external {
	flex: 0 0 auto;
}

.mbc-section-card__desc {
	margin: 0;
	color: var(--mbc-text-muted);
}

/* A paragraph that holds one "more" link ends in an arrow (decorative: not read out). */
.mbc-link-more a::after {
	content: " \2192";
	content: " \2192" / "";
}

/* ---- Logos (media flagged "This is a logo", inc/logo-flag.php): shown whole on a plain background; photos keep cropping.
   Last in the file and doubled so it out-weighs the frame rules above (cover on Info images, contain on partner logos). ---- */
body img.mbc-is-logo.mbc-is-logo {
	object-fit: contain;
	padding: var(--mbc-logo-padding);
	background: var(--mbc-logo-bg);
}
