/* Post Modal Popup
 * Structural rules apply always. Visual rules only apply with .pmp-styled
 * ("Use the built-in styling" setting), so you can style the popup yourself.
 */

/* ---------- Structure ---------- */

.pmp-modal {
	--pmp-max-width: 820px;
	--pmp-bg: #fff;
	--pmp-fg: inherit;
	--pmp-muted: #6b7280;
	--pmp-overlay: rgba(17, 24, 39, 0.6);
	--pmp-radius: 10px;
	--pmp-padding: clamp(20px, 4vw, 44px);

	--pmp-max-height: 90vh;

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

.pmp-modal[hidden] {
	display: none;
}

.pmp-modal.pmp-valign-top {
	align-items: flex-start;
	padding-top: 4vh;
}

.pmp-modal.is-open {
	opacity: 1;
}

html.pmp-locked,
html.pmp-locked body {
	overflow: hidden;
}

.pmp-overlay {
	position: absolute;
	inset: 0;
}

/* The dialog is a fixed frame; .pmp-body scrolls inside it, so the close button never moves or takes up space. */
.pmp-dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: var(--pmp-max-width);
	max-height: var(--pmp-max-height);
	overflow: hidden;
	outline: none;
}

.pmp-close {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 3;
	cursor: pointer;
}

.pmp-body {
	flex: 1 1 auto;
	min-height: 120px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.pmp-content img,
.pmp-content iframe,
.pmp-content video {
	max-width: 100%;
}

.pmp-content img {
	height: auto;
}

.pmp-dialog.pmp-is-iframe {
	max-width: min(1200px, 100%);
	height: var(--pmp-max-height);
	overflow: hidden;
}

.pmp-dialog.pmp-is-iframe .pmp-body {
	height: 100%;
}

.pmp-iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
}

.pmp-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* WP Post Popup compatibility: let the theme's .wp-post-modal width rules decide (its default was 70%). */
.pmp-compat .pmp-dialog {
	max-width: none;
	width: 70%;
}

.pmp-close img {
	display: block;
}

/* ---------- Built-in styling ---------- */

.pmp-styled .pmp-overlay {
	background: var(--pmp-overlay);
}

.pmp-styled .pmp-dialog {
	background: var(--pmp-bg);
	color: var(--pmp-fg);
	border-radius: var(--pmp-radius);
	box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
	transform: translateY(12px);
	transition: transform 0.2s ease;
}

.pmp-styled.is-open .pmp-dialog {
	transform: none;
}

.pmp-styled .pmp-close {
	width: 44px;
	height: 44px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	color: #111;
	font-size: 26px;
	line-height: 1;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.pmp-styled .pmp-close:hover {
	background: #fff;
}

.pmp-close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.pmp-styled .pmp-figure {
	margin: 0;
}

.pmp-styled .pmp-figure img {
	display: block;
	width: 100%;
	height: auto;
	max-height: 50vh;
	object-fit: cover;
	border-radius: var(--pmp-radius) var(--pmp-radius) 0 0;
}

.pmp-styled .pmp-header,
.pmp-styled .pmp-content,
.pmp-styled .pmp-footer {
	padding-left: var(--pmp-padding);
	padding-right: var(--pmp-padding);
}

.pmp-styled .pmp-header {
	padding-top: var(--pmp-padding);
	padding-right: calc(var(--pmp-padding) + 40px);
}

.pmp-styled .pmp-header-empty {
	padding-top: calc(var(--pmp-padding) + 20px);
}

.pmp-styled .pmp-title {
	margin: 0 0 0.4em;
	line-height: 1.2;
}

.pmp-styled .pmp-meta {
	color: var(--pmp-muted);
	font-size: 0.9em;
	margin-bottom: 1.2em;
}

.pmp-styled .pmp-content {
	padding-bottom: var(--pmp-padding);
	max-width: none;
	margin: 0;
}

.pmp-styled .pmp-footer {
	padding-top: 1em;
	padding-bottom: var(--pmp-padding);
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.pmp-styled .pmp-is-iframe .pmp-close {
	position: absolute;
	top: 10px;
	right: 10px;
	margin: 0;
}

.pmp-styled .pmp-is-iframe .pmp-iframe {
	border-radius: var(--pmp-radius);
}

.pmp-loading {
	display: grid;
	place-items: center;
	min-height: 240px;
}

.pmp-spinner {
	width: 36px;
	height: 36px;
	border: 3px solid rgba(0, 0, 0, 0.12);
	border-top-color: var(--pmp-muted, #6b7280);
	border-radius: 50%;
	animation: pmp-spin 0.8s linear infinite;
}

.pmp-error {
	padding: var(--pmp-padding, 24px);
	text-align: center;
}

@keyframes pmp-spin {
	to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
	.pmp-modal {
		padding: 0;
	}
	.pmp-dialog,
	.pmp-dialog.pmp-is-iframe {
		max-height: 100vh;
		height: 100%;
	}
	.pmp-compat .pmp-dialog {
		width: 100%;
	}
	.pmp-styled .pmp-dialog,
	.pmp-styled .pmp-figure img,
	.pmp-styled .pmp-is-iframe .pmp-iframe {
		border-radius: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pmp-modal,
	.pmp-styled .pmp-dialog {
		transition: none;
	}
	.pmp-spinner {
		animation-duration: 2s;
	}
}
