/*
 * CQI Engage front-end styles.
 *
 * Deliberately kept as a compact floating pill at every viewport size,
 * never a full-width docked bar. That is the mechanism by which this
 * plugin satisfies "must never cover or obstruct mobile content": a
 * bar spanning the viewport width will inevitably sit over content or
 * collide with a theme's own sticky elements, so the CTA is sized to
 * its content and anchored to a corner or bottom-center at all sizes.
 */

.cqi-engage {
	position: fixed;
	z-index: 99990;
	bottom: calc(16px + var(--cqi-engage-offset-y, 0px));
	display: flex;
	align-items: center;
	gap: 6px;
	max-width: calc(100vw - 32px);

	opacity: 0;
	visibility: hidden;
	transform: translateY(12px);
	pointer-events: none;

	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.cqi-engage.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

.cqi-engage--bottom-right {
	right: calc(16px + var(--cqi-engage-offset-x, 0px));
}

.cqi-engage--bottom-left {
	left: calc(16px + var(--cqi-engage-offset-x, 0px));
}

.cqi-engage--bottom-center {
	left: 50%;
	transform: translate(calc(-50% + var(--cqi-engage-offset-x, 0px)), 12px);
}

.cqi-engage--bottom-center.is-visible {
	transform: translate(calc(-50% + var(--cqi-engage-offset-x, 0px)), 0);
}

.cqi-engage__button {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px;
	border-radius: 999px;
	background-color: var(--cqi-engage-bg, #0FC5B8);
	color: var(--cqi-engage-text, #FFFFFF);
	font-size: 15px;
	font-weight: 400;
	line-height: 1.3;
	text-decoration: none;
	white-space: nowrap;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cqi-engage__button--box {
	border-radius: 10px;
	white-space: normal;
	max-width: 260px;
}

/*
 * Custom HTML mode. The root is a plain div, not a link, specifically so
 * it can contain more than one real <a> (a phone number and an email
 * address both being clickable in the same card, for example), which is
 * not valid nested inside CQI Engage's own single wrapping anchor. The
 * hover lift/shadow rules above still apply since they target
 * .cqi-engage__button generally, not the anchor tag specifically.
 *
 * Custom cards tend to carry longer unbroken strings than a marketing
 * button ever does, a full email address or phone number being the
 * obvious case, so the box shape gets extra width specifically when
 * paired with Custom HTML content rather than widening every plain
 * box-shaped button. overflow-wrap covers whatever still doesn't fit
 * (an unusually long domain, a narrow viewport) by breaking it cleanly
 * instead of overflowing the card's edge.
 */

.cqi-engage__button--box.cqi-engage__custom {
	min-width: min(240px, calc(100vw - 64px));
	max-width: 320px;
}

.cqi-engage__custom {
	display: block;
	text-align: var(--cqi-engage-custom-align, left);
	font-size: var(--cqi-engage-custom-font-size, 15px);
	line-height: 1.5;
	overflow-wrap: anywhere;
	cursor: default;
}

.cqi-engage__custom:hover,
.cqi-engage__custom:focus {
	transform: none;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

/*
 * Paragraphs are the natural way to write a multi-line card, but a
 * browser's default ~1em top/bottom margin on <p> produces uneven,
 * oversized gaps once several are stacked inside a small card. Reset to
 * one consistent, compact gap instead. Plain <div> is just as common a
 * way to wrap each line (a div has no default browser margin at all, so
 * without this it would sit flush against its neighbors, an equally
 * uneven result in the other direction), so both get the same treatment.
 * Only direct children are matched, so a div nested for some other
 * purpose inside one of these lines does not also pick up the rule.
 */
.cqi-engage__custom p,
.cqi-engage__custom > div {
	margin: 0 0 8px 0;
}

.cqi-engage__custom p:last-child,
.cqi-engage__custom > div:last-child {
	margin-bottom: 0;
}

/*
 * Once every line has its own consistent margin, a <br> placed directly
 * between two lines (rather than inside one, for a genuine mid-line
 * break) only ever adds an extra, inconsistent gap on top of that
 * margin. Hiding a top-level <br> removes that redundant gap without
 * touching a <br> used correctly inside a p/div/span for an actual
 * line break within one block.
 */
.cqi-engage__custom > br {
	display: none;
}

/*
 * Optional helper classes for common parts of a contact-style card.
 * Entirely optional: plain <strong>/<br> still works with no classes at
 * all, these just save an operator from re-declaring the same look by
 * hand (or reaching for the style attribute) every time.
 */
.cqi-engage__custom-heading {
	display: block;
	font-weight: 700;
	font-size: 1.05em;
	margin-bottom: 8px;
}

.cqi-engage__custom-label {
	font-weight: 700;
}

/*
 * Forces every link inside the card to the button's own text color
 * (inherited via currentColor) rather than whatever color/visited-color
 * the host theme applies to plain <a> tags. Without this, a theme's own
 * global link styling (often including a distinct :visited color) wins
 * on specificity, producing two different, off-brand colors for the
 * phone and email links instead of one consistent look. The !important
 * is deliberate: this is a small, self-contained widget where every
 * visual property should come from CQI Engage's own settings, not
 * whatever the surrounding page happens to style anchors as.
 */
.cqi-engage__custom a,
.cqi-engage__custom a:link,
.cqi-engage__custom a:visited {
	color: inherit !important;
	text-decoration: underline;
}

.cqi-engage__custom a:hover,
.cqi-engage__custom a:focus {
	color: inherit !important;
	opacity: 0.85;
}

.cqi-engage__custom a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.cqi-engage__button:hover,
.cqi-engage__button:focus {
	color: var(--cqi-engage-text, #FFFFFF);
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

.cqi-engage__button:focus-visible {
	outline: 3px solid var(--cqi-engage-text, #FFFFFF);
	outline-offset: 3px;
}

.cqi-engage__arrow {
	display: inline-block;
	transition: transform 0.15s ease;
}

.cqi-engage__button:hover .cqi-engage__arrow {
	transform: translateX(3px);
}

.cqi-engage__dismiss {
	width: 28px;
	height: 28px;
	flex: 0 0 auto;
	border: none;
	border-radius: 50%;
	background-color: rgba(0, 0, 0, 0.35);
	color: #FFFFFF;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
}

.cqi-engage__dismiss:focus-visible {
	outline: 2px solid #FFFFFF;
	outline-offset: 2px;
}

.cqi-engage__sr-announce {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

@media (max-width: 480px) {
	.cqi-engage__button {
		font-size: 14px;
		padding: 11px 16px;
	}

	.cqi-engage {
		bottom: calc(16px + var(--cqi-engage-offset-y, 0px) + var(--cqi-engage-mobile-offset-y, 0px));
	}
}

@media (prefers-reduced-motion: reduce) {
	.cqi-engage,
	.cqi-engage__button,
	.cqi-engage__arrow {
		transition: none;
	}
}
