/**
 * Meridian Sections — Markets
 *
 * Figma 22:12522 (nav) and 22:12543 (panel).
 */

.md-markets {
	/* Nav height, used both for its own sizing and for the scroll offset the
	 * panels need to clear it when jumped to. */
	--md-markets-nav-h: 3.6875rem; /* 57px + the 1px rules above and below */
}

/* --- Pill nav ------------------------------------------------------------ */
.md-markets__nav {
	border-block: var(--md-border-width, 1px) solid #e6e6e6;
	background-color: var(--md-white, #fff);
}

/* Sticks below the fixed site header rather than the viewport top. */
.md-markets__nav.is-sticky {
	position: sticky;
	top: var(--md-header-total, 5.0625rem);
	z-index: var(--md-z-sticky, 100);
}

.md-markets__nav-inner {
	display: flex;
	align-items: center;
	/*
	 * "safe" matters here, not decoration. A plain `center` inside a scroll
	 * container overflows equally in both directions, and the leading overflow
	 * is unreachable — the first pills get cut off with no way to scroll back
	 * to them. `safe` falls back to start alignment the moment the row is too
	 * wide, so the pills centre while they fit and stay reachable when they do
	 * not. Browsers without the keyword drop the declaration and left-align,
	 * which is the same safe outcome.
	 */
	justify-content: safe center;
	gap: var(--md-space-2xs, 0.5rem);
	padding-block: var(--md-space-xs, 0.75rem);
	/* The comp clips the row. Scrolling it keeps every market reachable when
	 * the pills outrun the viewport, which they do well before mobile. */
	overflow-x: auto;
	overscroll-behavior-inline: contain;
	scrollbar-width: thin;
}

.md-markets__pill {
	flex: none;
	padding: 0.4375rem 1.09375rem; /* 7.5 / 17.5 */
	border: 1.5px solid #d1d5db;
	border-radius: var(--md-radius-pill, 999px);
	color: #555;
	font-size: 0.75rem; /* 12px */
	font-weight: var(--md-weight-bold, 700);
	line-height: 1.5; /* 18px */
	letter-spacing: 0.06em; /* 0.72px on 12px */
	text-align: center;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	transition: color var(--md-transition, 200ms ease),
		border-color var(--md-transition, 200ms ease),
		background-color var(--md-transition, 200ms ease);
}

.md-markets__pill:hover,
.md-markets__pill:focus-visible {
	border-color: var(--md-blue, #006bb6);
	color: var(--md-blue, #006bb6);
}

.md-markets__pill.is-active {
	border-color: var(--md-blue, #006bb6);
	background-color: var(--md-blue, #006bb6);
	color: var(--md-white, #fff);
}

/* --- Panel --------------------------------------------------------------- */
.md-section.md-market {
	padding-block: 0;
	border-bottom: var(--md-border-width, 1px) solid var(--md-color-rule, #ebebeb);
	background-color: var(--md-white, #fff);
	/* Clear the fixed header plus the sticky nav when jumped to. */
	scroll-margin-top: calc(
		var(--md-header-total, 5.0625rem) + var(--md-markets-nav-h, 3.6875rem)
	);
}

.md-market__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
}

.md-market__media {
	padding: var(--md-space-lg, 2rem);
}

.md-market .md-market__img {
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 0.625rem; /* 10px */
	background-color: #e5e7eb;
}

.md-market__body {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	justify-content: center;
	padding: var(--md-space-xl, 3rem) var(--md-space-lg, 2rem);
}

.md-market__title {
	margin: 0;
	color: var(--md-color-heading, #0a1628);
	font-family: var(--md-font-heading, "Cabin", sans-serif);
	font-size: 2.25rem; /* 36px */
	font-weight: var(--md-weight-bold, 700);
	line-height: 1.06; /* 38.16 / 36 */
	text-wrap: balance;
}

.md-market__text {
	margin: 0;
	margin-block-start: 1.25rem; /* 20px */
	/*
	 * 90% of the copy column, rather than the comp's fixed 447px, so the cap tracks
	 * the column instead of stopping dead once the column grows past it.
	 *
	 * A ceiling, not a width: .md-market__body is a flex column with items at
	 * flex-start, so this paragraph is shrink-to-fit. It renders at whichever is
	 * smaller — its own longest line, or 90% of the column — which at 1440 is the
	 * line (533px inside a 590px cap) and at 1024 is also the line (346 inside 403).
	 * The 90% is the guard for long copy, not the measure for short copy.
	 */
	max-width: 90%;
	color: var(--md-color-text-body, #364153);
	/*
	 * 16px, not the 13px drawn. Bumped deliberately across every section whose body
	 * copy sat at 13 — Callouts, Card Grid, Leadership Grid, Markets, Mosaic List —
	 * because 13px prose is small to read and 16px is the browser default a reader
	 * expects. The 1.625 leading is unitless, so it follows to 26px.
	 */
	font-size: var(--md-text-small, 1rem); /* 16px */
	line-height: 1.625; /* 26 / 16 */
}

/* --- Tags ---------------------------------------------------------------- */
.md-market__tags {
	display: flex;
	flex-wrap: wrap;
	gap: var(--md-space-2xs, 0.5rem);
	margin: 0;
	margin-block-start: 1.75rem; /* 28px */
	padding: 0;
	list-style: none;
}

.md-market__tag {
	padding: 0.3125rem 0.8125rem; /* 5 / 13 */
	border: var(--md-border-width, 1px) solid #d9d9d9;
	border-radius: var(--md-radius-pill, 999px);
	color: var(--md-color-text-body, #364153);
	font-size: 0.6875rem; /* 11px */
	font-weight: var(--md-weight-semibold, 600);
	line-height: 1.5; /* 16.5px */
	letter-spacing: 0.04em; /* 0.44px on 11px */
}

/* --- Link ---------------------------------------------------------------- */
.md-market__link {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem; /* 6px */
	margin-block-start: 1.75rem;
	color: var(--md-blue, #006bb6);
	font-size: 0.8125rem; /* 13px */
	font-weight: var(--md-weight-bold, 700);
	line-height: 1.5; /* 19.5px */
	letter-spacing: 0.06em; /* 0.78px on 13px */
	text-transform: uppercase;
	text-decoration: none;
}

.md-market__link svg {
	width: 0.875rem; /* 14px */
	height: 0.875rem;
	fill: none;
	transition: transform var(--md-transition, 200ms ease);
}

.md-market__link:hover,
.md-market__link:focus-visible {
	text-decoration: underline;
	text-underline-offset: 0.25em;
}

.md-market__link:hover svg,
.md-market__link:focus-visible svg {
	transform: translateX(2px);
}

/* --- Two-up ------------------------------------------------------------- */
@media (min-width: 62em) {
	.md-market__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		align-items: center;
	}

	.md-market__media {
		padding: var(--md-space-xl, 3rem);
	}

	.md-market__body {
		padding: var(--md-space-3xl, 5rem) 4rem; /* 80 / 64 */
	}

	/*
	 * Zig-zag, on by default: image left on the first panel, right on the
	 * second, and so on.
	 *
	 * nth-of-type counts sections among their siblings, and the nav is a <nav>,
	 * so it does not shift the count — panel 1 is section 1. Only the media is
	 * placed explicitly; the body then auto-fills the remaining cell, so one
	 * declaration swaps the pair.
	 */
	.md-markets--alternate .md-market:nth-of-type(even) .md-market__media {
		grid-column: 2;
		grid-row: 1;
	}
}

/*
 * Image-right panels carry a tinted, dotted ground behind the photo while the
 * copy side stays white (Figma 22:12579). Three layers, painted top down:
 *
 *   1. white, opaque at the left edge fading to clear at the right — this is
 *      what keeps the copy half plain
 *   2. the dot grid, so it only shows through where that white has faded
 *   3. the flat tint underneath
 *
 * Sampling the comp put the dots on a 20px pitch with a core of 236 against a
 * 251 ground, which is what --md-color-dot already resolves to over this tint.
 * Scoped to the alternating layout: with the zig-zag off every panel keeps the
 * image left, and the comp draws that panel plain white.
 */
.md-markets--alternate .md-market:nth-of-type(even) {
	background-color: #fcfdfd;
	background-image: linear-gradient(
			to left,
			rgba(255, 255, 255, 0) 0%,
			var(--md-white, #fff) 100%
		),
		radial-gradient(
			circle,
			var(--md-color-dot, rgba(10, 22, 40, 0.06)) 1.5px,
			transparent 1.5px
		);
	background-size: auto, var(--md-dot-pitch, 20px) var(--md-dot-pitch, 20px);
}

/* Stacked single-column, there is no copy side to keep clear — the wash would
 * just dim the top of the panel, so the tint and dots carry the full width. */
@media (max-width: 61.9375em) {
	.md-markets--alternate .md-market:nth-of-type(even) {
		background-image: radial-gradient(
			circle,
			var(--md-color-dot, rgba(10, 22, 40, 0.06)) 1.5px,
			transparent 1.5px
		);
	}
}

@media (prefers-reduced-motion: reduce) {
	.md-market__link svg {
		transition: none;
	}
}
