/* Chat widget, styled like the rest of the site (black and brass) */

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

#chat-toggle {
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	z-index: 50;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.8rem 1.2rem;
	border: 1px solid var(--gold, #c9a64e);
	border-radius: 2rem;
	background: #000;
	color: var(--gold, #c9a64e);
	font: 500 1rem var(--sans, sans-serif);
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#chat-toggle svg {
	width: 1.25rem;
	height: 1.25rem;
}

#chat-toggle.unread::after {
	content: "";
	position: absolute;
	top: 0.2rem;
	right: 0.35rem;
	width: 0.7rem;
	height: 0.7rem;
	border-radius: 50%;
	background: #c0392b;
	border: 2px solid #000;
}

#chat-panel {
	--chat-bg: #fff;
	--chat-bubble: #fff;
	--chat-input: #fff;
	--chat-border: #ddd;
	position: fixed;
	right: 1.25rem;
	bottom: 5.25rem;
	z-index: 50;
	width: 22rem;
	max-width: calc(100vw - 2rem);
	height: 30rem;
	max-height: calc(100vh - 7rem);
	display: flex;
	flex-direction: column;
	background: var(--chat-bg);
	color: var(--ink, #23221f);
	border: 1px solid #000;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

#chat-panel[hidden] {
	display: none;
}

#chat-panel > header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.8rem 1rem;
	background: #000;
	color: var(--gold, #c9a64e);
}

#chat-panel > header strong {
	display: block;
	font-family: var(--serif, serif);
	font-weight: 500;
	letter-spacing: 0.04em;
}

#chat-status {
	font-size: 0.8rem;
	opacity: 0.75;
}

#chat-close {
	background: none;
	border: 0;
	color: var(--gold, #c9a64e);
	font-size: 1.6rem;
	line-height: 1;
	cursor: pointer;
	padding: 0 0.25rem;
}

#chat-messages {
	flex: 1;
	overflow-y: auto;
	list-style: none;
	margin: 0;
	padding: 1rem;
	background: var(--stone, #ecebe8);
}

#chat-messages li {
	max-width: 85%;
	margin-bottom: 0.6rem;
	padding: 0.55rem 0.8rem;
	background: var(--chat-bubble);
	border-radius: 2px;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
}

#chat-messages li.mine {
	margin-left: auto;
	background: #000;
	color: #eee7d3;
}

#chat-messages li.chat-welcome {
	max-width: none;
	background: none;
	color: var(--ink-soft, #57544d);
	font-size: 0.95rem;
	padding: 0;
}

.chat-meta {
	font-size: 0.75rem;
	opacity: 0.7;
	margin-bottom: 0.15rem;
}

#chat-form {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	padding: 0.75rem;
	border-top: 1px solid var(--chat-border);
}

#chat-form input {
	min-width: 0;
	padding: 0.6rem 0.7rem;
	border: 1px solid #bbb;
	border-radius: 2px;
	background: var(--chat-input);
	font: 1rem var(--sans, sans-serif);
	color: inherit;
}

#chat-name {
	width: 100%;
}

#chat-text {
	flex: 1;
}

#chat-form button {
	padding: 0.6rem 1rem;
	border: 0;
	border-radius: 2px;
	background: #000;
	color: var(--gold, #c9a64e);
	font: 500 1rem var(--sans, sans-serif);
	cursor: pointer;
}

.chat-privacy {
	width: 100%;
	margin: 0;
	font-size: 0.75rem;
	line-height: 1.4;
	color: var(--ink-soft, #57544d);
}

.chat-privacy a {
	color: inherit;
}

/* Consent, "no" and reCAPTCHA steps in front of the message form */
#chat-form[hidden] {
	display: none;
}

.chat-gate {
	flex: none;
	max-height: 75%;
	overflow-y: auto;
	padding: 0.75rem;
	border-top: 1px solid var(--chat-border);
	font-size: 0.9rem;
	line-height: 1.45;
}

.chat-gate p {
	margin: 0 0 0.6rem;
}

.chat-gate a {
	color: inherit;
}

.chat-gate-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 0.6rem;
}

.chat-gate button {
	padding: 0.6rem 1rem;
	border: 1px solid #000;
	border-radius: 2px;
	background: #000;
	color: var(--gold, #c9a64e);
	font: 500 1rem var(--sans, sans-serif);
	cursor: pointer;
}

.chat-gate button.quiet {
	background: transparent;
	border-color: #888;
	color: inherit;
}

.chat-error {
	color: #a4262c;
	font-weight: 500;
}

.chat-typing {
	padding: 0.4rem 0.8rem;
	font-size: 0.8rem;
	font-style: italic;
	color: var(--ink-soft, #57544d);
	background: var(--chat-bg, #fff);
	border-top: 1px dashed var(--chat-border);
	animation: chat-pulse 1.5s infinite ease-in-out;
}

@keyframes chat-pulse {
	0%, 100% { opacity: 0.6; }
	50% { opacity: 1; }
}

@media (max-width: 480px) {
	#chat-toggle span {
		display: none;
	}

	#chat-toggle {
		padding: 0.9rem;
	}
}

@media (prefers-color-scheme: dark) {
	#chat-panel {
		--chat-bg: #1c1b18;
		--chat-bubble: #2e2c27;
		--chat-input: #252420;
		--chat-border: #3d3a33;
		border-color: #3d3a33;
	}

	#chat-form input {
		border-color: #4a463d;
	}

	.chat-gate button {
		border-color: #3d3a33;
	}

	.chat-error {
		color: #ff8a80;
	}

	#chat-messages li.mine {
		background: #3a3120;
	}
}
