/**
 * The ask box.
 *
 * Two parts: a trigger that lives in the page and must sit quietly inside whatever
 * the theme puts around it, and a dialog that owns its own surface and therefore
 * states every colour it uses.
 *
 * Colours are cdesk.sk's own, read off the live site rather than chosen: #FF6A00 is
 * the accent, headings are Rubik, body text is Roboto at #777, and a 6px orange rule
 * across the top of a panel is the house device. There is deliberately no dark
 * variant - cdesk.sk is white in every browser, light mode or dark.
 *
 * Every rule is prefixed .cdesk-rag- and every property the theme might otherwise
 * supply is stated, because this runs inside someone else's stylesheet.
 */

.cdesk-rag-scrim,
.cdesk-rag-open {
	--cdesk-rag-orange: #ff6a00;
	--cdesk-rag-orange-2: #ed7825;
	--cdesk-rag-ink: #000;
	--cdesk-rag-body: #777;
	--cdesk-rag-line: #e2e4e6;
	--cdesk-rag-sub: #f4f5f6;
	--cdesk-rag-paper: #fff;
}

/* Most themes define this, but not all, and a visible duplicate label looks like a
   bug. Scoped so it cannot affect anything else on the page. */
.cdesk-rag-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* =========================================================================
   The trigger
   ========================================================================= */
.cdesk-rag-open {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 7px 18px 7px 8px;
	font-family: Rubik, Roboto, inherit;
	font-size: 0.9375rem;
	font-weight: 400;
	line-height: 1.2;
	color: inherit;
	background: transparent;
	border: 1px solid currentColor;
	border-radius: 50px;
	cursor: pointer;
	text-decoration: none;
	transition: color 0.18s, border-color 0.18s;
	-webkit-appearance: none;
	appearance: none;
}
.cdesk-rag-open:hover,
.cdesk-rag-open:focus-visible {
	color: var(--cdesk-rag-orange);
	border-color: var(--cdesk-rag-orange);
}

/* In a menu or a header bar: the magnifier alone, no chrome around it. */
.cdesk-rag-open-bare {
	padding: 0;
	border: 0;
	border-radius: 50%;
	width: 44px;
	height: 44px;
	justify-content: center;
	gap: 0;
}

.cdesk-rag-lupa {
	position: relative;
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	flex: none;
}
.cdesk-rag-open-bare .cdesk-rag-lupa { width: 44px; height: 44px; }

/* the halo, breathing */
.cdesk-rag-lupa::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(255, 106, 0, 0.42), rgba(255, 106, 0, 0) 68%);
	animation: cdesk-rag-breathe 3.6s ease-in-out infinite;
}
.cdesk-rag-open:hover .cdesk-rag-lupa::before { animation-duration: 1.8s; }

.cdesk-rag-lupa-icon {
	position: relative;
	width: 21px;
	height: 21px;
	display: block;
}
.cdesk-rag-glass {
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
}
/* the specular streak crossing the lens */
.cdesk-rag-sweep {
	fill: var(--cdesk-rag-orange);
	opacity: 0.9;
	animation: cdesk-rag-sweep 4.2s cubic-bezier(0.5, 0, 0.2, 1) infinite;
}

.cdesk-rag-spark {
	position: absolute;
	width: 7px;
	height: 7px;
	color: var(--cdesk-rag-orange);
	animation: cdesk-rag-twinkle 2.8s ease-in-out infinite;
}
.cdesk-rag-spark svg { width: 100%; height: 100%; display: block; fill: currentColor; }
.cdesk-rag-spark-a { top: 0; right: 1px; }
.cdesk-rag-spark-b { bottom: 2px; left: 0; width: 5px; height: 5px; animation-delay: 1.15s; }
.cdesk-rag-open-bare .cdesk-rag-spark-a { top: 5px; right: 6px; }
.cdesk-rag-open-bare .cdesk-rag-spark-b { bottom: 8px; left: 5px; }

@keyframes cdesk-rag-breathe {
	0%, 100% { opacity: 0.2; transform: scale(0.8); }
	50%      { opacity: 0.55; transform: scale(1); }
}
@keyframes cdesk-rag-sweep {
	0%, 62%   { transform: translateX(-16px); }
	78%, 100% { transform: translateX(16px); }
}
@keyframes cdesk-rag-twinkle {
	0%, 72%, 100% { opacity: 0; transform: scale(0.4) rotate(0deg); }
	84%           { opacity: 1; transform: scale(1) rotate(35deg); }
}

/* =========================================================================
   The dialog
   ========================================================================= */
.cdesk-rag-scrim {
	position: fixed;
	inset: 0;
	/* Above Popup Maker, the sticky header and the cookie bar. */
	z-index: 999990;
	display: grid;
	align-items: start;
	justify-items: center;
	padding: 7vh 16px 24px;
	overflow-y: auto;
	background: rgba(33, 38, 41, 0.72);
	animation: cdesk-rag-fade 0.2s ease-out;
	box-sizing: border-box;
}
.cdesk-rag-scrim[hidden] { display: none; }
.cdesk-rag-scrim *,
.cdesk-rag-scrim *::before,
.cdesk-rag-scrim *::after { box-sizing: border-box; }

@keyframes cdesk-rag-fade { from { opacity: 0; } }

.cdesk-rag-panel {
	position: relative;
	width: 100%;
	max-width: 760px;
	background: var(--cdesk-rag-paper);
	/* the house device, same as the cards on cdesk.sk */
	border-top: 6px solid var(--cdesk-rag-orange);
	box-shadow: 0 26px 64px -16px rgba(33, 38, 41, 0.42);
	font-family: Roboto, -apple-system, "Segoe UI", sans-serif;
	font-size: 16px;
	line-height: 1.5;
	color: var(--cdesk-rag-body);
	text-align: left;
	animation: cdesk-rag-drop 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes cdesk-rag-drop { from { opacity: 0; transform: translateY(-14px); } }

.cdesk-rag-close {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 34px;
	height: 34px;
	display: grid;
	place-items: center;
	padding: 0;
	font-size: 21px;
	line-height: 1;
	color: var(--cdesk-rag-body);
	background: transparent;
	border: 0;
	border-radius: 0;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}
.cdesk-rag-close:hover { color: var(--cdesk-rag-ink); background: transparent; }

/* ---- the one field ---- */
.cdesk-rag-form {
	display: flex;
	align-items: center;
	gap: 14px;
	/* right padding clears the close button in the corner */
	padding: 12px 52px 12px 22px;
	margin: 0;
}
.cdesk-rag-form[hidden] { display: none; }

.cdesk-rag-icon {
	flex: none;
	width: 21px;
	height: 21px;
	color: var(--cdesk-rag-orange);
}
.cdesk-rag-icon svg {
	width: 100%;
	height: 100%;
	display: block;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
}

/* Two class names deep and qualified by the element, because a theme's own
   `input[type="text"]` colour rule outranks a single class and greys out what the
   visitor is typing. -webkit-text-fill-color is the other half: Safari and Chrome
   paint the text with that rather than `color` inside an autofilled field. */
.cdesk-rag-panel input.cdesk-rag-q {
	flex: 1 1 auto;
	min-width: 0;
	width: auto;
	margin: 0;
	padding: 15px 0;
	font-family: inherit;
	font-size: 1.1875rem;
	line-height: 1.4;
	color: var(--cdesk-rag-ink);
	-webkit-text-fill-color: var(--cdesk-rag-ink);
	opacity: 1;
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}
.cdesk-rag-panel input.cdesk-rag-q::placeholder {
	color: var(--cdesk-rag-body);
	-webkit-text-fill-color: var(--cdesk-rag-body);
	opacity: 1;
}

.cdesk-rag-go,
.cdesk-rag-again {
	flex: none;
	font-family: Roboto, inherit;
	font-size: 0.9375rem;
	font-weight: 400;
	line-height: 1.2;
	border-radius: 50px;
	cursor: pointer;
	text-decoration: none;
	transition: background 0.18s, color 0.18s, border-color 0.18s;
	-webkit-appearance: none;
	appearance: none;
}
.cdesk-rag-go {
	padding: 11px 26px;
	color: #fff;
	background: var(--cdesk-rag-orange);
	border: 1px solid var(--cdesk-rag-orange);
}
.cdesk-rag-go:hover:not([disabled]) {
	background: var(--cdesk-rag-orange-2);
	border-color: var(--cdesk-rag-orange-2);
	color: #fff;
}
.cdesk-rag-go[disabled] { opacity: 0.4; cursor: default; }

.cdesk-rag-again {
	padding: 9px 22px;
	color: var(--cdesk-rag-ink);
	background: transparent;
	border: 1px solid var(--cdesk-rag-ink);
}
.cdesk-rag-again:hover { background: var(--cdesk-rag-ink); color: var(--cdesk-rag-paper); }

/* ---- the question, once asked: it stops being editable ---- */
.cdesk-rag-asked {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	padding: 20px 52px 20px 22px;
	background: var(--cdesk-rag-sub);
	border-bottom: 1px solid var(--cdesk-rag-line);
}
.cdesk-rag-asked[hidden] { display: none; }
.cdesk-rag-asked .cdesk-rag-icon { margin-top: 3px; }
.cdesk-rag-asked-text {
	margin: 0;
	font-family: Rubik, Roboto, inherit;
	font-size: 1.1875rem;
	font-weight: 500;
	line-height: 1.35;
	color: var(--cdesk-rag-ink);
}

.cdesk-rag-body { padding: 24px 22px 26px; }
.cdesk-rag-body[hidden] { display: none; }

/* ---- working ---- */
.cdesk-rag-working-label {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 18px;
	font-family: Rubik, Roboto, inherit;
	font-size: 0.8125rem;
	letter-spacing: 0.02em;
	color: var(--cdesk-rag-body);
}
.cdesk-rag-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--cdesk-rag-orange);
	animation: cdesk-rag-pulse 1.1s ease-in-out infinite;
}
@keyframes cdesk-rag-pulse { 50% { opacity: 0.2; transform: scale(0.65); } }

.cdesk-rag-skeleton { display: grid; gap: 11px; }
.cdesk-rag-skeleton i {
	display: block;
	height: 11px;
	background: linear-gradient(90deg, var(--cdesk-rag-sub) 25%, var(--cdesk-rag-line) 37%, var(--cdesk-rag-sub) 63%);
	background-size: 380% 100%;
	animation: cdesk-rag-shimmer 1.3s linear infinite;
}
.cdesk-rag-skeleton i:nth-child(2) { width: 94%; }
.cdesk-rag-skeleton i:nth-child(3) { width: 87%; }
.cdesk-rag-skeleton i:nth-child(4) { width: 54%; }
@keyframes cdesk-rag-shimmer { to { background-position: -380% 0; } }

/* ---- the answer ---- */
.cdesk-rag-answer {
	/* The answer may legitimately contain line breaks and short lists. */
	white-space: pre-wrap;
	line-height: 1.68;
	font-size: 1rem;
	color: var(--cdesk-rag-ink);
	max-width: 66ch;
}

/* Words are hidden with opacity, never display:none, so the paragraph holds its full
   height from the first frame: nothing reflows as it appears, and a screen reader is
   handed the whole answer at once instead of a stuttering feed. */
.cdesk-rag-w { opacity: 0; transition: opacity 0.14s linear; }
.cdesk-rag-w-on { opacity: 1; }

.cdesk-rag-caret {
	display: inline-block;
	width: 2px;
	height: 1.05em;
	background: var(--cdesk-rag-orange);
	vertical-align: -0.15em;
	margin-left: 1px;
	animation: cdesk-rag-blink 1s steps(1) infinite;
}
@keyframes cdesk-rag-blink { 50% { opacity: 0; } }

/* Sources and buttons wait until the sentence is finished. */
.cdesk-rag-later {
	opacity: 0;
	transform: translateY(5px);
	transition: opacity 0.3s ease, transform 0.3s ease;
}
.cdesk-rag-later-on { opacity: 1; transform: none; }

.cdesk-rag-sources-heading {
	/* The heading carries the gap: there is no wrapper around the list. */
	margin: 28px 0 4px;
	font-family: Rubik, Roboto, inherit;
	font-size: 0.6875rem;
	font-weight: 500;
	letter-spacing: 0.13em;
	text-transform: uppercase;
	color: var(--cdesk-rag-body);
}
.cdesk-rag-sources-heading::after {
	content: "";
	display: block;
	width: 26px;
	height: 3px;
	background: var(--cdesk-rag-orange);
	margin-top: 8px;
}
.cdesk-rag-sources {
	list-style: none;
	margin: 12px 0 0;
	padding: 0;
	counter-reset: cdesk-rag-src;
}
.cdesk-rag-sources li {
	counter-increment: cdesk-rag-src;
	margin: 0;
	padding: 0;
	list-style: none;
}
.cdesk-rag-sources li::before,
.cdesk-rag-sources li::marker { content: none; }

.cdesk-rag-src {
	display: grid;
	grid-template-columns: 20px 1fr;
	gap: 12px;
	align-items: baseline;
	padding: 9px 10px 9px 6px;
	margin: 0 -6px;
	text-decoration: none;
	color: inherit;
	box-shadow: none;
	transition: background 0.15s;
}
a.cdesk-rag-src:hover { background: rgba(255, 106, 0, 0.09); text-decoration: none; color: inherit; }
.cdesk-rag-src::before {
	content: counter(cdesk-rag-src);
	font-family: Rubik, Roboto, inherit;
	font-size: 0.75rem;
	font-weight: 500;
	font-variant-numeric: tabular-nums;
	color: var(--cdesk-rag-orange);
	text-align: right;
}
.cdesk-rag-src-title {
	font-family: Rubik, Roboto, inherit;
	font-weight: 500;
	font-size: 0.9375rem;
	line-height: 1.35;
	color: var(--cdesk-rag-ink);
}
.cdesk-rag-src-section {
	display: block;
	font-family: Roboto, inherit;
	font-weight: 400;
	font-size: 0.8125rem;
	line-height: 1.45;
	color: var(--cdesk-rag-body);
	margin-top: 3px;
}

/* A footnote, not a source: it explains why something has no link. It sits below the
   sources rather than among them. */
.cdesk-rag-no-page {
	margin: 16px 0 0;
	padding-left: 13px;
	border-left: 2px solid var(--cdesk-rag-line);
	font-size: 0.8125rem;
	line-height: 1.6;
	color: var(--cdesk-rag-body);
}

/* What to try next, under a refusal. Quieter than the sentence it follows. */
.cdesk-rag-hint {
	margin: 12px 0 0;
	font-size: 0.9375rem;
	line-height: 1.6;
	color: var(--cdesk-rag-body);
	max-width: 60ch;
}

/* The service could not be reached. Set apart from an answer, because it is not one. */
.cdesk-rag-note {
	margin: 0;
	font-style: italic;
	line-height: 1.6;
	color: var(--cdesk-rag-body);
}

.cdesk-rag-foot {
	margin-top: 28px;
	padding-top: 20px;
	border-top: 1px solid var(--cdesk-rag-line);
}

.cdesk-rag-scrim :focus-visible {
	outline: 2px solid var(--cdesk-rag-orange);
	outline-offset: 3px;
}

@media (max-width: 600px) {
	.cdesk-rag-scrim { padding: 0; }
	.cdesk-rag-panel { max-width: none; min-height: 100%; }
	.cdesk-rag-form { padding: 10px 46px 10px 16px; flex-wrap: wrap; }
	.cdesk-rag-q { flex-basis: 100%; font-size: 1.0625rem; padding-bottom: 6px; }
	.cdesk-rag-go { margin-left: 35px; }
	.cdesk-rag-asked { padding: 16px 46px 16px 16px; }
	.cdesk-rag-asked-text { font-size: 1.0625rem; }
	.cdesk-rag-body { padding: 20px 16px 24px; }
}

@media (prefers-reduced-motion: reduce) {
	.cdesk-rag-scrim,
	.cdesk-rag-scrim *,
	.cdesk-rag-open * {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
	.cdesk-rag-lupa::before { opacity: 0.4; transform: scale(0.95); }
	.cdesk-rag-spark { opacity: 1; }
}
