/* =====================================================================
 * HFDN Live Chat — 8-bit AOL-style widget
 * Version: 1.1.0
 *
 * Design intent: chunky 2px black borders, no radius, monospace body,
 * HFDN pink title bar, yellow send button, AIM-style colored usernames.
 * Loads everywhere the chat widget renders: homepage Mingle block, single
 * Place / Event / Leaderboard pages.
 *
 * Structural BEM classes (.hfdn-chat__*) are preserved so the JS query
 * selectors remain valid. New visual variants are added as modifier
 * classes (.hfdn-chat__status--live, .hfdn-chat__who--c1, etc.).
 * ===================================================================== */

/* ---------- shared color tokens ---------- */
.hfdn-chat,
.hfdn-live-chat-window {
	--hfdn-chat-ink: #1a1a1a;
	--hfdn-chat-paper: #ffffff;
	--hfdn-chat-pink: #e91e8c;
	--hfdn-chat-yellow: #fbe44a;
	--hfdn-chat-pink-50: #fbeaf0;
	--hfdn-chat-pink-text: #993556;
	--hfdn-chat-pink-text-dark: #4b1528;
	--hfdn-chat-amber-bg: #fac775;
	--hfdn-chat-amber-text: #412402;
	--hfdn-chat-amber-border: #633806;
	--hfdn-chat-muted-bg: #f1efe8;
	--hfdn-chat-muted-text: #444;
	--hfdn-chat-mono: ui-monospace, "Courier New", Menlo, Consolas, monospace;
}

/* ---------- mount wrapper + loading state ---------- */
.hfdn-live-chat-window {
	margin: 0 0 20px;
}

.hfdn-live-chat-window__loading {
	border: 2px solid var(--hfdn-chat-ink);
	background: var(--hfdn-chat-paper);
	padding: 12px 14px;
	color: var(--hfdn-chat-muted-text);
	font-family: var(--hfdn-chat-mono);
	font-size: 12px;
	letter-spacing: 0.02em;
}

/* ---------- container ---------- */
.hfdn-chat {
	border: 2px solid var(--hfdn-chat-ink);
	border-radius: 0;
	background: var(--hfdn-chat-paper);
	box-shadow: none;
	overflow: hidden;
	font-family: var(--hfdn-chat-mono);
	color: var(--hfdn-chat-ink);
}

/* ---------- title bar ---------- */
.hfdn-chat__titlebar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	padding: 6px 10px;
	border-bottom: 2px solid var(--hfdn-chat-ink);
	background: var(--hfdn-chat-pink);
	color: var(--hfdn-chat-paper);
	min-height: 28px;
}

.hfdn-chat__title {
	font-family: var(--hfdn-chat-mono);
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	line-height: 1.1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ---------- status pill ---------- */
.hfdn-chat__status {
	flex-shrink: 0;
	display: inline-block;
	padding: 2px 6px;
	font-family: var(--hfdn-chat-mono);
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	border: 1px solid var(--hfdn-chat-ink);
	background: #888780;
	color: #f1efe8;
	white-space: nowrap;
	line-height: 1.2;
}

.hfdn-chat__status--connect {
	background: #888780;
	color: #f1efe8;
}

.hfdn-chat__status--live {
	background: #173404;
	color: #c0dd97;
}

.hfdn-chat__status--poll {
	background: #5f5e5a;
	color: #d3d1c7;
}

.hfdn-chat__status--err {
	background: #791f1f;
	color: #f7c1c1;
}

/* ---------- body two-column layout ---------- */
.hfdn-chat__body {
	display: grid;
	grid-template-columns: 1fr 200px;
	background: var(--hfdn-chat-paper);
}

.hfdn-chat__messages-wrap {
	border-right: 2px solid var(--hfdn-chat-ink);
	background: var(--hfdn-chat-paper);
	min-height: 220px;
	display: flex;
	flex-direction: column;
}

/* When the presence pane is hidden (non-global rooms), reclaim the space. */
.hfdn-chat__body:not(:has(.hfdn-chat__presence:not([hidden]))) {
	grid-template-columns: 1fr;
}

.hfdn-chat__body:not(:has(.hfdn-chat__presence:not([hidden]))) .hfdn-chat__messages-wrap {
	border-right: 0;
}

/* ---------- messages list ---------- */
.hfdn-chat__messages {
	height: 280px;
	overflow-y: auto;
	padding: 10px 12px;
	font-family: var(--hfdn-chat-mono);
	font-size: 12px;
	line-height: 1.5;
	color: var(--hfdn-chat-ink);
	scrollbar-width: thin;
}

.hfdn-chat__messages::-webkit-scrollbar {
	width: 8px;
}

.hfdn-chat__messages::-webkit-scrollbar-track {
	background: var(--hfdn-chat-paper);
}

.hfdn-chat__messages::-webkit-scrollbar-thumb {
	background: var(--hfdn-chat-ink);
	border-radius: 0;
}

/* ---------- load older ---------- */
.hfdn-chat__load-older {
	margin: 8px 12px 10px;
	border: 2px solid var(--hfdn-chat-ink);
	border-radius: 0;
	background: var(--hfdn-chat-muted-bg);
	color: var(--hfdn-chat-ink);
	padding: 4px 8px;
	text-align: center;
	font-family: var(--hfdn-chat-mono);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	cursor: pointer;
}

.hfdn-chat__load-older:hover:not(:disabled) {
	background: var(--hfdn-chat-yellow);
}

.hfdn-chat__load-older:disabled {
	opacity: 0.5;
	cursor: default;
}

/* ---------- message row ---------- */
.hfdn-chat__message {
	margin-bottom: 8px;
	line-height: 1.5;
	position: relative;
}

.hfdn-chat__message:last-child {
	margin-bottom: 0;
}

.hfdn-chat__message-head {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
	font-size: 12px;
}

/* ---------- username (AIM-style cycled colors) ---------- */
.hfdn-chat__who {
	font-family: var(--hfdn-chat-mono);
	font-weight: 500;
	font-size: 12px;
	color: var(--hfdn-chat-ink); /* fallback */
}

.hfdn-chat__who::after {
	content: ":";
	margin-left: 1px;
	color: var(--hfdn-chat-ink);
	font-weight: 500;
}

.hfdn-chat__who--c0 { color: #993556; } /* pink   */
.hfdn-chat__who--c1 { color: #185fa5; } /* blue   */
.hfdn-chat__who--c2 { color: #3b6d11; } /* green  */
.hfdn-chat__who--c3 { color: #854f0b; } /* amber  */

/* ---------- room tag pill (replaces inline [brackets]) ---------- */
.hfdn-chat__room-tag {
	display: inline-block;
	padding: 0 4px;
	font-family: var(--hfdn-chat-mono);
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	background: var(--hfdn-chat-amber-bg);
	color: var(--hfdn-chat-amber-text);
	border: 1px solid var(--hfdn-chat-amber-border);
	line-height: 1.4;
	white-space: nowrap;
}

/* ---------- message body ---------- */
.hfdn-chat__message-body {
	display: inline;
	font-family: var(--hfdn-chat-mono);
	font-size: 12px;
	color: var(--hfdn-chat-ink);
	margin-left: 4px;
	word-break: break-word;
}

/* Place body inline with the username for AIM-style "name: message" flow. */
.hfdn-chat__message-head + .hfdn-chat__message-body {
	display: block;
	margin-left: 0;
	margin-top: 2px;
}

/* ---------- delete button (hover-reveal on desktop, dim on touch) ---------- */
.hfdn-chat__delete {
	margin-left: auto;
	border: 1px solid var(--hfdn-chat-ink);
	background: var(--hfdn-chat-paper);
	color: var(--hfdn-chat-ink);
	font-family: var(--hfdn-chat-mono);
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	padding: 1px 5px;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.12s ease;
}

.hfdn-chat__message:hover .hfdn-chat__delete,
.hfdn-chat__message:focus-within .hfdn-chat__delete,
.hfdn-chat__message.is-revealed .hfdn-chat__delete {
	opacity: 1;
}

.hfdn-chat__delete:hover {
	background: #791f1f;
	color: #f7c1c1;
	border-color: #791f1f;
}

@media (hover: none) {
	.hfdn-chat__delete {
		opacity: 0.45;
	}
	.hfdn-chat__message.is-revealed .hfdn-chat__delete {
		opacity: 1;
	}
}

/* ---------- buddy list ("Who's On") ---------- */
.hfdn-chat__presence {
	background: var(--hfdn-chat-pink-50);
	padding: 10px 10px 12px;
}

.hfdn-chat__presence-title {
	font-family: var(--hfdn-chat-mono);
	font-size: 10px;
	font-weight: 700;
	color: var(--hfdn-chat-pink-text);
	margin-bottom: 8px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	border-bottom: 1px solid var(--hfdn-chat-pink-text-dark);
	padding-bottom: 4px;
}

.hfdn-chat__presence-list {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 280px;
	overflow-y: auto;
}

.hfdn-chat__presence-item,
.hfdn-chat__presence-empty {
	background: transparent;
	border: 0;
	border-radius: 0;
	margin-bottom: 4px;
	padding: 2px 0;
	font-family: var(--hfdn-chat-mono);
	font-size: 11px;
	color: var(--hfdn-chat-pink-text-dark);
	display: flex;
	align-items: center;
	gap: 6px;
	line-height: 1.3;
}

.hfdn-chat__presence-empty {
	font-style: italic;
	color: #888;
}

/* Pixel avatar — solid 12px square, no radius, dark border.
   Color cycles per user via --p0 through --p3 modifiers. */
.hfdn-chat__presence-avatar {
	width: 12px;
	height: 12px;
	flex-shrink: 0;
	border: 1px solid var(--hfdn-chat-pink-text-dark);
	border-radius: 0;
	background-color: #ed93b1; /* default fallback */
	background-size: cover;
	background-position: center;
	image-rendering: pixelated;
}

.hfdn-chat__presence-avatar--p0 { background-color: #ed93b1; } /* pink   */
.hfdn-chat__presence-avatar--p1 { background-color: #85b7eb; } /* blue   */
.hfdn-chat__presence-avatar--p2 { background-color: #c0dd97; } /* green  */
.hfdn-chat__presence-avatar--p3 { background-color: #fac775; } /* amber  */

.hfdn-chat__presence-name {
	font-weight: 500;
	color: var(--hfdn-chat-pink-text-dark);
}

/* ---------- composer ---------- */
.hfdn-chat__composer {
	border-top: 2px solid var(--hfdn-chat-ink);
	padding: 10px 12px;
	background: var(--hfdn-chat-paper);
}

.hfdn-chat__input {
	width: 100%;
	box-sizing: border-box;
	resize: vertical;
	border: 2px solid #888;
	border-radius: 0;
	background: var(--hfdn-chat-paper);
	min-height: 56px;
	font-family: var(--hfdn-chat-mono);
	font-size: 12px;
	line-height: 1.4;
	color: var(--hfdn-chat-ink);
	padding: 6px 8px;
}

.hfdn-chat__input:focus {
	outline: none;
	border-color: var(--hfdn-chat-ink);
	box-shadow: none;
}

.hfdn-chat__composer-footer {
	margin-top: 8px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	min-height: 24px;
}

.hfdn-chat__count {
	font-family: var(--hfdn-chat-mono);
	font-size: 10px;
	color: #888;
	letter-spacing: 0.02em;
	visibility: hidden; /* hidden until threshold (set via .is-visible) */
}

.hfdn-chat__count.is-visible {
	visibility: visible;
}

.hfdn-chat__count.is-warn {
	color: #791f1f;
	font-weight: 700;
}

.hfdn-chat__send {
	margin-left: auto;
	border: 2px solid var(--hfdn-chat-ink);
	border-radius: 0;
	background: var(--hfdn-chat-yellow);
	color: var(--hfdn-chat-ink);
	font-family: var(--hfdn-chat-mono);
	font-size: 11px;
	font-weight: 500;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	padding: 4px 12px;
	cursor: pointer;
	transition: transform 0.05s ease;
}

.hfdn-chat__send:hover:not(:disabled) {
	background: #ffd700;
}

.hfdn-chat__send:active:not(:disabled) {
	transform: translate(1px, 1px);
}

.hfdn-chat__send:disabled {
	opacity: 0.55;
	cursor: default;
}

/* ---------- locked composer (logged-out state) ---------- */
.hfdn-chat__locked {
	border-top: 2px solid var(--hfdn-chat-ink);
	background: var(--hfdn-chat-muted-bg);
	color: var(--hfdn-chat-muted-text);
	padding: 12px 14px;
	font-family: var(--hfdn-chat-mono);
	font-size: 11px;
	line-height: 1.5;
	text-align: center;
	letter-spacing: 0.02em;
}

.hfdn-chat__locked a {
	color: var(--hfdn-chat-pink);
	text-decoration: underline;
	text-underline-offset: 2px;
	font-weight: 700;
}

.hfdn-chat__locked a:hover {
	color: var(--hfdn-chat-pink-text);
}

/* ---------- mobile responsive ---------- */
@media (max-width: 860px) {
	.hfdn-chat__body {
		grid-template-columns: 1fr;
	}

	.hfdn-chat__messages-wrap {
		border-right: 0;
		border-bottom: 2px solid var(--hfdn-chat-ink);
	}

	.hfdn-chat__presence {
		max-height: 140px;
		overflow-y: auto;
	}

	.hfdn-chat__title {
		font-size: 11px;
	}

	.hfdn-chat__messages {
		height: 240px;
	}
}

@media (max-width: 520px) {
	.hfdn-chat__titlebar {
		padding: 5px 8px;
	}

	.hfdn-chat__title {
		font-size: 10px;
		letter-spacing: 0.04em;
	}

	.hfdn-chat__status {
		font-size: 8px;
		padding: 1px 4px;
	}
}
