/* Principito tokens (Baubap/baubap-design-system-foundations, tokens/pds_tokens.json). */
:root {
  --bb-color-text-title: #171721;
  --bb-color-text-body-primary: #404164;
  --bb-color-text-body-secondary: #636894;
  --bb-color-text-highlight: #7d33ff;
  --bb-color-bg-default: #ffffff;
  --bb-color-bg-weak: #f7f7fb;
  --bb-color-bg-primary-subtle: #f2ebff;
  --bb-color-border-ghost: #f2f2f8;
  --bb-color-fill-hover: #6529ce;

  --bb-radius-small: 8px;
  --bb-radius-large: 16px;
  --bb-radius-xlarge: 24px;
  --bb-radius-full: 100px;

  --bb-space-2: 4px;
  --bb-space-3: 8px;
  --bb-space-4: 12px;
  --bb-space-5: 16px;
  --bb-space-6: 20px;
  --bb-space-7: 24px;
  --bb-space-9: 32px;
  --bb-space-13: 48px;

  --bb-font-family: "Onest", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Outside Principito: WhatsApp green, darkened from #25D366 so white text passes AA (5.0:1). */
  --whatsapp: #15803d;
  --whatsapp-pressed: #116a32;

  --column: 440px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bb-color-bg-weak);
  color: var(--bb-color-text-title);
  font-family: var(--bb-font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

img { display: block; max-width: 100%; }
button { font: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Phone: one screen. Header on top, the conversation sits right above the actions,
   actions in the thumb zone at the bottom, like a chat with its composer. */
.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bb-color-bg-default);
  padding: var(--bb-space-4) var(--bb-space-6);
  padding-top: max(var(--bb-space-4), env(safe-area-inset-top));
  border-bottom: 1px solid var(--bb-color-border-ghost);
}

.topbar img {
  width: 104px;
  height: auto;
}

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--bb-space-7) var(--bb-space-6) var(--bb-space-7);
}

/* Who you are about to talk to, the way WhatsApp shows a contact. */
.agent {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.agent-photo {
  width: 88px;
  height: 88px;
  margin-bottom: var(--bb-space-4);
  border-radius: var(--bb-radius-full);
  object-fit: cover;
  background: var(--bb-color-bg-primary-subtle);
}

.agent-name,
.agent-role,
.bubble {
  margin: 0;
}

.agent-name {
  font-size: 26px;
  line-height: 34px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--bb-color-text-title);
}

.agent-role {
  font-size: 16px;
  line-height: 22px;
  color: var(--bb-color-text-body-secondary);
}

/* Her messages sit right above the button, like the latest messages above a chat's composer. */
.messages {
  margin-top: auto;
  padding-top: var(--bb-space-9);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--bb-space-2);
}

.bubble {
  max-width: 32ch;
  padding: var(--bb-space-4) var(--bb-space-5);
  background: var(--bb-color-bg-default);
  border-radius: 20px;
  font-size: 18px;
  line-height: 26px;
  font-weight: 400;
  color: var(--bb-color-text-title);
  box-shadow: 0 1px 1px rgba(23, 23, 33, 0.04);
}

.bubble:first-child {
  font-weight: 500;
}

/* The last message in a group gets the tail. */
.bubble:last-child {
  border-bottom-left-radius: 6px;
}

.composer {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: var(--bb-space-2);
  padding: var(--bb-space-5) var(--bb-space-6);
  padding-bottom: max(var(--bb-space-4), env(safe-area-inset-bottom));
  background: var(--bb-color-bg-default);
  border-radius: var(--bb-radius-xlarge) var(--bb-radius-xlarge) 0 0;
  box-shadow: 0 -1px 0 var(--bb-color-border-ghost);
}

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--bb-space-4);
  min-height: 60px;
  padding: var(--bb-space-4) var(--bb-space-6);
  border-radius: var(--bb-radius-large);
  background: var(--whatsapp);
  color: #ffffff;
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.cta svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  flex: 0 0 auto;
}

.cta:hover { background: var(--whatsapp-pressed); }
.cta:active { background: var(--whatsapp-pressed); transform: scale(0.99); }

.alt {
  min-height: 48px;
  padding: var(--bb-space-3);
  border: 0;
  border-radius: var(--bb-radius-small);
  background: transparent;
  color: var(--bb-color-text-body-secondary);
  font-size: 16px;
  line-height: 22px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.alt span {
  color: var(--bb-color-text-highlight);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.alt:hover span { color: var(--bb-color-fill-hover); }

.cta:focus-visible,
.alt:focus-visible {
  outline: 3px solid var(--bb-color-text-highlight);
  outline-offset: 3px;
}

/* One moment of motion: Jessica's two messages arrive like a chat on first load.
   The button never waits for them. */
@media (prefers-reduced-motion: no-preference) {
  .bubble {
    animation: arrive 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    transform-origin: 0 100%;
  }
  .bubble:first-child { animation-delay: 0.15s; }
  .bubble:last-child { animation-delay: 0.75s; }
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* Small phones (iPhone SE first generation and similar). */
@media (max-width: 360px) {
  .chat { padding-left: var(--bb-space-5); padding-right: var(--bb-space-5); }
  .composer { padding-left: var(--bb-space-5); padding-right: var(--bb-space-5); }
  .bubble { font-size: 17px; line-height: 24px; }
  .agent-photo { width: 72px; height: 72px; }
  .agent-name { font-size: 24px; line-height: 32px; }
  .cta { font-size: 17px; gap: var(--bb-space-3); }
}

/* Short screens: shrink the contact header so the messages stay in view above the button. */
@media (max-height: 640px) and (max-width: 719px) {
  .chat { padding-top: var(--bb-space-5); }
  .agent-photo { width: 56px; height: 56px; margin-bottom: var(--bb-space-3); }
  .agent-name { font-size: 22px; line-height: 28px; }
  .messages { padding-top: var(--bb-space-5); }
}

/* Tablet and desktop: the same conversation as a centred column. */
@media (min-width: 720px) {
  .shell {
    min-height: 100vh;
  }

  .topbar {
    padding: var(--bb-space-5) var(--bb-space-6);
  }

  .topbar img {
    width: 120px;
    margin: 0 auto;
  }

  .chat,
  .composer {
    width: min(100% - 2 * var(--bb-space-6), var(--column));
    margin-left: auto;
    margin-right: auto;
  }

  .chat {
    flex: 0 0 auto;
    padding: 8vh 0 var(--bb-space-7);
  }

  .composer {
    position: static;
    padding: var(--bb-space-6);
    border-radius: var(--bb-radius-xlarge);
    box-shadow: none;
    margin-bottom: var(--bb-space-13);
  }

  .cta { cursor: pointer; }
}
