/* Simple Popup Kit — frontend styles
 * Colours and sizing come from CSS custom properties set inline on #spk-popup.
 */

.spk-overlay {
	position: fixed;
	inset: 0;
	display: none;
	z-index: var(--spk-z, 99999);
	box-sizing: border-box;
	padding: 20px;
	background: var(--spk-overlay, rgba(0, 0, 0, 0.6));
	-webkit-overflow-scrolling: touch;
}

.spk-overlay.spk-visible {
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Position variants */
.spk-overlay.spk-pos-top.spk-visible          { align-items: flex-start; }
.spk-overlay.spk-pos-bottom.spk-visible       { align-items: flex-end; }
.spk-overlay.spk-pos-bottom-right.spk-visible { align-items: flex-end; justify-content: flex-end; }
.spk-overlay.spk-pos-bottom-left.spk-visible  { align-items: flex-end; justify-content: flex-start; }

.spk-box {
	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: var(--spk-max-width, 600px);
	max-height: calc(100vh - 40px);
	overflow: auto;
	background-color: var(--spk-bg, #fff);
	background-size: cover;
	background-position: center;
	color: var(--spk-text, #1a1a1a);
	border-radius: var(--spk-radius, 10px);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

/* Corner positions shrink the box a little so it reads as a toast */
.spk-pos-bottom-right .spk-box,
.spk-pos-bottom-left .spk-box {
	max-width: min(var(--spk-max-width, 600px), 420px);
}

/* Close button — 40px tap target */
.spk-close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 40px;
	height: 40px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.5);
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 3;
}

.spk-close:hover { background: rgba(0, 0, 0, 0.75); }
.spk-close:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* Image mode */
.spk-image-wrap {
	display: block;
	line-height: 0;
}

.spk-image-wrap img {
	width: 100%;
	height: auto;
	display: block;
	border-radius: inherit;
}

/* Content mode */
.spk-content.spk-has-bg { position: relative; }

.spk-content.spk-has-bg::before {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	border-radius: inherit;
}

.spk-content-inner {
	position: relative;
	z-index: 1;
	padding: clamp(24px, 5vw, 48px);
}

.spk-title {
	margin: 0 0 0.5em;
	font-size: clamp(1.5rem, 4vw, 2rem);
	line-height: 1.2;
	color: inherit;
}

.spk-message {
	font-size: 1rem;
	line-height: 1.6;
}

.spk-message :first-child { margin-top: 0; }
.spk-message :last-child  { margin-bottom: 0; }

.spk-cta {
	display: inline-block;
	margin-top: 1.25em;
	padding: 0.75em 1.6em;
	border-radius: 6px;
	background: var(--spk-cta-bg, #1a1a1a);
	color: var(--spk-cta-text, #fff);
	text-decoration: none;
	font-weight: 600;
	line-height: 1.2;
}

.spk-cta:hover  { opacity: 0.9; }
.spk-cta:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }

/* Lock background scroll while open */
body.spk-no-scroll { overflow: hidden; }

/* Animations (applied to the box when the overlay becomes visible) */
.spk-anim-fade.spk-visible .spk-box     { animation: spk-fade 0.3s ease both; }
.spk-anim-zoom.spk-visible .spk-box     { animation: spk-zoom 0.3s ease both; }
.spk-anim-slide-up.spk-visible .spk-box { animation: spk-slide 0.35s ease both; }

@keyframes spk-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes spk-zoom {
	from { opacity: 0; transform: scale(0.92); }
	to   { opacity: 1; transform: none; }
}

@keyframes spk-slide {
	from { opacity: 0; transform: translateY(30px); }
	to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.spk-box { animation: none !important; }
}

/* Small screens */
@media (max-width: 480px) {
	.spk-overlay { padding: 12px; }
	.spk-box { max-height: calc(100vh - 24px); }
	.spk-pos-bottom-right .spk-box,
	.spk-pos-bottom-left .spk-box { max-width: 100%; }
}
