/* =========================================================
   Pastoral chat box
   ========================================================= */
.ccf-chat { position: fixed; right: 20px; bottom: 20px; z-index: 900; font-family: var(--sans); }

.chat-fab {
	position: relative; display: inline-flex; align-items: center; gap: 10px; border: 0; cursor: pointer;
	padding: 14px 20px 14px 16px; border-radius: 999px; background: linear-gradient(160deg, var(--crimson) 0%, var(--maroon) 100%);
	color: #fff; font: 600 .95rem var(--sans); box-shadow: 0 10px 28px rgba(43,10,12,.35); transition: transform .2s, box-shadow .2s;
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(43,10,12,.4); }
.chat-fab svg { color: var(--gold-light); flex: none; }
.chat-dot { position: absolute; top: 4px; right: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--gold); border: 2px solid #fff; }
.chat-dot[hidden] { display: none; }
.chat-fab.has-reply { animation: chat-nudge 2.4s ease-in-out 3; }
@keyframes chat-nudge { 0%, 100% { transform: none; } 10% { transform: translateY(-4px); } 20% { transform: none; } }
.ccf-chat.is-open .chat-fab-label { display: none; }
.ccf-chat.is-open .chat-fab { padding: 14px; }

.chat-panel {
	position: absolute; right: 0; bottom: calc(100% + 14px); width: 380px; max-width: calc(100vw - 40px);
	height: min(600px, calc(100vh - 120px)); display: flex; flex-direction: column; overflow: hidden;
	background: #fff; border-radius: 18px; box-shadow: 0 24px 60px rgba(0,0,0,.3); animation: chat-in .18s ease;
}
.chat-panel[hidden] { display: none; }
@keyframes chat-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.chat-head {
	display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 14px 18px;
	background: linear-gradient(160deg, var(--maroon) 0%, var(--maroon-deep) 100%); color: #fff; flex: none;
}
.chat-head strong { display: block; font-size: 1.05rem; }
.chat-head span { font-size: .8rem; color: var(--gold-light); }
.chat-close { width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; flex: none; }
.chat-close:hover { background: rgba(255,255,255,.22); }

.chat-body { flex: 1; overflow-y: auto; padding: 14px 16px; background: var(--cream); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

.chat-crisis {
	display: flex; gap: 8px; align-items: flex-start; margin: 0 0 14px; padding: 10px 12px; border-radius: 10px;
	background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--crimson); font-size: .8rem; line-height: 1.45; color: var(--text);
}
.chat-crisis svg { color: var(--crimson); flex: none; margin-top: 2px; }

.chat-welcome { font-size: .92rem; color: var(--text); margin: 0 0 12px; }
.chat-label { display: block; font-size: .8rem; font-weight: 600; color: var(--maroon); margin: 0 0 4px; }
.chat-start textarea, .chat-start input[type="text"], .chat-start input[type="email"] {
	width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: .65rem .8rem; font: inherit; font-size: 16px;
	background: #fff; color: var(--text); margin-bottom: 10px;
}
.chat-start textarea { resize: vertical; min-height: 96px; }
.chat-start textarea:focus, .chat-start input:focus, .chat-reply textarea:focus { outline: 0; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,154,62,.2); }
.chat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chat-hint { font-size: .75rem; color: var(--muted); margin: -4px 0 10px; }
.chat-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.chat-consent { display: flex; gap: 8px; align-items: flex-start; font-size: .8rem; line-height: 1.45; color: var(--text); margin-bottom: 12px; cursor: pointer; }
.chat-consent input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--crimson); }
.chat-consent a { color: var(--crimson); }
.chat-error { background: #fdecec; color: #8e1f26; border: 1px solid #f3c9cb; border-radius: 8px; padding: 8px 10px; font-size: .85rem; margin: 0 0 10px; }
.chat-error[hidden] { display: none; }
.chat-send-btn {
	width: 100%; border: 0; border-radius: 999px; padding: .85rem 1rem; background: var(--gold-grad); color: var(--maroon-deep);
	font: 700 .95rem var(--sans); cursor: pointer;
}
.chat-send-btn:disabled { opacity: .6; cursor: wait; }

.chat-thread { display: flex; flex-direction: column; gap: 10px; }
.chat-thread[hidden], .chat-start[hidden], .chat-reply[hidden], .chat-forget[hidden] { display: none; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: .93rem; line-height: 1.5; overflow-wrap: anywhere; }
.msg-meta { font-size: .7rem; opacity: .7; margin-top: 4px; }
.msg.from-visitor { align-self: flex-end; background: var(--maroon); color: #fff; border-bottom-right-radius: 4px; }
.msg.from-team { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.from-auto { align-self: flex-start; background: #fff8e8; border: 1px solid #ecd9a8; border-bottom-left-radius: 4px; color: var(--maroon); }
.msg a { color: inherit; text-decoration: underline; font-weight: 600; }
.msg-wait { font-size: .78rem; color: var(--muted); text-align: center; margin: 4px 0 0; }

.chat-reply { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); background: #fff; flex: none; }
.chat-reply textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 20px; padding: .6rem .9rem; font: inherit; font-size: 16px; max-height: 140px; background: var(--cream); }
.chat-reply button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--gold-grad); color: var(--maroon-deep); cursor: pointer; flex: none; display: flex; align-items: center; justify-content: center; }
.chat-reply button:disabled { opacity: .6; }
.chat-forget { border: 0; background: #fff; color: var(--muted); font-size: .75rem; padding: 0 12px 10px; cursor: pointer; text-decoration: underline; flex: none; }

/* Phones: full-screen chat */
@media (max-width: 600px) {
	.ccf-chat { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
	.chat-fab { padding: 13px 16px 13px 14px; font-size: .88rem; }
	.chat-fab-label { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.chat-panel {
		position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; height: 100dvh; border-radius: 0;
		padding-bottom: env(safe-area-inset-bottom);
	}
	.ccf-chat.is-open .chat-fab { display: none; }
	html.chat-open, html.chat-open body { overflow: hidden; }
	.chat-row { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) { .chat-fab.has-reply { animation: none; } }
