/*
 * A caixa de pedido e o palco da conversa (inc/caixa.php, assets/js/caixa-de-pedido.js):
 * o palco é tela cheia, como um Typeform, com uma pergunta por vez.
 *
 * Fica no @layer components, como o catálogo. Usa os tokens do tema (--primary,
 * --foreground...) e os do catálogo com o valor de reserva, porque a caixa
 * também vai a páginas sem o catalogo.css (a home).
 */
@layer properties, theme, base, components, utilities;

@layer components {
	.cx {
		--cx-tinta: var(--foreground, #1a1a2e);
		--cx-grafite: var(--cat-grafite, #4b5563);
		--cx-lapis: var(--cat-lapis, #5f6673);
		--cx-linha: var(--cat-linha-forte, rgb(26 26 46 / 0.16));
		--cx-acento: var(--cat-acento, #cf4a0c);
		--cx-acento-forte: var(--cat-acento-forte, #b13e0a);
		--cx-marca: var(--primary, #5b3df5);
		display: flex;
		width: min(44rem, 100%);
		flex-direction: column;
		align-items: center;
		gap: 0.875rem;
		margin-inline: auto;
	}

	/* O campo: borda escura e a sombra deslocada na cor da marca; o botão no laranja dos CTAs. */
	.cx-campo {
		display: flex;
		width: 100%;
		align-items: stretch;
		gap: 0.5rem;
		padding: 0.5rem;
		border-radius: 1rem;
		background: #fff;
		box-shadow: inset 0 0 0 2px var(--cx-tinta), 6px 6px 0 var(--cx-marca);
		text-align: left;
		transition: box-shadow 0.2s ease;
	}

	.cx-campo:focus-within {
		box-shadow: inset 0 0 0 2px var(--cx-acento), 6px 6px 0 var(--cx-marca);
	}

	.cx-texto {
		flex: 1;
		min-width: 0;
		min-height: 3.5rem;
		padding: 0.625rem 0.75rem;
		border: 0;
		outline: 0;
		resize: none;
		background: transparent;
		color: var(--cx-tinta);
		font: inherit;
		font-size: 1.0625rem;
		line-height: 1.45;
	}

	.cx-texto::placeholder {
		color: var(--cx-lapis);
	}

	.cx-enviar {
		display: inline-flex;
		flex: none;
		align-items: center;
		justify-content: center;
		gap: 0.5rem;
		min-height: 3rem;
		padding-inline: 1.25rem;
		border: 0;
		border-radius: 0.75rem;
		background: var(--cx-acento);
		color: #fff;
		font: inherit;
		font-size: 1.0625rem;
		font-weight: 600;
		white-space: nowrap;
		cursor: pointer;
		transition: background-color 0.2s ease;
	}

	.cx-enviar:hover {
		background: var(--cx-acento-forte);
	}

	.cx-enviar:focus-visible {
		outline: 2px solid var(--cx-marca);
		outline-offset: 2px;
	}

	/* Os exemplos: agentes (na página de app) ou áreas (com as sugestões embaixo). */
	.cx-chips {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: center;
		gap: 0.5rem;
	}

	.cx-chips__rotulo {
		color: var(--cx-lapis);
		font-size: 0.9375rem;
		font-weight: 500;
	}

	.cx-chip,
	.cx-sugestao {
		min-height: 2.25rem;
		padding: 0.375rem 0.875rem;
		border: 1px solid var(--cx-linha);
		border-radius: 9999px;
		background: #fff;
		color: var(--cx-grafite);
		font: inherit;
		font-size: 0.9375rem;
		line-height: 1.3;
		text-align: center;
		cursor: pointer;
		transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
	}

	.cx-chip:hover,
	.cx-sugestao:hover,
	.cx-chip[aria-expanded="true"] {
		border-color: var(--cx-marca);
		background: var(--accent, #f1edff);
		color: var(--cx-marca);
	}

	.cx-chip[aria-expanded="true"] {
		font-weight: 600;
	}

	.cx-sugestoes {
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		gap: 0.5rem;
	}

	.cx-sugestoes[hidden] {
		display: none;
	}

	.cx-sugestao {
		border-style: dashed;
	}

	/* ------------------------------------- O palco da conversa: tela cheia, como um Typeform */

	.cx-palco {
		--cx-tinta: var(--foreground, #1a1a2e);
		--cx-grafite: var(--cat-grafite, #4b5563);
		--cx-lapis: var(--cat-lapis, #5f6673);
		--cx-linha: var(--cat-linha-forte, rgb(26 26 46 / 0.16));
		--cx-acento: var(--cat-acento, #cf4a0c);
		--cx-acento-forte: var(--cat-acento-forte, #b13e0a);
		--cx-marca: var(--primary, #5b3df5);
		--cx-display: var(--cat-display, var(--font-bricolage, system-ui), sans-serif);
		--cx-erro: #b91c1c;
		position: fixed;
		z-index: 1000;
		inset: 0;
		display: flex;
		flex-direction: column;
		padding-top: env(safe-area-inset-top, 0px);
		padding-bottom: env(safe-area-inset-bottom, 0px);
		background:
			radial-gradient(60rem 30rem at 100% 0%, rgb(91 61 245 / 0.08), transparent 60%),
			radial-gradient(50rem 26rem at 0% 100%, rgb(207 74 12 / 0.07), transparent 60%),
			#fff;
		color: var(--cx-tinta);
		text-align: left;
	}

	.cx-palco[hidden] {
		display: none;
	}

	html.cx-aberto {
		overflow: hidden;
	}

	.cx-palco__topo {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 1rem;
		padding: 0.875rem max(1.25rem, env(safe-area-inset-right, 0px)) 0.875rem max(1.25rem, env(safe-area-inset-left, 0px));
	}

	.cx-palco__marca {
		display: inline-flex;
		align-items: center;
		gap: 0.625rem;
		font-weight: 600;
	}

	.cx-palco__cubo {
		display: inline-flex;
		width: 1.75rem;
		height: 1.75rem;
		color: var(--cx-marca);
	}

	.cx-palco__cubo svg,
	.cx-espera__cubo svg {
		width: 100%;
		height: 100%;
	}

	.cx-palco__fechar {
		display: inline-flex;
		width: 2.75rem;
		height: 2.75rem;
		flex: none;
		align-items: center;
		justify-content: center;
		border: 0;
		border-radius: 9999px;
		background: var(--secondary, #f4f5f8);
		color: var(--cx-tinta);
		font: inherit;
		font-size: 1.5rem;
		line-height: 1;
		cursor: pointer;
	}

	.cx-palco__progresso {
		height: 4px;
		background: rgb(91 61 245 / 0.12);
	}

	.cx-palco__progresso span {
		display: block;
		width: 4%;
		height: 100%;
		border-radius: 0 9999px 9999px 0;
		background: linear-gradient(90deg, var(--cx-marca), var(--cx-acento));
		transition: width 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
	}

	.cx-palco__cena {
		display: flex;
		flex: 1;
		overflow: auto;
		overscroll-behavior: contain;
		padding: 2rem max(1.25rem, env(safe-area-inset-right, 0px)) 2rem max(1.25rem, env(safe-area-inset-left, 0px));
	}

	.cx-palco__aviso {
		padding: 0.625rem 1.25rem 0.875rem;
		color: var(--cx-lapis);
		font-size: 0.8125rem;
		text-align: center;
	}

	/* A cena: entra de baixo e sai para cima. */
	.cx-cena {
		display: flex;
		width: min(42rem, 100%);
		flex-direction: column;
		gap: 1rem;
		margin: auto;
		transition: opacity 0.28s ease, transform 0.32s cubic-bezier(0.2, 0.7, 0.2, 1);
	}

	.cx-cena--entrando {
		opacity: 0;
		transform: translateY(18px);
	}

	.cx-cena--saindo {
		opacity: 0;
		transform: translateY(-14px);
		transition-duration: 0.18s;
	}

	.cx-disse {
		align-self: flex-start;
		padding: 0.5rem 0.75rem;
		border-radius: 0.75rem;
		background: var(--secondary, #f4f5f8);
		color: var(--cx-grafite);
		font-size: 0.9375rem;
		overflow-wrap: anywhere;
	}

	.cx-disse strong {
		color: var(--cx-tinta);
		font-weight: 600;
	}

	.cx-entendi {
		display: flex;
		align-items: flex-start;
		gap: 0.5rem;
		color: var(--cx-grafite);
		font-size: 1rem;
		line-height: 1.5;
	}

	.cx-entendi__check {
		display: inline-flex;
		width: 1.125rem;
		height: 1.125rem;
		flex: none;
		margin-top: 0.2rem;
		color: var(--cat-verde, #047857);
	}

	.cx-entendi__check svg,
	.cx-ok__check svg,
	.cx-sabia__brilho svg,
	.cx-final__selo svg {
		width: 100%;
		height: 100%;
	}

	/* A pergunta: o número, o texto grande e a dica. */
	.cx-pergunta__numero {
		display: inline-flex;
		align-items: center;
		gap: 0.375rem;
		margin-top: 0.25rem;
		color: var(--cx-marca);
		font-size: 0.9375rem;
		font-weight: 600;
	}

	.cx-pergunta__texto {
		font-family: var(--cx-display);
		font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.125rem);
		font-weight: 700;
		line-height: 1.18;
		letter-spacing: -0.02em;
		text-wrap: balance;
		outline: 0;
	}

	.cx-pergunta__dica {
		margin-top: -0.375rem;
		color: var(--cx-lapis);
		font-size: 0.9375rem;
	}

	/* As opções: cartões com o ícone (ou o logo), o texto e a tecla. */
	.cx-escolhas {
		display: grid;
		grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
		gap: 0.625rem;
		margin-top: 0.5rem;
	}

	.cx-escolhas--logos {
		grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
	}

	.cx-escolha {
		display: flex;
		min-height: 3.75rem;
		align-items: center;
		gap: 0.75rem;
		padding: 0.75rem 0.875rem;
		border: 1px solid var(--cx-linha);
		border-radius: 0.875rem;
		background: #fff;
		box-shadow: 0 1px 2px rgb(26 26 46 / 0.05);
		color: var(--cx-tinta);
		font: inherit;
		font-size: 1rem;
		font-weight: 500;
		line-height: 1.35;
		text-align: left;
		cursor: pointer;
		transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
		animation: cx-surgir 0.38s cubic-bezier(0.2, 0.7, 0.2, 1) both;
		animation-delay: var(--atraso, 0ms);
	}

	.cx-escolha:hover {
		border-color: var(--cx-marca);
		box-shadow: 0 8px 20px -12px rgb(91 61 245 / 0.5);
		transform: translateY(-1px);
	}

	.cx-escolha:focus-visible {
		outline: 2px solid var(--cx-marca);
		outline-offset: 2px;
	}

	.cx-escolha[aria-pressed="true"] {
		border-color: var(--cx-marca);
		background: var(--accent, #f1edff);
		box-shadow: inset 0 0 0 1px var(--cx-marca);
	}

	.cx-escolha--escolhida {
		animation: cx-piscar 0.42s ease;
	}

	.cx-escolha__figura {
		display: inline-flex;
		width: 2.5rem;
		height: 2.5rem;
		flex: none;
		align-items: center;
		justify-content: center;
		overflow: hidden;
		border-radius: 0.75rem;
		background: var(--accent, #f1edff);
		color: var(--cx-marca);
		transition: background-color 0.15s ease, color 0.15s ease;
	}

	.cx-escolha__figura svg {
		width: 1.375rem;
		height: 1.375rem;
	}

	.cx-escolha[aria-pressed="true"] .cx-escolha__figura {
		background: var(--cx-marca);
		color: #fff;
	}

	/* O logo da plataforma ocupa o quadro todo, no branco. */
	.cx-escolha__figura--logo,
	.cx-escolha[aria-pressed="true"] .cx-escolha__figura--logo {
		background: #fff;
		box-shadow: inset 0 0 0 1px var(--cx-linha);
	}

	.cx-escolha__figura--logo > span {
		width: 2.5rem !important;
		height: 2.5rem !important;
	}

	.cx-escolha__figura--logo svg {
		width: auto;
		height: auto;
	}

	.cx-escolha__rotulo {
		flex: 1;
		min-width: 0;
		overflow-wrap: anywhere;
	}

	/* Na grade de logos, o cartão é estreito: a letra vai para o canto, e o nome ("WooCommerce") ganha o espaço dela. */
	.cx-escolhas--logos .cx-escolha {
		position: relative;
	}

	.cx-escolhas--logos .cx-escolha__tecla {
		position: absolute;
		top: 0.375rem;
		right: 0.375rem;
	}

	.cx-escolha__tecla {
		display: inline-flex;
		min-width: 1.5rem;
		height: 1.5rem;
		flex: none;
		align-items: center;
		justify-content: center;
		padding: 0 0.375rem;
		border: 1px solid var(--cx-linha);
		border-radius: 0.375rem;
		background: #fff;
		color: var(--cx-lapis);
		font: inherit;
		font-size: 0.75rem;
		font-weight: 600;
	}

	.cx-escolha[aria-pressed="true"] .cx-escolha__tecla {
		border-color: var(--cx-marca);
		background: var(--cx-marca);
		color: #fff;
	}

	@keyframes cx-surgir {
		from {
			opacity: 0;
			transform: translateY(10px);
		}

		to {
			opacity: 1;
			transform: none;
		}
	}

	@keyframes cx-piscar {
		0%,
		100% {
			transform: none;
		}

		30% {
			transform: scale(0.98);
		}

		60% {
			transform: scale(1.01);
		}
	}

	/* As ações: OK, pular, voltar. */
	.cx-acoes {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 0.75rem 1.25rem;
		margin-top: 0.75rem;
	}

	.cx-acoes__dica,
	.cx-nota {
		color: var(--cx-lapis);
		font-size: 0.875rem;
		line-height: 1.5;
	}

	.cx-ok {
		display: inline-flex;
		min-height: 3rem;
		align-items: center;
		gap: 0.5rem;
		padding: 0 1.375rem;
		border: 0;
		border-radius: 0.75rem;
		background: var(--cx-marca);
		color: #fff;
		font: inherit;
		font-size: 1.0625rem;
		font-weight: 600;
		cursor: pointer;
		transition: filter 0.15s ease;
	}

	.cx-ok:hover {
		filter: brightness(1.08);
	}

	.cx-ok[disabled] {
		opacity: 0.45;
		cursor: not-allowed;
	}

	.cx-ok__check {
		display: inline-flex;
		width: 1.125rem;
		height: 1.125rem;
	}

	.cx-link {
		padding: 0;
		border: 0;
		background: none;
		color: var(--cx-marca);
		font: inherit;
		font-size: 0.9375rem;
		font-weight: 500;
		text-decoration: underline;
		text-underline-offset: 0.2em;
		cursor: pointer;
	}

	.cx-link--voltar {
		color: var(--cx-lapis);
		text-decoration: none;
	}

	.cx-link--voltar:hover {
		color: var(--cx-tinta);
	}

	/* A espera: o cubo flutuando e o "Você sabia?", num cartão como os do site. */
	.cx-espera {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 1.25rem;
		padding-block: 1rem;
		text-align: center;
	}

	.cx-espera__cubo {
		display: inline-flex;
		width: 3.5rem;
		height: 3.5rem;
		color: var(--cx-marca);
		filter: drop-shadow(0 12px 18px rgb(91 61 245 / 0.25));
		animation: cx-flutuar 2.4s ease-in-out infinite;
	}

	@keyframes cx-flutuar {
		0%,
		100% {
			transform: translateY(0) rotate(0);
		}

		50% {
			transform: translateY(-8px) rotate(-4deg);
		}
	}

	.cx-espera__titulo {
		font-family: var(--cx-display);
		font-size: 1.25rem;
		font-weight: 700;
		outline: 0;
	}

	.cx-sabia {
		width: min(36rem, 100%);
		padding: 1.125rem 1.375rem 1.25rem;
		border: 1px solid var(--cx-linha);
		border-radius: var(--cat-raio-card, 1.25rem);
		background: #fff;
		box-shadow: 0 1px 2px rgb(26 26 46 / 0.05), 0 24px 48px -32px rgb(91 61 245 / 0.4);
		color: var(--cx-tinta);
		text-align: left;
	}

	.cx-sabia__rotulo {
		display: flex;
		align-items: center;
		gap: 0.5rem;
		color: var(--cx-marca);
		font-size: 0.8125rem;
		font-weight: 700;
		letter-spacing: 0.06em;
		text-transform: uppercase;
	}

	.cx-sabia__brilho {
		display: inline-flex;
		width: 1rem;
		height: 1rem;
	}

	.cx-sabia__texto {
		min-height: 4.65em;
		margin-top: 0.625rem;
		font-size: 1.0625rem;
		line-height: 1.55;
		transition: opacity 0.25s ease;
	}

	.cx-sabia__texto--saindo {
		opacity: 0;
	}

	.cx-sabia__cursor {
		display: inline-block;
		width: 2px;
		height: 1.15em;
		margin-left: 2px;
		vertical-align: -0.2em;
		border-radius: 1px;
		background: var(--cx-marca);
		animation: cx-cursor 1s steps(1) infinite;
	}

	@keyframes cx-cursor {
		50% {
			opacity: 0;
		}
	}

	/* O fim: o agente, o que conectar e "Criar Agente Grátis". */
	.cx-final {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: 0.875rem;
	}

	.cx-final__selo {
		display: inline-flex;
		width: 3rem;
		height: 3rem;
		align-items: center;
		justify-content: center;
		padding: 0.75rem;
		border-radius: 9999px;
		background: linear-gradient(135deg, var(--cx-marca), var(--cx-acento));
		color: #fff;
		animation: cx-surgir 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
	}

	.cx-final__rotulo {
		color: var(--cx-marca);
		font-weight: 600;
	}

	.cx-final__titulo {
		font-family: var(--cx-display);
		font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
		font-weight: 800;
		line-height: 1.1;
		letter-spacing: -0.025em;
		text-wrap: balance;
		outline: 0;
	}

	.cx-final__resumo {
		max-width: 38rem;
		color: var(--cx-grafite);
		font-size: 1.125rem;
		line-height: 1.55;
	}

	.cx-final__conecta {
		margin-top: 0.25rem;
		color: var(--cx-lapis);
		font-size: 0.8125rem;
		font-weight: 700;
		letter-spacing: 0.05em;
		text-transform: uppercase;
	}

	.cx-final__apps {
		display: flex;
		flex-wrap: wrap;
		gap: 0.5rem;
		margin: 0;
		padding: 0;
		list-style: none;
	}

	.cx-final__apps li {
		display: inline-flex;
		align-items: center;
		gap: 0.5rem;
		padding: 0.3125rem 0.875rem 0.3125rem 0.3125rem;
		border: 1px solid var(--cx-linha);
		border-radius: 9999px;
		background: #fff;
		font-size: 0.9375rem;
		font-weight: 500;
	}

	.cx-final__logo {
		display: inline-flex;
		width: 1.75rem;
		height: 1.75rem;
		align-items: center;
		justify-content: center;
		overflow: hidden;
		border-radius: 9999px;
	}

	.cx-final__logo > span {
		width: 1.75rem !important;
		height: 1.75rem !important;
	}

	.cx-final__whatsapp .cx-final__logo {
		background: #25d366;
		color: #fff;
	}

	.cx-final__whatsapp .cx-final__logo svg {
		width: 1.0625rem;
		height: 1.0625rem;
	}

	.cx-ativar {
		display: inline-flex;
		min-height: 3.5rem;
		align-items: center;
		justify-content: center;
		gap: 0.625rem;
		margin-top: 0.5rem;
		padding: 0 1.75rem;
		border-radius: 0.875rem;
		background: var(--cx-acento);
		box-shadow: 0 12px 24px -12px rgb(207 74 12 / 0.75);
		color: #fff;
		border: 0;
		cursor: pointer;
		font-family: inherit;
		font-size: 1.125rem;
		font-weight: 700;
		text-decoration: none;
		transition: background-color 0.15s ease, transform 0.15s ease;
	}

	.cx-ativar:disabled {
		cursor: progress;
		opacity: 0.8;
		transform: none;
	}

	/* O nome e o e-mail corporativo antes do "Criar Agente Grátis", lado a lado. */
	.cx-contato {
		display: flex;
		width: 100%;
		flex-direction: column;
		align-items: flex-start;
		gap: 0.75rem;
		margin-top: 0.5rem;
		padding-top: 1.25rem;
		border-top: 1px solid var(--cx-linha);
	}

	.cx-contato [hidden] {
		display: none;
	}

	.cx-contato__titulo {
		color: var(--cx-tinta);
		font-weight: 600;
	}

	.cx-contato__campos {
		display: grid;
		width: 100%;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 0.75rem;
	}

	.cx-contato__campo {
		display: flex;
		min-width: 0;
		flex-direction: column;
		gap: 0.375rem;
	}

	.cx-contato__rotulo {
		color: var(--cx-grafite);
		font-size: 0.875rem;
		font-weight: 600;
	}

	.cx-contato__entrada {
		min-height: 3rem;
		padding: 0.625rem 0.875rem;
		border: 1px solid var(--cx-linha);
		border-radius: 0.75rem;
		background: #fff;
		color: var(--cx-tinta);
		font: inherit;
		font-size: 1rem;
	}

	.cx-contato__entrada:focus-visible {
		border-color: var(--cx-marca);
		outline: 3px solid rgb(91 61 245 / 0.2);
		outline-offset: 0;
	}

	.cx-contato__entrada[aria-invalid="true"] {
		border-color: var(--cx-erro);
	}

	.cx-contato__erro {
		color: var(--cx-erro);
		font-size: 0.8125rem;
		line-height: 1.4;
	}

	.cx-contato .cx-nota a {
		color: inherit;
		text-decoration: underline;
		text-underline-offset: 2px;
	}

	.cx-ativar:hover {
		background: var(--cx-acento-forte);
		transform: translateY(-1px);
	}

	@media (prefers-reduced-motion: reduce) {
		.cx-cena,
		.cx-escolha,
		.cx-palco__progresso span {
			transition: none;
		}

		.cx-escolha,
		.cx-escolha--escolhida,
		.cx-espera__cubo,
		.cx-final__selo,
		.cx-sabia__cursor {
			animation: none;
		}
	}

	@media (max-width: 40rem) {
		.cx-palco__cena {
			padding-top: 1.25rem;
		}

		.cx-escolhas {
			grid-template-columns: minmax(0, 1fr);
		}

		.cx-escolhas--logos {
			grid-template-columns: repeat(2, minmax(0, 1fr));
		}

		.cx-ativar {
			align-self: stretch;
		}

		.cx-contato__campos {
			grid-template-columns: minmax(0, 1fr);
		}
	}

	/* Sem teclado à vista (celular, tablet de toque): as letras das opções e o "ou aperte Enter" somem. */
	@media (max-width: 40rem), (hover: none) and (pointer: coarse) {
		.cx-escolha__tecla,
		.cx-acoes__dica {
			display: none;
		}
	}

	@media (max-width: 30rem) {
		.cx-campo {
			flex-direction: column;
			box-shadow: inset 0 0 0 2px var(--cx-tinta), 4px 4px 0 var(--cx-marca);
		}

		.cx-campo:focus-within {
			box-shadow: inset 0 0 0 2px var(--cx-acento), 4px 4px 0 var(--cx-marca);
		}

		.cx-enviar {
			width: 100%;
		}
	}
}
