/**
 * Hyper Website Builder — Popup Engine
 * Frontend styles for popup display, animations, and positioning.
 *
 * @package VisualForge\PopupEngine
 * @since 1.0.0
 */

/* ==========================================================================
   Base Popup Styles
   ========================================================================== */

.vf-popup {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 999999;
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
}

.vf-popup[aria-hidden="false"] {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* ==========================================================================
   Backdrop
   ========================================================================== */

.vf-popup__backdrop {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.6);
	z-index: 1;
}

/* ==========================================================================
   Container
   ========================================================================== */

.vf-popup__container {
	position: absolute;
	z-index: 2;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	max-height: 90vh;
	overflow-y: auto;
	outline: none;
}

/* ==========================================================================
   Position Variants
   ========================================================================== */

/* Center (Modal) */
.vf-popup--position-center .vf-popup__container {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 90%;
	max-width: 600px;
}

/* Top */
.vf-popup--position-top .vf-popup__container {
	top: 0;
	left: 0;
	width: 100%;
	border-radius: 0;
	max-width: 100%;
}

/* Bottom */
.vf-popup--position-bottom .vf-popup__container {
	bottom: 0;
	left: 0;
	width: 100%;
	border-radius: 0;
	max-width: 100%;
}

/* Bottom Right */
.vf-popup--position-bottom-right .vf-popup__container {
	bottom: 20px;
	right: 20px;
	width: 360px;
	max-width: calc(100% - 40px);
}

/* Bottom Left */
.vf-popup--position-bottom-left .vf-popup__container {
	bottom: 20px;
	left: 20px;
	width: 360px;
	max-width: calc(100% - 40px);
}

/* Top Right */
.vf-popup--position-top-right .vf-popup__container {
	top: 20px;
	right: 20px;
	width: 360px;
	max-width: calc(100% - 40px);
}

/* Top Left */
.vf-popup--position-top-left .vf-popup__container {
	top: 20px;
	left: 20px;
	width: 360px;
	max-width: calc(100% - 40px);
}

/* ==========================================================================
   Type Variants
   ========================================================================== */

/* Fullscreen */
.vf-popup--fullscreen .vf-popup__container {
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	max-height: 100vh;
	border-radius: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Notification Bar */
.vf-popup--notification_bar {
	height: auto;
	pointer-events: none;
}

.vf-popup--notification_bar .vf-popup__container {
	position: fixed;
	width: 100%;
	border-radius: 0;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
	padding: 12px 20px;
}

.vf-popup--notification_bar.vf-popup--position-top .vf-popup__container {
	top: 0;
	left: 0;
}

.vf-popup--notification_bar.vf-popup--position-bottom .vf-popup__container {
	bottom: 0;
	left: 0;
	top: auto;
}

/* Slide-in */
.vf-popup--slide_in {
	height: auto;
	width: auto;
	pointer-events: none;
}

.vf-popup--slide_in .vf-popup__container {
	pointer-events: auto;
}

/* Fly-in */
.vf-popup--fly_in {
	height: auto;
	width: auto;
	pointer-events: none;
}

.vf-popup--fly_in .vf-popup__container {
	pointer-events: auto;
}

/* ==========================================================================
   Close Button
   ========================================================================== */

.vf-popup__close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	font-size: 24px;
	line-height: 1;
	color: #333;
	transition: background-color 0.2s ease, color 0.2s ease;
	z-index: 10;
	padding: 0;
}

.vf-popup__close:hover,
.vf-popup__close:focus {
	background-color: rgba(0, 0, 0, 0.1);
	color: #000;
	outline: 2px solid #0073aa;
	outline-offset: 2px;
}

/* ==========================================================================
   Content
   ========================================================================== */

.vf-popup__content {
	padding: 24px;
}

.vf-popup--notification_bar .vf-popup__content {
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Screen reader text (accessible title) */
.vf-popup__title.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ==========================================================================
   Animation Keyframes
   ========================================================================== */

@keyframes vfPopupFadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@keyframes vfPopupFadeOut {
	from {
		opacity: 1;
	}
	to {
		opacity: 0;
	}
}

@keyframes vfPopupSlideInUp {
	from {
		transform: translate(-50%, calc(-50% + 30px));
		opacity: 0;
	}
	to {
		transform: translate(-50%, -50%);
		opacity: 1;
	}
}

@keyframes vfPopupSlideInRight {
	from {
		transform: translateX(100%);
		opacity: 0;
	}
	to {
		transform: translateX(0);
		opacity: 1;
	}
}

@keyframes vfPopupSlideInLeft {
	from {
		transform: translateX(-100%);
		opacity: 0;
	}
	to {
		transform: translateX(0);
		opacity: 1;
	}
}

@keyframes vfPopupSlideInDown {
	from {
		transform: translateY(-100%);
		opacity: 0;
	}
	to {
		transform: translateY(0);
		opacity: 1;
	}
}

@keyframes vfPopupZoomIn {
	from {
		transform: translate(-50%, -50%) scale(0.7);
		opacity: 0;
	}
	to {
		transform: translate(-50%, -50%) scale(1);
		opacity: 1;
	}
}

@keyframes vfPopupBounceIn {
	0% {
		transform: translate(-50%, -50%) scale(0.3);
		opacity: 0;
	}
	50% {
		transform: translate(-50%, -50%) scale(1.05);
	}
	70% {
		transform: translate(-50%, -50%) scale(0.95);
	}
	100% {
		transform: translate(-50%, -50%) scale(1);
		opacity: 1;
	}
}

/* ==========================================================================
   Animation Classes (applied via JS)
   ========================================================================== */

.vf-popup--animating-in .vf-popup__container {
	animation-duration: 0.3s;
	animation-fill-mode: forwards;
	animation-timing-function: ease-out;
}

.vf-popup--animation-fade.vf-popup--animating-in .vf-popup__container {
	animation-name: vfPopupFadeIn;
}

.vf-popup--animation-slide.vf-popup--position-center.vf-popup--animating-in .vf-popup__container {
	animation-name: vfPopupSlideInUp;
}

.vf-popup--animation-slide.vf-popup--position-bottom-right.vf-popup--animating-in .vf-popup__container,
.vf-popup--animation-slide.vf-popup--position-top-right.vf-popup--animating-in .vf-popup__container {
	animation-name: vfPopupSlideInRight;
}

.vf-popup--animation-slide.vf-popup--position-bottom-left.vf-popup--animating-in .vf-popup__container,
.vf-popup--animation-slide.vf-popup--position-top-left.vf-popup--animating-in .vf-popup__container {
	animation-name: vfPopupSlideInLeft;
}

.vf-popup--animation-slide.vf-popup--position-top.vf-popup--animating-in .vf-popup__container {
	animation-name: vfPopupSlideInDown;
}

.vf-popup--animation-zoom.vf-popup--animating-in .vf-popup__container {
	animation-name: vfPopupZoomIn;
}

.vf-popup--animation-bounce.vf-popup--animating-in .vf-popup__container {
	animation-name: vfPopupBounceIn;
	animation-duration: 0.5s;
}

/* ==========================================================================
   Focus Trap Styles
   ========================================================================== */

.vf-popup:focus-within .vf-popup__container {
	outline: none;
}

.vf-popup__focus-trap-start,
.vf-popup__focus-trap-end {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
	.vf-popup--position-center .vf-popup__container {
		width: 95%;
		max-width: none;
	}

	.vf-popup--position-bottom-right .vf-popup__container,
	.vf-popup--position-bottom-left .vf-popup__container,
	.vf-popup--position-top-right .vf-popup__container,
	.vf-popup--position-top-left .vf-popup__container {
		width: calc(100% - 20px);
		left: 10px;
		right: 10px;
		max-width: none;
	}

	.vf-popup__content {
		padding: 16px;
	}
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.vf-popup--animating-in .vf-popup__container {
		animation-duration: 0.01ms;
	}

	.vf-popup {
		transition-duration: 0.01ms;
	}
}
