/**
 * Rushd Campaign Manager: Promo Modal styles.
 *
 * The dialog shrinks to fit the image, and the image is capped to the viewport
 * in both width and height, so it is never cropped, letterboxed or scrolled.
 * Override the custom properties below in your theme to restyle the modal.
 */

.rcm-modal {
	--rcm-max-width: 640px;
	--rcm-radius: 12px;
	--rcm-gap: clamp(12px, 3vw, 24px);
	--rcm-actions-space: clamp(70px, 9vw, 82px);
	--rcm-backdrop-color: 10, 12, 16;
	--rcm-backdrop-dim: 0.7;
	--rcm-tint: 0;
	--rcm-surface: #fff;
	--rcm-focus: #2271b1;
	--rcm-duration: 250ms;

	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	/* Above the Hello Bar (99990) and the admin bar (99999). */
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--rcm-gap);
	box-sizing: border-box;
}

/*
 * Fonts: always the host website's. Nothing here loads or names a font; the
 * plugin inherits from the theme (or from --rcm-font-family when the admin
 * picks a theme variable or a custom stack under Settings > Font source).
 */
.rcm-modal,
.rcm-hellobar {
	font-family: var(--rcm-font-family, inherit);
}

.rcm-modal *,
.rcm-hellobar * {
	font-family: inherit;
}

/* Buttons, inputs and links don't inherit fonts by default. */
.rcm-modal button,
.rcm-hellobar button,
.rcm-modal a,
.rcm-hellobar a {
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	letter-spacing: inherit;
}

.rcm-modal[hidden] {
	display: none !important;
}

.rcm-modal *,
.rcm-modal *::before,
.rcm-modal *::after {
	box-sizing: border-box;
}

/* Backdrop ------------------------------------------------------------- */

.rcm-modal__overlay {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	overflow: hidden;
	opacity: 0;
	transition: opacity var(--rcm-duration) ease;
}

/* Dimming layer, above the optional backdrop image. */
.rcm-modal__overlay::after {
	content: "";
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background: rgba(var(--rcm-backdrop-color), var(--rcm-backdrop-dim));
}

.rcm-modal .rcm-modal__backdrop {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	object-fit: cover;
	object-position: center;
	border-radius: 0;
}

/* Dialog --------------------------------------------------------------- */

.rcm-modal__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: auto;
	max-width: min(var(--rcm-max-width), 100%);
	max-height: 100%;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--rcm-surface);
	border-radius: var(--rcm-radius);
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
	opacity: 0;
	transform: translateY(12px) scale(0.96);
	transition: opacity var(--rcm-duration) ease, transform var(--rcm-duration) cubic-bezier(0.2, 0.8, 0.2, 1);
}

.rcm-modal.is-open .rcm-modal__overlay {
	opacity: 1;
}

.rcm-modal.is-open .rcm-modal__dialog {
	opacity: 1;
	transform: none;
}

/*
 * The dialog receives focus programmatically when it opens (for screen
 * readers), so it never shows a focus ring. Buttons inside keep theirs for
 * keyboard users.
 */
.rcm-modal .rcm-modal__dialog:focus,
.rcm-modal .rcm-modal__dialog:focus-visible {
	outline: none !important;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

/* Visually hidden, still announced as the dialog name. */
.rcm-modal .rcm-modal__title,
.rcm-modal .rcm-modal__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;
}

/* Image ---------------------------------------------------------------- */

.rcm-modal__media {
	position: relative;
	flex: 0 0 auto;
	line-height: 0;
}

.rcm-modal .rcm-modal__image {
	display: block;
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: calc(100vh - 2 * var(--rcm-gap) - var(--rcm-actions-space));
	max-height: calc(100dvh - 2 * var(--rcm-gap) - var(--rcm-actions-space));
	margin: 0 auto;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

/* Buttons -------------------------------------------------------------- */

.rcm-modal__actions {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding: clamp(12px, 2.5vw, 18px) clamp(12px, 3vw, 20px);
}

/*
 * Both buttons share the Hello Bar CTA's fixed design; only colors come from
 * the admin. A color that is not set is not output, so the fallbacks apply.
 */
.rcm-modal a.rcm-modal__cta,
.rcm-modal a.rcm-modal__secondary {
	/* Layout resets so theme link/button styles cannot change the design. */
	box-sizing: border-box;
	flex: 0 1 auto;
	min-width: 0;
	max-width: 100%;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	overflow: hidden;
	line-height: 1;
	letter-spacing: normal;
	font-weight: inherit;
	text-overflow: ellipsis;

	height: 42px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 20px;
	text-transform: uppercase;
	font-family: var(--rcm-font-family, var(--body-font, inherit));
	font-size: 12px; /* fixed, as before */
	text-decoration: none;
	white-space: nowrap;
	transition: var(--transition, all 0.25s ease);
}

/* Primary CTA: solid, gold by default. */
.rcm-modal a.rcm-modal__cta {
	border-left: 1px solid rgba(184, 151, 58, 0.3);
	color: var(--rcm-modal-cta-text, #1b2a4a);
	background-color: var(--rcm-modal-cta-bg, var(--gold-muted, #c9a84c));
}

.rcm-modal a.rcm-modal__cta:hover,
.rcm-modal a.rcm-modal__cta:focus-visible {
	color: var(--rcm-modal-cta-hover-text, var(--rcm-modal-cta-text, #1b2a4a));
	background-color: var(--rcm-modal-cta-hover-bg, var(--rcm-modal-cta-bg, var(--gold-muted, #c9a84c)));
	text-decoration: none;
}

/* Secondary: outlined, white by default (like "View sessions"). */
.rcm-modal a.rcm-modal__secondary {
	border: 1px solid var(--rcm-modal-secondary-border, #fff);
	color: var(--rcm-modal-secondary-text, #fff);
	background-color: var(--rcm-modal-secondary-bg, transparent);
}

.rcm-modal a.rcm-modal__secondary:hover,
.rcm-modal a.rcm-modal__secondary:focus-visible {
	color: var(--rcm-modal-secondary-hover-text, var(--rcm-modal-secondary-text, #fff));
	background-color: var(--rcm-modal-secondary-hover-bg, var(--rcm-modal-secondary-bg, transparent));
	text-decoration: none;
}

/* On the image, an unset secondary background gets a translucent navy so the label stays readable. */
.rcm-modal--background a.rcm-modal__secondary,
.rcm-modal--background a.rcm-modal__secondary:focus:not(:focus-visible):not(:hover) {
	background-color: var(--rcm-modal-secondary-bg, rgba(27, 42, 74, 0.6));
}

.rcm-modal--background a.rcm-modal__secondary:hover,
.rcm-modal--background a.rcm-modal__secondary:focus-visible {
	background-color: var(--rcm-modal-secondary-hover-bg, var(--rcm-modal-secondary-bg, rgba(27, 42, 74, 0.85)));
}

/* Mouse focus keeps the normal colors (themes often restyle a:focus). */
.rcm-modal a.rcm-modal__cta:focus:not(:focus-visible):not(:hover) {
	color: var(--rcm-modal-cta-text, #1b2a4a);
	background-color: var(--rcm-modal-cta-bg, var(--gold-muted, #c9a84c));
}

.rcm-modal a.rcm-modal__secondary:focus:not(:focus-visible):not(:hover) {
	color: var(--rcm-modal-secondary-text, #fff);
	background-color: var(--rcm-modal-secondary-bg, transparent);
}

/* Layout: buttons in a footer below the image ------------------------- */

.rcm-modal--stacked .rcm-modal__actions {
	padding: clamp(14px, 2.5vw, 20px) clamp(14px, 3vw, 24px);
	background: var(--rcm-modal-footer-bg, #1b2a4a);
}

/* Close button --------------------------------------------------------- */

.rcm-modal button.rcm-modal__close {
	position: absolute;
	top: clamp(6px, 1.5vw, 10px);
	right: clamp(6px, 1.5vw, 10px);
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: clamp(34px, 8vw, 40px);
	height: clamp(34px, 8vw, 40px);
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	color: #111;
	line-height: 1;
	cursor: pointer;
	transition: background-color 150ms ease;
}

.rcm-modal button.rcm-modal__close:hover,
.rcm-modal button.rcm-modal__close:focus {
	background: #fff;
	color: #111;
}

.rcm-modal__close svg {
	display: block;
	width: 45%;
	height: 45%;
	pointer-events: none;
}

/* Rings only for keyboard focus, never on mouse or touch. */
.rcm-modal a.rcm-modal__cta:focus,
.rcm-modal a.rcm-modal__secondary:focus,
.rcm-modal button.rcm-modal__close:focus {
	outline: none;
}

.rcm-modal a.rcm-modal__cta:focus-visible,
.rcm-modal a.rcm-modal__secondary:focus-visible,
.rcm-modal button.rcm-modal__close:focus-visible {
	outline: 3px solid var(--rcm-focus);
	outline-offset: 2px;
}

/* Layout: buttons on the image ---------------------------------------- */

.rcm-modal--background,
.rcm-modal--no-cta {
	--rcm-actions-space: 0px;
}

.rcm-modal--background .rcm-modal__dialog {
	background: #000;
}

.rcm-modal--background .rcm-modal__media::after {
	content: "";
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background: rgba(0, 0, 0, var(--rcm-tint));
	pointer-events: none;
}

.rcm-modal--background .rcm-modal__actions {
	position: absolute;
	right: 0;
	left: 0;
	z-index: 1;
	padding: clamp(12px, 3vw, 24px);
}

.rcm-modal--cta-bottom .rcm-modal__actions {
	bottom: 0;
}

.rcm-modal--cta-center .rcm-modal__actions {
	top: 50%;
	transform: translateY(-50%);
}

/* Keep clear of the close button. */
.rcm-modal--cta-top .rcm-modal__actions {
	top: 0;
	padding-right: clamp(48px, 10vw, 64px);
	padding-left: clamp(48px, 10vw, 64px);
}

/* Small screens -------------------------------------------------------- */

@media (max-width: 480px) {
	.rcm-modal {
		--rcm-radius: 10px;
	}

	/* Buttons share one row and fill it; long labels end with "…". */
	.rcm-modal__actions {
		gap: 10px;
	}

	.rcm-modal a.rcm-modal__cta,
	.rcm-modal a.rcm-modal__secondary {
		flex: 1 1 0;
		padding: 0 12px;
	}
}

/* Page scroll lock ----------------------------------------------------- */

html.rcm-scroll-locked,
html.rcm-scroll-locked body {
	overflow: hidden !important;
}

/* Reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.rcm-modal__overlay,
	.rcm-modal__dialog,
	.rcm-modal a.rcm-modal__cta,
	.rcm-modal a.rcm-modal__secondary,
	.rcm-modal button.rcm-modal__close {
		transition: none;
	}

	.rcm-modal__dialog {
		transform: none;
	}
}
