/*
 * Publication chat box: behaviour only (always loaded). The look lives in chat-box.css.
 */

/* Spam trap: invisible to people, tempting to bots. */
.upchat-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.upchat .upchat-form textarea {
	box-sizing: border-box;
}

.upchat .chat-response[aria-busy="true"] {
	opacity: 0.9;
}

/* A soft caret at the end of an answer while it is still being written. */
.upchat .chat-response.upchat-streaming > :last-child::after {
	content: "\258D";
	margin-left: 0.15em;
	animation: upchat-blink 1s steps(2, start) infinite;
}

@keyframes upchat-blink {
	to {
		visibility: hidden;
	}
}

/* A stored answer has nothing to stream, so its blocks fade in one after another instead. */
.upchat .chat-response.upchat-reveal > * {
	animation: upchat-fade 0.4s ease both;
	animation-delay: calc(var(--i, 0) * 110ms);
}

@keyframes upchat-fade {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.upchat .chat-response.upchat-streaming > :last-child::after,
	.upchat .chat-response.upchat-reveal > * {
		animation: none;
	}
}

.upchat .chat-response.upchat-error {
	font-style: italic;
}

.upchat .upchat-submit[disabled] {
	opacity: 0.6;
	cursor: wait;
}
