/**
 * Popup Add-on — Frontend Styles
 *
 * Base layout for every popup type plus entrance/exit animations. Per-popup
 * design values (size, colors, overlay, close button) are emitted server-side
 * as CSS scoped to each popup's container ID.
 */

/* ------------------------------------------------------------------ */

/* Container / overlay                                                 */

/* ------------------------------------------------------------------ */

.afb-popup {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	pointer-events: none;
}

.afb-popup.is-open {
	display: block;
}

.afb-popup__overlay {
	position: fixed;
	inset: 0;
	background-color: rgb(15 23 42 / 60%);
	pointer-events: auto;
	display: none;
}

.afb-popup--has-overlay .afb-popup__overlay {
	display: block;
}

.afb-popup-scroll-lock,
.afb-popup-scroll-lock body {
	overflow: hidden;
}

/* ------------------------------------------------------------------ */

/* Dialog                                                              */

/* ------------------------------------------------------------------ */

.afb-popup__dialog {
	position: fixed;
	background: #fff;
	color: inherit;
	box-shadow: 0 20px 60px rgb(15 23 42 / 30%);
	pointer-events: auto;
	display: flex;
	flex-direction: column;
	max-width: calc(100vw - 32px);
	outline: none;
	box-sizing: border-box;
}

.afb-popup__content {
	overflow-y: auto;
	flex: 1 1 auto;
	min-height: 0;
}

.afb-popup--align-center .afb-popup__content {
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.afb-popup--align-bottom .afb-popup__content {
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
}

.afb-popup__heading {
	margin: 0 0 8px;
	font-size: 1.4em;
	line-height: 1.3;
}

.afb-popup__message {
	margin: 0 0 16px;
}

/* ------------------------------------------------------------------ */

/* Type: modal (default) + fullscreen + welcome mat                    */

/* ------------------------------------------------------------------ */

.afb-popup--modal .afb-popup__dialog {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
}

.afb-popup--fullscreen .afb-popup__dialog,
.afb-popup--welcome_mat .afb-popup__dialog {
	inset: 0;
	width: 100%;
	max-width: 100%;
	height: 100%;
	max-height: 100%;
	margin: 0 !important;
	border-radius: 0;
}

.afb-popup--welcome_mat .afb-popup__dialog {
	bottom: auto;
	height: 100vh;
}

/* ------------------------------------------------------------------ */

/* Type: slide-in                                                      */

/* ------------------------------------------------------------------ */

.afb-popup--slide_in .afb-popup__dialog {
	border-radius: 12px;
}

.afb-popup--slide_in.afb-popup--pos-bottom_right .afb-popup__dialog,
.afb-popup--slide_in.afb-popup--pos-center .afb-popup__dialog {
	right: 0;
	bottom: 0;
}

.afb-popup--slide_in.afb-popup--pos-bottom_left .afb-popup__dialog {
	left: 0;
	bottom: 0;
}

.afb-popup--slide_in.afb-popup--pos-top_right .afb-popup__dialog {
	right: 0;
	top: 0;
}

.afb-popup--slide_in.afb-popup--pos-top_left .afb-popup__dialog {
	left: 0;
	top: 0;
}

.afb-popup--slide_in.afb-popup--pos-top .afb-popup__dialog {
	top: 0;
	left: 50%;
	transform: translateX(-50%);
}

.afb-popup--slide_in.afb-popup--pos-bottom .afb-popup__dialog {
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
}

/* ------------------------------------------------------------------ */

/* Type: sticky bar                                                    */

/* ------------------------------------------------------------------ */

.afb-popup--bar .afb-popup__dialog {
	left: 0;
	right: 0;
	width: 100%;
	max-width: 100%;
	margin: 0 !important;
	border-radius: 0;
}

.afb-popup--bar.afb-popup--pos-top .afb-popup__dialog,
.afb-popup--bar.afb-popup--pos-top_left .afb-popup__dialog,
.afb-popup--bar.afb-popup--pos-top_right .afb-popup__dialog,
.afb-popup--bar.afb-popup--pos-center .afb-popup__dialog {
	top: 0;
	bottom: auto;
}

.afb-popup--bar.afb-popup--pos-bottom .afb-popup__dialog,
.afb-popup--bar.afb-popup--pos-bottom_left .afb-popup__dialog,
.afb-popup--bar.afb-popup--pos-bottom_right .afb-popup__dialog {
	bottom: 0;
	top: auto;
}

/* ------------------------------------------------------------------ */

/* Type: launcher                                                      */

/* ------------------------------------------------------------------ */

.afb-popup--launcher .afb-popup__dialog {
	right: 16px;
	bottom: 16px;
	border-radius: 12px;
}

.afb-popup-launcher {
	position: fixed;
	z-index: 99998;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px;
	border: 0;
	border-radius: 999px;
	background: #1d4ed8;
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 8px 24px rgb(15 23 42 / 25%);
}

.afb-popup-launcher:hover {
	background: #1e40af;
}

.afb-popup-launcher--pos-bottom_right,
.afb-popup-launcher--pos-center {
	right: 20px;
	bottom: 20px;
}

.afb-popup-launcher--pos-bottom_left {
	left: 20px;
	bottom: 20px;
}

.afb-popup-launcher--pos-top_right {
	right: 20px;
	top: 20px;
}

.afb-popup-launcher--pos-top_left {
	left: 20px;
	top: 20px;
}

/* ------------------------------------------------------------------ */

/* Close button                                                        */

/* ------------------------------------------------------------------ */

.afb-popup__close {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgb(15 23 42 / 6%);
	color: #334155;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.afb-popup__close:hover {
	background: rgb(15 23 42 / 14%);
}

.afb-popup__close.is-delayed {
	visibility: hidden;
}

.afb-popup__close-label {
	font-size: 12px;
	font-weight: 600;
}

.afb-popup__close--labeled {
	width: auto;
	padding: 0 10px;
	border-radius: 999px;
}

/* ------------------------------------------------------------------ */

/* Two-step gate                                                       */

/* ------------------------------------------------------------------ */

.afb-popup__step-gate {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 8px 0 4px;
}

.afb-popup__step-gate.is-hidden {
	display: none;
}

.afb-popup__gate-yes {
	padding: 12px 20px;
	border: 0;
	border-radius: 8px;
	background: #1d4ed8;
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
}

.afb-popup__gate-yes:hover {
	background: #1e40af;
}

.afb-popup__gate-no {
	padding: 8px;
	border: 0;
	background: none;
	color: #64748b;
	font-size: 13px;
	cursor: pointer;
	text-decoration: underline;
}

.afb-popup__body--gated {
	display: none;
}

.afb-popup__body--gated.is-revealed {
	display: block;
}

/* ------------------------------------------------------------------ */

/* Entrance animations                                                 */

/* ------------------------------------------------------------------ */

@keyframes afb-popup-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes afb-popup-slide-up {
	from { opacity: 0; transform: translate(-50%, calc(-50% + 60px)); }
	to { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes afb-popup-slide-down {
	from { opacity: 0; transform: translate(-50%, calc(-50% - 60px)); }
	to { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes afb-popup-slide-left {
	from { opacity: 0; transform: translate(calc(-50% + 80px), -50%); }
	to { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes afb-popup-slide-right {
	from { opacity: 0; transform: translate(calc(-50% - 80px), -50%); }
	to { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes afb-popup-slide-up-short {
	from { opacity: 0; transform: translate(-50%, calc(-50% + 20px)); }
	to { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes afb-popup-slide-down-short {
	from { opacity: 0; transform: translate(-50%, calc(-50% - 20px)); }
	to { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes afb-popup-zoom {
	from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
	to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes afb-popup-flip-x {
	from { opacity: 0; transform: translate(-50%, -50%) rotateX(60deg); }
	to { opacity: 1; transform: translate(-50%, -50%) rotateX(0); }
}

@keyframes afb-popup-flip-y {
	from { opacity: 0; transform: translate(-50%, -50%) rotateY(60deg); }
	to { opacity: 1; transform: translate(-50%, -50%) rotateY(0); }
}

@keyframes afb-popup-snap {
	0% { opacity: 0; transform: translate(-50%, -50%) scale(1.15); }
	60% { opacity: 1; transform: translate(-50%, -50%) scale(0.97); }
	100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Non-centered types animate with simpler, transform-safe variants. */
@keyframes afb-popup-fade-simple {
	from { opacity: 0; }
	to { opacity: 1; }
}

.afb-popup--modal .afb-popup__dialog[data-afb-anim-in='fade'] { animation: afb-popup-fade 0.25s ease both; }
.afb-popup--modal .afb-popup__dialog[data-afb-anim-in='slide_up'] { animation: afb-popup-slide-up 0.35s ease both; }
.afb-popup--modal .afb-popup__dialog[data-afb-anim-in='slide_down'] { animation: afb-popup-slide-down 0.35s ease both; }
.afb-popup--modal .afb-popup__dialog[data-afb-anim-in='slide_left'] { animation: afb-popup-slide-left 0.35s ease both; }
.afb-popup--modal .afb-popup__dialog[data-afb-anim-in='slide_right'] { animation: afb-popup-slide-right 0.35s ease both; }
.afb-popup--modal .afb-popup__dialog[data-afb-anim-in='slide_up_short'] { animation: afb-popup-slide-up-short 0.25s ease both; }
.afb-popup--modal .afb-popup__dialog[data-afb-anim-in='slide_down_short'] { animation: afb-popup-slide-down-short 0.25s ease both; }
.afb-popup--modal .afb-popup__dialog[data-afb-anim-in='zoom'] { animation: afb-popup-zoom 0.3s ease both; }
.afb-popup--modal .afb-popup__dialog[data-afb-anim-in='flip_x'] { animation: afb-popup-flip-x 0.4s ease both; }
.afb-popup--modal .afb-popup__dialog[data-afb-anim-in='flip_y'] { animation: afb-popup-flip-y 0.4s ease both; }
.afb-popup--modal .afb-popup__dialog[data-afb-anim-in='snap'] { animation: afb-popup-snap 0.35s ease both; }

/* Every other popup type: all entrance animations resolve to a safe fade
   (their position relies on their own transform/inset rules). */
.afb-popup:not(.afb-popup--modal) .afb-popup__dialog[data-afb-anim-in] {
	animation: afb-popup-fade-simple 0.3s ease both;
}

/* Exit animations: reverse the fade for everything (position-safe). */
@keyframes afb-popup-fade-out {
	from { opacity: 1; }
	to { opacity: 0; }
}

.afb-popup .afb-popup__dialog[data-afb-anim-out] {
	animation: afb-popup-fade-out 0.2s ease both;
}

/* ------------------------------------------------------------------ */

/* Reduced motion                                                      */

/* ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.afb-popup .afb-popup__dialog[data-afb-anim-in],
	.afb-popup .afb-popup__dialog[data-afb-anim-out] {
		animation: none;
	}
}

/* ------------------------------------------------------------------ */

/* Screen reader helper (in case the theme doesn't ship one)           */

/* ------------------------------------------------------------------ */

.afb-popup-live,
.afb-popup .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ------------------------------------------------------------------ */

/* Small screens                                                       */

/* ------------------------------------------------------------------ */

@media (width <= 600px) {
	.afb-popup--modal .afb-popup__dialog,
	.afb-popup--slide_in .afb-popup__dialog {
		width: calc(100vw - 24px) !important;
	}
}
