/* Handmade Kapamilya chat widget — on-brand, minimal, accessible. */

.hmk-chat-launcher {
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	z-index: 9998;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: #B79D70;
	color: #1A1714;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 150ms ease, background 150ms ease;
}

.hmk-chat-launcher:hover {
	transform: translateY(-2px);
	background: #C9B187;
}

.hmk-chat-launcher svg { width: 24px; height: 24px; }

.hmk-chat-panel {
	position: fixed;
	right: 1rem;
	bottom: 5rem;
	z-index: 9999;
	width: min(380px, calc(100vw - 2rem));
	height: min(560px, calc(100vh - 8rem));
	background: var(--wp--preset--color--off-white, #FBF8F3);
	border: 1px solid var(--wp--preset--color--line, #E9E2D6);
	border-radius: 50px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
	display: none;
	flex-direction: column;
	overflow: hidden;
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.hmk-chat-panel.is-open { display: flex; }

.hmk-chat-header {
	padding: 0.75rem 1rem;
	border-bottom: 1px solid var(--wp--preset--color--line, #E9E2D6);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	background: var(--wp--preset--color--ivory, #F7F1E8);
}

.hmk-chat-title {
	font-family: 'Fraunces', Georgia, serif;
	font-size: 1.05rem;
	font-weight: 500;
	color: var(--wp--preset--color--charcoal, #1F1B17);
}

.hmk-chat-phone {
	font-size: 0.8rem;
	color: var(--wp--preset--color--gold-dark, #7A5D33);
	text-decoration: none;
	font-weight: 500;
	padding: 0.25rem 0.5rem;
	border: 1px solid var(--wp--preset--color--line, #E9E2D6);
	border-radius: 2px;
	white-space: nowrap;
}

.hmk-chat-close {
	background: none;
	border: none;
	cursor: pointer;
	font-size: 1.25rem;
	line-height: 1;
	color: var(--wp--preset--color--muted, #6A635B);
	padding: 0.25rem 0.5rem;
	min-height: 44px;
	min-width: 44px;
}

.hmk-chat-log {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	font-size: 0.95rem;
	line-height: 1.45;
	color: #1A1714;
}

.hmk-chat-msg {
	padding: 0.6rem 0.85rem;
	border-radius: 8px;
	max-width: 85%;
	word-wrap: break-word;
}

.hmk-chat-msg--bot {
	align-self: flex-start;
	background: var(--wp--preset--color--ivory, #F7F1E8);
	border-bottom-left-radius: 2px;
}

.hmk-chat-msg--bot a,
.hmk-chat-msg--system a {
	color: #1A1714;
	text-decoration: underline;
	font-weight: 600;
}
.hmk-chat-msg--bot a:hover,
.hmk-chat-msg--system a:hover { color: var(--wp--preset--color--gold-dark, #7A5D33); }

/* In-chat "Have a person reach out" button — appended to bot bubbles when
   the AI's reply mentions handoff/escalation. Clicking opens the existing
   escalation form (does NOT itself create a ClickUp task). */
.hmk-chat-msg__escalate-btn {
	display: inline-block;
	margin-top: 0.625rem;
	padding: 0.5rem 0.875rem;
	background: #1A1714;
	color: #FBF8F3;
	border: 1px solid #1A1714;
	border-radius: 50px;
	font: inherit;
	font-size: 0.85rem;
	font-weight: 500;
	cursor: pointer;
	text-align: center;
	transition: background 160ms ease, color 160ms ease;
}
.hmk-chat-msg__escalate-btn:hover {
	background: var(--wp--preset--color--gold-dark, #7A5D33);
	border-color: var(--wp--preset--color--gold-dark, #7A5D33);
}

.hmk-chat-msg--user {
	align-self: flex-end;
	background: var(--wp--preset--color--charcoal, #1F1B17);
	color: var(--wp--preset--color--off-white, #FBF8F3);
	border-bottom-right-radius: 2px;
}

.hmk-chat-msg--system {
	align-self: stretch;
	font-size: 0.8rem;
	color: var(--wp--preset--color--muted, #6A635B);
	text-align: center;
	background: none;
	padding: 0.25rem 0;
}

.hmk-chat-typing {
	align-self: flex-start;
	padding: 0.6rem 0.85rem;
	color: var(--wp--preset--color--muted, #6A635B);
	font-size: 0.85rem;
	display: none;
}

.hmk-chat-typing.is-active { display: block; }

.hmk-chat-form {
	padding: 0.625rem 1.25rem 1.25rem;
	border-top: 1px solid var(--wp--preset--color--line, #E9E2D6);
	display: flex;
	gap: 0.5rem;
	align-items: flex-end;
	background: var(--wp--preset--color--off-white, #FBF8F3);
}

/* Match the topnav search field for visual consistency: cream bg, 1.5px
   gold border, pill radius, ink text + soft ink placeholder. Focus state
   uses the deep-gold border + soft gold ring used elsewhere on the site. */
.hmk-chat-input {
	flex: 1;
	min-height: 40px;
	max-height: 120px;
	padding: 0.45rem 0.875rem;
	border: 1.5px solid #b79d70;
	border-radius: 50px;
	font: inherit;
	font-size: 0.9rem;
	line-height: 1.4;
	resize: none;
	background: #F5EFE4;
	color: #1A1714;
}

.hmk-chat-input::placeholder { color: rgba(26, 23, 20, 0.55); }

.hmk-chat-input:focus {
	outline: none;
	border-color: #5E4823;
	box-shadow: 0 0 0 3px rgba(183, 157, 112, 0.25);
}

.hmk-chat-send {
	min-height: 38px;
	padding: 0 1rem;
	background: #1A1714;
	color: var(--wp--preset--color--off-white, #FBF8F3);
	border: none;
	border-radius: 50px;
	cursor: pointer;
	font: inherit;
	font-size: 0.9rem;
	font-weight: 500;
}

.hmk-chat-send:hover { background: var(--wp--preset--color--gold-dark, #7A5D33); }
.hmk-chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* "Have a person reach out" — single line below the input. Looks like a
   subtle text link, not a button, so it doesn't compete with Send. */
.hmk-chat-handoff {
	padding: 0 1.25rem 0.75rem;
	background: var(--wp--preset--color--off-white, #FBF8F3);
	text-align: center;
}
.hmk-chat-handoff__open {
	background: none;
	border: none;
	cursor: pointer;
	font: inherit;
	font-size: 0.78rem;
	color: var(--wp--preset--color--gold-dark, #7A5D33);
	text-decoration: underline;
	padding: 0.25rem 0.5rem;
	min-height: 32px;
}
.hmk-chat-handoff__open:hover { color: #1A1714; }

/* Inline escalation form — slides into the same footer area, replacing the
   chat input while open. */
.hmk-chat-escalate {
	padding: 0.75rem 1.25rem 1.25rem;
	border-top: 1px solid var(--wp--preset--color--line, #E9E2D6);
	background: var(--wp--preset--color--off-white, #FBF8F3);
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}
.hmk-chat-escalate[hidden] { display: none; }
.hmk-chat-escalate__title {
	font-family: 'Fraunces', Georgia, serif;
	font-size: 0.95rem;
	color: #1A1714;
	margin-bottom: 0.25rem;
}
.hmk-chat-escalate__name,
.hmk-chat-escalate__email,
.hmk-chat-escalate__msg {
	width: 100%;
	box-sizing: border-box;
	padding: 0.5rem 0.875rem;
	border: 1px solid var(--wp--preset--color--line, #E9E2D6);
	border-radius: 50px;
	font: inherit;
	font-size: 0.9rem;
	background: #fff;
	color: #1A1714;
	resize: none;
}
.hmk-chat-escalate__msg { border-radius: 18px; min-height: 64px; }
.hmk-chat-escalate__name:focus,
.hmk-chat-escalate__email:focus,
.hmk-chat-escalate__msg:focus {
	outline: 2px solid var(--wp--preset--color--gold, #A7824A);
	outline-offset: 0;
	border-color: var(--wp--preset--color--gold, #A7824A);
}
.hmk-chat-escalate__row {
	display: flex;
	gap: 0.5rem;
	justify-content: flex-end;
	margin-top: 0.25rem;
}
.hmk-chat-escalate__cancel,
.hmk-chat-escalate__submit {
	min-height: 38px;
	padding: 0 1rem;
	border: none;
	border-radius: 50px;
	cursor: pointer;
	font: inherit;
	font-size: 0.85rem;
	font-weight: 500;
}
.hmk-chat-escalate__cancel {
	background: transparent;
	color: var(--wp--preset--color--muted, #6A635B);
}
.hmk-chat-escalate__submit {
	background: #1A1714;
	color: #FBF8F3;
}
.hmk-chat-escalate__submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Promoted phone CTA after 2 low-confidence turns */
.hmk-chat-phone-cta {
	align-self: stretch;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.75rem;
	background: var(--wp--preset--color--charcoal, #1F1B17);
	color: var(--wp--preset--color--off-white, #FBF8F3);
	border-radius: 2px;
	text-decoration: none;
	font-weight: 500;
	margin: 0.5rem 0;
}
