/* Fake AI prompt on homepage, sits between hero and main nav */

/* The chat's own neutrals, all mixed from the page ink so they follow the
   theme: secondary text, hairlines, the soft fill, one low shadow. */
.introChat,
.homeAssistant {
  --ha-muted: color-mix(in srgb, var(--frgd) 64%, transparent);
  --ha-line: color-mix(in srgb, var(--frgd) 10%, transparent);
  --ha-line-strong: color-mix(in srgb, var(--frgd) 22%, transparent);
  --ha-fill: color-mix(in srgb, var(--frgd) 5%, transparent);
  --ha-shadow: 0 1px 2px rgb(5 0 56 / 4%), 0 12px 28px -18px rgb(5 0 56 / 22%);
  /* The two brand tints the gradients are mixed from: the site's blue and a
     lilac beside it. Used in small doses only. */
  --ha-blue: #5670ff;
  --ha-lilac: #9b8cff;
}

.homeAssistant {
  min-height: 70vh;
  display: flex;
  box-sizing: border-box;
  width: 100%;
  max-width: 720px;
  margin: -8px auto 0;
  padding: 0 var(--space-4) var(--space-6);
  position: relative;
  z-index: 4;
  align-content: center;
  align-items: center;
}

.homeAssistant__inner {
  box-sizing: border-box;
  width: 100%;
  padding: var(--space-7) var(--space-4) var(--space-4);
  border-radius: 20px;
  background: var(--bkgd);
  box-shadow: none;
}

.homeAssistant__thread {
  box-sizing: border-box;
  min-height: 28vh;
  max-height: none;
  overflow-y: auto;
  margin: 0 0 var(--space-5);
  padding: 8px 4px 12px;
  scroll-behavior: smooth;
}

.homeAssistant__thread::-webkit-scrollbar {
  width: 6px;
}

.homeAssistant__thread::-webkit-scrollbar-thumb {
  background: rgb(97 97 97 / 25%);
  border-radius: 999px;
}

.homeAssistant__message {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  animation: homeAssistantMessageIn 0.35s ease;
}

.homeAssistant__message--user {
  justify-content: flex-end;
}

.homeAssistant__message--bot {
  justify-content: flex-start;
}

.homeAssistant__avatar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--ha-fill);
}

/* Both sides are bubbles. Ricardo's is near-white with a faint cool fall-off
   and the corner by his avatar squared; the visitor's is a pale blue-to-lilac
   wash. */
.homeAssistant__bubble {
  box-sizing: border-box;
  max-width: min(100%, 520px);
  font-family: var(--font-text);
  font-size: var(--text-body);
  line-height: 1.5;
  color: var(--frgd);
  overflow-wrap: break-word;
}

.homeAssistant__bubble p,
.homeAssistant__bubble li {
  margin: 0 0 0.65em;
  font-size: inherit;
  line-height: inherit;
  text-align: inherit;
}

.homeAssistant__bubble p:last-child,
.homeAssistant__bubble li:last-child {
  margin-bottom: 0;
}

.homeAssistant__bubble--bot {
  padding: 12px 16px;
  border-radius: 6px 18px 18px 18px;
  background-color: var(--bkgd, #fff);
  background-image: linear-gradient(180deg, var(--bkgd, #fff) 40%, color-mix(in srgb, var(--ha-blue) 3%, var(--bkgd, #fff)));
  box-shadow: 0 0 0 1px var(--ha-line), 0 1px 2px rgb(5 0 56 / 4%), 0 10px 24px -18px rgb(5 0 56 / 24%);
}

/* A 1px border in a slightly deeper version of the same blue-to-lilac wash,
   so the pill keeps its edge against the tinted page. Two background layers:
   the fill clipped to the padding box, the border colour showing through a
   transparent border. Longhands only (see scripts/critical-css.mjs). */
.homeAssistant__bubble.homeAssistant__bubble--user {
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 18px;
  background-color: color-mix(in srgb, var(--ha-blue) 10%, var(--bkgd, #fff));
  background-image:
    linear-gradient(120deg, color-mix(in srgb, var(--ha-blue) 11%, var(--bkgd, #fff)), color-mix(in srgb, var(--ha-lilac) 13%, var(--bkgd, #fff))),
    linear-gradient(120deg, color-mix(in srgb, var(--ha-blue) 26%, var(--bkgd, #fff)), color-mix(in srgb, var(--ha-lilac) 30%, var(--bkgd, #fff)));
  background-origin: padding-box, border-box;
  background-clip: padding-box, border-box;
}

.homeAssistant__message--reasoning {
  align-items: center;
  margin-bottom: 10px;
}

.homeAssistant__thinking {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  max-width: 100%;
  padding: 4px 0;
  font-family: var(--font-meta);
  font-size: var(--text-meta);
  font-weight: var(--weight-ui);
  line-height: 1.35;
  letter-spacing: var(--tracking-meta);
  color: var(--ha-muted);
}

.homeAssistant__thinkingGlow {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  margin-right: 2px;
  border-radius: 50%;
  background: var(--ha-line-strong);
  animation: homeAssistantThinkingBreathe 1.8s ease-in-out infinite;
  transform-origin: center center;
  will-change: transform;
}

.homeAssistant__thinkingTime,
.homeAssistant__thinkingTokens,
.homeAssistant__thinkingAction {
  flex: 0 1 auto;
  white-space: nowrap;
}

.homeAssistant__thinkingSep {
  flex: 0 0 auto;
  line-height: 1;
}

.homeAssistant__thinkingAction {
  display: inline-block;
  min-width: 0;
  white-space: normal;
}

.homeAssistant__thinkingAction.is-swap {
  animation: homeAssistantReasoningSwap 0.45s ease;
}

.homeAssistant__thinkingAction.is-failure {
  color: #a14a3a;
}

.homeAssistant__bubble a {
  font-weight: 400;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Sources under a reply: a quiet label and one small chip per page. */
.homeAssistant__bubble .homeAssistant__caseSource {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
  font-family: var(--font-meta);
  font-size: var(--text-functional-sm);
  line-height: 1.3;
  letter-spacing: var(--tracking-meta);
  color: var(--ha-muted);
  font-weight: var(--weight-ui);
}

.homeAssistant__bubble .homeAssistant__caseLink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--ha-line);
  border-radius: 8px;
  font-weight: var(--weight-ui);
  color: var(--frgd);
  text-decoration: none;
  text-transform: capitalize;
  transition: background 0.15s ease;
}

.homeAssistant__bubble .homeAssistant__caseLink:hover {
  background: var(--ha-fill);
}

.homeAssistant__caseFavicon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ha-fill);
  font-size: 0.5625rem;
  font-weight: 700;
  line-height: 1;
}

.homeAssistant__bubble .homeAssistant__lead {
  margin: 0 0 10px;
}

/* Suggested follow-up questions under a reply */
.homeAssistant__related {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 2px;
}

.homeAssistant__relatedChip {
  box-sizing: border-box;
  max-width: 100%;
  padding: 6px 12px;
  font-family: var(--font-text);
  font-size: var(--text-functional);
  line-height: 1.3;
  font-weight: var(--weight-ui);
  text-align: left;
  color: var(--frgd);
  background: transparent;
  border: 1px solid var(--ha-line);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.homeAssistant__relatedChip:hover:not(:disabled) {
  background: var(--ha-fill);
}

.homeAssistant__relatedChip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.homeAssistant__quote {
  margin: 0 0 10px;
  padding: 10px 12px;
  font-style: italic;
  border-radius: 10px;
  background: var(--ha-fill);
}

.homeAssistant__bubble .homeAssistant__quoteMeta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 4px;
  font-family: var(--font-meta);
  font-size: var(--text-functional);
  line-height: 1.4;
  letter-spacing: var(--tracking-meta);
  font-weight: var(--weight-ui);
}

.homeAssistant__quoteAvatarWrap {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  overflow: hidden;
  border-radius: 50%;
}

.homeAssistant__quoteAvatarWrap .homeAssistant__quoteAvatar {
  display: block;
  margin: 0;
  transform: scale(0.5714285714);
  transform-origin: top left;
  filter: grayscale(1);
  opacity: 0.85;
}

.homeAssistant__quoteMetaText {
  min-width: 0;
}

.homeAssistant__bubble .homeAssistant__fallback {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  font-family: var(--font-meta);
  font-size: var(--text-functional-sm);
  letter-spacing: var(--tracking-meta);
  color: var(--ha-muted);
  background: var(--ha-fill);
  font-weight: var(--weight-ui);
}

/* Scoped to the bubble so it outranks `.homeAssistant__bubble p`. */
.homeAssistant__bubble .homeAssistant__cqCredit {
  margin: 10px 0 0;
  font-family: var(--font-meta);
  font-size: var(--text-meta);
  line-height: 1.2;
  letter-spacing: var(--tracking-meta);
  color: var(--ha-muted);
  font-weight: var(--weight-ui);
}

.homeAssistant__cqCredit a {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  color: inherit;
  text-decoration: none;
}

.homeAssistant__cqCredit a:hover .homeAssistant__cqMadeByLabel,
.homeAssistant__cqMadeBy a:hover .homeAssistant__cqMadeByLabel {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* The small print under the field. The disclaimer goes once the first answer
   starts loading. */
.homeAssistant__disclaimer,
.homeAssistant__cqMadeBy {
  margin: 0;
  padding: 0;
  font-family: var(--font-meta);
  font-size: var(--text-meta);
  line-height: 1.4;
  letter-spacing: var(--tracking-meta);
  text-align: center;
  color: var(--ha-muted);
  font-weight: var(--weight-ui);
}

.homeAssistant__cqMadeBy {
  filter: grayscale(1);
  transition: filter 0.15s ease;
}

.homeAssistant__cqMadeBy:hover,
.homeAssistant__cqMadeBy:focus-within {
  filter: none;
}

.homeAssistant__cqMadeBy a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  color: inherit;
  text-decoration: none;
}

.homeAssistant__cqMadeByLabel {
  white-space: nowrap;
}

.homeAssistant__cqLogo {
  display: block;
  width: auto;
  height: auto;
  object-fit: contain;
}

.homeAssistant__cqLogo--form {
  width: 52px;
  height: 15px;
}

.homeAssistant__cqLogo--msg {
  width: 36px;
  height: 10px;
}

.homeAssistant__form {
  display: flex;
  margin-bottom: var(--space-3);
}

.homeAssistant__form--busy {
  opacity: 0.72;
}

.homeAssistant__field {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  width: 100%;
}

/* One hairline ring and a low shadow; focus swaps the ring for the ink. */
.homeAssistant__input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 14px 52px 14px 16px;
  font-family: var(--font-text);
  font-size: var(--text-body);
  line-height: 1.5;
  color: var(--frgd);
  caret-color: var(--frgd);
  background: var(--bkgd, #fff);
  border: 0;
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--ha-line-strong), var(--ha-shadow);
  outline: none;
  transition: box-shadow 0.15s ease;
}

.homeAssistant__input::placeholder {
  color: var(--ha-muted);
  opacity: 1;
}

.homeAssistant__field:focus-within .homeAssistant__input {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ha-blue) 60%, var(--frgd)), 0 0 0 4px color-mix(in srgb, var(--ha-blue) 14%, transparent), var(--ha-shadow);
}

.homeAssistant__input:disabled {
  cursor: not-allowed;
}

.homeAssistant__submit {
  position: absolute;
  right: 8px;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--frgd);
  background-color: var(--action, #ffd02f);
  background-image: linear-gradient(180deg, color-mix(in srgb, #fff 28%, var(--action, #ffd02f)), var(--action, #ffd02f));
  border: 0;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgb(5 0 56 / 8%), 0 1px 2px rgb(5 0 56 / 10%);
  cursor: pointer;
  transform: translateY(-50%);
  transition: opacity 0.15s ease;
}

.homeAssistant__submit .material-symbols-outlined {
  font-size: 1.25rem;
  line-height: 1;
  color: inherit;
}

.homeAssistant__submit:hover {
  background-image: none;
}

.homeAssistant__submit:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.homeAssistant__submit:focus-visible,
.homeAssistant__chip:focus-visible,
.homeAssistant__relatedChip:focus-visible {
  outline: 2px solid var(--frgd);
  outline-offset: 2px;
}

.homeAssistant__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.homeAssistant__suggestions li {
  display: flex;
  margin: 0;
}

.homeAssistant__chip {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  font-family: var(--font-text);
  font-size: var(--text-functional);
  line-height: 1.3;
  font-weight: var(--weight-ui);
  color: var(--frgd);
  text-decoration: none;
  background: color-mix(in srgb, var(--bkgd, #fff) 75%, transparent);
  border: 1px solid var(--ha-line);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.homeAssistant__chip .material-symbols-outlined {
  font-size: 1rem;
  flex: 0 0 auto;
  color: var(--ha-muted);
}

.homeAssistant__chip:hover:not(:disabled) {
  background: var(--bkgd, #fff);
  border-color: var(--ha-line-strong);
}

.homeAssistant__chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@keyframes homeAssistantMessageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes homeAssistantThinkingBreathe {
  0%,
  100% {
    transform: scale(0.72);
    opacity: 0.72;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
}

@keyframes homeAssistantReasoningSwap {
  from {
    opacity: 0.2;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 769px) {
  .homeAssistant {
    display: block !important;
  }
}

@media (max-width: 520px) {
  .homeAssistant__inner {
    padding: 0;
  }

  .homeAssistant__thread {
    min-height: 24vh;
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .homeAssistant__message,
  .homeAssistant__thinkingGlow,
  .homeAssistant__thinkingAction.is-swap {
    animation: none;
  }

  .homeAssistant__thinkingGlow {
    transform: none;
    opacity: 1;
  }

  .homeAssistant__thread {
    scroll-behavior: auto;
  }
}
