/* Base */
.fsp-popup {
	position: fixed;
	z-index: 99999;
	visibility: hidden;
	transition: opacity 0.25s ease, transform 0.35s ease, visibility 0.35s;
}

.fsp-popup.is-open {
	visibility: visible;
}

.fsp-modal {
	position: relative;
	width: 100%;
	overflow-y: auto;
	background: #fff;
	color: inherit;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.fsp-modal:focus {
	outline: none;
}

.fsp-close {
	position: absolute;
	z-index: 2;
	top: 8px;
	right: 10px;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	background: transparent;
	color: #333;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}

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

.fsp-content > *:first-child {
	margin-top: 0;
}

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

.fsp-content img {
	max-width: 100%;
	height: auto;
}

/* Columns */
.fsp-modal {
	container-type: inline-size;
}

.fsp-cols {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 28px;
	align-items: center;
}

.fsp-ratio-left {
	grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}

.fsp-ratio-right {
	grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
}

.fsp-col > *:first-child {
	margin-top: 0;
}

.fsp-col > *:last-child {
	margin-bottom: 0;
}

.fsp-col img {
	display: block;
	max-width: 100%;
	height: auto;
}

/* Stack when the popup itself is too narrow for two columns. */
@container (max-width: 520px) {
	.fsp-cols {
		grid-template-columns: minmax(0, 1fr);
		gap: 20px;
	}
}

/* Fallback for browsers without container queries. */
@supports not (container-type: inline-size) {
	@media (max-width: 600px) {
		.fsp-cols {
			grid-template-columns: minmax(0, 1fr);
			gap: 20px;
		}
	}
}

/* Give two-column popups more room. */
.fsp-pos-center.fsp-has-cols .fsp-modal {
	max-width: var(--fsp-width, 820px);
}

.fsp-pos-slide-left.fsp-has-cols,
.fsp-pos-slide-right.fsp-has-cols {
	max-width: var(--fsp-width, 580px);
}

.fsp-pos-bottom.fsp-has-cols .fsp-cols {
	max-width: 1100px;
	margin: 0 auto;
}

/* No padding option */
.fsp-popup.fsp-no-pad .fsp-modal {
	padding: 0;
}

.fsp-pos-bottom.fsp-no-pad .fsp-modal {
	padding: 0 0 env(safe-area-inset-bottom, 0px);
}

.fsp-no-pad .fsp-content img {
	display: block;
}

/* One column runs to the edge, the other keeps its padding. */
.fsp-flush-left .fsp-cols,
.fsp-flush-right .fsp-cols {
	gap: 0;
	align-items: stretch;
}

.fsp-flush-left .fsp-col:not(.fsp-col-flush),
.fsp-flush-right .fsp-col:not(.fsp-col-flush) {
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 40px 32px;
}

.fsp-col-flush {
	position: relative;
	min-height: 220px;
}

/* The image (and any link or paragraph WordPress wraps it in) fills the column. */
.fsp-col-flush > *,
.fsp-col-flush a {
	display: block;
	height: 100%;
	margin: 0;
}

/* Positioned so the image fills the column without setting its height.
   The text column decides how tall the popup is. */
.fsp-col-flush img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.fsp-pos-bottom.fsp-flush-left .fsp-cols,
.fsp-pos-bottom.fsp-flush-right .fsp-cols {
	max-width: none;
}

.fsp-pos-bottom.fsp-flush-left .fsp-col:not(.fsp-col-flush),
.fsp-pos-bottom.fsp-flush-right .fsp-col:not(.fsp-col-flush) {
	padding: 24px 56px 24px 32px;
}

@container (max-width: 520px) {
	/* Stacked: the image goes on top as a banner. */
	.fsp-col-flush {
		order: -1;
		min-height: 0;
	}

	.fsp-col-flush img {
		position: static;
		height: auto;
		max-height: 240px;
	}

	.fsp-flush-left .fsp-col:not(.fsp-col-flush),
	.fsp-flush-right .fsp-col:not(.fsp-col-flush) {
		padding: 24px;
	}
}

/* Keep the close button readable when it sits over an image. */
.fsp-no-pad .fsp-close {
	top: 10px;
	right: 10px;
	width: 32px;
	height: 32px;
	font-size: 22px;
	background: rgba(255, 255, 255, 0.92);
	border-radius: 50%;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

body.fsp-no-scroll {
	overflow: hidden;
}

/* Center modal */
.fsp-pos-center {
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(0, 0, 0, 0.6);
	opacity: 0;
}

.fsp-pos-center.is-open {
	opacity: 1;
}

.fsp-pos-center .fsp-modal {
	max-width: var(--fsp-width, 560px);
	max-height: 90vh;
	padding: 40px 32px 32px;
	border-radius: 6px;
	transform: translateY(12px);
	transition: transform 0.25s ease;
}

.fsp-pos-center.is-open .fsp-modal {
	transform: translateY(0);
}

/* Bottom bar */
.fsp-pos-bottom {
	left: 0;
	right: 0;
	bottom: 0;
	transform: translateY(100%);
}

.fsp-pos-bottom.is-open {
	transform: translateY(0);
}

.fsp-pos-bottom .fsp-modal {
	max-height: 60vh;
	padding: 24px 56px calc(24px + env(safe-area-inset-bottom, 0px)) 24px;
	box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

/* Slide-ins */
.fsp-pos-slide-left,
.fsp-pos-slide-right {
	bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	width: calc(100% - 40px);
	max-width: var(--fsp-width, 380px);
}

.fsp-pos-slide-left {
	left: 20px;
	transform: translateX(calc(-100% - 40px));
}

.fsp-pos-slide-right {
	right: 20px;
	transform: translateX(calc(100% + 40px));
}

.fsp-pos-slide-left.is-open,
.fsp-pos-slide-right.is-open {
	transform: translateX(0);
}

.fsp-pos-slide-left .fsp-modal,
.fsp-pos-slide-right .fsp-modal {
	max-height: 70vh;
	padding: 36px 24px 24px;
	border-radius: 6px;
}

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

/* Preview label (admins only, preview mode only) */
.fsp-preview-badge {
	position: fixed;
	top: calc(12px + env(safe-area-inset-top, 0px));
	left: 50%;
	z-index: 100000;
	max-width: calc(100% - 24px);
	padding: 8px 14px;
	transform: translateX(-50%);
	background: #1d2327;
	color: #fff;
	font: 500 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	border-radius: 999px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
	text-align: center;
	pointer-events: none;
}

body.admin-bar .fsp-preview-badge {
	top: calc(44px + env(safe-area-inset-top, 0px));
}
