/* Maghost Popups — frontend
 * Personalizare din temă, fără a modifica pluginul:
 *   .mghp-popup { --mghp-bg: #fff; --mghp-radius: 0; --mghp-overlay: rgba(0,0,0,.8); }
 *   #mghp-popup-123 .mghp-dialog { ... }   (un singur pop-up)
 */

.mghp-popup {
	--mghp-bg: #ffffff;
	--mghp-text: #1f2328;
	--mghp-radius: 10px;
	--mghp-padding: clamp(22px, 4vw, 40px);
	--mghp-overlay: rgba(20, 22, 26, 0.62);
	--mghp-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.45);
	--mghp-z: 999999;

	position: fixed;
	inset: 0;
	z-index: var(--mghp-z);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	box-sizing: border-box;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.mghp-popup[hidden] {
	display: none !important;
}

.mghp-popup.is-open {
	opacity: 1;
	visibility: visible;
	transition: opacity 0.2s ease, visibility 0s;
}

.mghp-overlay {
	position: absolute;
	inset: 0;
	background: var(--mghp-overlay);
}

.mghp-dialog {
	position: relative;
	width: 100%;
	max-width: var(--mghp-width, 600px);
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	overflow-y: auto;
	overscroll-behavior: contain;
	box-sizing: border-box;
	padding: var(--mghp-padding);
	background: var(--mghp-bg);
	color: var(--mghp-text);
	border-radius: var(--mghp-radius);
	box-shadow: var(--mghp-shadow);
	outline: none;
	transform: translateY(14px);
	transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mghp-popup.is-open .mghp-dialog {
	transform: none;
}

/* Butonul X — resetat, pentru că temele stilizează agresiv <button> */
.mghp-popup .mghp-dialog > button.mghp-x {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	box-shadow: none;
	line-height: 1;
	text-transform: none;
	letter-spacing: normal;
	opacity: 0.6;
	cursor: pointer;
	transition: opacity 0.15s ease, background-color 0.15s ease;
}

.mghp-popup .mghp-dialog > button.mghp-x:hover {
	opacity: 1;
	background: rgba(127, 127, 127, 0.14);
}

.mghp-popup .mghp-dialog > button.mghp-x:focus-visible {
	opacity: 1;
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.mghp-popup .mghp-dialog > button.mghp-x svg {
	display: block;
	pointer-events: none;
}

/* Conținut */
.mghp-content > :first-child {
	margin-top: 0;
}

.mghp-content > :last-child {
	margin-bottom: 0;
}

/* Titlul de sus să nu intre sub X */
.mghp-content > :first-child:is(h1, h2, h3, h4, h5, h6, p) {
	padding-right: 28px;
}

.mghp-content img,
.mghp-content video {
	max-width: 100%;
	height: auto;
}

.mghp-content iframe {
	max-width: 100%;
}

/* ---------------- Stil „Doar imagine” ---------------- */

.mghp-popup--image .mghp-dialog {
	width: auto;
	max-width: none;
	max-height: none;
	padding: 0;
	overflow: hidden;
	background: transparent;
	border-radius: 0;
	box-shadow: none;
}

.mghp-popup--image .mghp-content :is(figure, p, div, a) {
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
	border: 0 !important;
	background: none !important;
}

.mghp-popup--image .mghp-content figcaption {
	display: none;
}

/* Lățimea = cea mai mică dintre: setarea din admin, lățimea ecranului,
   înălțimea ecranului × raportul imaginii (ca să încapă întreagă).
   !important pentru că editorul pune stiluri inline pe imaginile redimensionate. */
.mghp-popup--image .mghp-content img {
	display: block !important;
	width: min(var(--mghp-width, 600px), calc(100vw - 32px), calc((100vh - 32px) * var(--mghp-ratio, 10))) !important;
	width: min(var(--mghp-width, 600px), calc(100vw - 32px), calc((100dvh - 32px) * var(--mghp-ratio, 10))) !important;
	height: auto !important;
	max-width: none !important;
	max-height: calc(100vh - 32px) !important;
	max-height: calc(100dvh - 32px) !important;
	aspect-ratio: auto !important;
	margin: 0 !important;
	object-fit: contain !important;
	border: 0 !important;
	border-radius: 0;
	box-shadow: none !important;
}

.mghp-popup.mghp-popup--image .mghp-dialog > button.mghp-x {
	top: 8px;
	right: 8px;
	background: rgba(255, 255, 255, 0.92);
	color: #1f2328;
	opacity: 1;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.mghp-popup.mghp-popup--image .mghp-dialog > button.mghp-x:hover {
	background: #ffffff;
}

/* Blocare scroll pagină cât e deschis */
html.mghp-lock {
	overflow: hidden;
}

html.mghp-lock body {
	padding-right: var(--mghp-scrollbar, 0px);
}

@media (prefers-reduced-motion: reduce) {
	.mghp-popup,
	.mghp-popup.is-open,
	.mghp-dialog {
		transition: none;
	}
	.mghp-dialog {
		transform: none;
	}
}
