/* ============================================================
 * Document360 Exit Survey — self-contained widget styles.
 * No framework dependency; every class is prefixed d360es.
 * ============================================================ */

.d360es {
	--d360es-surface: #232746;
	--d360es-surface-2: #1b1f3b;
	--d360es-border: #3a3f66;
	--d360es-text: #ffffff;
	--d360es-text-muted: #b6b9d4;
	--d360es-purple: #7f56d9;
	--d360es-purple-hover: #6645ae;
	--d360es-radius: 10px;
	--d360es-choice-radius: 999px;

	/* Every colour below was previously hardcoded in a rule. The values are unchanged;
	   they are variables now only so the dashboard can override them. */
	--d360es-accent-text: #ffffff;
	/* Field and option text are separate from dialog text: a light field background
	   needs dark text inside it while the dialog heading stays light. */
	--d360es-field-text: #ffffff;
	--d360es-field-focus: #7f56d9;
	/* Fields get their own border colour. The general --d360es-border is deliberately
	   subtle for option pills and dividers, but at 1.6:1 against the field fill it left
	   text inputs with no visible edge at all — below the 3:1 WCAG 1.4.11 minimum for
	   UI component boundaries. This clears it at ~3.6:1. */
	--d360es-field-border: #6f74a6;
	--d360es-choice-text: #ffffff;
	--d360es-error: #ff8f73;
	--d360es-placeholder: #7b7fa3;
	--d360es-disabled-bg: #383d63;
	--d360es-disabled-text: #9a9db8;
	--d360es-choice-hover-bg: #232849;
	--d360es-choice-hover-border: #5b5f8c;
	--d360es-focus: #b29ae8;
	--d360es-close-hover-bg: rgba(255, 255, 255, 0.08);

	/* Overlay and shadows share one colour, expressed as an rgb triplet so alpha can
	   vary per use. */
	--d360es-shadow-rgb: 9, 9, 11;
	--d360es-backdrop: rgba(9, 9, 11, 0.55);

	/* Accent tints, derived from the accent colour by the dashboard when it changes. */
	--d360es-accent-soft: rgba(127, 86, 217, 0.16);
	--d360es-accent-ring: rgba(127, 86, 217, 0.45);
	--d360es-accent-ring-soft: rgba(127, 86, 217, 0.24);
	--d360es-accent-dot: rgba(127, 86, 217, 0.35);

	position: fixed;
	inset: 0;
	z-index: 999999;
	font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

.d360es[hidden] {
	display: none;
}

/* ---------- Backdrop ---------- */

.d360es__backdrop {
	position: absolute;
	inset: 0;
	background: var(--d360es-backdrop);
	opacity: 0;
	transition: opacity 0.22s ease;
}

.d360es.is-open .d360es__backdrop {
	opacity: 1;
}

.d360es--corner {
	pointer-events: none;
}

.d360es--corner .d360es__backdrop {
	display: none;
}

.d360es--corner .d360es__dialog {
	pointer-events: auto;
}

/* ---------- Dialog shell ---------- */

.d360es__dialog {
	position: absolute;
	box-sizing: border-box;
	width: calc(100% - 32px);
	max-width: 460px;
	padding: 28px 28px 24px;
	background: var(--d360es-surface);
	color: var(--d360es-text);
	border-radius: var(--d360es-radius);
	box-shadow: 0 18px 48px rgba(var(--d360es-shadow-rgb), 0.45);
	opacity: 0;
	transition: opacity 0.24s ease, transform 0.24s ease;
}

.d360es--center .d360es__dialog {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -46%);
}

.d360es--center.is-open .d360es__dialog {
	opacity: 1;
	transform: translate(-50%, -50%);
}

.d360es--corner .d360es__dialog {
	right: 24px;
	bottom: 24px;
	max-width: 380px;
	padding: 22px 22px 18px;
	transform: translateY(14px);
}

/*
 * Which corner. Deliberately scoped to wide viewports: these selectors are more
 * specific than the mobile bottom-sheet rules below, so left unscoped they would win
 * inside the mobile media query and pin the sheet to one side instead of spanning the
 * screen. Small screens get their placement from the mobile rules alone.
 */
@media (min-width: 768px) {
	.d360es--corner .d360es__dialog,
	.d360es--corner.d360es--right .d360es__dialog {
		right: 24px;
		left: auto;
	}

	.d360es--corner.d360es--left .d360es__dialog {
		left: 24px;
		right: auto;
	}
}

.d360es--corner.is-open .d360es__dialog {
	opacity: 1;
	transform: translateY(0);
}

/* ---------- Close button ---------- */

.d360es__close {
	position: absolute;
	top: 12px;
	right: 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	color: var(--d360es-text-muted);
	background: none;
	border: 0;
	border-radius: 6px;
	cursor: pointer;
	transition: color 0.15s ease, background 0.15s ease;
}

.d360es__close:hover,
.d360es__close:focus-visible {
	color: var(--d360es-text);
	background: var(--d360es-close-hover-bg);
}

/* ---------- Steps ---------- */

.d360es__step {
	display: none;
}

.d360es__step.is-active {
	display: block;
	animation: d360es-step-in 200ms ease both;
}

@keyframes d360es-step-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.d360es__question {
	/* Centred with symmetric margins so the close button does not pull it off-axis. */
	margin: 0 8px 18px;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.45;
	text-align: center;
	color: var(--d360es-text);
}

/* Follow-up questions in a stacked survey read as sub-headings, so they stay left. */
.d360es__question--sub {
	text-align: left;
	margin-left: 0;
	margin-right: 0;
}

.d360es__question--lg {
	margin-bottom: 18px;
	font-size: 18px;
}

.d360es__srlabel {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- Choice list ---------- */

.d360es__choices {
	margin: 0 0 4px;
	padding: 0;
	border: 0;
}

.d360es__choice {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 18px;
	margin-bottom: 6px;
	font-size: 14px;
	line-height: 1.45;
	color: var(--d360es-choice-text);
	background: var(--d360es-surface-2);
	border: 1px solid var(--d360es-border);
	border-radius: var(--d360es-choice-radius);
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.d360es__choice:hover {
	border-color: var(--d360es-choice-hover-border);
	background: var(--d360es-choice-hover-bg);
}

.d360es__choice input {
	flex: 0 0 auto;
	width: 17px;
	height: 17px;
	margin: 0;
	accent-color: var(--d360es-purple);
	cursor: pointer;
}

/* :has is progressive — without it the row simply doesn't get the selected tint. */
.d360es__choice:has( input:checked ) {
	border-color: var(--d360es-purple);
	background: var(--d360es-accent-soft);
}

.d360es__choice:focus-within {
	border-color: var(--d360es-purple);
	box-shadow: 0 0 0 3px var(--d360es-accent-ring-soft);
}

.d360es__textwrap[hidden] {
	display: none;
}

.d360es__textwrap {
	margin-top: 10px;
}

/* ---------- Fields ---------- */

/*
 * Doubled-up selector (.d360es .d360es__input) on purpose. The widget sits at body level
 * where a theme's own form styling can reach it — the Document360 theme ships Bootstrap 5,
 * whose .form-control rules would otherwise outrank a single class here.
 */
.d360es .d360es__textarea,
.d360es .d360es__input {
	display: block;
	box-sizing: border-box;
	width: 100%;
	margin: 0;
	padding: 12px 14px;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.5;
	color: var(--d360es-field-text);
	background: var(--d360es-surface-2);
	border: 1px solid var(--d360es-field-border);
	border-radius: 10px;
	outline: none;
	box-shadow: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.d360es__textarea {
	min-height: 96px;
	resize: vertical;
}

.d360es__input {
	height: 48px;
}

.d360es__textarea::placeholder,
.d360es__input::placeholder {
	color: var(--d360es-placeholder);
}

.d360es .d360es__textarea:focus,
.d360es .d360es__input:focus {
	border-color: var(--d360es-field-focus)!important;
	box-shadow: 0 0 3px 2px var(--d360es-accent-ring)!important;
}

.d360es__error {
	margin: 10px 0 0;
	font-size: 13px;
	color: var(--d360es-error);
}

.d360es__consent {
	margin: 10px 0 0;
	font-size: 12px;
	line-height: 1.5;
	color: var(--d360es-text-muted);
}

.d360es__consent a {
	color: inherit;
	text-decoration: underline;
}

/* ---------- Actions ---------- */

.d360es__actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 18px;
	padding-top: 14px;
	border-top: 1px solid var(--d360es-border);
}

.d360es__skip {
	padding: 8px 10px;
	font-family: inherit;
	font-size: 14px;
	color: var(--d360es-text-muted);
	background: none;
	border: 0;
	border-radius: 6px;
	text-decoration: underline;
	cursor: pointer;
	transition: color 0.15s ease;
}

.d360es__skip:hover,
.d360es__skip:focus-visible {
	color: var(--d360es-text);
}

.d360es__next {
	min-width: 84px;
	padding: 10px 20px;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	color: var(--d360es-accent-text);
	background: var(--d360es-purple);
	border: 0;
	border-radius: 8px;
	cursor: pointer;
	transition: background 0.15s ease, opacity 0.15s ease;
}

.d360es__next:hover:not(:disabled),
.d360es__next:focus-visible:not(:disabled) {
	background: var(--d360es-purple-hover);
}

.d360es__next:disabled {
	color: var(--d360es-disabled-text);
	background: var(--d360es-disabled-bg);
	cursor: not-allowed;
}

.d360es__next.is-busy {
	opacity: 0.7;
	pointer-events: none;
}

/* ---------- Step 3 ---------- */

.d360es__step--thanks {
	padding-top: 12px;
	text-align: center;
}

.d360es__thanks {
	margin: 0 0 26px;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.35;
	color: var(--d360es-text);
}

.d360es__cta {
	display: block;
	width: 100%;
	padding: 16px 24px;
	font-family: inherit;
	font-size: 18px;
	font-weight: 700;
	color: var(--d360es-accent-text);
	background: var(--d360es-purple);
	border: 0;
	border-radius: 8px;
	cursor: pointer;
	transition: background 0.15s ease;
}

.d360es__cta:hover,
.d360es__cta:focus-visible {
	background: var(--d360es-purple-hover);
}

/* ---------- CAPTCHA ---------- */

/* Empty unless the provider decides to show an interactive challenge, so it must not
   reserve vertical space in the common case. */
.d360es__captcha:not(:empty) {
	margin-top: 14px;
}

.d360es__badge {
	margin: 12px 0 0;
	font-size: 11px;
	line-height: 1.5;
	color: var(--d360es-text-muted);
	opacity: 0.75;
}

.d360es__badge a {
	color: inherit;
	text-decoration: underline;
}

/* ---------- Honeypot ---------- */

.d360es__hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ---------- Focus ring ---------- */

.d360es button:focus-visible {
	outline: 2px solid var(--d360es-focus);
	outline-offset: 2px;
}

/* ---------- Scroll lock (modal only) ---------- */

html.d360es-locked,
html.d360es-locked body {
	overflow: hidden;
}

html.d360es-locked body {
	position: fixed;
	width: 100%;
}

/* ---------- Mobile ---------- */

/* "off" — never render on small screens. The JS also refuses to open, but the class
   guarantees it even if the script is cached from an older configuration. */
@media (max-width: 767px) {
	.d360es--m-off {
		display: none !important;
	}
}

/*
 * Bottom sheet. A full-screen overlay on mobile is what Google classifies as an
 * intrusive interstitial, so the sheet stays anchored to the bottom, keeps a chunk of
 * the page visible and never dims the whole viewport. The close control is sized to
 * the 44px minimum tap target.
 */
@media (max-width: 767px) {
	.d360es--m-sheet {
		pointer-events: none;
	}

	.d360es--m-sheet .d360es__backdrop {
		display: none;
	}

	.d360es--m-sheet .d360es__dialog {
		top: auto;
		right: 0;
		bottom: 0;
		left: 0;
		width: 100%;
		max-width: none;
		max-height: 72vh;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		padding: 20px 18px calc(16px + env(safe-area-inset-bottom, 0px));
		border-radius: 14px 14px 0 0;
		box-shadow: 0 -8px 32px rgba(var(--d360es-shadow-rgb), 0.4);
		pointer-events: auto;
		transform: translateY(100%);
	}

	.d360es--m-sheet.is-open .d360es__dialog {
		transform: translateY(0);
	}

	.d360es--m-sheet .d360es__close {
		top: 8px;
		right: 8px;
		width: 44px;
		height: 44px;
	}

	.d360es--m-sheet .d360es__question {
		margin-right: 44px;
		font-size: 15px;
	}

	.d360es--m-sheet .d360es__thanks {
		font-size: 19px;
	}
}

/* Small screens, when the desktop presentation is inherited. */
@media (max-width: 480px) {
	.d360es--m-inherit .d360es__dialog {
		right: 12px;
		left: 12px;
		bottom: 12px;
		width: auto;
		max-width: none;
		padding: 22px 20px 18px;
	}

	.d360es--m-inherit.d360es--center .d360es__dialog {
		top: auto;
		left: 12px;
		transform: translateY(14px);
	}

	.d360es--m-inherit.d360es--center.is-open .d360es__dialog {
		transform: translateY(0);
	}

	.d360es__thanks {
		font-size: 19px;
	}

	.d360es__cta {
		font-size: 16px;
		padding: 14px 20px;
	}
}

/* ---------- Respect reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.d360es__backdrop,
	.d360es__dialog {
		transition: none;
	}

	.d360es__step.is-active {
		animation: none;
	}
}

/* ---------- Multiple questions in one card ---------- */

.d360es__q + .d360es__q {
	margin-top: 18px;
	padding-top: 16px;
	border-top: 1px solid var(--d360es-border);
}

/* Follow-up questions are subordinate to the first, so they read smaller. */
.d360es__question--sub {
	margin-right: 0;
	font-size: 14px;
	font-weight: 600;
	color: var(--d360es-text);
}

.d360es__req {
	color: var(--d360es-error);
	margin-left: 2px;
}

/* With several questions the card can outgrow a short viewport. */
.d360es--center .d360es__dialog {
	max-height: calc(100vh - 48px);
	overflow-y: auto;
}

/* ---------- Stepper ---------- */

/* One question at a time. Without JS every question is visible, which degrades to the
   stacked layout rather than to a blank card. */
.d360es--stepper .d360es__q {
	display: none;
}

.d360es--stepper .d360es__q.is-current {
	display: block;
}

/* The separators only make sense when questions sit together. */
.d360es--stepper .d360es__q + .d360es__q {
	margin-top: 0;
	padding-top: 0;
	border-top: 0;
}

.d360es__progress {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 34px 16px 0;
}

.d360es__progress-text {
	font-size: 12px;
	font-weight: 600;
	color: var(--d360es-text-muted);
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.02em;
}

.d360es__progress-track {
	display: flex;
	flex: 1 1 auto;
	gap: 5px;
}

.d360es__progress-dot {
	flex: 1 1 auto;
	height: 3px;
	border-radius: 2px;
	background: var(--d360es-border);
	transition: background 0.2s ease;
}

.d360es__progress-dot.is-done,
.d360es__progress-dot.is-current {
	background: var(--d360es-purple);
}

.d360es__progress-dot.is-current {
	box-shadow: 0 0 0 1px var(--d360es-accent-dot);
}

/* Back sits away from Skip/Next so it is not mistaken for the primary path. */
.d360es__back {
	margin-right: auto;
	padding: 8px 10px;
	font-family: inherit;
	font-size: 14px;
	color: var(--d360es-text-muted);
	background: none;
	border: 0;
	border-radius: 6px;
	cursor: pointer;
	transition: color 0.15s ease;
}

.d360es__back:hover,
.d360es__back:focus-visible {
	color: var(--d360es-text);
}

.d360es__back[hidden] {
	display: none;
}
