$popup-button-bg: #1f7a8c;
$popup-button-bg-hover: #195f6d;
$popup-button-color: #fff;
$popup-overlay-bg: rgba(0, 0, 0, 0.55);
$popup-box-bg: #fff;
$popup-box-color: #1a1a1a;
$popup-close-color: #333;
$popup-close-color-hover: #111;
$popup-transition: 0.2s ease;
$popup-z-index: 2147483647;

.ea-popup-widget {
	display: block;
}

.ea-popup-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 12px 24px;
	border: 1px solid transparent;
	border-radius: 4px;
	background: $popup-button-bg;
	color: $popup-button-color;
	font: inherit;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition:
		background-color $popup-transition,
		border-color $popup-transition,
		color $popup-transition,
		box-shadow $popup-transition,
		transform $popup-transition;

	&:hover,
	&:focus {
		background: $popup-button-bg-hover;
		color: $popup-button-color;
		text-decoration: none;
	}

	&:focus-visible {
		outline: 2px solid currentColor;
		outline-offset: 3px;
	}
}

.ea-popup-modal {
	position: fixed;
	inset: 0;
	z-index: $popup-z-index;
	width: 100vw;
	max-width: none;
	height: 100vh;
	max-height: none;
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	border: 0;
	background: $popup-overlay-bg;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity $popup-transition, visibility $popup-transition;

	&:not([open]) {
		display: none;
	}

	&.is-open {
		display: flex;
		opacity: 1;
		visibility: visible;
		pointer-events: auto;

		.ea-popup-dialog {
			transform: translateY(0);
		}
	}

	&::backdrop {
		background: transparent;
	}
}

.ea-popup-dialog {
	position: relative;
	width: 100%;
	margin: auto;
	max-width: 720px;
	max-height: calc(100vh - 48px);
	overflow: auto;
	padding: 32px;
	border-radius: 8px;
	background: $popup-box-bg;
	color: $popup-box-color;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
	transform: translateY(12px);
	transition: transform $popup-transition;
}

.ea-popup-close {
	position: absolute;
	top: 12px;
	right: 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: $popup-close-color;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;

	&:hover,
	&:focus {
		background: rgba(0, 0, 0, 0.08);
		color: $popup-close-color-hover;
	}

	&:focus-visible {
		outline: 2px solid currentColor;
		outline-offset: 3px;
	}
}

.ea-popup-content {
	padding-right: 20px;

	> :first-child {
		margin-top: 0;
	}

	> :last-child {
		margin-bottom: 0;
	}
}

body.ea-popup-lock {
	overflow: hidden;
}

@media (max-width: 767px) {
	.ea-popup-modal {
		padding: 16px;
	}

	.ea-popup-dialog {
		max-height: calc(100vh - 32px);
		padding: 28px 22px;
	}
}
