/*
 * Support chat additions.
 *
 * The panel, header, bubbles, chips and input row already live in main.css
 * (.chat-widget, .bubble, .chat-chips, .chat-input) — this file only carries
 * what the theme never had: the launcher's outward waves, the name/phone gate,
 * the pending turn and notices.
 */

.chat-widget [hidden]{display:none !important}

/*
 * Launcher waves. The theme's old pulse grew the button's own box-shadow, so the
 * disc swelled and shrank — nothing actually left it. Two rings now start at the
 * rim and travel outward, one beginning as the other dies, half a cycle apart.
 * The largest ring reaches 20px past the button, inside the 22px the float tray
 * keeps from the viewport edge, so a wave is never cut off mid-flight.
 */
.fab.chat::before,
.fab.chat::after{
  content:'';
  position:absolute;
  inset:-1px;
  z-index:-1;
  border-radius:50%;
  border:2px solid rgba(255,73,89,.55);
  /* Resting state is invisible so a motion-freezing browser leaves nothing
     behind: the rings only exist while the wave is actually travelling. */
  opacity:0;
  animation:sg7chatwave 2.6s cubic-bezier(.3,0,.2,1) infinite;
  pointer-events:none;
}
.fab.chat::after{animation-delay:1.3s}
@keyframes sg7chatwave{0%{transform:scale(1);opacity:0}18%{opacity:.9}100%{transform:scale(1.7);opacity:0}}
/* The button has been answered once the panel is up — no reason to keep waving. */
.fab.chat[aria-expanded="true"]::before,
.fab.chat[aria-expanded="true"]::after{animation:none}

.chat-gate{padding:16px;display:flex;flex-direction:column;gap:7px;background:var(--bg-alt);flex:1 1 auto;min-height:0;overflow-y:auto;scrollbar-width:thin}
.chat-lead{margin:0 0 6px;font-size:.82rem;line-height:1.55;color:var(--text-2)}
.chat-lead b{color:var(--text)}
.chat-gate label{font-size:.68rem;font-weight:800;letter-spacing:.07em;text-transform:uppercase;color:var(--text-3)}
.chat-gate label em{color:var(--copper);font-style:normal}
.chat-gate label span{font-weight:600;letter-spacing:0;text-transform:none;color:var(--muted)}
.chat-gate .input{width:100%;padding:11px 13px;border:1px solid var(--line);border-radius:11px;background:var(--surface);font-size:.88rem;color:var(--text)}
.chat-gate .input:focus{outline:none;border-color:var(--copper);box-shadow:0 0 0 3px rgba(216,58,86,.13)}
.chat-gate .chat-start{margin-top:8px;width:100%;min-height:44px;border-radius:12px;font-size:.88rem}

/* A reply that is still on its way — three dots, no fake text. */
.bubble.pending{display:flex;gap:5px;align-items:center;padding:14px 16px}
.bubble.pending i{width:7px;height:7px;border-radius:50%;background:var(--muted);animation:sg7dot 1.1s ease-in-out infinite}
.bubble.pending i:nth-child(2){animation-delay:.15s}
.bubble.pending i:nth-child(3){animation-delay:.3s}
@keyframes sg7dot{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}

/* Answers carry line breaks and bullet lines; nothing carries markup. */
.bubble{white-space:pre-line;word-break:break-word}

.chat-flag{margin:0;padding:9px 11px;border-radius:10px;background:rgba(216,58,86,.09);border:1px solid rgba(216,58,86,.28);color:#8d1830;font-size:.78rem;line-height:1.5}
.chat-flag[data-tone="info"]{background:rgba(80,184,132,.1);border-color:rgba(80,184,132,.3);color:#1d6b46}

.chat-terms{margin:0;padding:9px 14px 12px;background:var(--surface);border-top:1px solid var(--line-soft);font-size:.68rem;line-height:1.5;color:var(--muted);text-align:center}
.chat-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}

/* Ending the chat: the stars take the conversation's place. */
.chat-head .chat-end{margin-left:auto;width:32px;height:32px;border-radius:50%;display:grid;place-items:center;background:rgba(255,255,255,.15);color:#fff;transition:var(--t-fast)}
.chat-head .chat-end:hover{background:rgba(255,255,255,.28)}
/* .chat-close already asked for the free space; the star button has it now. */
.chat-head .chat-close{margin-left:6px}

.chat-rate{padding:16px;display:flex;flex-direction:column;gap:10px;background:var(--bg-alt);flex:1 1 auto;min-height:0;overflow-y:auto;scrollbar-width:thin}
.chat-stars{display:flex;gap:6px;justify-content:center}
.chat-stars .star{width:44px;height:44px;border-radius:12px;display:grid;place-items:center;background:var(--surface);border:1px solid var(--line);color:#cbb9c2;transition:var(--t-fast)}
.chat-stars .star svg{width:22px;height:22px;fill:currentColor;stroke:none}
.chat-stars .star:hover,.chat-stars .star.on{color:#e8a33d;border-color:#e8a33d;transform:translateY(-1px)}
.chat-rate .input{width:100%;padding:10px 13px;border:1px solid var(--line);border-radius:11px;background:var(--surface);font-size:.86rem;font-family:inherit;color:var(--text);resize:vertical;min-height:60px}
.chat-rate .input:focus{outline:none;border-color:var(--copper);box-shadow:0 0 0 3px rgba(216,58,86,.13)}
.chat-rate-foot{display:flex;gap:8px}
.chat-rate-foot .chat-send{flex:1;min-height:44px;border-radius:12px;font-size:.88rem}
.chat-rate-foot .chat-skip{flex:none;min-height:44px;padding:0 16px;border-radius:12px;font-size:.85rem}
/* Until a star is tapped the action is disabled — keep it legible in the panel
   instead of letting the generic .btn[disabled] fade white text to near-invisible. */
.chat-rate-foot .chat-send[disabled]{
  opacity:1;
  background:rgba(201,59,78,.10);
  border-color:rgba(201,59,78,.28);
  color:#9a3345;
  box-shadow:none;
}
/* The thank-you replaces the whole step, so it reads as a closed loop. */
.chat-rate.thanks{align-items:flex-start}
.chat-rate.thanks .chat-lead{font-size:.9rem;color:var(--text);font-weight:600}

@media (max-width:640px){
  .chat-widget{right:12px;left:12px;width:auto;bottom:88px;max-height:calc(100vh - 120px)}
}
