/*
 * Add event popup (Monthly Events Calendar 1.8.1).
 *
 * A native <dialog>: the browser keeps focus inside it, closes it with
 * Escape and returns focus to the button. This file only places it:
 * a panel on the right or the left, or a box in the centre. On phones it
 * fills the screen.
 */

.ecwp-popup {
	box-sizing: border-box;
	padding: 0;
	border: 0;
	background: #fff;
	color: #1d2327;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
	overflow: hidden;
	font-size: 1rem;
	line-height: 1.5;
	text-align: start;
}

.ecwp-popup *,
.ecwp-popup *::before,
.ecwp-popup *::after {
	box-sizing: inherit;
}

/* Only when open: a closed dialog must stay hidden. */
.ecwp-popup[open] {
	display: flex;
	flex-direction: column;
}

.ecwp-popup::backdrop {
	background: rgba(0, 0, 0, 0.5);
}

/* ---------- Positions ---------- */

.ecwp-popup--right,
.ecwp-popup--left {
	width: min(32rem, 100vw);
	max-width: none;
	height: 100vh;
	height: 100dvh;
	max-height: none;
	margin: 0;
}

.ecwp-popup--right {
	margin-left: auto;
}

.ecwp-popup--left {
	margin-right: auto;
}

.ecwp-popup--center {
	width: min(42rem, calc(100vw - 2rem));
	max-width: none;
	max-height: calc(100vh - 2rem);
	max-height: calc(100dvh - 2rem);
	margin: auto;
	border-radius: 12px;
}

@media (max-width: 600px) {
	.ecwp-popup--right,
	.ecwp-popup--left,
	.ecwp-popup--center {
		width: 100vw;
		height: 100vh;
		height: 100dvh;
		max-height: none;
		margin: 0;
		border-radius: 0;
	}
}

/* ---------- Parts ---------- */

.ecwp-popup__header {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.75rem 0.75rem 0.75rem 1.25rem;
	border-bottom: 1px solid #dcdcde;
}

.ecwp-popup .ecwp-popup__title {
	margin: 0;
	padding: 0;
	color: inherit;
	font-size: 1.25rem;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: normal;
	text-transform: none;
}

.ecwp-popup .ecwp-popup__title:focus {
	outline: none;
}

.ecwp-popup .ecwp-popup__header .ecwp-popup__close {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	box-shadow: none;
	color: inherit;
	cursor: pointer;
}

.ecwp-popup .ecwp-popup__header .ecwp-popup__close:hover {
	background: #f0f0f1;
	color: inherit;
}

.ecwp-popup .ecwp-popup__header .ecwp-popup__close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.ecwp-popup__body {
	flex: 1 1 auto;
	min-height: 0;
	padding: 1.25rem;
	overflow: auto;
	/* Scrolling to the end of the form doesn't start scrolling the page behind. */
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.ecwp-popup__body > .ecwp-submit {
	margin: 0;
}

.ecwp-popup .ecwp-popup__status {
	margin: 0 0 1rem;
}

/* ---------- Opening ---------- */

@media (prefers-reduced-motion: no-preference) {
	.ecwp-popup--right[open] {
		animation: ecwp-popup-from-right 0.2s ease-out;
	}

	.ecwp-popup--left[open] {
		animation: ecwp-popup-from-left 0.2s ease-out;
	}

	.ecwp-popup--center[open] {
		animation: ecwp-popup-rise 0.15s ease-out;
	}

	.ecwp-popup[open]::backdrop {
		animation: ecwp-popup-dim 0.2s ease-out;
	}
}

@keyframes ecwp-popup-from-right {
	from {
		transform: translateX(100%);
	}
}

@keyframes ecwp-popup-from-left {
	from {
		transform: translateX(-100%);
	}
}

@keyframes ecwp-popup-rise {
	from {
		opacity: 0;
		transform: translateY(0.5rem);
	}
}

@keyframes ecwp-popup-dim {
	from {
		opacity: 0;
	}
}
