/* Aria chat: the section around it and the chat card. Forest-led, from the Aria chat design. */

.aria {
  background: var(--surface);
  color: var(--color-white);
  padding-block: var(--space-6) 28px;
  scroll-margin-top: calc(var(--header-h) + var(--space-4));
}

.aria__intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  text-align: center;
}

.aria__eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-sky);
}
.aria__eyebrow::before {
  content: '';
  width: 22px;
  height: 1px;
  background: currentColor;
}

/* On phones the card follows the eyebrow directly; the heading stays for screen readers. */
.aria__title {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.aria__lead { display: none; }

/* Soft lime halo behind the chat card — gives the card some depth against
   the flat forest-deep section instead of sitting perfectly flush with it.
   A blurred, slightly-oversized fill sits behind the card; the card itself
   stays fully opaque, so this never touches text contrast. Single-tone
   lime rather than the sky-to-lime gradient: blurring the sky (a grayish
   blue) read as a dirty smear on one side instead of a clean glow
   (Andrés's feedback, 2026-09-24) — one hue reads as a deliberate accent,
   matching the rest of the page's "lime as a small, solid accent" rule.
   Wraps .chat instead of living inside it because .chat needs its own
   overflow:hidden (message list, rounded corners) which would otherwise
   clip the glow where it extends past the card's edges. */
.chat-glow {
  position: relative;
}
.chat-glow::before {
  content: '';
  position: absolute;
  /* Kept tight on mobile (gutter is only 20px there) so the glow's box
     never pushes past the viewport edge into a horizontal scrollbar —
     the blur itself doesn't affect layout, only this inset does. */
  inset: -14px;
  background: var(--color-lime);
  border-radius: 34px;
  filter: blur(28px);
  opacity: 0.3;
  pointer-events: none;
}

/* CARD */
.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  height: clamp(420px, 70vh, 560px);
  height: clamp(420px, 70dvh, 560px);
  max-width: 760px;
  margin-inline: auto;
  overflow: hidden;
  background: var(--color-forest);
  border: 1px solid rgb(157 196 213 / 0.22);
  border-radius: var(--radius-lg);
}

.chat__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px var(--space-4);
  background: rgb(157 196 213 / 0.07);
  border-bottom: 1px solid rgb(255 255 255 / 0.12);
}

.chat__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-forest-raised);
}
.chat__avatar img { height: 26px; width: auto; display: block; }

.chat__who {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.chat__name { display: flex; align-items: center; gap: var(--space-2); }
.chat__title { font-size: 1.0625rem; font-weight: var(--fw-semibold); color: var(--color-white); }
.chat__tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding-inline: var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-lime);
  color: var(--color-forest);
  font-size: 0.6875rem;
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
}

.chat__status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-small);
  color: rgb(255 255 255 / 0.75);
}
.chat__status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-sky);
}
.chat__status[data-state='typing'] { color: var(--color-lime); }
.chat__status[data-state='typing']::before {
  background: var(--color-lime);
  animation: status-pulse 1.6s cubic-bezier(0.2, 0.8, 0.3, 1) infinite;
}
.chat__status[data-state='offline']::before { background: rgb(255 255 255 / 0.45); }

.chat__badge { display: none; }

/* MESSAGES
   Two layers, not one: .chat__scroll owns the scrolling (plain top-to-
   bottom overflow), .chat__list just decides how ITS OWN content sits
   inside it. This used to be a single element with both overflow-y:auto
   AND justify-content:flex-end (to anchor short conversations to the
   bottom, next to the composer, instead of floating at the top with dead
   space below). That combination is a real flexbox trap: once content
   overflows a flex-end-justified column, browsers stop treating the
   overflow as scrollable at all — scrollHeight stops growing past the
   container's own height, so neither the chat nor the page could be
   scrolled from within it (Andrés's bug report, 2026-09-24 — a dead zone
   in both directions). Splitting the "scroll" and "anchor short content to
   the bottom" jobs across two elements keeps both working: .chat__scroll
   is a normal, boring scroll container (native overflow works exactly as
   expected), and .chat__list — sized to at least fill it via min-height,
   growing taller than that once content overflows — handles the bottom-
   anchoring purely visually, with no effect on what's scrollable. */
/* overscroll-behavior stays at its default (auto), deliberately not
   "contain": contain swallowed the wheel/touch scroll even when the chat had
   nothing to scroll, so the mouse over the chat did nothing at all — the
   second half of the dead zone. With auto, an overflowing chat scrolls
   itself first, and a short chat (or one already at its top/bottom) hands
   the scroll to the page. */
.chat__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.chat__list {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--space-4);
  padding: 18px var(--space-4);
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 86%;
  animation: msg-in 0.28s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.msg--aria { align-items: flex-start; }
.msg--user { align-items: flex-end; align-self: flex-end; }

.msg__bubble {
  padding: 13px var(--space-4);
  font-size: var(--text-body);
  font-weight: var(--fw-regular);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--aria .msg__bubble {
  background: var(--color-forest-raised);
  color: var(--color-white);
  border-radius: 18px 18px 18px 6px;
}
/* Aria's reply reveals sentence by sentence instead of appearing all at once. */
.msg__sentence {
  opacity: 0;
  animation: sentence-in 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.msg--user .msg__bubble {
  background: var(--color-sky);
  color: var(--color-forest);
  font-weight: var(--fw-medium);
  border-radius: 18px 18px 6px 18px;
}

.msg__time {
  padding-inline: 4px;
  font-size: 0.75rem;
  color: rgb(255 255 255 / 0.62);
}

/* Aria typing: three lime dots. */
.msg--typing .msg__bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 15px 18px;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-lime);
  animation: typing-dot 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

/* Suggestion chips under the greeting. */
.chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-top: 2px;
}
.chat__chip {
  min-height: 44px;
  padding: 10px var(--space-4);
  border: 1px solid rgb(157 196 213 / 0.5);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-white);
  font: inherit;
  font-size: var(--text-body);
  font-weight: var(--fw-medium);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  opacity: 0;
  animation: chip-in 0.28s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.chat__chip:hover {
  border-color: var(--color-sky);
  background: rgb(157 196 213 / 0.14);
}

/* Error notice */
.chat__notice {
  align-self: center;
  max-width: 94%;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px var(--space-4);
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: var(--radius-lg);
  background: rgb(255 255 255 / 0.1);
  font-size: var(--text-small);
  line-height: 1.4;
  color: var(--color-white);
}
.chat__notice svg { flex: none; margin-top: 2px; }

/* Error notice with a WhatsApp escape hatch: icon+text row, button below. */
.chat__notice--action {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.chat__notice-row { display: flex; align-items: flex-start; gap: 9px; }
.chat__notice-row svg { flex: none; margin-top: 2px; }
.chat__notice-cta { align-self: center; }

/* COMPOSER */
.chat__composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) 14px 14px;
  background: rgb(157 196 213 / 0.06);
  border-top: 1px solid rgb(255 255 255 / 0.12);
}

.chat__row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.chat__input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  max-height: 132px;
  padding: 11px 18px;
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 24px;
  background: rgb(255 255 255 / 0.06);
  color: var(--color-white);
  font: inherit;
  font-size: var(--text-body); /* 16px or more so iPhones do not zoom in */
  line-height: 1.45;
  resize: none;
  outline: none;
}
.chat__input::placeholder { color: rgb(255 255 255 / 0.6); }
.chat__input:focus {
  border-color: var(--color-sky);
  box-shadow: 0 0 0 3px rgb(157 196 213 / 0.35);
}
/* Invites typing after 10s of no activity (see js/chat.js) — a soft,
   breathing ring, not an attention-grabbing flash. Stops the moment the
   field is focused or typed in. */
.chat__input--invite {
  animation: chat-input-invite 1.8s cubic-bezier(0.2, 0.8, 0.3, 1) infinite;
}
@keyframes chat-input-invite {
  0%, 100% { box-shadow: 0 0 0 0 rgb(157 196 213 / 0.35); border-color: rgb(255 255 255 / 0.28); }
  50% { box-shadow: 0 0 0 4px rgb(157 196 213 / 0.25); border-color: rgb(157 196 213 / 0.6); }
}
@media (prefers-reduced-motion: reduce) {
  .chat__input--invite { animation: none; }
}

.chat__send {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex: none;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--color-lime);
  color: var(--color-forest);
  font: inherit;
  font-size: var(--text-body);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.chat__send:hover:not(:disabled) { background: var(--color-lime-hover); }
.chat__send:disabled {
  background: rgb(255 255 255 / 0.08);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.2);
  color: rgb(255 255 255 / 0.45);
  cursor: not-allowed;
}
.chat__send-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.chat__caption {
  padding-inline: 4px;
  font-size: var(--text-small);
  line-height: 1.35;
  color: rgb(255 255 255 / 0.82);
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
@keyframes status-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(1.35); }
}
@keyframes sentence-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes chip-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .msg { animation: none; }
  .typing-dot { animation: none; opacity: 0.75; }
  .chat__status[data-state='typing']::before { animation: none; }
  .msg__sentence { animation: none; opacity: 1; }
  .chat__chip { animation: none; opacity: 1; }
}

/* DESKTOP */
@media (min-width: 900px) {
  .aria { padding-block: 72px; }
  .chat-glow::before { inset: -26px; border-radius: 46px; filter: blur(38px); }
  .aria__intro { gap: var(--space-3); margin-bottom: var(--space-8); }
  .aria__eyebrow { font-size: var(--text-eyebrow); }
  .aria__eyebrow::before { width: 28px; }

  .aria__title {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    max-width: 20ch;
    font-size: 2.75rem;
    font-weight: var(--fw-bold);
    line-height: 1.08;
    letter-spacing: -0.02em;
  }
  .aria__lead {
    display: block;
    max-width: 58ch;
    font-size: 1.125rem;
    font-weight: var(--fw-light);
    line-height: 1.55;
    color: rgb(255 255 255 / 0.8);
  }

  .chat {
    height: 600px;
    border-radius: 24px;
    box-shadow: 0 30px 70px -30px rgb(0 0 0 / 0.5);
  }
  .chat__header { gap: 14px; padding: var(--space-4) 22px; }
  .chat__avatar { width: 48px; height: 48px; }
  .chat__avatar img { height: 28px; }
  .chat__title { font-size: 1.1875rem; }
  .chat__tag { height: 21px; font-size: 0.75rem; }
  .chat__status { font-size: 0.9375rem; }
  .chat__badge { display: block; font-size: var(--text-small); color: rgb(255 255 255 / 0.6); }

  .chat__list { gap: 18px; padding: var(--space-6) 22px; }
  .msg { max-width: 70%; }
  .msg__bubble { padding: 14px 18px; font-size: 1.0625rem; }
  .msg--aria .msg__bubble { border-radius: 20px 20px 20px 6px; }
  .msg--user .msg__bubble { border-radius: 20px 20px 6px 20px; }
  .msg__time { font-size: 0.8125rem; }

  .chat__composer { gap: 9px; padding: var(--space-4) var(--space-5) 18px; }
  .chat__row { gap: var(--space-3); }
  .chat__input { min-height: 52px; padding: 13px 20px; border-radius: 26px; }
  .chat__send { width: auto; height: 52px; padding-inline: var(--space-6); }
  .chat__send-label {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
  }
  .chat__caption { font-size: 0.9375rem; }
}
