/*
 * The customer chat widget.
 *
 * ─── WHY THIS LOOKS THE WAY IT DOES ──────────────────────────────────────────
 *
 * Drawn from "Customer Chat Widget.dc.html" in the Atomic Signs design project:
 * a navy header, a paper-grey thread, cyan for the customer's own voice, pills
 * for every action. Four screens — launcher, pre-chat, live thread, out of
 * hours — which is why so much of this file is toggling rather than styling.
 *
 * Colours still come from the theme's own custom properties WITH the design's
 * values as fallbacks, so the widget follows a rebrand instead of needing one.
 * The retired Tawk form hardcoded #1ab0e0 and #2d3445 into functions.php, which
 * is why it still looked like the old theme after the site stopped doing.
 *
 * ─── The one place this departs from the mock ────────────────────────────────
 *
 * TWO CYANS, not one. #1ab0e0 carries white text at 2.5:1, which fails WCAG AA
 * (4.5:1) and fails it at every size — so the two surfaces that actually carry
 * white WORDS, the customer's own bubbles and the primary button, use the
 * design's OTHER cyan, #0e7ca0, at 4.8:1. Everything decorative — the launcher,
 * the send circle, accents, focus rings — keeps #1ab0e0 exactly as drawn.
 *
 * Change --desk-accent-ink to var(--desk-accent) to have the mock back to the
 * pixel; the split is here so that is a one-line decision rather than a
 * rewrite.
 *
 * ─── Scope ───────────────────────────────────────────────────────────────────
 *
 * Every rule is namespaced under .desk-w. This loads on EVERY page including
 * checkout, so a selector that escapes its scope is a payment page with a
 * layout bug, and nothing about the widget is worth that.
 *
 * z-index sits below common modal/overlay ranges deliberately: a chat bubble
 * must never cover a card-entry field or a cookie banner someone has to
 * dismiss.
 */

.desk-w,
.desk-w * {
	box-sizing: border-box;
}

.desk-w {
	--desk-bg: var(--color-surface, #ffffff);
	--desk-alt: var(--color-surface-alt, #e4e4e4);
	--desk-tint: var(--color-surface-tint, #e3f6fc);
	--desk-navy: var(--color-navy, #2d3445);
	--desk-text: var(--color-text, #2d384b);
	--desk-muted: var(--color-text-muted, #555b68);
	--desk-faint: var(--color-text-faint, #9aa0ad);
	--desk-invert: var(--color-text-invert, #ffffff);

	/* Graphics. As drawn. */
	--desk-accent: var(--desk-accent-color, #1ab0e0);

	/* Surfaces that carry white words. See the note above. */
	--desk-accent-ink: var(--desk-accent-ink-color, #0e7ca0);

	--desk-good: var(--color-good, #2fa45c);
	--desk-line: rgba(45, 56, 75, .18);
	--desk-hair: rgba(45, 56, 75, .08);
	--desk-radius: 22px;

	/*
	 * ─── BOTTOM LEFT, DELIBERATELY ───────────────────────────────────────
	 *
	 * The bottom right is where every chat widget goes and it is where the
	 * shop cannot afford to lose a corner. That is the side the buy band
	 * sticks to, the side a cart drawer slides from, and the side a "back to
	 * top" or a cookie bar lands on — so the one control the customer needs at
	 * the moment of buying is the one a bubble sits on top of.
	 *
	 * Nothing about asking a question needs the right-hand corner. Everything
	 * about completing an order does.
	 */
	position: fixed;
	left: 24px;
	bottom: 24px;
	z-index: 9000;
	font-family: var(--font-sans, "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif);
	font-size: 14px;
	line-height: 1.5;
	color: var(--desk-text);
	display: flex;
	flex-direction: column;
	/* The stack grows from the dock side, which is now the left one. */
	align-items: flex-start;
	gap: 12px;
}

.desk-w[hidden],
.desk-w [hidden] {
	display: none;
}

/* ── 1a. The launcher ─────────────────────────────────────────────────────── */

.desk-w-bubble {
	position: relative;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: 0;
	background: var(--desk-accent);
	color: var(--desk-invert);
	cursor: pointer;
	box-shadow: 0 10px 26px rgba(26, 176, 224, .45);
	display: grid;
	place-items: center;
	padding: 0;
	flex: none;
}

.desk-w-bubble:focus-visible {
	outline: 3px solid var(--desk-accent);
	outline-offset: 3px;
}

.desk-w-bubble svg {
	width: 26px;
	height: 26px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/*
 * Are we in? The one thing a launcher can say before it is clicked, and the
 * reason the greeting can promise a reply "in a couple minutes" without lying.
 */
.desk-w-presence {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--desk-faint);
	border: 2.5px solid var(--desk-alt);
}

.desk-w.is-open-shop .desk-w-presence {
	background: var(--desk-good);
}

/* Unread replies. Sits where the presence dot does, and wins — a waiting
 * answer is more urgent news than whether the shop is staffed. */
.desk-w-dot {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 22px;
	height: 22px;
	border-radius: 11px;
	background: #c2372b;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 22px;
	text-align: center;
	padding: 0 6px;
	border: 2.5px solid var(--desk-alt);
}

.desk-w-greeting {
	position: relative;
	background: var(--desk-bg);
	border: 0;
	text-align: left;
	font: inherit;
	color: inherit;
	/*
	 * The flattened corner is the tail: it points down at the launcher the
	 * greeting belongs to. With the widget on the left that launcher is below
	 * and to the LEFT, so the flat corner moves with it — bottom-right was a
	 * bubble pointing at nothing.
	 */
	border-radius: 16px 16px 16px 4px;
	padding: 14px 16px;
	box-shadow: 0 10px 26px rgba(36, 41, 56, .18);
	max-width: 250px;
	display: flex;
	flex-direction: column;
	gap: 3px;
	cursor: pointer;
}

.desk-w-greeting strong {
	font-weight: 700;
	font-size: 13px;
	line-height: 1.35;
}

.desk-w-greeting span {
	font-size: 11.5px;
	color: var(--desk-muted);
}

.desk-w-greeting:focus-visible {
	outline: 2px solid var(--desk-accent);
	outline-offset: 2px;
}

/* ── The panel ────────────────────────────────────────────────────────────── */

.desk-w-panel {
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 600px;
	max-height: calc(100vh - 100px);
	background: var(--desk-bg);
	border-radius: var(--desk-radius);
	box-shadow: 0 24px 60px rgba(36, 41, 56, .25);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* ── Headers ──────────────────────────────────────────────────────────────── */

.desk-w-head {
	background: var(--desk-navy);
	color: var(--desk-invert);
	flex: none;
}

/* The tall one: logo, a question, and whether anyone is in. */
.desk-w-brandhead {
	padding: 22px 22px 20px;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.desk-w-brandtop {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

/*
 * 26px tall — about 98px wide, the size in Dennis's 2026-11-14 screenshot.
 * (It was 18px while the heading under it was 24px; the heading is 18px now.)
 *
 * `.desk-w-panel` in front of it is not decoration. WooCommerce ships
 * `.woocommerce-page img { height: auto }` — (0,1,1), beating a bare
 * `.desk-w-logo` at (0,1,0) — so on every product, shop and cart page the
 * mark drew at its natural 300×80, clamped to the header's width: 336×90, a
 * third of the panel's height before a word of it. Off those pages it was
 * fine, which is why it went unseen.
 */
.desk-w-panel .desk-w-logo {
	height: 26px;
	width: auto;
	/* The mark is drawn in ink; the header is navy. */
	filter: brightness(0) invert(1);
}

/* 18px, so "Hi there! What are you making?" sits on one line (Dennis,
   2026-11-14). At 24px it wrapped to two in a 336px column. */
.desk-w-heading {
	font-size: 18px;
	font-weight: 800;
	letter-spacing: -.02em;
	line-height: 1.1;
	margin: 0;
}

.desk-w-presenceline {
	display: flex;
	align-items: center;
	gap: 7px;
	font-size: 12px;
	color: #c3c8d2;
	margin-top: 4px;
}

.desk-w-presenceline::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--desk-faint);
	flex: none;
}

.desk-w.is-open-shop .desk-w-presenceline::before {
	background: var(--desk-good);
}

.desk-w-presenceline strong {
	color: var(--desk-invert);
	font-weight: 700;
}

/* The short one: who you are talking to. */
.desk-w-agenthead {
	padding: 14px 18px;
	display: flex;
	align-items: center;
	gap: 12px;
}

.desk-w-avatar {
	position: relative;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--desk-accent);
	display: grid;
	place-items: center;
	font-weight: 800;
	font-size: 14px;
	flex: none;
}

.desk-w.is-open-shop .desk-w-avatar::after {
	content: "";
	position: absolute;
	bottom: 0;
	right: 0;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: var(--desk-good);
	border: 2px solid var(--desk-navy);
}

.desk-w-agentname {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}

.desk-w-agentname strong {
	font-weight: 700;
	font-size: 14px;
}

.desk-w-agentname span {
	font-size: 11.5px;
	color: #c3c8d2;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.desk-w-actions {
	display: flex;
	gap: 4px;
	flex: none;
}

.desk-w-act {
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: 50%;
	background: none;
	color: #c3c8d2;
	font: inherit;
	font-size: 18px;
	line-height: 1;
	display: grid;
	place-items: center;
	cursor: pointer;
	padding: 0;
}

.desk-w-act:hover {
	background: rgba(255, 255, 255, .1);
	color: var(--desk-invert);
}

.desk-w-act:focus-visible {
	outline: 2px solid var(--desk-invert);
	outline-offset: -2px;
}

/* ── 1b / 1d. The forms ───────────────────────────────────────────────────── */

.desk-w-form {
	flex: 1;
	padding: 20px 22px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	overflow-y: auto;
	overflow-x: hidden;
}

.desk-w-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.desk-w-field > label {
	font-size: 11px;
	font-weight: 800;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--desk-muted);
}

/* Contact: one label, then name and email stacked. 6px under the label
   like any field, 14px between the two inputs like the gap between fields. */
.desk-w-contact input + input {
	margin-top: 8px;
}

.desk-w-form input[type="text"],
.desk-w-form input[type="email"],
.desk-w-form textarea {
	width: 100%;
	border: 1.5px solid var(--desk-line);
	border-radius: 12px;
	padding: 12px 14px;
	font: inherit;
	font-size: 14px;
	color: inherit;
	background: var(--desk-bg);
	resize: none;
}

.desk-w-form textarea {
	min-height: 70px;
}

.desk-w-form input::placeholder,
.desk-w-form textarea::placeholder {
	color: var(--desk-faint);
}

.desk-w-form input:focus,
.desk-w-form textarea:focus {
	outline: 2px solid var(--desk-accent);
	outline-offset: 1px;
	border-color: transparent;
}

/*
 * One row that scrolls sideways, not two that wrap (Dennis, 2026-11-14).
 *
 * It runs out to the panel's edges — the negative margin undoes the form's
 * 22px padding and the padding puts the first chip back in line with the
 * fields — so a chip that does not fit is cut by the edge of the panel, which
 * reads as "more this way", rather than by an invisible line 22px short of it.
 * No scrollbar: the cut chip says it, and desk-widget.js turns a mouse wheel
 * sideways over the row.
 */
.desk-w-topics {
	display: flex;
	gap: 6px;
	flex-wrap: nowrap;
	overflow-x: auto;
	margin-inline: -22px;
	padding-inline: 22px;
	scroll-padding-inline: 22px;
	/* A scrolling box clips both ways: room for a chip's focus outline
	   (2px + 2px offset), given back so the row sits where it did. */
	padding-block: 4px;
	margin-block: -4px;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
}

.desk-w-topics::-webkit-scrollbar {
	display: none;
}

.desk-w-topic {
	flex: none;
	white-space: nowrap;
	font: inherit;
	font-size: 12px;
	font-weight: 600;
	border: 1.5px solid var(--desk-line);
	background: none;
	color: var(--desk-text);
	border-radius: 999px;
	padding: 7px 13px;
	cursor: pointer;
}

.desk-w-topic[aria-pressed="true"] {
	background: var(--desk-accent-ink);
	border-color: var(--desk-accent-ink);
	color: var(--desk-invert);
}

.desk-w-topic:focus-visible {
	outline: 2px solid var(--desk-accent);
	outline-offset: 2px;
}

/* The hours card, out of hours. */
.desk-w-hours {
	background: var(--desk-tint);
	border-radius: 14px;
	padding: 12px 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.desk-w-hours h3 {
	margin: 0;
	font-size: 11px;
	font-weight: 800;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--desk-accent-ink);
}

.desk-w-hours dl {
	margin: 0;
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 3px 14px;
	font-size: 12.5px;
}

.desk-w-hours dt {
	font-weight: 700;
}

.desk-w-hours dd {
	margin: 0;
}

.desk-w-rush {
	font-size: 12px;
	color: var(--desk-muted);
	line-height: 1.5;
}

.desk-w-rush a {
	font-weight: 700;
	color: var(--desk-accent-ink);
}

/* ── The form's footer: one big pill, and the other ways to reach us ──────── */

.desk-w-formfoot {
	flex: none;
	padding: 14px 22px 20px;
	border-top: 1px solid var(--desk-hair);
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.desk-w-primary {
	border: 0;
	border-radius: 999px;
	background: var(--desk-accent-ink);
	color: var(--desk-invert);
	font: inherit;
	font-weight: 700;
	font-size: 14.5px;
	padding: 14px;
	text-align: center;
	cursor: pointer;
	width: 100%;
}

/* Out of hours the shop is not the bright thing on the screen. */
.desk-w-panel[data-view="offline"] .desk-w-primary {
	background: var(--desk-navy);
}

.desk-w-primary:hover {
	filter: brightness(1.08);
}

.desk-w-primary[disabled] {
	opacity: .55;
	cursor: default;
	filter: none;
}

.desk-w-primary:focus-visible {
	outline: 3px solid var(--desk-accent);
	outline-offset: 2px;
}

.desk-w-fallback {
	font-size: 11px;
	color: var(--desk-faint);
	text-align: center;
}

.desk-w-fallback a {
	color: inherit;
	text-decoration: underline;
}

/* ── 1c. The thread ───────────────────────────────────────────────────────── */

.desk-w-log {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 18px;
	margin: 0;
	list-style: none;
	background: var(--desk-alt);
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/*
 * Sit the conversation on the bottom of the panel.
 *
 * A single opening message pinned to the top of 400px of empty grey reads as a
 * thread that has failed to load. An auto margin on a zero-height first item
 * pushes everything down and then collapses to nothing the moment the messages
 * are tall enough to scroll — which justify-content: flex-end does not do, and
 * cannot, without clipping the top of a long thread.
 */
.desk-w-log::before {
	content: "";
	margin-top: auto;
}

.desk-w-day {
	align-self: center;
	font-size: 10.5px;
	font-weight: 700;
	color: var(--desk-faint);
	letter-spacing: .06em;
	text-transform: uppercase;
}

.desk-w-msg {
	display: flex;
	flex-direction: column;
	gap: 3px;
	max-width: 85%;
	margin: 0;
}

.desk-w-msg b {
	padding: 11px 14px;
	font-size: 13.5px;
	font-weight: 400;
	line-height: 1.5;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
}

.desk-w-msg small {
	font-size: 10.5px;
	color: var(--desk-faint);
	padding: 0 6px;
}

.desk-w-them {
	align-self: flex-start;
	align-items: flex-start;
}

.desk-w-them b {
	background: var(--desk-bg);
	color: var(--desk-text);
	border-radius: 16px 16px 16px 4px;
	box-shadow: 0 2px 6px rgba(36, 41, 56, .06);
}

.desk-w-me {
	align-self: flex-end;
	align-items: flex-end;
}

.desk-w-me b {
	background: var(--desk-accent-ink);
	color: var(--desk-invert);
	border-radius: 16px 16px 4px 16px;
}

.desk-w-note {
	align-self: center;
	max-width: 100%;
	text-align: center;
	color: var(--desk-muted);
	font-size: 12px;
	padding: 2px 10px;
	margin: 0;
}

/* The email prompt is a note that asks something, so it gets room to. */
.desk-w-ask {
	align-self: stretch;
	background: var(--desk-bg);
	border-radius: 14px;
	padding: 12px 14px;
	box-shadow: 0 2px 6px rgba(36, 41, 56, .06);
	text-align: left;
}

.desk-w-ask input {
	width: 100%;
	border: 1.5px solid var(--desk-line);
	border-radius: 999px;
	padding: 9px 14px;
	font: inherit;
	font-size: 13px;
	background: var(--desk-bg);
	color: inherit;
}

.desk-w-ask .desk-w-row {
	display: flex;
	gap: 6px;
	margin-top: 8px;
}

.desk-w-ask .desk-w-row input {
	flex: 1;
	min-width: 0;
}

.desk-w-ask button {
	border: 0;
	border-radius: 999px;
	background: var(--desk-accent-ink);
	color: var(--desk-invert);
	font: inherit;
	font-weight: 700;
	font-size: 13px;
	padding: 9px 18px;
	cursor: pointer;
	flex: none;
}

/* ── The composer ─────────────────────────────────────────────────────────── */

.desk-w-foot {
	flex: none;
	padding: 12px 14px 14px;
	border-top: 1px solid var(--desk-hair);
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--desk-bg);
}

.desk-w-chips {
	display: flex;
	gap: 6px;
	overflow-x: auto;
	scrollbar-width: none;
}

.desk-w-chips::-webkit-scrollbar {
	display: none;
}

.desk-w-chip {
	flex: none;
	font: inherit;
	font-size: 11.5px;
	font-weight: 600;
	background: var(--desk-tint);
	color: var(--desk-accent-ink);
	border: 0;
	border-radius: 999px;
	padding: 6px 12px;
	cursor: pointer;
}

.desk-w-chip:focus-visible {
	outline: 2px solid var(--desk-accent);
	outline-offset: 2px;
}

.desk-w-compose {
	display: flex;
	align-items: center;
	gap: 8px;
	border: 1.5px solid var(--desk-line);
	border-radius: 22px;
	padding: 6px 6px 6px 14px;
}

.desk-w-compose:focus-within {
	border-color: var(--desk-accent);
}

.desk-w-compose textarea {
	flex: 1;
	border: 0;
	background: none;
	font: inherit;
	font-size: 14px;
	color: inherit;
	resize: none;
	padding: 8px 0;
	min-height: 38px;
	max-height: 120px;
	line-height: 1.4;
}

.desk-w-compose textarea:focus {
	outline: none;
}

.desk-w-compose textarea::placeholder {
	color: var(--desk-faint);
}

.desk-w-send {
	width: 38px;
	height: 38px;
	flex: none;
	border: 0;
	border-radius: 50%;
	background: var(--desk-accent);
	color: var(--desk-invert);
	display: grid;
	place-items: center;
	cursor: pointer;
	padding: 0;
}

.desk-w-send svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.desk-w-send[disabled] {
	opacity: .5;
	cursor: default;
}

.desk-w-send:focus-visible {
	outline: 2px solid var(--desk-accent);
	outline-offset: 2px;
}

.desk-w-status {
	font-size: 12px;
	color: var(--desk-muted);
	text-align: center;
	min-height: 0;
}

.desk-w-status:empty {
	display: none;
}

.desk-w-status.is-error {
	color: #c2372b;
	font-weight: 600;
}

.desk-w-legal {
	font-size: 10.5px;
	color: var(--desk-faint);
	text-align: center;
}

.desk-w-legal a {
	color: inherit;
	text-decoration: underline;
}

/* The honeypot. Off-screen rather than display:none, which some bots skip. */
.desk-w-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
}

/*
 * Phones. The panel becomes a sheet rather than a floating card, because a
 * 380px card on a 390px screen is a card with an accidental margin.
 */
@media screen and (max-width: 480px) {
	.desk-w {
		bottom: calc(16px + var(--as-buybar-h, 0px));
	}

	.desk-w-greeting {
		max-width: calc(100vw - 48px);
	}

	.desk-w.is-open {
		left: 0;
		right: 0;
		bottom: 0;
		top: 0;
		gap: 0;
	}

	.desk-w.is-open .desk-w-panel {
		width: 100%;
		max-width: none;
		height: 100%;
		max-height: none;
		border-radius: 0;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.desk-w-panel {
		animation: desk-w-in .16s ease-out;
	}

	.desk-w-greeting {
		animation: desk-w-in .24s ease-out;
	}

	@keyframes desk-w-in {
		from { opacity: 0; transform: translateY(8px); }
		to   { opacity: 1; transform: none; }
	}
}

/* ─────────────────────────────────────────────────────────────────────────────
 * PHONES: RIGHT-HAND SIDE, AND ABOVE THE BUY BAR
 *
 * The desktop rule docks the widget bottom-LEFT, because that is the corner an
 * ecommerce page can spare — the buy band sticks to the right, and so does a
 * cart drawer. On a phone none of that holds: the band is the full width of
 * the screen, so there is no side to hide on, and the bottom-left corner is
 * the one a right thumb reaches last.
 *
 * So on a phone it goes back to the right and gets out of the way vertically
 * instead. `--as-buybar-h` is published by the theme (see header.js) and says
 * how much of the bottom edge the buy band is currently holding — the full
 * band while it is pinned, zero once it settles or on a page that has none.
 * The launcher rides on top of it and drops back down on its own.
 * ───────────────────────────────────────────────────────────────────────────── */

@media screen and (max-width: 640px) {
	.desk-w {
		left: auto;
		right: 16px;
		align-items: flex-end;
		/*
		 * No transition on this. It is driven by scrolling, so an animated
		 * bottom is always chasing the finger and reads as lag — and a
		 * transition on a property that only changes at a threshold is the
		 * same trap the buy band's head fell into: when it does not complete,
		 * the element silently keeps its old position.
		 */
		bottom: calc(16px + var(--as-buybar-h, 0px));
	}

	/* The tail points at the launcher, which is below-RIGHT again here. */
	.desk-w-greeting { border-radius: 16px 16px 4px 16px; }
}
