/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * The Islands demo: the page around the islands, and the chat islands themselves, the React one
 * and the Svelte one sharing these classes. All in the colors of the theme.
 */

.islands {
	display: grid;
	gap: 1em;
}

.islands__intro {
	margin: 0;
}

.islands__container {
	display: grid;
	gap: 0.4em;
	padding: 0.75em;
	border: 1px dashed var(--antilia-theme-border, #ccc);
	border-radius: 0.5em;
}

.islands__rendered {
	margin: 0;
	font-size: 0.85em;
	color: color-mix(in srgb, var(--antilia-theme-text, #222) 65%, transparent);
}

.islands__chats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 22em), 1fr));
	gap: 1em;
}

.islands__island {
	min-width: 0;
}

/* the panel of the server, rendered by Wicket */

.islands__server {
	display: grid;
	gap: 0.6em;
	padding: 0.75em 1em;
	border: 1px solid var(--antilia-theme-border, #ccc);
	border-radius: 0.5em;
	background: color-mix(in srgb, var(--antilia-theme-primary, #2f5bd3) 4%,
		var(--antilia-theme-surface, #ffffff));
}

.islands__server-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5em;
}

.islands__server-title {
	margin: 0;
	font-size: 1.1em;
}

.islands__count,
.islands__none,
.islands__hint {
	margin: 0;
}

.islands__none,
.islands__hint {
	font-size: 0.9em;
	color: color-mix(in srgb, var(--antilia-theme-text, #222) 70%, transparent);
}

.islands__events {
	display: grid;
	gap: 0.25em;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 0.9em;
}

.islands__event {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
}

.islands__event-time {
	font-variant-numeric: tabular-nums;
	color: color-mix(in srgb, var(--antilia-theme-text, #222) 65%, transparent);
}

.islands__event-who {
	font-weight: 600;
}

.islands__event-what {
	overflow-wrap: anywhere;
}

.islands__event-question::before {
	content: "“";
}

.islands__event-question::after {
	content: "”";
}

.islands__event-outcome::before {
	content: "→ ";
}

.islands__form {
	display: grid;
	gap: 0.3em;
}

.islands__form-label {
	font-weight: 600;
}

.islands__form-row {
	display: flex;
	gap: 0.5em;
}

.islands__form-input {
	flex: 1;
	min-width: 0;
}

.islands__form-input,
.chat__input {
	box-sizing: border-box;
	padding: 0.4em 0.5em;
	border: 1px solid var(--antilia-theme-border, #ccc);
	border-radius: 0.4em;
	font: inherit;
	color: inherit;
	background: var(--antilia-theme-surface, #ffffff);
}

.islands__form-input:focus-visible,
.chat__input:focus-visible {
	outline: 2px solid var(--antilia-theme-primary, #2f5bd3);
	outline-offset: 1px;
}

.islands__form-message {
	margin: 0;
	color: var(--antilia-theme-error, #c62828);
}

.islands__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
}

/* the chat islands */

.chat {
	display: flex;
	flex-direction: column;
	gap: 0.5em;
	height: 32em;
	padding: 0.75em;
	border: 1px solid var(--antilia-theme-border, #ccc);
	border-radius: 0.5em;
	background: var(--antilia-theme-surface, #ffffff);
	color: var(--antilia-theme-text, #222);
}

.chat__header {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5em;
}

.chat__badge {
	padding: 0.1em 0.6em;
	border: 1px solid transparent;
	border-radius: 1em;
	font-size: 0.85em;
	font-weight: 600;
	color: var(--antilia-theme-on-primary, #fff);
	background: var(--antilia-theme-primary, #2f5bd3);
}

.chat--svelte .chat__badge {
	border: 1px solid var(--antilia-theme-primary, #2f5bd3);
	color: var(--antilia-theme-primary, #2f5bd3);
	background: transparent;
}

.chat__life {
	font-size: 0.8em;
	font-variant-numeric: tabular-nums;
	color: color-mix(in srgb, var(--antilia-theme-text, #222) 65%, transparent);
}

/* the scrolling div of a Scrollable fills the chat between its header and its form */
.chat > .antilia-scrollbar {
	flex: 1;
	min-height: 0;
}

.chat__messages {
	display: flex;
	flex-direction: column;
	gap: 0.5em;
	box-sizing: border-box;
	height: 100%;
	padding: 0.25em 0.5em 0.25em 0.25em;
	overflow-y: auto;
}

.chat__empty {
	margin: auto 0;
	text-align: center;
	color: color-mix(in srgb, var(--antilia-theme-text, #222) 65%, transparent);
}

.chat__message {
	display: grid;
	gap: 0.2em;
	max-width: 85%;
	padding: 0.45em 0.7em;
	border-radius: 0.7em;
	border: 1px solid transparent;
}

.chat__message--user {
	align-self: flex-end;
	background: color-mix(in srgb, var(--antilia-theme-primary, #2f5bd3) 14%,
		var(--antilia-theme-surface, #ffffff));
}

.chat__message--wicket {
	align-self: flex-start;
	background: var(--antilia-theme-surface-alt, #f3f4f6);
}

.chat__message--pending {
	opacity: 0.6;
}

.chat__message--answer {
	border-color: var(--antilia-theme-primary, #2f5bd3);
}

.chat__author {
	font-size: 0.75em;
	font-weight: 600;
	color: color-mix(in srgb, var(--antilia-theme-text, #222) 70%, transparent);
}

.chat__text {
	margin: 0;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.chat__code {
	margin: 0;
	padding: 0.4em 0.6em;
	overflow-x: auto;
	border-radius: 0.3em;
	font-size: 0.85em;
	background: color-mix(in srgb, var(--antilia-theme-text, #222) 7%, transparent);
}

.chat__link {
	justify-self: start;
	color: var(--antilia-theme-primary, #2f5bd3);
}

.chat__time {
	justify-self: end;
	font-size: 0.7em;
	color: color-mix(in srgb, var(--antilia-theme-text, #222) 60%, transparent);
}

.chat__thinking {
	align-self: flex-start;
	margin: 0;
	font-size: 0.85em;
	font-style: italic;
	color: color-mix(in srgb, var(--antilia-theme-text, #222) 65%, transparent);
}

.chat__suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35em;
}

.chat__suggestion {
	padding: 0.2em 0.7em;
	border: 1px solid var(--antilia-theme-border, #ccc);
	border-radius: 1em;
	font: inherit;
	font-size: 0.8em;
	color: inherit;
	background: transparent;
	cursor: pointer;
}

.chat__suggestion:hover,
.chat__suggestion:focus-visible {
	border-color: var(--antilia-theme-primary, #2f5bd3);
	background: var(--antilia-theme-hover, rgba(0, 0, 0, 0.05));
}

.chat__form {
	display: flex;
	align-items: flex-end;
	gap: 0.5em;
}

.chat__input {
	flex: 1;
	min-width: 0;
	resize: none;
}

.chat__error,
.chat__status {
	margin: 0;
	font-size: 0.85em;
}

.chat__error {
	color: var(--antilia-theme-error, #c62828);
}

.chat__status {
	color: color-mix(in srgb, var(--antilia-theme-text, #222) 70%, transparent);
}
