/**
 * IFW Popup Manager - front-end styles.
 * Self-contained and theme friendly.
 */

/* -------------------------------------------------------------------------
 * Base
 * ---------------------------------------------------------------------- */
.ifw-popup,
.ifw-popup *,
.ifw-popup *::before,
.ifw-popup *::after,
.ifw-popup-trigger {
	box-sizing: border-box;
}

/* -------------------------------------------------------------------------
 * Trigger button
 * ---------------------------------------------------------------------- */
.ifw-popup-trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	margin: 0;
	padding: 12px 24px;
	border: 1px solid transparent;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.01em;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	cursor: pointer;
	box-shadow: none;
	transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease,
		color 0.18s ease, border-color 0.18s ease;
	-webkit-appearance: none;
	appearance: none;
	vertical-align: middle;
}

.ifw-popup-trigger:hover,
.ifw-popup-trigger:focus {
	text-decoration: none;
}

.ifw-popup-trigger:focus-visible {
	outline: 3px solid rgba(37, 99, 235, 0.4);
	outline-offset: 2px;
}

.ifw-popup-trigger--primary {
	background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
	color: #ffffff;
	box-shadow: 0 10px 24px -10px rgba(37, 99, 235, 0.75);
}

.ifw-popup-trigger--primary:hover {
	background: linear-gradient(135deg, #1d4ed8 0%, #4338ca 100%);
	color: #ffffff;
	transform: translateY(-1px);
	box-shadow: 0 16px 32px -10px rgba(37, 99, 235, 0.85);
}

.ifw-popup-trigger--secondary {
	background: #0f172a;
	color: #ffffff;
	box-shadow: 0 10px 24px -12px rgba(15, 23, 42, 0.7);
}

.ifw-popup-trigger--secondary:hover {
	background: #1e293b;
	color: #ffffff;
	transform: translateY(-1px);
}

.ifw-popup-trigger--outline {
	background: transparent;
	border-color: #2563eb;
	color: #2563eb;
}

.ifw-popup-trigger--outline:hover {
	background: rgba(37, 99, 235, 0.08);
	color: #1d4ed8;
	border-color: #1d4ed8;
}

.ifw-popup-trigger--light {
	background: #ffffff;
	border-color: #e2e8f0;
	color: #0f172a;
	box-shadow: 0 6px 18px -8px rgba(15, 23, 42, 0.35);
}

.ifw-popup-trigger--light:hover {
	background: #f8fafc;
	color: #0f172a;
	border-color: #cbd5e1;
	transform: translateY(-1px);
}

.ifw-popup-trigger--link {
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: #2563eb;
	text-decoration: underline;
	text-underline-offset: 2px;
	box-shadow: none;
}

.ifw-popup-trigger--link:hover {
	color: #1d4ed8;
}

.ifw-popup-trigger--sm {
	padding: 9px 16px;
	font-size: 13px;
}

.ifw-popup-trigger--lg {
	padding: 15px 30px;
	font-size: 17px;
}

.ifw-popup-trigger--link.ifw-popup-trigger--sm,
.ifw-popup-trigger--link.ifw-popup-trigger--md,
.ifw-popup-trigger--link.ifw-popup-trigger--lg {
	padding: 0;
	border: 0;
	border-radius: 0;
}

.ifw-popup-trigger--block {
	display: flex;
	width: 100%;
}

.ifw-popup-trigger.is-loading {
	opacity: 0.65;
	pointer-events: none;
}

.ifw-popup-missing {
	display: inline-block;
	padding: 6px 10px;
	border-radius: 6px;
	background: #fef2f2;
	color: #b91c1c;
	font-size: 12px;
}

.ifw-popup-error {
	display: inline-block;
	margin-top: 6px;
	color: #b91c1c;
	font-size: 12px;
	line-height: 1.4;
}

/* -------------------------------------------------------------------------
 * Lightbox
 * ---------------------------------------------------------------------- */
.ifw-popup {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: clamp(12px, 3vw, 28px);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.22s ease, visibility 0s linear 0.22s;
	-webkit-font-smoothing: antialiased;
}

.ifw-popup[hidden] {
	display: none !important;
}

.ifw-popup.is-open {
	opacity: 1;
	visibility: visible;
	transition: opacity 0.22s ease, visibility 0s;
}

.ifw-popup__overlay {
	position: absolute;
	inset: 0;
	background: var(--ifw-popup-overlay, rgba(15, 23, 42, 0.72));
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
}

.ifw-popup__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(var(--ifw-popup-width, 720px), 100%);
	max-height: calc(100vh - 48px);
	max-height: min(calc(100dvh - 48px), 1200px);
	overflow: hidden;
	border-radius: 20px;
	background: #ffffff;
	color: #334155;
	box-shadow: 0 32px 80px -20px rgba(2, 6, 23, 0.5), 0 0 0 1px rgba(15, 23, 42, 0.06);
	opacity: 0;
	transform: translateY(10px) scale(0.97);
	transition: opacity 0.25s ease, transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
	outline: none;
}

.ifw-popup.is-open .ifw-popup__dialog {
	opacity: 1;
	transform: translateY(0) scale(1);
}

.ifw-popup--fade .ifw-popup__dialog {
	transform: none;
}

.ifw-popup--zoom .ifw-popup__dialog {
	transform: scale(0.9);
}

.ifw-popup--slide-up .ifw-popup__dialog {
	transform: translateY(32px);
}

.ifw-popup--slide-down .ifw-popup__dialog {
	transform: translateY(-32px);
}

.ifw-popup__close {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(15, 23, 42, 0.06);
	color: #0f172a;
	line-height: 1;
	cursor: pointer;
	box-shadow: none;
	transition: background-color 0.2s ease, color 0.2s ease, transform 0.25s ease;
	-webkit-appearance: none;
	appearance: none;
}

.ifw-popup__close:hover {
	background: #0f172a;
	color: #ffffff;
	transform: rotate(90deg);
}

.ifw-popup__close:focus-visible {
	outline: 2px solid #2563eb;
	outline-offset: 2px;
}

.ifw-popup__close svg {
	display: block;
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.2;
	stroke-linecap: round;
}

.ifw-popup__content {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: #cbd5e1 transparent;
}

.ifw-popup__content::-webkit-scrollbar {
	width: 8px;
}

.ifw-popup__content::-webkit-scrollbar-thumb {
	border-radius: 999px;
	background: #cbd5e1;
}

.ifw-popup__body {
	padding: 30px 32px 34px;
	color: #334155;
	font-size: 16px;
	line-height: 1.65;
}

.ifw-popup--no-title .ifw-popup__body {
	padding-top: 58px;
}

.ifw-popup__title {
	margin: 0 0 18px;
	padding: 0 48px 0 0;
	color: #0f172a;
	font-size: clamp(1.25rem, 2vw, 1.6rem);
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -0.01em;
}

/* Screen-reader only heading used for accessible naming. */
.ifw-popup__sr {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* -------------------------------------------------------------------------
 * Content typography
 * ---------------------------------------------------------------------- */
.ifw-popup__body > *:first-child {
	margin-top: 0;
}

.ifw-popup__body > *:last-child {
	margin-bottom: 0;
}

.ifw-popup__body p {
	margin: 0 0 1em;
}

.ifw-popup__body h1,
.ifw-popup__body h2,
.ifw-popup__body h3,
.ifw-popup__body h4,
.ifw-popup__body h5,
.ifw-popup__body h6 {
	margin: 1.4em 0 0.55em;
	color: #0f172a;
	font-weight: 700;
	line-height: 1.3;
}

.ifw-popup__body h1 {
	font-size: 1.6em;
}

.ifw-popup__body h2 {
	font-size: 1.35em;
}

.ifw-popup__body h3 {
	font-size: 1.15em;
}

.ifw-popup__body a {
	color: #2563eb;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.ifw-popup__body a:hover {
	color: #1d4ed8;
}

.ifw-popup__body ul,
.ifw-popup__body ol {
	margin: 0 0 1em;
	padding-left: 1.35em;
}

.ifw-popup__body li {
	margin: 0.35em 0;
}

.ifw-popup__body ul li::marker {
	color: #2563eb;
}

.ifw-popup__body img {
	max-width: 100%;
	height: auto;
	border-radius: 12px;
	vertical-align: middle;
}

.ifw-popup__body iframe,
.ifw-popup__body video {
	max-width: 100%;
	width: 100%;
	border: 0;
	border-radius: 12px;
}

.ifw-popup__body blockquote {
	margin: 0 0 1em;
	padding: 0.8em 1em;
	border-left: 4px solid #2563eb;
	border-radius: 0 10px 10px 0;
	background: #f1f5f9;
	color: #334155;
}

.ifw-popup__body blockquote p:last-child {
	margin-bottom: 0;
}

.ifw-popup__body table {
	width: 100%;
	margin: 0 0 1em;
	border-collapse: collapse;
	font-size: 0.95em;
}

.ifw-popup__body th,
.ifw-popup__body td {
	padding: 0.55em 0.7em;
	border: 1px solid #e2e8f0;
	text-align: left;
}

.ifw-popup__body th {
	background: #f8fafc;
	color: #0f172a;
	font-weight: 600;
}

.ifw-popup__body hr {
	margin: 1.5em 0;
	border: 0;
	border-top: 1px solid #e2e8f0;
}

.ifw-popup__body code {
	padding: 0.15em 0.4em;
	border-radius: 6px;
	background: #f1f5f9;
	font-size: 0.9em;
}

.ifw-popup__body pre {
	margin: 0 0 1em;
	padding: 1em;
	overflow: auto;
	border-radius: 12px;
	background: #0f172a;
	color: #e2e8f0;
}

.ifw-popup__body pre code {
	padding: 0;
	background: none;
	color: inherit;
}

/* -------------------------------------------------------------------------
 * Body scroll lock
 * ---------------------------------------------------------------------- */
body.ifw-popup-is-open {
	overflow: hidden !important;
	padding-right: var(--ifw-popup-scrollbar-width, 0px);
	overscroll-behavior: none;
}

/* -------------------------------------------------------------------------
 * Responsive
 * ---------------------------------------------------------------------- */
@media (max-width: 600px) {
	.ifw-popup {
		padding: 10px;
	}

	.ifw-popup__dialog {
		max-height: calc(100vh - 20px);
		max-height: calc(100dvh - 20px);
		border-radius: 16px;
	}

	.ifw-popup__body {
		padding: 24px 20px 28px;
		font-size: 15.5px;
	}

	.ifw-popup--no-title .ifw-popup__body {
		padding-top: 56px;
	}

	.ifw-popup__close {
		top: 10px;
		right: 10px;
		width: 38px;
		height: 38px;
	}

	.ifw-popup__title {
		padding-right: 42px;
	}
}

/* -------------------------------------------------------------------------
 * Accessibility / print
 * ---------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.ifw-popup,
	.ifw-popup__dialog,
	.ifw-popup__overlay,
	.ifw-popup__close,
	.ifw-popup-trigger {
		transition: none !important;
		animation: none !important;
	}

	.ifw-popup__dialog {
		transform: none !important;
	}
}

@media print {
	.ifw-popup {
		display: none !important;
	}
}
