/* =================================================================
   Simple Popups — responsive styles
   Breakpoints:
     - phone   : ≤ 480px  (fullscreen sheet from bottom)
     - tablet  : 481–768  (bottom sheet, wider)
     - desktop : 769–1200 (centered dialog, 600px)
     - large   : > 1200px (centered dialog, up to 720px)
================================================================= */

/* -------------------------------------------------------------------
   Trigger button
------------------------------------------------------------------- */
.sp-trigger {
	display: inline-block;
	max-width: 100%;
	padding: 8px 20px;
	background: var(--sp-btn-bg, #A2123D) !important;
	color: var(--sp-btn-color, #ffffff) !important;
	font-family: 'satoshi-medium', 'Satoshi Medium', 'Satoshi', sans-serif;
	font-size: 20px;
	font-weight: 500;
	line-height: 1.3;
	border: 0 !important;
	border-radius: 0 !important;
	cursor: pointer;
	text-decoration: none;
	text-align: left;
	white-space: normal;             /* long labels wrap on mobile */
	word-break: break-word;
	transition: opacity 0.15s ease, transform 0.15s ease;
	-webkit-tap-highlight-color: transparent;
}
.sp-trigger:hover { opacity: 0.9; }
.sp-trigger:active { transform: translateY(1px); }
.sp-trigger:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

/* Small phones: full-width button, keep 16px minimum to prevent iOS zoom */
@media (max-width: 480px) {
	.sp-trigger {
		display: block;
		width: 100%;
		padding: 10px 20px;
		font-size: 18px;            /* min 16px prevents iOS zoom on tap */
	}
}

/* -------------------------------------------------------------------
   Modal wrapper (positioned to viewport)
------------------------------------------------------------------- */
.sp-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 999999;
	align-items: center;
	justify-content: center;
	padding: 20px;
	box-sizing: border-box;
	/* iOS safe-area support (notch, home bar) */
	padding-top: max(20px, env(safe-area-inset-top));
	padding-bottom: max(20px, env(safe-area-inset-bottom));
	padding-left: max(20px, env(safe-area-inset-left));
	padding-right: max(20px, env(safe-area-inset-right));
}
.sp-modal.sp-open { display: flex; }

.sp-modal-bg {
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0, 0, 0, 0.6);
	animation: sp-fade 0.2s ease;
}

/* -------------------------------------------------------------------
   Dialog box — fluid across all sizes
------------------------------------------------------------------- */
.sp-modal-box {
	position: relative;
	width: 100%;
	max-width: 600px;
	max-height: calc(100vh - 40px);  /* fallback */
	max-height: calc(100dvh - 40px); /* modern: dynamic viewport (mobile browsers) */
	background: #fff;
	border-radius: 10px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 30px;
	box-sizing: border-box;
	animation: sp-pop 0.25s ease;
}

/* Larger screens — slightly bigger modal */
@media (min-width: 1201px) {
	.sp-modal-box { max-width: 720px; }
}

/* Tablet — still centered, roomier */
@media (max-width: 1024px) {
	.sp-modal-box {
		max-width: 92vw;
		padding: 28px;
	}
}

/* Phones — top-aligned full-width modal that scrolls internally.
 * Avoids bottom-sheet pattern because mobile browsers' dynamic URL
 * bars + variable viewport heights make the bottom of a sheet get
 * cut off below the visible area. */
@media (max-width: 600px) {
	.sp-modal {
		padding: 10px;
		align-items: flex-start;     /* anchor to top */
		overflow-y: auto;            /* outer scroll if needed */
		-webkit-overflow-scrolling: touch;
	}
	.sp-modal-box {
		max-width: 100%;
		/* Use small-vh units when supported (excludes URL bar),
		 * fallback to vh for older browsers. */
		max-height: calc(100vh - 20px);
		max-height: calc(100svh - 20px);
		margin-top: 10px;
		margin-bottom: 10px;
		border-radius: 10px;
		padding: 24px 18px;
		padding-top: max(24px, env(safe-area-inset-top));
		padding-bottom: max(24px, env(safe-area-inset-bottom));
		animation: sp-pop 0.25s ease;  /* simple fade-in, no slide */
	}
}

/* Short landscape phones — same approach */
@media (max-height: 500px) and (orientation: landscape) {
	.sp-modal {
		padding: 10px;
		align-items: flex-start;
		overflow-y: auto;
	}
	.sp-modal-box {
		max-height: calc(100vh - 20px);
		max-height: calc(100svh - 20px);
		margin: 10px auto;
		border-radius: 10px;
		padding: 18px;
	}
}

/* -------------------------------------------------------------------
   Close button
------------------------------------------------------------------- */
.sp-close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 40px;
	height: 40px;
	padding: 0;
	font-size: 28px;
	line-height: 1;
	background: transparent;
	border: 0;
	color: #666;
	cursor: pointer;
	border-radius: 6px;
	-webkit-tap-highlight-color: transparent;
}
.sp-close:hover { background: #f0f0f0; color: #000; }
.sp-close:focus-visible {
	outline: 2px solid #2563eb;
	outline-offset: 2px;
}

@media (max-width: 480px) {
	/* Bigger hit area on touch screens */
	.sp-close {
		width: 44px;
		height: 44px;
		font-size: 32px;
	}
}

/* -------------------------------------------------------------------
   Content area — responsive embeds
------------------------------------------------------------------- */
.sp-modal-content {
	/* Keep space for the close button */
	padding-top: 8px;
}

/* All embed iframes fluid */
.sp-modal-content iframe,
.sp-modal-content video,
.sp-modal-content embed,
.sp-modal-content object {
	max-width: 100%;
	height: auto;
}

/* Video embeds: enforce 16:9 */
.sp-modal-content iframe[src*="youtube"],
.sp-modal-content iframe[src*="youtu.be"],
.sp-modal-content iframe[src*="vimeo"],
.sp-modal-content iframe[src*="wistia"],
.sp-modal-content iframe[src*="loom"] {
	width: 100%;
	aspect-ratio: 16 / 9;
	height: auto;
	min-height: 200px;
}

/* HubSpot form containers — they sometimes set fixed widths inline */
.sp-modal-content .hbspt-form,
.sp-modal-content .hs-form,
.sp-modal-content form {
	max-width: 100% !important;
	width: 100% !important;
}
.sp-modal-content input,
.sp-modal-content select,
.sp-modal-content textarea {
	max-width: 100%;
	box-sizing: border-box;
}

/* Images — always fluid */
.sp-modal-content img {
	max-width: 100%;
	height: auto;
}

/* Tables in popup content should scroll horizontally, not break layout */
.sp-modal-content table {
	display: block;
	overflow-x: auto;
	max-width: 100%;
}

/* Long URLs / code blocks wrap instead of overflowing */
.sp-modal-content pre,
.sp-modal-content code {
	white-space: pre-wrap;
	word-break: break-word;
}

/* First/last element spacing cleanup */
.sp-modal-content > *:first-child { margin-top: 0; }
.sp-modal-content > *:last-child  { margin-bottom: 0; }

/* -------------------------------------------------------------------
   Body lock when modal open
------------------------------------------------------------------- */
body.sp-no-scroll {
	overflow: hidden;
	/* Prevent iOS scroll-bounce under the modal */
	position: relative;
}

/* -------------------------------------------------------------------
   Animations
------------------------------------------------------------------- */
@keyframes sp-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}
@keyframes sp-pop {
	from { opacity: 0; transform: translateY(15px) scale(0.97); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes sp-slide-up {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
	.sp-modal-bg,
	.sp-modal-box,
	.sp-trigger { animation: none !important; transition: none !important; }
}
