/* Email / WeChat popup (mgbrands-core). Noel's PDF card (425 x 655 pt) at 500 px wide: 1 pt = 1.1765 px.
   Each margin below puts a baseline where the PDF has it (documentation/analyze-popup-2026-11-05.md):
   with line-height 1.2 the brand font's baseline sits 0.9633em below the line top.
   Theme presets first, with fallbacks so it survives a theme change. */
.mg-popup {
	--mg-navy: var(--wp--preset--color--navy, #12313d);
	--mg-teal: var(--wp--preset--color--teal, #087d91);
	--mg-slate: var(--wp--preset--color--slate, #647482);
	--mg-rule: var(--wp--preset--color--grey-tint, #d0d6d8);
	--mg-white: var(--wp--preset--color--white, #fff);
	--mg-focus: var(--wp--preset--color--orange, #f58733);
	--mg-pad: 31.76px;
	box-sizing: border-box;
	width: min(500px, 100vw - 32px);
	max-width: none;
	max-height: calc(100dvh - 32px);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: 21.18px;
	background: var(--mg-white);
	color: var(--mg-navy);
	overflow: auto;
	overscroll-behavior: contain;
	font-family: var(--wp--preset--font-family--brand, "Helvetica Neue", Arial, sans-serif);
	font-weight: 500;
	line-height: 1.2;
	text-align: center;
	box-shadow: 0 24px 60px rgba(18, 49, 61, .28);
}
.mg-popup:focus { outline: none; } /* focused on open so screen readers announce it; Tab goes on to the close button */
.mg-popup__seg { white-space: nowrap; }
.mg-popup::backdrop { background: rgba(18, 49, 61, .55); }
html:has(.mg-popup[open]) { overflow: hidden; }

.mg-popup__card { position: relative; padding: 0 var(--mg-pad) 38.69px; }
.mg-popup__card::before { /* the teal bar, full width */
	content: "";
	display: block;
	height: 18.82px;
	margin: 0 calc(-1 * var(--mg-pad));
	background: var(--mg-teal);
}
.mg-popup :where(h2, h3, p) { margin: 0; padding: 0; line-height: 1.2; }
/* Tracking: measured against the PDF's line widths (Helvetica in the mockup is wider than the brand font):
   bold lines +0.03em, regular lines +0.015em put every line within about 3% of Noel's width. */
.mg-popup :where(h2, h3, .mg-popup__email) { letter-spacing: .03em; }
.mg-popup :where(.mg-popup__sub, .mg-popup__caption, .mg-popup__line, .mg-popup__foot) { letter-spacing: .015em; }

.mg-popup__title { margin-top: 22.22px !important; font-size: 27.06px; font-weight: 700; color: var(--mg-navy); }
.mg-popup__sub { margin-top: 12.83px !important; font-size: 12.94px; color: var(--mg-slate); }
.mg-popup__bar { margin: 0 .55em; color: var(--mg-rule); } /* Noel's bars are light grey, like the rules */

.mg-popup__part { margin-top: 18.84px; padding-top: 18.97px; border-top: 1px solid var(--mg-rule); }
.mg-popup__part--email { margin-top: 28.42px; padding-top: 16.67px; }
.mg-popup__heading { font-size: 18.82px; font-weight: 700; color: var(--mg-navy); }

/* The QR at its own proportions (630x612) inside the PDF's square box, so nothing is distorted. */
.mg-popup__qr { display: block; width: 289.41px; max-width: 100%; height: auto; aspect-ratio: 1; margin: 29.65px auto 0; object-fit: contain; }
.mg-popup__caption { margin-top: 12.27px !important; font-size: 11.76px; color: var(--mg-slate); }

.mg-popup__email { margin-top: 16.25px !important; font-size: 17.65px; font-weight: 700; }
.mg-popup__email a { color: var(--mg-teal); text-decoration: none; overflow-wrap: anywhere; }
.mg-popup__email a:hover { text-decoration: underline; }
.mg-popup__line { margin-top: 27.99px !important; font-size: 11.76px; color: var(--mg-slate); }
.mg-popup__foot { margin-top: 62.32px !important; font-size: 10.59px; color: var(--mg-slate); }

/* Close: not in the mockup; needed for touch and keyboard users. Navy x, 40 px target, under the bar. */
.mg-popup__close-form { position: absolute; top: 28px; right: 12px; margin: 0; }
.mg-popup__close {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--mg-navy);
	cursor: pointer;
}
.mg-popup__close:hover { background: var(--wp--preset--color--off-white, #f4f6f7); }
.mg-popup :focus-visible { outline: 3px solid var(--mg-focus); outline-offset: 2px; border-radius: 4px; }
.mg-popup__close:focus-visible { border-radius: 50%; }

@media (prefers-reduced-motion: no-preference) {
	.mg-popup[open] { animation: mg-popup-in .18s ease-out; }
	.mg-popup[open]::backdrop { animation: mg-popup-fade .18s ease-out; }
}
@keyframes mg-popup-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes mg-popup-fade { from { opacity: 0; } }

/* Phones: the card fills the width less a 16px gutter; tighter sides, the QR fits, the title clears the close button. */
@media (max-width: 539px) {
	.mg-popup { --mg-pad: 20px; }
	.mg-popup__title { font-size: 24px; padding: 0 30px; }
	.mg-popup__close-form { top: 26px; right: 6px; }
}

/* Phones: no text under 15px (Karol, 2026-11-09). The popup's small lines (10.6-12.9px in Noel's design) grow there. */
@media (max-width: 781px) {
	.mg-popup__sub, .mg-popup__caption, .mg-popup__line, .mg-popup__foot, .mg-popup__email { font-size: 15px !important; }
	.mg-popup__sub, .mg-popup__foot { display: flex; flex-wrap: wrap; justify-content: center; row-gap: 2px; } /* wrap between the | parts, never inside one */
	.mg-popup__part, .mg-popup__part--email { padding-top: 16px; }
	.mg-popup__foot { margin-top: 28px !important; }
	.mg-popup__line { margin-top: 16px !important; }
}
