/*
 * Announcement pop-up. Sizes follow the Figma frame (975 × 503: 364px photo,
 * 40px padding, Heading 1 + Body text styles). The fonts come from the
 * Montford Group theme; the fallbacks only matter under another theme.
 */

.mgap {
	--mgap-bg: #f0f0f0;
	--mgap-text: #1e1e1e;
	--mgap-accent: #8a7b65;
	--mgap-width: min(975px, 100vw - 32px);

	container-type: inline-size; /* the heading scales with the dialog, not the viewport */
	box-sizing: border-box;
	width: var(--mgap-width);
	max-width: none;
	max-height: calc(100dvh - 32px);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: 0;
	overflow: auto;
	overscroll-behavior: contain;
	background: var(--mgap-bg);
	color: var(--mgap-text);
}

.mgap:focus {
	outline: none; /* popup.js focuses the dialog itself, so the close button doesn't open with a focus ring */
}

.mgap[open] {
	display: grid;
	grid-template-columns: 364fr 611fr;
	min-height: calc(var(--mgap-width) * 503 / 975);
	animation: mgap-in 0.35s ease-out;
}

.mgap::backdrop {
	background: rgba(30, 30, 30, 0.72);
	animation: mgap-fade 0.35s ease-out;
}

.mgap *,
.mgap *::before,
.mgap *::after {
	box-sizing: border-box;
}

.mgap__media {
	position: relative;
	overflow: hidden;
	background: #2a2a2a;
}

.mgap__img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

.mgap__content {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 48px;
	padding: 40px;
}

.mgap__mark {
	display: block;
	flex: none;
	width: 76px;
	height: 57px;
	fill: var(--mgap-accent);
}

.mgap__title {
	margin: 0;
	color: inherit;
	font-family: var(--font-heading, 'STIX Two Text', Georgia, serif);
	font-size: clamp(32px, 5.34cqi, var(--text-h1-max, 52px)); /* 52px at the full 975px */
	font-weight: 400;
	line-height: var(--text-h1-line-height, 1);
	letter-spacing: var(--text-h1-letter-spacing, -0.015em);
	text-transform: none;
}

.mgap__body {
	margin-top: 40px;
	font-family: var(--font-body, 'STK Miso', 'Arial Narrow', Arial, sans-serif);
	font-size: 16px;
	font-weight: 400;
	line-height: 1.2;
}

.mgap__body p {
	margin: 0;
}

.mgap__body p + p {
	margin-top: 0.8em;
}

.mgap__body a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* Figma "Button 1": Earth fill / Stucco Gray text; hover = Style=Solid Light (Lava Stone fill),
   as the pop-up's background is light. */
.mgap__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-top: 32px;
	padding: var(--btn1-padding, 6px 12px);
	background: var(--mgap-accent);
	color: var(--mgap-bg);
	font-family: var(--font-body, 'STK Miso', 'Arial Narrow', Arial, sans-serif);
	font-size: 16px;
	line-height: 1.2;
	text-decoration: none;
	transition: background 0.2s, color 0.2s;
}

.mgap__button:hover,
.mgap__button:focus-visible {
	background: var(--mgap-text);
	color: var(--mgap-bg);
}

.mgap__button:focus-visible {
	outline: 2px solid var(--mgap-accent);
	outline-offset: 2px;
}

.mgap__close {
	position: absolute;
	top: 7px;
	right: 7px;
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--mgap-text);
	cursor: pointer;
}

.mgap__close svg {
	display: block;
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
}

.mgap__close:hover {
	color: var(--mgap-accent);
}

.mgap__close:focus-visible {
	outline: 2px solid var(--mgap-accent);
	outline-offset: -2px;
}

/* The page behind stays put while the dialog is open. */
html.mgap-is-open {
	overflow: hidden;
}

/* Phones: stack the photo above the text as a short band. */
@media (max-width: 640px) {
	.mgap[open] {
		grid-template-columns: 1fr;
		grid-template-rows: 180px auto;
		min-height: 0;
	}

	.mgap__img {
		object-position: 50% 72%; /* keep the bench in the short band */
	}

	.mgap__content {
		gap: 40px;
		padding: 24px;
	}

	.mgap__mark {
		width: 56px;
		height: 42px;
	}

	.mgap__body {
		margin-top: 24px;
	}

	.mgap__button {
		margin-top: 24px;
	}

	/* The close button sits on the photo here, so give it its own backdrop. */
	.mgap__close {
		top: 8px;
		right: 8px;
		background: var(--mgap-bg);
	}
}

@keyframes mgap-in {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
}

@keyframes mgap-fade {
	from {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mgap[open],
	.mgap::backdrop {
		animation: none;
	}
}
