/*
 * Smart Popup (ADR-0025) — one layout for every campaign, in the site UI.
 * States (legacy names kept for assets/js/script.js):
 *   .dv-open  = collapsed: only the tab peeks in from the right edge
 *   .dv-close = expanded: the card slides in
 */

#dv-alert-wrapper.sp-popup {
	--sp-w: 248px;
	--sp-tab-w: 32px;
	--sp-gap: 12px;
	--sp-accent: var(--rade-persian, #072ac8);
	--sp-accent-text: #fff;
	--sp-surface: #fff;
	--sp-border: #e3e7ef;
	--sp-text: #232425;
	--sp-muted: #6c6f72;
	--sp-ease: cubic-bezier(0.22, 1, 0.36, 1);

	position: fixed;
	right: var(--sp-gap);
	bottom: 96px;
	/* The theme still ships a legacy width: 300px for this id */
	width: auto;
	z-index: 99999999;
	display: flex;
	align-items: center;
	direction: ltr;
	font-family: inherit;
	transform: translateX(calc(var(--sp-w) + var(--sp-gap)));
	transition: transform 0.6s var(--sp-ease), opacity 0.35s ease;
	will-change: transform;
}

#dv-alert-wrapper.sp-popup.dv-close {
	transform: translateX(0);
}

/* Over the footer: fade the collapsed tab so the footer stays readable; full opacity on hover or when open */
#dv-alert-wrapper.sp-popup.sp-over-footer.dv-open {
	opacity: 0.45;
}

#dv-alert-wrapper.sp-popup.sp-over-footer.dv-open:hover,
#dv-alert-wrapper.sp-popup.sp-over-footer.dv-open:focus-within {
	opacity: 1;
}

/* Tab */
#dv-alert-wrapper .sp-tab {
	display: flex;
	flex: 0 0 var(--sp-tab-w);
	flex-direction: column;
	align-items: center;
	gap: 8px;
	width: var(--sp-tab-w);
	max-height: 190px;
	margin: 0;
	padding: 12px 0;
	border: 0;
	border-radius: 12px 0 0 12px;
	background: var(--rade-persian, #072ac8) !important;
	color: #fff !important;
	box-shadow: -4px 6px 18px color-mix(in srgb, rgba(7, 42, 200, 0.25) var(--rade-shadow-opacity, 100%), transparent);
	cursor: pointer;
	position: relative;
	z-index: 0;
	transform: translateX(0);
	opacity: 1;
	visibility: visible;
	transition: transform 0.35s var(--sp-ease), opacity 0.2s ease, background-color 0.2s ease, visibility 0s;
}

#dv-alert-wrapper.dv-close .sp-tab {
	transform: translateX(var(--sp-tab-w));
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition-delay: 0s, 0s, 0s, 0.35s;
}

#dv-alert-wrapper .sp-tab:hover {
	background: var(--rade-navy, #000099) !important;
}

#dv-alert-wrapper .sp-tab:focus-visible {
	outline: 2px solid var(--rade-color-accent, #55c1ff);
	outline-offset: 2px;
}

#dv-alert-wrapper .sp-tab__label {
	overflow: hidden;
	max-height: 150px;
	font-size: 12.5px;
	font-weight: 600;
	line-height: var(--sp-tab-w);
	text-overflow: ellipsis;
	white-space: nowrap;
	writing-mode: vertical-rl;
	transform: rotate(180deg);
}

#dv-alert-wrapper .sp-tab__chevron {
	flex: 0 0 auto;
	width: 7px;
	height: 7px;
	border-left: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(45deg);
	transition: transform 0.4s var(--sp-ease);
}

#dv-alert-wrapper.dv-close .sp-tab__chevron {
	transform: rotate(-135deg);
}

/* Card */
#dv-alert-wrapper .sp-card {
	position: relative;
	z-index: 1;
	box-sizing: border-box;
	width: var(--sp-w);
	padding: 18px 16px 14px;
	border: 1px solid var(--sp-border);
	border-radius: 16px;
	background: var(--sp-surface);
	box-shadow: 0 18px 44px color-mix(in srgb, rgba(15, 23, 42, 0.18) var(--rade-shadow-opacity, 100%), transparent);
	color: var(--sp-text);
	direction: rtl;
	text-align: center;
	opacity: 0;
	transition: opacity 0.35s ease;
}

#dv-alert-wrapper.dv-close .sp-card {
	opacity: 1;
	transition-delay: 0.08s;
}

#dv-alert-wrapper .sp-card {
	max-height: calc(100dvh - 115px);
	overflow: auto;
}

#dv-alert-wrapper :is(.sp-close, .sp-cta, .btn-group-sp a):focus-visible {
	outline: 2px solid var(--rade-color-link, #072ac8);
	outline-offset: 2px;
}

#dv-alert-wrapper .sp-close {
	position: absolute;
	top: 10px;
	left: 10px;
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #f1f3f7 !important;
	color: var(--sp-muted) !important;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

#dv-alert-wrapper .sp-close:hover {
	background: #e4e8f0 !important;
	color: var(--sp-text) !important;
}

#dv-alert-wrapper .sp-logo {
	display: block;
	max-width: 120px;
	max-height: 44px;
	margin: 2px auto 10px;
	object-fit: contain;
}

#dv-alert-wrapper .sp-title {
	margin: 0;
	padding: 0 22px;
	color: var(--sp-text);
	font-size: 15px;
	font-weight: 800;
	line-height: 1.6;
}

#dv-alert-wrapper .sp-text {
	margin-top: 4px;
	color: var(--sp-muted);
	font-size: 13px;
	line-height: 1.8;
}

#dv-alert-wrapper .sp-button {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 42px;
	margin-top: 14px;
	border-radius: 10px;
	background: var(--sp-accent);
	color: var(--sp-accent-text) !important;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	#dv-alert-wrapper :is(.sp-button, .btn-group-sp a) {
		position: relative;
		isolation: isolate;
		overflow: hidden;
	}

	#dv-alert-wrapper :is(.sp-button, .btn-group-sp a):hover::after {
		content: "";
		position: absolute;
		inset: 0;
		z-index: -1;
		pointer-events: none;
		background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / 55%) 50%, transparent 70%);
		animation: sp-cta-shine 650ms ease-out both;
	}
}

@keyframes sp-cta-shine {
	from { transform: translateX(100%); }
	to { transform: translateX(-100%); }
}

#dv-alert-wrapper .sp-brand {
	margin-top: 8px;
	color: var(--sp-muted);
	font-size: 11.5px;
}

/* Custom body (campaigns with their own HTML): align legacy markup with the default look */
#dv-alert-wrapper .sp-body--custom {
	padding-top: 8px;
	color: var(--sp-text);
	font-size: 13.5px;
	line-height: 1.8;
}

#dv-alert-wrapper .sp-body--custom .custom-logo {
	display: block;
	max-width: 100%;
	height: auto;
	margin: 8px auto;
	border-radius: 8px;
}

#dv-alert-wrapper .btn-group-sp {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 12px;
}

#dv-alert-wrapper .btn-group-sp a {
	display: flex !important;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 42px;
	margin: 0 !important;
	padding: 8px 14px !important;
	border-radius: 10px;
	background-color: var(--sp-accent);
	color: var(--sp-accent-text) !important;
	font-size: 13.5px;
	font-weight: 600;
	text-decoration: none;
	/* Some legacy custom bodies set hover geometry inline. */
	transform: none !important;
	box-shadow: none !important;
}

#dv-alert-wrapper .btn-group-sp .cta-fill-hover::before {
	content: none;
}

#dv-alert-wrapper .btn-group-sp img {
	width: 20px;
	height: 20px;
	background: transparent !important;
}

#dv-alert-wrapper .btn-group-sp .text-white {
	color: inherit !important;
}

#dv-alert-wrapper .popupcf7_phone {
	width: 100%;
}

/* Dark mode */
body.__dm #dv-alert-wrapper.sp-popup {
	--sp-surface: #2c2f31;
	--sp-border: #3a3d42;
	--sp-text: var(--rade-color-text, #f1f1f1);
	--sp-muted: var(--rade-color-text-muted, #b4b8bf);
}

body.__dm #dv-alert-wrapper .sp-card {
	box-shadow: 0 18px 44px color-mix(in srgb, rgba(0, 0, 0, 0.5) var(--rade-shadow-opacity, 100%), transparent);
}

body.__dm #dv-alert-wrapper .sp-close {
	background: #3a3d42 !important;
}

/* Logos are made for light backgrounds */
body.__dm #dv-alert-wrapper .sp-logo {
	padding: 4px 8px;
	border-radius: 8px;
	background: #fff;
}

/* Mobile: keep the footer unobstructed, including after a sticky touch hover. */
@media (max-width: 767px) {
	#dv-alert-wrapper.sp-popup.sp-over-footer.dv-open:not(:focus-within) {
		opacity: 0.08;
	}
}

/* Small screens: keep the card inside the viewport */
@media (max-width: 480px) {
	#dv-alert-wrapper.sp-popup {
		--sp-w: min(248px, calc(100vw - 64px));
		bottom: 84px;
	}
}

@media (prefers-reduced-motion: reduce) {
	#dv-alert-wrapper.sp-popup,
	#dv-alert-wrapper .sp-card,
	#dv-alert-wrapper .sp-tab,
	#dv-alert-wrapper .sp-tab__chevron {
		transition: none;
	}
	#dv-alert-wrapper .btn-group-sp a {
		animation: none !important;
	}
}
