/** Professional Standards — assistant. */

.ps-assistant {
	--ps-assistant-gap: clamp(0.75rem, 0.5rem + 1vw, 1.5rem);
	--ps-assistant-width: 24rem;
	--ps-assistant-radius: 1.25rem;
	--ps-assistant-shadow: 0 1.25rem 3rem rgb(23 75 53 / 0.28), 0 0.25rem 0.75rem rgb(23 75 53 / 0.18);
}

/* Not during the intro (it has the whole screen). */
html[data-ps-intro="play"] .ps-assistant {
	display: none;
}

/* ---------------------------------------------------------------- The face */

.ps-assistant__face {
	inline-size: 2.5rem;
	block-size: 2.5rem;
	flex: none;
}

.ps-assistant__face-bg {
	fill: var(--ps-color-neutral-0);
}

.ps-assistant__face-ring {
	fill: none;
	stroke-width: 5;
}

.ps-assistant__face-seed {
	fill: var(--ps-color-logo-seed);
}

.ps-assistant__stop--frame {
	stop-color: var(--ps-color-turquoise);
}

.ps-assistant__stop--seed {
	stop-color: var(--ps-color-logo-seed);
}

.ps-assistant__stop--dash {
	stop-color: var(--ps-color-logo-navy);
}

/* ---------------------------------------------------------------- The button */

.ps-assistant__launcher {
	position: fixed;
	z-index: 90;
	inset-block-end: calc(var(--ps-assistant-gap) + env(safe-area-inset-bottom, 0px));
	inset-inline-end: var(--ps-assistant-gap);
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	padding-block: 0.375rem;
	padding-inline: 0.375rem 1.15rem;
	border: 0;
	border-radius: var(--ps-radius-pill);
	background-color: var(--ps-scene-bg);
	color: var(--ps-scene-text);
	font: inherit;
	font-weight: 700;
	font-size: var(--ps-step-0);
	line-height: 1;
	box-shadow: var(--ps-assistant-shadow);
	cursor: pointer;
	transition: transform var(--ps-duration-base) var(--ps-ease-out), box-shadow var(--ps-duration-base) var(--ps-ease-out);
}

.ps-assistant__launcher[hidden],
.ps-assistant.is-open .ps-assistant__launcher {
	display: none;
}

.ps-assistant__launcher:hover {
	transform: translateY(-2px);
}

/* The seed's little orange heartbeat ring on hover: the brand's small accent. */
.ps-assistant__launcher:hover .ps-assistant__face-bg,
.ps-assistant__launcher:focus-visible .ps-assistant__face-bg {
	fill: var(--ps-color-neutral-0);
	stroke: var(--ps-accent);
	stroke-width: 2;
}

.ps-assistant__launcher:focus-visible {
	outline: 3px solid var(--ps-focus-halo);
	outline-offset: 3px;
}

/* Phones: the face alone (its name is still read aloud). */
@media (max-width: 40rem) {
	.ps-assistant__launcher {
		padding: 0.3rem;
	}

	.ps-assistant__launcher .ps-assistant__face {
		inline-size: 2.9rem;
		block-size: 2.9rem;
	}

	.ps-assistant__launcher-text {
		position: absolute;
		inline-size: 1px;
		block-size: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}
}

/* An article's reading stem lives at the same edge: it stops above the button. */
body:has(.ps-assistant__launcher:not([hidden])) .ps-reading-stem {
	inset-block-end: 5.25rem;
}

/* ---------------------------------------------------------------- The window */

.ps-assistant__panel {
	position: fixed;
	z-index: 95;
	inset-block-end: calc(var(--ps-assistant-gap) + env(safe-area-inset-bottom, 0px));
	inset-inline-end: var(--ps-assistant-gap);
	display: flex;
	flex-direction: column;
	inline-size: min(var(--ps-assistant-width), calc(100vw - 2 * var(--ps-assistant-gap)));
	block-size: min(40rem, calc(100dvh - 2 * var(--ps-assistant-gap) - 5rem));
	border-radius: var(--ps-assistant-radius);
	background-color: var(--ps-surface);
	color: var(--ps-text);
	box-shadow: var(--ps-assistant-shadow);
	overflow: hidden;
	animation: ps-assistant-in var(--ps-duration-slow) var(--ps-ease-out);
	transform-origin: bottom var(--ps-assistant-origin, left);
}

[dir="ltr"] .ps-assistant__panel {
	--ps-assistant-origin: right;
}

.ps-assistant__panel[hidden] {
	display: none;
}

@keyframes ps-assistant-in {
	from {
		opacity: 0;
		transform: translateY(0.75rem) scale(0.97);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@media (max-width: 40rem) {
	/* The whole screen: above the sticky header too (the window's own head has the close button). */
	.ps-assistant__panel {
		z-index: calc(var(--ps-z-header) + 10);
		inset: 0;
		inline-size: 100%;
		block-size: 100dvh;
		border-radius: 0;
	}

	html.ps-assistant-open,
	html.ps-assistant-open body {
		overflow: hidden;
	}
}

/* The head. */
.ps-assistant__head {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	padding: 0.75rem 1rem;
	padding-block-start: calc(0.75rem + env(safe-area-inset-top, 0px));
	background-color: var(--ps-scene-bg);
	color: var(--ps-scene-text);
}

.ps-assistant__who {
	flex: 1;
	min-inline-size: 0;
}

.ps-assistant__name {
	margin: 0;
	font-size: var(--ps-step-1);
	line-height: 1.2;
}

.ps-assistant__sub {
	margin: 0.15rem 0 0;
	color: var(--ps-scene-text-muted);
	font-size: var(--ps-step--1);
	line-height: 1.4;
}

.ps-assistant__tool {
	display: inline-grid;
	place-items: center;
	inline-size: 2.5rem;
	block-size: 2.5rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.ps-assistant__tool .ps-icon {
	inline-size: 1.25rem;
	block-size: 1.25rem;
}

.ps-assistant__tool:hover {
	background-color: rgb(255 255 255 / 0.12);
}

.ps-assistant__tool:focus-visible {
	outline: 2px solid var(--ps-focus-inverse);
	outline-offset: 2px;
}

/* The conversation. */
.ps-assistant__log {
	position: relative;
	flex: 1;
	min-block-size: 0;
	padding: 1rem;
	overflow-y: auto;
	overscroll-behavior: contain;
	scroll-padding-block-start: 0.75rem;
}

.ps-assistant__log:focus-visible {
	outline: 2px solid var(--ps-focus-halo);
	outline-offset: -2px;
}

.ps-assistant__turn {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin-block-end: 0.9rem;
	animation: ps-assistant-turn var(--ps-duration-base) var(--ps-ease-out);
}

@keyframes ps-assistant-turn {
	from {
		opacity: 0;
		transform: translateY(0.35rem);
	}
}

.ps-assistant__bubble {
	max-inline-size: 92%;
	margin: 0;
	padding: 0.7rem 0.95rem;
	border-radius: 1rem;
	font-size: var(--ps-step-0);
	line-height: 1.75;
	overflow-wrap: anywhere;
}

.ps-assistant__turn--you {
	align-items: flex-end;
}

.ps-assistant__turn--you .ps-assistant__bubble {
	border-end-end-radius: 0.3rem;
	background-color: var(--ps-scene-bg);
	color: var(--ps-scene-text);
	white-space: pre-wrap;
}

.ps-assistant__turn--assistant {
	align-items: flex-start;
}

.ps-assistant__turn--assistant .ps-assistant__bubble {
	border: 1px solid var(--ps-border);
	border-end-start-radius: 0.3rem;
	background-color: var(--ps-bg);
}

.ps-assistant__bubble p {
	margin: 0 0 0.55rem;
}

.ps-assistant__bubble > :last-child {
	margin-block-end: 0;
}

.ps-assistant__bubble .ps-assistant__lead {
	font-weight: 700;
}

.ps-assistant__bubble ul,
.ps-assistant__bubble ol {
	margin: 0 0 0.55rem;
	padding-inline-start: 1.2rem;
}

.ps-assistant__bubble li {
	margin-block-end: 0.3rem;
}

.ps-assistant__bubble li::marker {
	color: var(--ps-color-logo-seed);
}

.ps-assistant__link {
	color: var(--ps-link);
	font-weight: 700;
	text-decoration-color: var(--ps-link-decoration);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.2em;
}

.ps-assistant__link:hover {
	text-decoration-color: var(--ps-accent);
}

/* «يكتب…»: three dots that breathe. */
.ps-assistant__dots {
	display: inline-flex;
	gap: 0.3rem;
	padding-block: 0.35rem;
}

.ps-assistant__dots::before,
.ps-assistant__dots::after,
.ps-assistant__turn--typing .ps-assistant__bubble::before {
	content: "";
	inline-size: 0.45rem;
	block-size: 0.45rem;
	border-radius: 50%;
	background-color: var(--ps-color-logo-seed);
	animation: ps-assistant-dot 1s var(--ps-ease-in-out) infinite;
}

.ps-assistant__turn--typing .ps-assistant__bubble {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
}

.ps-assistant__dots::before {
	animation-delay: 0.15s;
}

.ps-assistant__dots::after {
	animation-delay: 0.3s;
}

@keyframes ps-assistant-dot {
	0%,
	100% {
		opacity: 0.35;
		transform: translateY(0);
	}

	50% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

/* The buttons to the team. */
.ps-assistant__acts {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
}

.ps-assistant__act {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	min-block-size: 2.5rem;
	padding: 0.45rem 0.9rem;
	border: 1.5px solid var(--ps-scene-bg);
	border-radius: var(--ps-radius-pill);
	background-color: var(--ps-bg);
	color: var(--ps-scene-bg);
	font-size: var(--ps-step--1);
	font-weight: 700;
	line-height: 1.2;
	text-decoration: none;
}

.ps-assistant__act .ps-icon {
	inline-size: 1.1rem;
	block-size: 1.1rem;
	flex: none;
}

.ps-assistant__act:hover {
	background-color: var(--ps-scene-bg);
	color: var(--ps-scene-text);
}

/* The free consultation: the one orange touch (navy words on orange: 5.4:1). */
.ps-assistant__act--consult {
	border-color: var(--ps-accent);
	background-color: var(--ps-accent);
	color: var(--ps-color-navy);
}

.ps-assistant__act--consult:hover {
	border-color: var(--ps-scene-bg);
}

.ps-assistant__act:focus-visible,
.ps-assistant__chip:focus-visible,
.ps-assistant__social:focus-visible,
.ps-assistant__contact:focus-visible,
.ps-assistant__link:focus-visible,
.ps-assistant__send:focus-visible,
.ps-assistant__input:focus-visible {
	outline: 3px solid var(--ps-focus-halo);
	outline-offset: 2px;
}

/* The questions to tap. */
.ps-assistant__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	max-inline-size: 100%;
}

.ps-assistant__chips-title {
	flex-basis: 100%;
	margin: 0.2rem 0 0;
	color: var(--ps-text-muted);
	font-size: var(--ps-step--1);
	font-weight: 700;
}

.ps-assistant__chip {
	padding: 0.45rem 0.85rem;
	border: 1.5px solid var(--ps-color-turquoise-a60);
	border-radius: var(--ps-radius-pill);
	background-color: var(--ps-bg);
	color: var(--ps-text);
	font: inherit;
	font-size: var(--ps-step--1);
	line-height: 1.4;
	text-align: start;
	cursor: pointer;
	transition: background-color var(--ps-duration-fast), border-color var(--ps-duration-fast);
}

.ps-assistant__chip:hover {
	border-color: var(--ps-color-turquoise);
	background-color: var(--ps-color-turquoise-a10);
}

.ps-assistant__retry {
	align-self: flex-start;
}

/* The cards. */
.ps-assistant__card {
	inline-size: min(100%, 20rem);
	padding: 0.75rem 0.85rem;
	border-radius: 0.9rem;
	background-color: var(--ps-scene-bg);
	color: var(--ps-scene-text);
}

.ps-assistant__card-title {
	margin: 0 0 0.45rem;
	font-size: var(--ps-step--1);
	font-weight: 700;
	color: var(--ps-scene-text-muted);
}

.ps-assistant__card-list {
	display: grid;
	gap: 0.3rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ps-assistant__card--social .ps-assistant__card-list {
	grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
}

.ps-assistant__contact,
.ps-assistant__social {
	display: grid;
	grid-template-columns: auto 1fr;
	align-items: center;
	column-gap: 0.55rem;
	padding: 0.35rem 0.4rem;
	border-radius: 0.6rem;
	color: inherit;
	text-decoration: none;
}

.ps-assistant__social {
	display: flex;
	gap: 0.45rem;
	font-size: var(--ps-step--1);
	font-weight: 700;
}

.ps-assistant__contact .ps-icon,
.ps-assistant__social .ps-icon {
	grid-row: span 2;
	inline-size: 1.25rem;
	block-size: 1.25rem;
	color: var(--ps-color-turquoise);
}

a.ps-assistant__contact:hover,
.ps-assistant__social:hover {
	background-color: rgb(255 255 255 / 0.1);
}

.ps-assistant__contact-label {
	font-size: 0.78rem;
	color: var(--ps-scene-text-muted);
	line-height: 1.3;
}

.ps-assistant__contact-value {
	font-weight: 700;
	line-height: 1.35;
	overflow-wrap: anywhere;
}

/* The box. */
.ps-assistant__form {
	display: flex;
	align-items: flex-end;
	gap: 0.5rem;
	padding: 0.65rem 0.75rem 0.4rem;
	border-block-start: 1px solid var(--ps-border);
	background-color: var(--ps-bg);
}

.ps-assistant__input {
	flex: 1;
	min-block-size: 2.75rem;
	max-block-size: 7rem;
	padding: 0.6rem 0.85rem;
	border: 1.5px solid var(--ps-border);
	border-radius: 1.4rem;
	background-color: var(--ps-surface);
	color: var(--ps-text);
	font: inherit;
	font-size: max(16px, var(--ps-step-0)); /* 16px+: phones do not zoom into the box. */
	line-height: 1.5;
	resize: none;
}

.ps-assistant__input:focus {
	border-color: var(--ps-color-turquoise);
	background-color: var(--ps-bg);
}

.ps-assistant__send {
	display: inline-grid;
	place-items: center;
	flex: none;
	inline-size: 2.75rem;
	block-size: 2.75rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: var(--ps-scene-bg);
	color: var(--ps-scene-text);
	cursor: pointer;
}

.ps-assistant__send .ps-icon {
	inline-size: 1.25rem;
	block-size: 1.25rem;
}

/* The send arrow points the way the text runs. */
[dir="rtl"] .ps-assistant__send .ps-icon {
	transform: scaleX(-1);
}

.ps-assistant__send:hover {
	background-color: var(--ps-color-logo-navy);
}

.ps-assistant__note {
	margin: 0;
	padding: 0 0.9rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
	background-color: var(--ps-bg);
	color: var(--ps-text-muted);
	font-size: 0.78rem;
	line-height: 1.5;
}

.ps-assistant__note a {
	color: var(--ps-text);
	font-weight: 700;
	text-decoration-color: var(--ps-link-decoration);
}

/* Reduced motion (or the footer's «إيقاف الحركة»): no movement at all. */
@media (prefers-reduced-motion: reduce) {
	.ps-assistant__panel,
	.ps-assistant__turn,
	.ps-assistant__dots::before,
	.ps-assistant__dots::after,
	.ps-assistant__turn--typing .ps-assistant__bubble::before {
		animation: none;
	}

	.ps-assistant__launcher:hover {
		transform: none;
	}
}

html[data-ps-motion="off"] .ps-assistant__panel,
html[data-ps-motion="off"] .ps-assistant__turn {
	animation: none;
}

/* Windows high-contrast: the bubbles keep their edges. */
@media (forced-colors: active) {
	.ps-assistant__bubble,
	.ps-assistant__card,
	.ps-assistant__launcher {
		border: 1px solid CanvasText;
	}
}

@media print {
	.ps-assistant {
		display: none;
	}
}
