/**
 * Websel Announcement Popup — front-end styles.
 *
 * Colours come from the settings screen as custom properties on the root element,
 * so the same stylesheet serves every announcement without inline CSS blocks.
 * Layout is intentionally self-contained (no reliance on theme classes) because
 * this markup is injected into themes we have never seen.
 */

.wsap {
	position: fixed;
	inset: 0;
	z-index: 999990;
	pointer-events: none;
	font-family: inherit;
	--wsap-bg: #ffffff;
	--wsap-text: #0f172a;
	--wsap-accent: #2563eb;
	--wsap-cta-text: #ffffff;
	--wsap-radius: 14px;
}

.wsap[hidden] {
	display: none !important;
}

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

/* ------------------------------------------------------------------ overlay */

.wsap__overlay {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.24s ease;
}

.wsap.is-open .wsap__overlay {
	opacity: 1;
	pointer-events: auto;
}

.wsap--no-overlay .wsap__overlay {
	display: none;
}

/* ---------------------------------------------------------------------- box */

.wsap__box {
	pointer-events: auto;
	background: var(--wsap-bg);
	color: var(--wsap-text);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.24s ease, transform 0.24s ease, visibility 0.24s;
}

.wsap.is-open .wsap__box {
	opacity: 1;
	visibility: visible;
}

/* --------------------------------------------------------------- modal form */

.wsap--modal {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.wsap--modal .wsap__box {
	position: relative;
	width: 100%;
	max-width: 440px;
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	border-radius: var(--wsap-radius);
	box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
	transform: translateY(10px);
}

.wsap--modal.is-open .wsap__box {
	transform: none;
}

/* ----------------------------------------------------------------- bar form */

.wsap--bar_top .wsap__box {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 12px 56px 12px 20px;
	box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
	transform: translateY(-100%);
}

.wsap--bar_top.is-open .wsap__box {
	transform: none;
}

/* ------------------------------------------------------------------ content */

.wsap__image {
	display: block;
	width: 100%;
	height: auto;
	max-height: 220px;
	/*
	 * `contain` (not `cover`): announcement images run from square logos to
	 * tall portrait covers, and a fixed-ratio box will always crop something.
	 * Contexts that genuinely want a cropped square (the 40px bar icon below)
	 * opt back into `cover` explicitly rather than inheriting it by default.
	 */
	object-fit: contain;
}

.wsap--bar_top .wsap__image {
	width: 40px;
	height: 40px;
	flex: 0 0 auto;
	border-radius: 8px;
	object-fit: cover;
}

.wsap__body {
	padding: 26px 26px 28px;
}

.wsap--bar_top .wsap__body {
	display: flex;
	flex: 1 1 auto;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 16px;
	padding: 0;
}

.wsap__title {
	margin: 0 0 10px;
	font-size: 21px;
	line-height: 1.3;
	font-weight: 700;
	color: var(--wsap-text);
}

.wsap--bar_top .wsap__title {
	margin: 0;
	font-size: 16px;
}

.wsap__text {
	font-size: 15px;
	line-height: 1.65;
	opacity: 0.85;
}

.wsap--bar_top .wsap__text {
	font-size: 14px;
}

.wsap__text p {
	margin: 0 0 0.75em;
}

.wsap__text p:last-child {
	margin: 0;
}

.wsap__text a {
	color: var(--wsap-accent);
}

.wsap__cta {
	display: inline-block;
	margin-top: 20px;
	padding: 11px 24px;
	border-radius: 999px;
	background: var(--wsap-accent);
	color: var(--wsap-cta-text);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
}

.wsap__cta:hover,
.wsap__cta:focus {
	color: var(--wsap-cta-text);
	filter: brightness(1.08);
}

.wsap--bar_top .wsap__cta {
	margin: 0 0 0 auto;
	padding: 9px 20px;
	font-size: 14px;
	white-space: nowrap;
}

/* -------------------------------------------------------------------- close */

.wsap__close {
	position: absolute;
	z-index: 3; /* above the positioned image link, which would otherwise swallow the click */
	top: 12px;
	right: 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	opacity: 0.55;
	cursor: pointer;
	transition: opacity 0.15s ease, background-color 0.15s ease;
}

.wsap--bar_top .wsap__close {
	top: 50%;
	transform: translateY(-50%);
	right: 14px;
}

.wsap__close:hover {
	opacity: 1;
	background: rgba(127, 127, 127, 0.16);
}

.wsap__close:focus-visible,
.wsap__cta:focus-visible {
	outline: 2px solid var(--wsap-accent);
	outline-offset: 2px;
	opacity: 1;
}

/*
 * With an image the close button sits on a photo, where "inherit the text colour"
 * can vanish completely. A neutral chip keeps it visible on any image.
 */
.wsap--has-image.wsap--modal .wsap__close {
	background: rgba(255, 255, 255, 0.86);
	color: #0f172a;
	opacity: 1;
	box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

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

html.wsap-locked {
	overflow: hidden;
}

/* ------------------------------------------------------------- small screens */

@media (max-width: 600px) {
	.wsap__body {
		padding: 20px 20px 22px;
	}

	.wsap__title {
		font-size: 19px;
	}

	.wsap--bar_top .wsap__box {
		align-items: flex-start;
		padding: 12px 48px 12px 16px;
	}

	.wsap--bar_top .wsap__cta {
		margin: 4px 0 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wsap__box,
	.wsap__overlay {
		transition-duration: 0.01ms;
	}

	.wsap--modal .wsap__box,
	.wsap--bar_top .wsap__box {
		transform: none;
	}
}

/* ----------------------------------------------------- linked image only */

.wsap__imagelink {
	display: block;
	position: relative;
	cursor: pointer;
}

/*
 * Hover / focus / press ring in the announcement's accent colour. It is an
 * inset overlay (not an outline) so the box's rounded corners and
 * `overflow: hidden` clip it cleanly, and it is a pseudo-element so it never
 * shifts the image. It tells people the picture is a link.
 */
.wsap__imagelink::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	box-shadow: inset 0 0 0 0 var(--wsap-accent);
	pointer-events: none;
	transition: box-shadow 0.18s ease;
}

.wsap__imagelink:hover::after,
.wsap__imagelink:focus-visible::after,
.wsap__imagelink:active::after {
	box-shadow: inset 0 0 0 6px var(--wsap-accent);
}

.wsap__imagelink:focus-visible {
	outline: none;
}

@media (prefers-reduced-motion: reduce) {
	.wsap__imagelink::after {
		transition: none;
	}
}

/*
 * The image is the whole announcement: the box wraps the picture at its own
 * size (capped at 960px) instead of the 440px text-card width, and a picture
 * taller than the window shrinks to fit it, never cropped.
 */
.wsap--image-only.wsap--modal .wsap__box {
	width: auto;
	max-width: min(960px, 100%);
}

.wsap--image-only .wsap__image {
	width: auto;
	max-width: 100%;
	max-height: calc(100vh - 32px);
	margin: 0 auto;
}

.wsap--image-only.wsap--modal .wsap__box {
	overflow: hidden;
}
