/* Site Popup - Frontend (classic = current VGF look) */

.ap-popup-overlay {
	display: none;
	position: fixed;
	z-index: 99999;
	inset: 0;
	width: 100%;
	height: 100%;
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: rgba(0, 0, 0, 0.65);
	box-sizing: border-box;
	padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.ap-popup-overlay.is-visible {
	display: flex;
	align-items: center;
	justify-content: center;
	animation: ap-fade-in 0.5s;
}

.ap-popup-overlay.is-closing {
	pointer-events: none;
}

.ap-popup-dialog {
	margin: 0 auto;
	max-width: 500px;
	width: min(500px, 100%);
	max-height: min(92dvh, 920px);
	position: relative;
}

.ap-popup-content {
	text-align: center;
	background: #fff;
	border-radius: 12px;
	overflow: hidden;
	animation: ap-slide-down 0.4s;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
	display: flex;
	flex-direction: column;
	max-height: min(92dvh, 920px);
}

.ap-popup-close {
	position: absolute;
	right: 10px;
	top: 10px;
	z-index: 5;
	border: 2px solid rgba(255, 255, 255, 0.95);
	background: #6b0000;
	color: #ffffff !important;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-shadow:
		0 6px 16px rgba(107, 0, 0, 0.45),
		0 0 0 0 rgba(154, 0, 0, 0.55);
	animation: ap-close-pulse 2s ease-in-out infinite;
	transition: transform 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.ap-popup-close:hover,
.ap-popup-close:focus {
	background: #9a0000;
	transform: rotate(90deg) scale(1.08);
	animation: none;
	box-shadow: 0 8px 20px rgba(154, 0, 0, 0.5);
	outline: none;
}

.ap-popup-close:active {
	transform: rotate(90deg) scale(0.96);
}

@keyframes ap-close-pulse {
	0%,
	100% {
		box-shadow:
			0 6px 16px rgba(107, 0, 0, 0.45),
			0 0 0 0 rgba(154, 0, 0, 0.5);
	}
	50% {
		box-shadow:
			0 6px 16px rgba(107, 0, 0, 0.45),
			0 0 0 12px rgba(154, 0, 0, 0);
	}
}

.ap-popup-image-link {
	display: block;
	line-height: 0;
	width: 100%;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
}

.ap-popup-image {
	display: block;
	width: 100%;
	height: min(68dvh, 620px);
	max-height: min(68dvh, 620px);
	object-fit: cover;
	object-position: center center;
	background: transparent;
}

.ap-popup-cta {
	padding: 0.9rem 1rem 1.15rem;
	background: linear-gradient(180deg, #ffffff 0%, #f7f7f7 100%);
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	justify-content: center;
	align-items: stretch;
	gap: 0.7rem;
	border-top: 1px solid rgba(0, 0, 0, 0.06);
	flex-shrink: 0;
}

.ap-popup-button {
	--ap-btn-fg: #ffffff;
	--ap-btn-bg: #9A0000;
	--ap-btn-radius: 999px;
	position: relative;
	overflow: hidden;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	color: var(--ap-btn-fg);
	background: linear-gradient(145deg, color-mix(in srgb, var(--ap-btn-bg) 88%, #ffffff) 0%, var(--ap-btn-bg) 48%, color-mix(in srgb, var(--ap-btn-bg) 78%, #000000) 100%);
	margin: 0;
	padding: 0.85rem 1.5rem;
	border-radius: var(--ap-btn-radius);
	font-weight: 700;
	text-decoration: none;
	font-size: 1rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	min-width: min(100%, 260px);
	max-width: 100%;
	flex: 1 1 auto;
	text-align: center;
	box-sizing: border-box;
	white-space: nowrap;
	box-shadow:
		0 8px 18px color-mix(in srgb, var(--ap-btn-bg) 35%, transparent),
		0 2px 0 color-mix(in srgb, var(--ap-btn-bg) 55%, #000000),
		inset 0 1px 0 rgba(255, 255, 255, 0.28);
	transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.ap-popup-button::before {
	content: "";
	position: absolute;
	top: 0;
	left: -40%;
	width: 40%;
	height: 100%;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
	transform: skewX(-20deg);
	transition: left 0.45s ease;
	pointer-events: none;
}

.ap-popup-button-secondary {
	--ap-btn-bg: #1a365d;
}

.ap-popup-button:hover,
.ap-popup-button:focus {
	color: var(--ap-btn-fg);
	text-decoration: none;
	transform: translateY(-2px);
	filter: brightness(1.05);
	box-shadow:
		0 12px 24px color-mix(in srgb, var(--ap-btn-bg) 40%, transparent),
		0 3px 0 color-mix(in srgb, var(--ap-btn-bg) 55%, #000000),
		inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.ap-popup-button:hover::before,
.ap-popup-button:focus::before {
	left: 120%;
}

.ap-popup-button:active {
	transform: translateY(0);
	filter: brightness(0.98);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
	.ap-popup-button {
		background: var(--ap-btn-bg);
		box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
	}
}

.ap-popup-html {
	padding: 20px;
	font-size: 16px;
	color: #333;
	text-align: left;
	max-height: min(60dvh, 480px);
	overflow: auto;
}

.ap-popup-video {
	display: block;
	width: 100%;
	height: auto;
	max-height: min(60dvh, 480px);
	background: #000;
}

.ap-popup-youtube {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	max-height: min(55dvh, 420px);
	background: #000;
}

.ap-popup-youtube iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* Classic enter variants */
.ap-anim-in-slide-down { animation: ap-slide-down 0.4s forwards; }
.ap-anim-in-fade { animation: ap-fade-in 0.4s forwards; }
.ap-anim-in-zoom { animation: ap-zoom-in 0.4s forwards; }
.ap-anim-in-slide-up { animation: ap-slide-up 0.4s forwards; }
.ap-anim-in-bounce { animation: ap-bounce-in 0.55s forwards; }

.ap-anim-out-fade { animation: ap-fade-out 0.3s forwards; }
.ap-anim-out-zoom { animation: ap-zoom-out 0.3s forwards; }
.ap-anim-out-slide-down { animation: ap-slide-down-out 0.3s forwards; }
.ap-anim-out-slide-up { animation: ap-slide-up-out 0.3s forwards; }

@keyframes ap-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}
@keyframes ap-fade-out {
	from { opacity: 1; }
	to { opacity: 0; }
}
@keyframes ap-slide-down {
	from { transform: translateY(-50px); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}
@keyframes ap-slide-down-out {
	from { transform: translateY(0); opacity: 1; }
	to { transform: translateY(40px); opacity: 0; }
}
@keyframes ap-slide-up {
	from { transform: translateY(40px); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}
@keyframes ap-slide-up-out {
	from { transform: translateY(0); opacity: 1; }
	to { transform: translateY(-40px); opacity: 0; }
}
@keyframes ap-zoom-in {
	from { transform: scale(0.85); opacity: 0; }
	to { transform: scale(1); opacity: 1; }
}
@keyframes ap-zoom-out {
	from { transform: scale(1); opacity: 1; }
	to { transform: scale(0.85); opacity: 0; }
}
@keyframes ap-bounce-in {
	0% { transform: scale(0.3); opacity: 0; }
	50% { transform: scale(1.05); }
	70% { transform: scale(0.95); }
	100% { transform: scale(1); opacity: 1; }
}

/* Modern preset extras */
.ap-style-modern {
	background: rgba(15, 23, 42, 0.75);
	backdrop-filter: blur(6px);
}
.ap-style-modern .ap-popup-content {
	border-radius: 16px;
	box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
}

body.ap-popup-open {
	overflow: hidden;
	touch-action: none;
}

/* Tablets */
@media (max-width: 782px) {
	.ap-popup-dialog {
		width: min(520px, 100%);
		max-height: min(90dvh, 860px);
	}
	.ap-popup-image {
		height: min(64dvh, 560px);
		max-height: min(64dvh, 560px);
	}
}

/* Phones */
@media (max-width: 480px) {
	.ap-popup-overlay {
		padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
		align-items: flex-start;
		padding-top: max(16px, env(safe-area-inset-top));
	}

	.ap-popup-dialog {
		width: 100%;
		max-width: 100%;
		max-height: min(94dvh, 100%);
		margin-top: 4px;
	}

	.ap-popup-content {
		border-radius: 10px;
		max-height: min(94dvh, 100%);
	}

	.ap-popup-close {
		top: 8px;
		right: 8px;
		width: 38px;
		height: 38px;
		font-size: 20px;
	}

	.ap-popup-image {
		height: min(62dvh, 480px);
		max-height: min(62dvh, 480px);
		width: 100%;
		object-fit: cover;
	}

	.ap-popup-cta {
		padding: 0.75rem 0.75rem 0.95rem;
	}

	.ap-popup-button {
		min-width: 100%;
		width: 100%;
		padding: 0.8rem 1rem;
		font-size: 0.95rem;
		letter-spacing: 0.05em;
	}
}

/* Very small phones */
@media (max-width: 360px) {
	.ap-popup-image {
		height: min(58dvh, 400px);
		max-height: min(58dvh, 400px);
	}
	.ap-popup-button {
		font-size: 0.88rem;
		padding: 0.72rem 0.85rem;
	}
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
	.ap-popup-close {
		animation: none;
	}
	.ap-popup-overlay.is-visible,
	.ap-popup-content,
	.ap-popup-button::before {
		animation: none !important;
		transition: none !important;
	}
}
