/* The chat window: a floating button on every page that opens a small chat (full screen on phones). */

.chat-launcher { position: fixed; z-index: 56; left: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 52px; height: 52px; padding: 0; border: 0; border-radius: 2px; background: var(--lime); color: var(--forest); cursor: pointer; box-shadow: 0 10px 26px rgba(18, 24, 16, .35); font: 700 .78rem/1 var(--label); letter-spacing: .14em; text-transform: uppercase; }
.chat-launcher:hover { background: var(--lime-2); }
.chat-launcher:focus-visible { outline: 3px solid var(--forest); outline-offset: 3px; }
.chat-launcher svg { width: 26px; height: 26px; }
.chat-launcher-text { display: none; }
/* Order page on phones: the cart bar and the chat button share one row, so the chat button never covers the + and - buttons */
@media (max-width: 759px) {
  body.has-cart .chat-launcher { width: 48px; min-width: 48px; height: 48px; }
  body.has-cart .cart-pill { right: calc(var(--gutter) + 58px); padding-inline: 14px; gap: 8px; }
}
@media (max-width: 400px) { body.has-cart .cart-pill > span:last-child { display: none; } }
.chat-open .chat-launcher, .chat-open .wa-fab { display: none; }   /* the open window takes their place, so it never covers the menu */
@media (min-width: 760px) {
  .chat-launcher { left: 20px; bottom: 88px; padding: 0 20px 0 16px; }
  .chat-launcher-text { display: inline; }
  body.has-cart .chat-launcher { bottom: 88px; }
}

.chat-panel { position: fixed; z-index: 90; left: 0; right: 0; top: 0; bottom: 0; display: flex; flex-direction: column; background: #fff; color: var(--ink); overflow: hidden; overscroll-behavior: contain; }
.chat-panel[hidden] { display: none; }
@media (min-width: 760px) {
  .chat-panel { right: auto; top: auto; left: 20px; bottom: 20px; width: 380px; height: min(560px, calc(100vh - 150px)); border-radius: 4px; border-top: 4px solid var(--lime); box-shadow: 0 24px 60px rgba(18, 24, 16, .4); }
}
html.chat-open, html.chat-open body { overflow: hidden; }
@media (min-width: 760px) { html.chat-open, html.chat-open body { overflow: visible; } }

.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; background: var(--forest); color: #fff; flex: none; }
.chat-avatar { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 1px solid rgba(201, 162, 75, .7); border-radius: 2px; }
.chat-avatar svg { width: 22px; height: 22px; }
.chat-head-text { flex: 1; min-width: 0; }
.chat-head h2 { font: 600 1.15rem/1.2 var(--display); color: #fff; margin: 0; letter-spacing: 0; }
.chat-head p { margin: 2px 0 0; font-size: .8rem; line-height: 1.35; color: #d6d9c4; }
.chat-close { width: 48px; height: 48px; flex: none; border: 1px solid rgba(255, 255, 255, .3); border-radius: 2px; background: transparent; color: #fff; font: 400 1.7rem/1 var(--text); cursor: pointer; }
.chat-close:hover { background: #fff; color: var(--forest); }
.chat-panel :focus-visible { outline-color: var(--leaf); }
.chat-head :focus-visible { outline-color: var(--lime); }

.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--ivory); overscroll-behavior: contain; }
.chat-row { display: flex; flex-direction: column; gap: 8px; max-width: 86%; }
.chat-row.from-user { align-self: flex-end; align-items: flex-end; }
.chat-row.from-bot { align-self: flex-start; align-items: flex-start; }
.chat-bubble { padding: 10px 14px; border-radius: 4px; font-size: .96rem; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.from-bot .chat-bubble { background: #fff; border: 1px solid var(--line); border-top-left-radius: 0; }
.from-user .chat-bubble { background: var(--forest); color: #fff; border-top-right-radius: 0; }
.chat-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-action { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1.5px solid var(--forest); border-radius: 2px; background: #fff; color: var(--forest); text-decoration: none; font: 700 .74rem/1.2 var(--label); letter-spacing: .1em; text-transform: uppercase; }
.chat-action:hover { background: var(--forest); color: #fff; }
.chat-typing { display: inline-flex; gap: 5px; align-items: center; min-height: 40px; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--leaf); opacity: .5; }
@media (prefers-reduced-motion: no-preference) {
  .chat-typing span { animation: dot 1s infinite ease-in-out; }
  .chat-typing span:nth-child(2) { animation-delay: .15s; }
  .chat-typing span:nth-child(3) { animation-delay: .3s; }
  @keyframes dot { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
  .chat-row { animation: pop .25s ease-out both; }
  @keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; background: var(--ivory); flex: none; }
.chat-chips[hidden] { display: none; }
.chat-chip { min-height: 44px; padding: 0 14px; border: 1.5px solid var(--leaf); border-radius: 2px; background: #fff; color: var(--forest); cursor: pointer; font: 700 .74rem/1 var(--label); letter-spacing: .1em; text-transform: uppercase; }
.chat-chip:hover { background: var(--forest); border-color: var(--forest); color: #fff; }

.chat-form { display: flex; gap: 8px; padding: 12px 12px 8px; background: #fff; border-top: 1px solid var(--line); flex: none; }
.chat-form input { flex: 1; min-width: 0; font-size: 16px; }   /* 16px stops phones zooming in when you tap the box */
.chat-send { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border: 0; border-radius: 2px; background: var(--forest); color: #fff; cursor: pointer; }
.chat-send:hover { background: var(--forest-2); }
.chat-send svg { width: 22px; height: 22px; }
.chat-note { margin: 0; padding: 0 14px calc(10px + env(safe-area-inset-bottom)); background: #fff; font-size: .78rem; color: var(--ink-2); flex: none; }
@media (min-width: 760px) { .chat-note { padding-bottom: 10px; } }

.chat-help { margin: 0; font-size: .82rem; color: var(--ink-2); }
.chat-help a { color: var(--gold-d); font-weight: 700; }
.chat-head h2 { font-family: var(--display); }
