/*
 * CookPal — the launcher.
 *
 * The site's colours, the desktop chat size and the mobile top offset are
 * custom properties set on #cookpal-chat-container by an inline style
 * attached to this handle (Cookpal_Public::theme_css()); the defaults below
 * hold until it does. Rules are scoped under the container's id so a
 * theme's own button rules cannot win on source order.
 *
 * The chat window and its styles are served by the CookPal service
 * (/widget/v1/chat.css), loaded by cookpal-loader.js.
 */

.cookpal-chat-container,
.cookpal-inline {
	--cookpal-button: #152266;
	--cookpal-on-button: #ffffff;
	--cookpal-bubble: #152266;
	--cookpal-on-bubble: #ffffff;
	--cookpal-link: #152266;
	--cookpal-focus: #152266;
	--cookpal-chat-width: 392px;
	--cookpal-chat-height: 560px;
	--cookpal-mobile-top: 80px;
}

#cookpal-chat-container,
#cookpal-inline {
	--cookpal-ink: #333333;
	--cookpal-muted: #666666;
	--cookpal-font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
	--cookpal-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 6px 16px rgba(0, 0, 0, 0.08);
	--cookpal-shadow-open: 0 2px 6px rgba(0, 0, 0, 0.08), 0 16px 40px rgba(0, 0, 0, 0.18);
	--cookpal-smooth: cubic-bezier(0.2, 0.8, 0.2, 1);
}

#cookpal-chat-container {
	position: fixed;
	z-index: 9999999999;
	font-family: var(--cookpal-font);
	color: var(--cookpal-ink);
}

#cookpal-chat-container,
#cookpal-chat-container *,
#cookpal-chat-container *::before,
#cookpal-chat-container *::after {
	box-sizing: border-box;
}

#cookpal-chat-container button {
	float: none;
	width: auto;
	min-width: 0;
	max-width: none;
	height: auto;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	font: inherit;
	line-height: 1;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
	text-shadow: none;
	color: inherit;
	cursor: pointer;
}

#cookpal-chat-container span {
	font: inherit;
	letter-spacing: inherit;
	text-transform: inherit;
	text-decoration: inherit;
	text-shadow: inherit;
	color: inherit;
}

#cookpal-chat-container button:focus-visible {
	outline: 3px solid var(--cookpal-focus);
	outline-offset: 2px;
}

@keyframes cookpal-pulse {
	0%, 15.8%, 31.6% {
		box-shadow: 0 0 0 0 color-mix(in srgb, var(--cookpal-button) 55%, transparent);
	}
	15.7%, 31.5%, 47.3%, 100% {
		box-shadow: 0 0 0 16px color-mix(in srgb, var(--cookpal-button) 0%, transparent);
	}
}

/* Launcher: a tab on the side edge, icon only until the page is scrolled */
#cookpal-chat-container .cookpal-launcher {
	position: fixed;
	top: var(--cookpal-launcher-top, calc(50% - 20px));
	right: 0;
	display: flex;
	align-items: center;
	max-width: calc(100% - 16px);
	height: 40px;
	padding: 0 15px;
	border-radius: 20px 0 0 20px;
	background: var(--cookpal-button);
	color: var(--cookpal-on-button);
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
	transition: padding 0.3s var(--cookpal-smooth);
}

#cookpal-chat-container[data-side="left"] .cookpal-launcher {
	right: auto;
	left: 0;
	border-radius: 0 20px 20px 0;
}

/* A 44 px hit area around the 40 px tab on touch screens */
@media (pointer: coarse) {
	#cookpal-chat-container .cookpal-launcher::after {
		content: "";
		position: absolute;
		inset: -2px 0;
	}
}

#cookpal-chat-container .cookpal-launcher:focus-visible {
	outline-color: var(--cookpal-on-button);
	outline-offset: -3px;
}

#cookpal-chat-container .cookpal-launcher[data-cookpal-clicked] {
	cursor: progress;
}

@keyframes cookpal-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Busy: the chat icon turns into a spinner, in the launcher's own colour */
#cookpal-chat-container .cookpal-launcher[aria-busy="true"] .cookpal-launcher-icon {
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: cookpal-spin 0.8s linear infinite;
}

#cookpal-chat-container .cookpal-launcher[aria-busy="true"] .cookpal-launcher-icon > * {
	display: none;
}

/* The search tab, 10 px below the chat tab */
#cookpal-chat-container .cookpal-search {
	top: calc(var(--cookpal-launcher-top, calc(50% - 20px)) + 50px);
}

.cookpal-launcher svg {
	flex: none;
	display: block;
}

#cookpal-chat-container .cookpal-launcher-icon {
	width: 18px;
	height: 18px;
}

.cookpal-launcher-label {
	display: grid;
	grid-template-columns: 0fr;
	min-width: 0;
	opacity: 0;
	text-align: start;
	transition: grid-template-columns 0.4s var(--cookpal-smooth), margin 0.4s var(--cookpal-smooth), opacity 0.25s;
}

.cookpal-launcher-label > span {
	grid-area: 1 / 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cookpal-launcher-label > [aria-hidden] {
	visibility: hidden;
}

.cookpal-launcher-go {
	display: none;
}

/* Open: 14 px at the rounded end, 16 px at the screen edge */
#cookpal-chat-container .cookpal-launcher:is(.cookpal-launcher-open, :hover, :focus-visible) {
	padding: 0 16px 0 14px;
}

#cookpal-chat-container[data-side="left"] .cookpal-launcher:is(.cookpal-launcher-open, :hover, :focus-visible) {
	padding: 0 14px 0 16px;
}

.cookpal-launcher:is(.cookpal-launcher-open, :hover, :focus-visible) .cookpal-launcher-label {
	grid-template-columns: 1fr;
	margin-inline: 8px 0;
	opacity: 1;
}

.cookpal-pulse::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	pointer-events: none;
	animation: cookpal-pulse 7.6s infinite;
}

@media (max-width: 768px) {
	/* The side tab on a phone stays closed */
	#cookpal-chat-container[data-mobile="tab"] .cookpal-launcher:is(.cookpal-launcher-open, :hover, :focus-visible) {
		padding: 0 15px;
	}

	#cookpal-chat-container[data-mobile="tab"] .cookpal-launcher-label {
		display: none;
	}

	/* The bottom pill */
	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher,
	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher:is(.cookpal-launcher-open, :hover, :focus-visible) {
		top: auto;
		right: auto;
		left: 50%;
		bottom: var(--cookpal-launcher-bottom, 16px);
		transform: translateX(-50%);
		width: 60%;
		max-width: none;
		height: 46px;
		gap: 4px;
		padding-block: 0;
		padding-inline: 8px 6px;
		border: 1.5px solid var(--cookpal-button);
		border-radius: 999px;
		background: #ffffff;
		color: var(--cookpal-ink);
		font-size: 14px;
		font-weight: 400;
		box-shadow: var(--cookpal-shadow-open);
		transition: none;
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher:focus-visible {
		outline-color: var(--cookpal-focus);
		outline-offset: 2px;
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher-icon {
		width: 19px;
		height: 19px;
		margin: 2.5px;
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher-label {
		flex: 1;
		grid-template-columns: 1fr;
		margin: 0;
		opacity: 1;
		color: var(--cookpal-muted);
		text-align: start;
		transition: none;
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher-go {
		flex: none;
		display: grid;
		place-items: center;
		width: 28px;
		height: 28px;
		border-radius: 50%;
		background: var(--cookpal-button);
		color: var(--cookpal-on-button);
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-pulse::before {
		inset: -1.5px;
	}

	/* Lifted above something taller than a banner: slimmer */
	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher.cookpal-launcher-slim {
		width: 50%;
		height: 36px;
		font-size: 13px;
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher-slim .cookpal-launcher-icon {
		width: 17px;
		height: 17px;
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher-slim .cookpal-launcher-go {
		width: 24px;
		height: 24px;
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher-slim .cookpal-launcher-go svg {
		width: 13px;
		height: 13px;
	}

	/* With search: a round button left of the pill, the two centred as one */
	#cookpal-chat-container[data-search]:not([data-mobile="tab"]) .cookpal-launcher {
		left: calc(50% + 27px);
	}

	#cookpal-chat-container[data-search]:not([data-mobile="tab"]) .cookpal-launcher.cookpal-launcher-slim {
		left: calc(50% + 22px);
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher.cookpal-search {
		left: calc(20% - 27px);
		transform: none;
		justify-content: center;
		width: 46px;
		padding: 0;
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-launcher.cookpal-search.cookpal-launcher-slim {
		left: calc(25% - 22px);
		width: 36px;
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-search .cookpal-launcher-icon {
		margin: 0;
	}

	#cookpal-chat-container:not([data-mobile="tab"]) .cookpal-search .cookpal-launcher-label {
		display: none;
	}
}

/* A line above the launcher when the chat could not be loaded */
#cookpal-chat-container .cookpal-launcher-note {
	position: fixed;
	padding: 10px 14px;
	border-radius: 14px;
	background: #ffffff;
	box-shadow: var(--cookpal-shadow-open);
	color: var(--cookpal-ink);
	font-size: 14px;
	line-height: 1.4;
}

#cookpal-chat-container .cookpal-launcher-note[data-at="pill"] {
	transform: translateX(-50%);
}

#cookpal-chat-container .cookpal-launcher-keyboard {
	position: fixed;
	width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	border: 0;
	opacity: 0;
	background: transparent;
	color: transparent;
	caret-color: transparent;
	font-size: 16px;
	pointer-events: none;
}

/* The page's questions stacked above the desktop tab, placed by the loader */
@keyframes cookpal-starters-in {
	from {
		opacity: 0;
		transform: scale(0.92);
	}
}

#cookpal-chat-container .cookpal-starters {
	position: fixed;
	right: 12px;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 6px;
	max-width: calc(100% - 24px);
	transform-origin: bottom right;
	animation: cookpal-starters-in 0.36s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#cookpal-chat-container[data-side="left"] .cookpal-starters {
	right: auto;
	left: 12px;
	align-items: flex-start;
	transform-origin: bottom left;
}

#cookpal-chat-container .cookpal-starters[hidden] {
	display: none;
}

#cookpal-chat-container .cookpal-starters-close {
	display: grid;
	place-items: center;
	width: 26px;
	height: 26px;
	border: 1px solid #e6e6e6;
	border-radius: 50%;
	background: #ffffff;
	color: var(--cookpal-muted);
	box-shadow: var(--cookpal-shadow);
}

#cookpal-chat-container .cookpal-starter {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	width: auto;
	max-width: 100%;
	padding: 7px 12px;
	border: 1.5px solid var(--cookpal-button);
	border-radius: 999px;
	background: #ffffff;
	color: var(--cookpal-ink);
	font-size: 14px;
	line-height: 1.3;
	text-align: start;
	box-shadow: var(--cookpal-shadow);
	transition: transform 0.18s, box-shadow 0.18s, background-color 0.18s, color 0.18s;
}

#cookpal-chat-container .cookpal-starter:hover {
	transform: translateY(-2px);
	background: var(--cookpal-button);
	color: var(--cookpal-on-button);
	box-shadow: var(--cookpal-shadow-open);
}

.cookpal-star {
	flex: none;
	color: var(--cookpal-focus);
}

.cookpal-starter:hover .cookpal-star {
	color: inherit;
}

/* The inline block inside a post: reset under its id so theme rules for
   divs, buttons and spans neither break it nor leak into it */
#cookpal-inline,
#cookpal-inline * {
	box-sizing: border-box;
	float: none;
	position: static;
	width: auto;
	min-width: 0;
	max-width: none;
	height: auto;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	outline: 0;
	font: inherit;
	letter-spacing: normal;
	word-spacing: normal;
	text-align: start;
	text-decoration: none;
	text-indent: 0;
	text-shadow: none;
	text-transform: none;
	white-space: normal;
	color: inherit;
	opacity: 1;
	transform: none;
	transition: none;
}

#cookpal-inline::before,
#cookpal-inline::after,
#cookpal-inline *::before,
#cookpal-inline *::after {
	content: none;
	display: none;
}

#cookpal-inline {
	--cookpal-inline-border: 1px;
	display: block;
	margin-block: clamp(24px, 4.17%, 32px);
	padding: 20px;
	border: var(--cookpal-inline-border) solid var(--cookpal-button);
	border-radius: 22px;
	background: #ffffff;
	box-shadow: var(--cookpal-shadow);
	color: var(--cookpal-ink);
	font-family: var(--cookpal-font);
	font-size: 15px;
	font-weight: 400;
	font-style: normal;
	line-height: 1.3;
}

#cookpal-inline .cookpal-inline-h {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-block-end: 12px;
	font-size: 19px;
	font-weight: 700;
	color: var(--cookpal-ink);
}

#cookpal-inline .cookpal-inline-h span {
	text-align: center;
}

#cookpal-inline svg {
	display: block;
	flex: none;
	overflow: visible;
}

#cookpal-inline .cookpal-inline-star {
	width: 22px;
	height: 22px;
	color: var(--cookpal-button);
}

#cookpal-inline .cookpal-inline-prompts {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
}

#cookpal-inline .cookpal-inline-prompt {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	max-width: 100%;
	padding: 8px 14px;
	border: var(--cookpal-inline-border) solid var(--cookpal-button);
	border-radius: 999px;
	background: #ffffff;
	color: var(--cookpal-ink);
	overflow-wrap: anywhere;
	cursor: pointer;
}

#cookpal-inline .cookpal-inline-prompt:is(:hover, :focus-visible) {
	background: #ededed;
}

#cookpal-inline .cookpal-inline-prompt:focus-visible {
	outline: 3px solid var(--cookpal-focus);
	outline-offset: 2px;
}

#cookpal-inline .cookpal-star {
	width: 10px;
	height: 10px;
	color: var(--cookpal-focus);
}

#cookpal-inline[data-style="filled"] {
	border-color: var(--cookpal-inline-fill);
	background: var(--cookpal-inline-fill);
}

#cookpal-inline[data-style="filled"] :is(.cookpal-inline-h, .cookpal-inline-star) {
	color: var(--cookpal-inline-on);
}

#cookpal-inline[data-style="filled"] .cookpal-inline-prompt {
	border-color: transparent;
}

#cookpal-inline[data-style="filled"] .cookpal-inline-prompt:focus-visible {
	outline-color: var(--cookpal-inline-on);
}

@media (prefers-reduced-motion: reduce) {
	#cookpal-chat-container *,
	#cookpal-chat-container *::before {
		animation: none !important;
		transition: none !important;
	}

	#cookpal-chat-container .cookpal-starter:hover {
		transform: none;
	}
}
