/*
 * Publication chat box: look and feel.
 *
 * Loaded by the plugin by default. To manage these styles in the theme instead, paste this file into the
 * theme stylesheet and untick "Load the plugin's chat box styling" in Settings > Publication Chat.
 * (Functional styles such as the streaming caret live in chat.css and always load.)
 *
 * Colours come from the theme's custom properties, with fallbacks so the box also works elsewhere:
 *   --urbedtrust-canopy     the green frame
 *   --urbedtrust-darkgrey   text
 *   --urbedtrust-transport  the Ask button
 *
 * Design: the brand-green frame holds only the heading (large white text passes contrast on the green);
 * everything a visitor has to read sits on a white panel inside it.
 */

.upchat {
	--upchat-green: var(--urbedtrust-canopy, #74a30f);
	--upchat-ink: var(--urbedtrust-darkgrey, #5d5850);
	--upchat-accent: var(--urbedtrust-transport, #bc1823);
	--upchat-tint: #f1f6e3;
	--upchat-line: #dcd9d0;
	--upchat-slab: "Egyptian Slate Pro", Georgia, "Times New Roman", serif;
}

@supports (background: color-mix(in srgb, red, blue)) {
	.upchat {
		--upchat-tint: color-mix(in srgb, var(--upchat-green) 13%, #fff);
	}
}

/* Frame */
.entry-chat.upchat {
	background: var(--upchat-green);
	padding: 1.25rem;
	margin: 2rem 0;
	border-radius: 4px;
}

.upchat .upchat-title {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin: 0 0 1rem;
	font-size: 1.75rem;
	line-height: 1.2;
	color: #fff;
}

.upchat .upchat-title .dashicons {
	flex: none;
	width: 34px;
	height: 34px;
	font-size: 34px;
}

/* White panel */
.upchat .upchat-panel {
	background: #fff;
	color: var(--upchat-ink);
	padding: 1.5rem;
	border-radius: 3px;
}

.upchat .upchat-panel p {
	margin: 0 0 1rem;
	font-size: 1rem;
	line-height: 1.55;
	color: inherit;
}

.upchat .upchat-intro {
	max-width: 62ch;
}

/* Example questions as chips */
.upchat .chat-samples {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0 0 1.25rem;
	padding: 0;
	list-style: none;
}

.upchat .chat-samples li {
	margin: 0;
	padding: 0;
	font-size: 1rem;
}

/* !important: the theme's legacy ".entry-chat a { color: white !important }" would otherwise make these invisible. */
.entry-chat.upchat .chat-samples a {
	display: block;
	padding: 0.4rem 0.9rem;
	border: 1px solid var(--upchat-green);
	border-radius: 1.1rem;
	background: #fff;
	color: var(--upchat-ink) !important;
	font-size: 0.95rem;
	line-height: 1.35;
	text-decoration: none;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.entry-chat.upchat .chat-samples a:hover,
.entry-chat.upchat .chat-samples a:focus-visible {
	background: var(--upchat-tint);
	border-color: var(--upchat-ink);
}

.upchat .chat-samples a:focus-visible,
.upchat .upchat-actions button:focus-visible {
	outline: 2px solid var(--upchat-ink);
	outline-offset: 2px;
}

/* Question box and button */
.upchat .upchat-form {
	display: flex;
	gap: 0.5rem;
	align-items: stretch;
	margin: 0 0 1.25rem;
}

.upchat .upchat-form textarea {
	flex: 1 1 auto;
	width: auto;
	min-width: 0;
	min-height: 3.4rem;
	padding: 0.6rem 0.75rem;
	border: 1px solid #b9b5ac;
	border-radius: 3px;
	color: var(--upchat-ink);
	font-family: var(--upchat-slab);
	font-size: 1.05rem;
	line-height: 1.4;
	resize: vertical;
}

.upchat .upchat-form textarea:focus {
	border-color: var(--upchat-green);
	outline: 2px solid var(--upchat-green);
	outline-offset: 1px;
}

.upchat .upchat-form > p {
	display: flex;
	margin: 0;
}

.entry-chat.upchat .upchat-submit {
	text-align: center;
	min-width: 5.5rem;
	padding: 0.5rem 1.25rem;
	border: 0;
	border-radius: 3px;
	background: var(--upchat-accent);
	color: #fff;
	font-size: 1.05rem;
	font-weight: 700;
	cursor: pointer;
}

.entry-chat.upchat .upchat-submit:hover:not([disabled]),
.entry-chat.upchat .upchat-submit:focus-visible {
	background: color-mix(in srgb, var(--upchat-accent) 85%, #000);
}

/* The question asked, shown above its answer */
.upchat .upchat-asked {
	margin: 0 0 0.5rem;
	font-size: 1rem;
}

.upchat .upchat-asked[hidden] {
	display: none;
}

.upchat .upchat-asked span {
	display: block;
	font-size: 0.72rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	opacity: 0.85;
}

.upchat .upchat-asked strong {
	font-weight: 700;
}

/* Answer */
.upchat .chat-response {
	margin: 0 0 0.5rem;
	padding: 1rem 1.25rem;
	/* border-left: 4px solid var(--upchat-green); */
	border-radius: 0 3px 3px 0;
	background: var(--upchat-tint);
	color: var(--upchat-ink);
	font-family: var(--upchat-slab);
	line-height: 1.5;
}

/* Beats the theme's bare "li { font-size: 1.2rem }" inside the chat box. */
.upchat .chat-response p,
.upchat .chat-response li {
	font-size: 1.15rem !important;
	line-height: 1.5;
}

.upchat .chat-response ul,
.upchat .chat-response ol {
	margin: 0 0 1rem;
	padding-left: 1.25rem;
}

.upchat .chat-response li {
	margin-bottom: 0.35rem;
}

.upchat .chat-response > :last-child {
	margin-bottom: 0;
}

.upchat .chat-response.upchat-empty,
.upchat .chat-response.upchat-waiting {
	font-style: normal;
	opacity: 0.85;
}

/* Copy / Clear */
.upchat .upchat-actions {
	display: flex;
	gap: 1.25rem;
	margin: 0 0 1rem;
}

.upchat .upchat-actions[hidden] {
	display: none;
}

.upchat .upchat-actions button {
	padding: 0.25rem 0;
	border: 0;
	background: none;
	color: var(--upchat-ink);
	font-size: 0.9rem;
	text-decoration: underline;
	cursor: pointer;
}

.upchat .upchat-actions button:hover {
	text-decoration: none;
}

.upchat .upchat-panel .upchat-remaining {
	margin: 0 0 1rem;
	font-size: 0.9rem;
}

.upchat .upchat-panel .upchat-disclaimer {
	margin: 1rem 0 0;
	padding-top: 0.9rem;
	border-top: 1px solid var(--upchat-line);
	font-size: 0.85rem;
	line-height: 1.5;
}

/* Narrow screens: stack everything */
@media (max-width: 575px) {
	.entry-chat.upchat {
		padding: 1rem;
	}

	.upchat .upchat-title {
		font-size: 1.5rem;
	}

	.upchat .upchat-panel {
		padding: 1rem;
	}

	.upchat .chat-samples {
		flex-direction: column;
	}

	.entry-chat.upchat .chat-samples a {
		border-radius: 0.6rem;
	}

	.upchat .upchat-form {
		flex-direction: column;
	}

	.upchat .upchat-form > p {
		display: block;
	}

	.entry-chat.upchat .upchat-submit {
		width: 100%;
		padding: 0.7rem;
	}

	.upchat .chat-response {
		padding: 0.9rem 1rem;
	}
}
