/* people screens: rules added by the UI pass of 25 Oct 2026; loaded after features.css so same-specificity rules here win. */

/* ---------- pop-up cards (lead + Inbox) ---------- */
/* A dialog is open (core.js toggles html.no-scroll): the cards step aside so they never cover its title, close button
   or an error toast. They come back the moment the dialog closes. */
html.no-scroll .lead-pops { visibility: hidden; }
/* The stack starts under the top bar INCLUDING the notch/status-bar area of the home-screen app (the top bar itself is
   var(--topbar-h) + env(safe-area-inset-top) tall), and leaves the bottom bar and the home indicator free. */
.lead-pops {
  top: calc(var(--topbar-h) + env(safe-area-inset-top) + 12px);
  max-height: calc(100vh - var(--topbar-h) - env(safe-area-inset-top) - var(--bottombar-h) - env(safe-area-inset-bottom) - 8px);
  max-height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top) - var(--bottombar-h) - env(safe-area-inset-bottom) - 8px);
}
@media (max-width: 700px) { .lead-pops { top: calc(var(--topbar-h) + env(safe-area-inset-top) + 8px); } }
/* The ✕ on every card: a 44px target on touch screens, without moving the card's text. */
@media (pointer: coarse) { .lp-x { min-width: 44px; min-height: 44px; margin: -10px -10px -10px 0; display: inline-grid; place-items: center; } }

/* ---------- one colour per meaning ---------- */
/* "Asking for help" is good news (a buyer): green everywhere — Leads and the pop-ups already use --ok; Alerts had it in
   orange next to the orange "Not opened" badge. */
.badge.hot { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
/* White text on the brand green reads 3.4:1 in light and 2.5:1 in dark; this deeper green keeps the identity and gives
   white 5.5:1 on both. --on-primary-bg is the theme's token for exactly this (theme.css); the value here is its fallback. */
#tab-inbox .bubble.out { background: var(--on-primary-bg, #047857); border-color: var(--on-primary-bg, #047857); }
#tab-inbox .conv-count { background: var(--on-primary-bg, #047857); }
#tab-home .quick-btn.primary { background: var(--on-primary-bg, #047857); border-color: var(--on-primary-bg, #047857); }
#tab-home .quick-btn.primary:hover { background: var(--on-primary-hover, #065f46); }

/* ---------- Leads: "who is posting" is a pick-several filter, so it looks like the app's toggle chips ---------- */
.intent-chips { flex: 1 1 auto; min-width: 0; }
.intent-chips .chip { white-space: nowrap; }

/* ---------- Inbox on a phone: one scroller, Send always reachable ---------- */
@media (max-width: 899.98px) {
  /* The list scrolls with the page (no scroll box inside a scroll box). */
  .inbox-layout { height: auto; min-height: 0; }
  .inbox-layout:not(.has-open) .inbox-list-pane, .inbox-layout:not(.has-open) .inbox-list { overflow: visible; }
  /* An open conversation runs edge to edge, filling exactly the room between the top bar and the bottom bar (both with
     their safe areas), like a chat app: the content's padding (16 top, 32 bottom, the side gutters) goes to the
     messages. The messages scroll inside; the reply box stays in view. */
  .inbox-layout.has-open {
    margin: -16px calc(-1 * max(var(--gutter), env(safe-area-inset-right))) -32px calc(-1 * max(var(--gutter), env(safe-area-inset-left)));
    height: calc(100vh - var(--topbar-h) - env(safe-area-inset-top) - var(--bottombar-h) - env(safe-area-inset-bottom));
    height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top) - var(--bottombar-h) - env(safe-area-inset-bottom));
    min-height: 360px; gap: 0;
  }
  /* With the keyboard open (html.kb-open, core.js) the room above it can be under 360px: the conversation fits that room
     (the messages get shorter) instead of pushing the reply box under the keyboard. */
  html.kb-open .inbox-layout.has-open { min-height: 0; }
  .inbox-layout.has-open > .inbox-thread-pane, .inbox-layout.has-open > .inbox-person-pane {
    border-radius: 0; border-left: 0; border-right: 0; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  }
  .inbox-layout.has-open > .inbox-thread-pane { border-top: 0; }
  .inbox-layout.has-open > .inbox-person-pane { border-bottom: 0; }
  /* The thread head (with its back button) is the wayfinding; the page title would only take its room. */
  body:has(#tab-inbox.active .inbox-layout.has-open) .pagehead { display: none; }
}

/* ---------- Inbox conversation on a phone: one-row head, a "⋯" menu, a compact reply box ---------- */
.thread-sub, .thread-more { display: none; }
.thread-more > summary { list-style: none; cursor: pointer; }
.thread-more > summary::-webkit-details-marker { display: none; }
.thread-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; display: grid; min-width: 220px; max-width: min(320px, 86vw); padding: 6px;
  border: 1px solid var(--glass-edge, var(--line-strong)); border-radius: var(--r); background: var(--glass-strong, var(--surface)); box-shadow: var(--shadow-3);
  -webkit-backdrop-filter: var(--blur, none); backdrop-filter: var(--blur, none); animation: pop-in var(--dur-2) var(--ease) both; transform-origin: top right;
}
.thread-menu .menu-item {
  display: flex; align-items: center; min-height: 44px; width: 100%; padding: 8px 12px; border: 0; border-radius: 8px; background: none;
  color: inherit; font: inherit; font-size: 0.9375rem; text-align: left; text-decoration: none; cursor: pointer;
}
.thread-menu .menu-item:hover, .thread-menu .menu-item:focus-visible { background: var(--surface-2); outline: none; }
@media (max-width: 899.98px) {
  .thread-head { flex-wrap: nowrap; align-items: center; gap: 8px; padding: 8px 8px 8px 6px; }
  .thread-head .avatar { width: 34px; height: 34px; font-size: 0.8125rem; }
  .thread-id { min-width: 0; }
  .thread-title { display: flex; align-items: baseline; gap: 6px; min-width: 0; white-space: nowrap; }
  .thread-title > b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .thread-handle { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .thread-chips, .thread-actions { display: none; }
  .thread-sub { display: block; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .thread-more { display: block; position: relative; flex: none; }
  .thread-more > summary { display: inline-grid; place-items: center; width: 40px; height: 40px; font-size: 1.25rem; line-height: 1; }
  .thread { padding: 10px; gap: 6px; }
  /* The reply box: one line to start, growing with the text (inbox.js autosize), tools on one row, Send widest. */
  .composer { gap: 6px; padding: 8px 10px; }
  .composer textarea { min-height: 44px; max-height: 30vh; max-height: 30dvh; resize: none; padding-top: 10px; padding-bottom: 10px; }
  .composer .composer-acts { flex-wrap: nowrap; align-items: center; gap: 6px; }
  .composer-acts .send-from { display: none; }
  .composer .composer-acts > .btn[data-act="send"] { flex: 1 1 auto; min-width: 0; min-height: 44px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .composer .composer-acts > .btn.sm { flex: none; min-width: 44px; min-height: 44px; justify-content: center; }
  .composer-note:not(.warn) { display: none; }
  .composer-note.warn { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}

/* ---------- Inbox: reply ideas (✨) ---------- */
/* A strip of their own between the messages and the reply box, never taller than the room that's left: they scroll on
   their own, the newest messages keep a strip, and the reply box and Send never move or get cut off. */
.thread-ideas { flex: 0 1 auto; display: flex; flex-direction: column; min-height: 60px; padding: 10px 14px 0; border-top: 1px solid var(--line); }
.thread-ideas:empty { display: none; }
.thread-ideas:not(:empty) + [data-role="composer"] > .composer { border-top: 0; }
.thread-ideas > .ai-panel { display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; }
.thread-ideas .ai-head { flex: none; }
.thread-ideas .ai-body { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.inbox-thread-pane > .thread { min-height: 80px; }
/* The safety net: in a window too short for all of it (ideas open on a short laptop screen, a phone on its side), the
   conversation scrolls as a whole instead of cutting off the reply box. When it all fits, nothing scrolls but the parts. */
.inbox-thread-pane { overflow: hidden auto; }
@media (max-width: 899.98px) {
  /* Scrolling something into view (the reply box, a focused field) stops above the bottom bar, not behind it. */
  html { scroll-padding-bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom) + 8px); }
  .inbox-thread-pane > .thread { min-height: 112px; min-height: clamp(72px, 16dvh, 112px); }
  /* While you read the ideas the "About this person" bar steps aside (it's back when they fold or close). */
  .inbox-layout.has-open:not(.pp-open):has(.thread-ideas > .ai-panel:not(.collapsed)) .inbox-person-pane { display: none; }
  .thread-ideas { padding: 8px 10px 0; }
  .thread-ideas .ai-body { gap: 8px; padding: 0 8px 8px; }
  .thread-ideas .variant { padding: 10px 12px; }
  /* While the ideas are open the reply box keeps to a few lines (it scrolls), so the ideas have room to be read. */
  .thread-ideas:has(> .ai-panel:not(.collapsed)) + [data-role="composer"] textarea { max-height: 96px; }
}
