/*
 * Operation Smile Pop-ups (OSDS os/modal)
 * Figma: Operation Smile Intl. UI Kit, component set 23324:19703
 *
 * Overlay (dialog backdrop) → Container → variant content.
 * One markup for both breakpoints; the 1024px min-width query switches to the desktop treatment.
 *
 * Design tokens exposed as custom properties so the theme can override them.
 */

:root {
	--os-overlay-scrim: rgba(0, 0, 0, 0.4);
	--os-radius-2xl: 24px;
	--os-spacing-xxs: 2px;
	--os-spacing-sm: 6px;
	--os-spacing-md: 8px;
	--os-spacing-xl: 16px;
	--os-spacing-3xl: 24px;
	--os-surface-default: #fff;
	--os-surface-alt: #f5f5f5;
	--os-gray-50: #f5f5f5;
	--os-blue-900: #001124;
	--os-text-heading: #0051a7;
	--os-text-body-secondary: #777;
	--os-text-checkbox-label: #111;
	--os-border-checkbox-unchecked: #ccc;
	--os-button-primary-bg: #007ea8;
	--os-button-primary-bg-hover: #006b8e;
	--os-button-primary-text: #fff;
	--os-button-destructive-bg: #ee2c3c;
	--os-button-destructive-bg-hover: #e71324;
	--os-button-destructive-text: #fff;
	--os-button-secondary-bg: #fff;
	--os-button-secondary-text: #333;
	--os-shadow-light: rgba(0, 0, 0, 0.12);
	--os-focus-ring: #0095c7;
	--os-font-body: 'Inter', sans-serif;
	--os-popup-gutter: 16px;
}

/* ---------------------------------------------------------------------------
 * Overlay
 * ------------------------------------------------------------------------- */

.os-popup {
	--os-popup-width: 343px;

	box-sizing: border-box;
	width: min(var(--os-popup-width), 100vw - var(--os-popup-gutter) * 2);
	max-width: none;
	max-height: none;
	margin: auto;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--os-text-body-secondary);
	font-family: var(--os-font-body);
	overflow: visible;
}

.os-popup::backdrop {
	background: var(--os-overlay-scrim);
}

.os-popup[open] {
	animation: os-popup-in 0.25s ease-out;
}

.os-popup[open]::backdrop {
	animation: os-popup-fade 0.25s ease-out;
}

@keyframes os-popup-in {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.98);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes os-popup-fade {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.os-popup[open],
	.os-popup[open]::backdrop {
		animation: none;
	}
}

/* Keep the page from scrolling behind the modal */
html.os-popup-open {
	overflow: hidden;
}

/* ---------------------------------------------------------------------------
 * Container: radius-2xl, clips its content, no border or shadow
 * ------------------------------------------------------------------------- */

.os-popup__container {
	position: relative;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	max-height: calc(100dvh - var(--os-popup-gutter) * 2);
	overflow: auto;
	scrollbar-width: thin;
	border-radius: var(--os-radius-2xl);
	background: var(--os-surface-default);
}

.os-popup *,
.os-popup *::before,
.os-popup *::after {
	box-sizing: border-box;
}

/* ---------------------------------------------------------------------------
 * Close button: 40px gray/50 circle, 12px from the top-right corner of the image,
 * fa6-solid:xmark 20px. The ::after pad extends the touch target to 44px.
 * ------------------------------------------------------------------------- */

.os-popup__close {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 10px 12px;
	border: 0;
	border-radius: 100px;
	background: var(--os-gray-50);
	color: var(--os-blue-900);
	line-height: 0;
	cursor: pointer;
	appearance: none;
	transition: background 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.os-popup__close::after {
	content: '';
	position: absolute;
	inset: -2px;
	border-radius: inherit;
}

.os-popup__close img {
	display: block;
	width: 20px;
	height: 20px;
}

.os-popup__close:hover {
	background: #fff;
	transform: scale(1.06);
}

.os-popup__close:focus-visible,
.os-popup__button:focus-visible,
.os-popup__image-link:focus-visible {
	outline: 3px solid var(--os-focus-ring);
	outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
 * Images
 * ------------------------------------------------------------------------- */

.os-popup__image-link {
	display: block;
	border: 0;
	line-height: 0;
}

.os-popup__picture,
.os-popup__media,
.os-popup__image {
	display: block;
	width: 100%;
	height: auto;
	line-height: 0;
}

.os-popup__image {
	background: var(--os-surface-alt);
	object-fit: cover;
}

/*
 * Image variant: 343px / 3:4 on mobile. From 1024px it takes the width of the English site's
 * pop-up (90vw, capped at 1280px) with our 16:9 image, narrowed on short viewports so the whole
 * pop-up stays on screen instead of scrolling.
 */
.os-popup--image .os-popup__image {
	aspect-ratio: 3 / 4;
}

@media (min-width: 1024px) {
	.os-popup--image {
		--os-popup-cta-height: 0px;
		--os-popup-width: min(
			90vw,
			1280px,
			(100dvh - var(--os-popup-gutter) * 2 - var(--os-popup-cta-height)) * 16 / 9
		);
	}

	/* Optional CTA row under the image: 24px padding + 50px button */
	.os-popup--image:has(.os-popup__body) {
		--os-popup-cta-height: 98px;
	}

	.os-popup--image .os-popup__image {
		aspect-ratio: 16 / 9;
	}
}

/* Image + Content variant: 4:3 on both breakpoints */
.os-popup--image-content .os-popup__image {
	aspect-ratio: 4 / 3;
}

/* ---------------------------------------------------------------------------
 * Content block: 24px padding, 24px between copy / checkbox / actions
 * ------------------------------------------------------------------------- */

.os-popup__body {
	display: flex;
	flex-direction: column;
	gap: var(--os-spacing-3xl);
	align-items: center;
	width: 100%;
	padding: var(--os-spacing-3xl);
	background: var(--os-surface-default);
}

.os-popup__copy {
	display: flex;
	flex-direction: column;
	gap: var(--os-spacing-xl);
	width: 100%;
	text-align: center;
	overflow-wrap: break-word;
}

/* Display/H6 */
.os-popup__title {
	margin: 0;
	color: var(--os-text-heading);
	font-family: var(--os-font-body);
	font-size: 20px;
	font-weight: 600;
	line-height: 28px;
	letter-spacing: 0;
}

/* Text/Regular/sm */
.os-popup__excerpt {
	margin: 0;
	color: var(--os-text-body-secondary);
	font-size: 16px;
	font-weight: 400;
	line-height: 24px;
}

/* Checkbox atom, Size=sm */
.os-popup__checkbox {
	display: flex;
	gap: var(--os-spacing-md);
	align-items: flex-start;
	margin: 0;
	color: var(--os-text-checkbox-label);
	font-size: 14px;
	font-weight: 400;
	line-height: 22px;
	cursor: pointer;
}

/* The theme visually hides native checkboxes (sr-text + styled sibling label); bring this one back */
.os-popup__checkbox input[type='checkbox'] {
	all: revert;
	position: static;
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	margin: var(--os-spacing-xxs) 0 0;
	overflow: visible;
	clip: auto;
	clip-path: none;
	white-space: normal;
	opacity: 1;
	border: 1px solid var(--os-border-checkbox-unchecked);
	border-radius: 0;
	appearance: auto;
	accent-color: var(--os-button-primary-bg);
	cursor: pointer;
}

.os-popup__checkbox input[type='checkbox']:focus-visible {
	outline: 3px solid var(--os-focus-ring);
	outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
 * Actions
 * Full-width stacked buttons, 12px apart. The Image variant's single CTA hugs its
 * label and sits at the right on desktop.
 * ------------------------------------------------------------------------- */

.os-popup__actions {
	display: flex;
	flex-direction: column;
	gap: 12px;
	align-items: center;
	width: 100%;
}

@media (min-width: 1024px) {
	.os-popup--image .os-popup__body {
		align-items: flex-end;
	}

	.os-popup--image .os-popup__actions {
		width: auto;
	}
}

/* ---------------------------------------------------------------------------
 * Buttons (Buttons/Button, Size=lg): Text/Label/md, pill, 16px 32px
 * ------------------------------------------------------------------------- */

.os-popup__button {
	display: inline-flex;
	gap: var(--os-spacing-sm);
	align-items: center;
	justify-content: center;
	width: 100%;
	margin: 0;
	padding: 16px 32px;
	border: 0;
	border-radius: 9999px;
	background: var(--os-button-primary-bg);
	color: var(--os-button-primary-text);
	font-family: var(--os-font-body);
	font-size: 12px;
	font-weight: 700;
	line-height: 18px;
	letter-spacing: 1px;
	text-align: center;
	text-decoration: none;
	text-transform: uppercase;
	white-space: nowrap;
	cursor: pointer;
	appearance: none;
	transition: background 0.15s ease-in-out, color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.os-popup__button:hover {
	background: var(--os-button-primary-bg-hover);
	color: var(--os-button-primary-text);
}

.os-popup__button--destructive {
	background: var(--os-button-destructive-bg);
	color: var(--os-button-destructive-text);
}

.os-popup__button--destructive:hover {
	background: var(--os-button-destructive-bg-hover);
	color: var(--os-button-destructive-text);
}

.os-popup__button--secondary {
	background: var(--os-button-secondary-bg);
	color: var(--os-button-secondary-text);
	box-shadow: 0 2px 12px 0 var(--os-shadow-light);
}

.os-popup__button--secondary:hover {
	background: var(--os-button-secondary-bg);
	color: var(--os-button-secondary-text);
	box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.2);
}

.os-popup__button[aria-disabled='true'] {
	opacity: 0.5;
	pointer-events: none;
}
