/**
 * Makura Popups — front end.
 *
 * Everything is scoped under .mkp-popup and uses custom properties, so a theme
 * can restyle the popup by overriding the variables rather than fighting
 * specificity. Nothing here leaks into the host theme.
 */

.mkp-popup {
	--mkp-max-width: 560px;
	--mkp-radius: 8px;
	--mkp-bg: #fff;
	--mkp-text: #1d2327;
	--mkp-accent: #044983;
	--mkp-accent-text: #fff;
	--mkp-link: var(--mkp-accent);
	--mkp-link-hover: #02305a;
	--mkp-backdrop: rgba(0, 0, 0, 0.6);

	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.mkp-popup[hidden] {
	display: none;
}

.mkp-popup.is-open {
	opacity: 1;
}

.mkp-popup__backdrop {
	position: absolute;
	inset: 0;
	background: var(--mkp-backdrop);
}

.mkp-popup__dialog {
	position: relative;
	width: 100%;
	max-width: var(--mkp-max-width);
	max-height: calc(100vh - 40px);
	overflow-y: auto;
	padding: 24px;
	background: var(--mkp-bg);
	color: var(--mkp-text);
	border-radius: var(--mkp-radius);
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
	transform: translateY(8px);
	transition: transform 0.2s ease;
}

.mkp-popup.is-open .mkp-popup__dialog {
	transform: translateY(0);
}

.mkp-popup__close {
	position: absolute;
	top: 12px;
	right: 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	color: var(--mkp-accent);
	background: transparent;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

.mkp-popup__close:hover,
.mkp-popup__close:focus-visible {
	background: rgba(0, 0, 0, 0.06);
}

.mkp-popup__heading {
	margin: 0 40px 16px 0;
	font-size: 24px;
	line-height: 1.3;
}

.mkp-popup__media {
	margin: 0 0 20px;
}

.mkp-popup__image {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 4px;
}

.mkp-popup__media--video {
	position: relative;
}

.mkp-popup__poster {
	position: relative;
	display: block;
	width: 100%;
	padding: 0;
	background: #000;
	border: 0;
	border-radius: 4px;
	overflow: hidden;
	cursor: pointer;
	line-height: 0;
}

.mkp-popup__play {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	transition: opacity 0.15s ease;
	opacity: 0.9;
}

.mkp-popup__poster:hover .mkp-popup__play {
	opacity: 1;
}

.mkp-popup__media--video iframe {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	border: 0;
	border-radius: 4px;
}

.mkp-popup__body {
	margin-bottom: 16px;
}

.mkp-popup__body > *:last-child {
	margin-bottom: 0;
}

/*
 * Links inside the description.
 *
 * A host theme can leave anchors with no colour of their own — USEF's reset sets
 * `a { color: var(--title) }` against a custom property nothing declares, which
 * is invalid at computed-value time and therefore falls back to *inherited*
 * colour. Combined with `text-decoration: none` that left a link in the popup
 * body rendering exactly like the text around it, with nothing marking it as a
 * link at all. Colour and underline are both set here so the affordance does not
 * depend on colour alone.
 *
 * (0,1,1) beats a bare `a` (0,0,1), so no !important is needed. Long URLs get
 * `overflow-wrap: anywhere` because a theme that also sets `display:inline-block`
 * on anchors would otherwise let one unbreakable token widen the dialog.
 */
.mkp-popup__body a {
	color: var(--mkp-link);
	text-decoration: underline;
	text-underline-offset: 2px;
	overflow-wrap: anywhere;
}

.mkp-popup__body a:hover,
.mkp-popup__body a:focus-visible {
	color: var(--mkp-link-hover);
	text-decoration-thickness: 2px;
}

.mkp-popup__actions {
	display: flex;
	justify-content: flex-end;
}

.mkp-popup__cta {
	display: inline-block;
	padding: 12px 24px;
	color: var(--mkp-accent-text);
	background: var(--mkp-accent);
	border-radius: 4px;
	font-weight: 600;
	text-decoration: none;
}

.mkp-popup__cta:hover,
.mkp-popup__cta:focus-visible {
	opacity: 0.9;
	color: var(--mkp-accent-text);
}

/* Stop the page behind the popup from scrolling while it is open. */
body.mkp-open {
	overflow: hidden;
}

@media (max-width: 600px) {
	.mkp-popup {
		padding: 12px;
	}

	.mkp-popup__dialog {
		padding: 20px 16px;
	}

	.mkp-popup__heading {
		font-size: 20px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mkp-popup,
	.mkp-popup__dialog {
		transition: none;
	}
}
