/*
 * WyverBox.
 *
 * Every visual decision is a custom property on .wyv. To reskin a demo, set
 * them in your theme or in a preset's `theme` array — no need to touch this
 * file:
 *
 *   .wyv--artist { --wyv-accent: #7c3aed; --wyv-radius: 20px; }
 */

.wyv {
	--wyv-paper: #f6f7f9;
	--wyv-surface: #ffffff;
	--wyv-ink: #141a24;
	--wyv-muted: #5b6472;
	--wyv-line: #dde2ea;
	--wyv-accent: #2f3fa0;
	--wyv-accent-soft: #eceefa;
	--wyv-radius: 14px;
	--wyv-font: inherit;
	--wyv-font-size: 1rem;
	--wyv-log-height: 420px;
	--wyv-gap: 18px;

	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	max-width: 760px;
	margin-inline: auto;
	font-family: var(--wyv-font);
	font-size: var(--wyv-font-size);
	line-height: 1.5;
	color: var(--wyv-ink);
	background: var(--wyv-surface);
	border: 1px solid var(--wyv-line);
	border-radius: var(--wyv-radius);
	overflow: hidden;
}

.wyv *,
.wyv *::before,
.wyv *::after {
	box-sizing: inherit;
}

/* ---------- head ---------- */

.wyv-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding: 14px var(--wyv-gap);
	background: var(--wyv-paper);
	border-bottom: 1px solid var(--wyv-line);
}

.wyv-title {
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
}

.wyv-badge {
	flex: none;
	padding: 2px 9px;
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--wyv-accent);
	background: var(--wyv-accent-soft);
	border-radius: 999px;
}

/* ---------- transcript ---------- */

.wyv-log {
	display: flex;
	flex-direction: column;
	gap: var(--wyv-gap);
	min-height: 180px;
	max-height: var(--wyv-log-height);
	padding: var(--wyv-gap);
	overflow-y: auto;
	overscroll-behavior: contain;
}

.wyv-intro {
	max-width: 58ch;
	margin: 0;
	color: var(--wyv-muted);
}

.wyv-q {
	align-self: flex-end;
	max-width: 85%;
	margin: 0;
	padding: 9px 14px;
	color: #fff;
	background: var(--wyv-accent);
	border-radius: var(--wyv-radius) var(--wyv-radius) 4px var(--wyv-radius);
	overflow-wrap: anywhere;
}

/* An answer and its blocks hang together on one thread. */
.wyv-a {
	position: relative;
	padding-left: 18px;
}

.wyv-a::before {
	content: "";
	position: absolute;
	inset-block: 6px;
	left: 0;
	width: 2px;
	background: var(--wyv-accent);
	border-radius: 2px;
}

.wyv-a.is-error::before {
	background: var(--wyv-line);
}

.wyv-a.is-error .wyv-text {
	color: var(--wyv-muted);
}

.wyv-block + .wyv-block {
	margin-top: 12px;
}

.wyv-text {
	margin: 0;
	max-width: 64ch;
	overflow-wrap: anywhere;
}

.wyv-text + .wyv-text {
	margin-top: 8px;
}

.wyv-cap {
	margin: 0 0 6px;
	font-size: 0.875rem;
	font-weight: 600;
}

.wyv-note {
	margin: 6px 0 0;
	font-size: 0.8125rem;
	color: var(--wyv-muted);
}

/* ---------- table block ---------- */

.wyv-scroll {
	overflow-x: auto;
	border: 1px solid var(--wyv-line);
	border-radius: 10px;
}

.wyv table {
	width: 100%;
	margin: 0;
	border-collapse: collapse;
	font-size: 0.875rem;
	font-variant-numeric: tabular-nums;
	background: var(--wyv-surface);
}

.wyv th,
.wyv td {
	padding: 7px 12px;
	text-align: right;
	white-space: nowrap;
	border: 0;
	border-bottom: 1px solid var(--wyv-line);
}

.wyv th {
	font-weight: 600;
	color: var(--wyv-muted);
	background: var(--wyv-paper);
}

.wyv th:first-child,
.wyv td:first-child {
	text-align: left;
}

.wyv tr:last-child td {
	border-bottom: 0;
}

/* ---------- image, html and action blocks ---------- */

.wyv-figure {
	margin: 0;
}

.wyv-figure img {
	display: block;
	max-width: 100%;
	height: auto;
	border-radius: 10px;
}

.wyv-figure figcaption {
	margin-top: 6px;
	font-size: 0.8125rem;
	color: var(--wyv-muted);
}

.wyv-html > :first-child {
	margin-top: 0;
}

.wyv-html > :last-child {
	margin-bottom: 0;
}

.wyv-html a {
	color: var(--wyv-accent);
}

.wyv-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.wyv-action {
	display: inline-flex;
	align-items: center;
	min-height: 38px;
	padding: 0 14px;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--wyv-accent);
	text-decoration: none;
	background: var(--wyv-accent-soft);
	border-radius: 999px;
}

.wyv-action:hover,
.wyv-action:visited {
	color: var(--wyv-accent);
}

/* ---------- evidence ---------- */

.wyv details {
	margin-top: 10px;
}

.wyv summary {
	display: inline-block;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--wyv-accent);
	cursor: pointer;
}

.wyv pre {
	margin: 6px 0 0;
	padding: 10px 12px;
	font: 0.8125rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	background: var(--wyv-accent-soft);
	border-radius: 10px;
}

/* ---------- waiting ---------- */

.wyv-wait {
	display: inline-flex;
	gap: 5px;
	padding: 6px 0;
}

.wyv-wait i {
	width: 6px;
	height: 6px;
	background: var(--wyv-accent);
	border-radius: 50%;
	animation: wyv-beat 1s infinite ease-in-out;
}

.wyv-wait i:nth-child(2) { animation-delay: 0.15s; }
.wyv-wait i:nth-child(3) { animation-delay: 0.3s; }

@keyframes wyv-beat {
	0%, 80%, 100% { opacity: 0.25; }
	40% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.wyv-wait i { animation: none; opacity: 0.6; }
}

/* ---------- starter questions ---------- */

.wyv-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 var(--wyv-gap) 14px;
}

.wyv-chip {
	padding: 6px 12px;
	font: inherit;
	font-size: 0.875rem;
	color: var(--wyv-accent);
	text-align: left;
	background: var(--wyv-accent-soft);
	border: 0;
	border-radius: 999px;
	cursor: pointer;
}

/* ---------- composer ---------- */

.wyv-gate:not(:empty) {
	padding: 0 var(--wyv-gap);
	background: var(--wyv-paper);
}

.wyv-form {
	display: flex;
	gap: 10px;
	align-items: flex-end;
	padding: 12px var(--wyv-gap);
	background: var(--wyv-paper);
	border-top: 1px solid var(--wyv-line);
}

.wyv-input {
	flex: 1;
	min-height: 44px;
	max-height: 132px;
	padding: 10px 12px;
	font: inherit;
	color: var(--wyv-ink);
	resize: none;
	background: var(--wyv-surface);
	border: 1px solid var(--wyv-line);
	border-radius: 10px;
}

.wyv-send,
.wyv-cta {
	flex: none;
	min-height: 44px;
	padding: 0 18px;
	font: inherit;
	font-weight: 600;
	color: #fff;
	text-decoration: none;
	background: var(--wyv-ink);
	border: 0;
	border-radius: 10px;
	cursor: pointer;
}

.wyv-send[disabled] {
	opacity: 0.45;
	cursor: default;
}

.wyv-cta {
	display: inline-flex;
	align-items: center;
	margin-top: 10px;
	background: var(--wyv-accent);
}

.wyv-cta:hover,
.wyv-cta:visited {
	color: #fff;
}

.wyv-foot {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin: 0;
	padding: 0 var(--wyv-gap) 12px;
	font-size: 0.8125rem;
	color: var(--wyv-muted);
	background: var(--wyv-paper);
}

.wyv-foot:empty,
.wyv-form.is-done {
	display: none;
}

.wyv summary:focus-visible,
.wyv button:focus-visible,
.wyv a:focus-visible,
.wyv textarea:focus-visible {
	outline: 2px solid var(--wyv-accent);
	outline-offset: 2px;
}

@media (max-width: 480px) {
	.wyv { --wyv-gap: 14px; --wyv-log-height: 360px; }
	.wyv-q { max-width: 92%; }
}
