/* =====================================================================
   THE HELP CHAT (templates/_help_chat.html, static/js/help-chat.js):
   a walnut button in the bottom corner; it opens a card on big screens
   and a sheet from the bottom on phones.
   ===================================================================== */
.hc {
  --hc-ink: #1d1815;
  --hc-walnut: var(--bl-walnut, #5c4033);
  --hc-soft: #f6f3f0;
  --hc-line: #ece5e0;
  --hc-muted: #786357;
  font-family: 'Josefin Sans', sans-serif;
}

/* ---------- the button ---------- */
.hc-toggle {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 56px;
  padding: 0 22px 0 18px;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--bl-grad-brown, #5c4033);
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(10, 6, 5, 0.35);
  cursor: pointer;
  transition: transform 0.2s var(--bl-ease, ease), box-shadow 0.2s;
  animation: hcPop 0.5s var(--bl-ease, ease) 0.6s both;
}

.hc-toggle:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(10, 6, 5, 0.42); }
.hc-toggle:focus-visible { outline: 3px solid var(--bl-mint, #c7d8bb); outline-offset: 3px; }
.hc-toggle i { font-size: 1.35rem; line-height: 1; }
.hc-toggle-close { display: none; }

/* open: just a round close button under the card */
.hc-toggle[aria-expanded="true"] { width: 56px; padding: 0; justify-content: center; }
.hc-toggle[aria-expanded="true"] .hc-toggle-open,
.hc-toggle[aria-expanded="true"] .hc-toggle-text { display: none; }
.hc-toggle[aria-expanded="true"] .hc-toggle-close { display: block; font-size: 1.1rem; }

/* ---------- the card ---------- */
.hc-panel {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 70px);
  z-index: 1201;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: min(580px, calc(100dvh / var(--fit, 1) - 110px));
  overflow: hidden;
  text-align: left;
  color: var(--hc-ink);
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(10, 6, 5, 0.35);
  transform-origin: bottom right;
  animation: hcOpen 0.26s var(--bl-ease, ease) both;
}

.hc-panel[hidden] { display: none; }

.hc-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 14px 16px;
  color: #fff;
  background: var(--bl-grad-brown, #5c4033);
}

.hc-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: #fff;
  border-radius: 50%;
}

.hc-avatar img { width: 30px; height: 30px; object-fit: contain; }

.hc-who { flex: 1; min-width: 0; }
.hc-title { margin: 0; font-size: 1.05rem; font-weight: 700; line-height: 1.2; color: #fff; }

.hc-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.82);
}

.hc-status::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: #7fd69a;
  border-radius: 50%;
}

.hc-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 1rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.hc-icon:hover { background: rgba(255, 255, 255, 0.26); }
.hc-icon:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- the conversation ---------- */
.hc-log {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fcfaf8;
}

.hc-msg { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.hc-msg--you { align-items: flex-end; }

.hc-bubble {
  max-width: 88%;
  margin: 0;
  padding: 10px 14px;
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-line;
  overflow-wrap: anywhere;
  border-radius: 18px;
  animation: hcBubble 0.25s var(--bl-ease, ease) both;
}

.hc-msg--bot .hc-bubble { color: var(--hc-ink); background: var(--hc-soft); border-bottom-left-radius: 6px; }
.hc-msg--you .hc-bubble { color: #fff; background: var(--hc-ink); border-bottom-right-radius: 6px; }

/* pages a reply points to */
.hc-links { display: flex; flex-wrap: wrap; gap: 6px; max-width: 88%; }

.hc-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--hc-walnut);
  text-decoration: none;
  background: #fff;
  border: 1.5px solid var(--hc-line);
  border-radius: 999px;
  transition: border-color 0.2s;
}

.hc-link:hover { color: var(--hc-walnut); border-color: var(--hc-walnut); }

/* typing... */
.hc-typing .hc-bubble { display: inline-flex; gap: 5px; padding: 14px 16px; }

.hc-typing i {
  width: 7px;
  height: 7px;
  background: #b9b0aa;
  border-radius: 50%;
  animation: hcDot 1s ease-in-out infinite;
}

.hc-typing i:nth-child(2) { animation-delay: 0.15s; }
.hc-typing i:nth-child(3) { animation-delay: 0.3s; }

/* ---------- one-tap questions, the box, the note ---------- */
/* the quick questions scroll sideways on every screen (help-chat.js): a swipe, the mouse wheel, a
   click and drag, or the arrows at whichever end has more -- and that end fades out */
.hc-quick-wrap {
  position: relative;
  flex: none;
}

.hc-quick {
  display: flex;
  gap: 8px;
  padding: 10px 14px 2px;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.hc-quick::-webkit-scrollbar { display: none; }
.hc-quick.is-dragging { cursor: grabbing; user-select: none; }
.hc-quick.is-dragging .hc-chip { cursor: grabbing; }

.hc-quick-wrap::before,
.hc-quick-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  width: 46px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.hc-quick-wrap::before { left: 0; background: linear-gradient(90deg, #fff 30%, rgba(255, 255, 255, 0)); }
.hc-quick-wrap::after { right: 0; background: linear-gradient(270deg, #fff 30%, rgba(255, 255, 255, 0)); }
.hc-quick-wrap.can-left::before,
.hc-quick-wrap.can-right::after { opacity: 1; }

.hc-scroll {
  position: absolute;
  top: calc(10px + 18px);          /* the middle of the chips (the row's top padding + half a chip) */
  z-index: 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 0.85rem;
  color: var(--hc-ink);
  background: #fff;
  border: 1.5px solid var(--hc-line);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(10, 6, 5, 0.16);
  transform: translateY(-50%);
  cursor: pointer;
}

.hc-scroll:hover { border-color: var(--hc-ink); }
.hc-scroll:focus-visible { outline: 3px solid var(--bl-mint, #c7d8bb); outline-offset: 2px; }
.hc-scroll--left { left: 6px; }
.hc-scroll--right { right: 6px; }
.hc-scroll[hidden] { display: none; }

.hc-chip {
  flex: none;
  min-height: 36px;
  padding: 0 14px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--hc-ink);
  background: #fff;
  border: 1.5px solid var(--hc-line);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.hc-chip:hover { border-color: var(--hc-ink); }

.hc-form {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 6px 14px;
}

.hc-input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 16px;
  font: inherit;
  font-size: 1rem;                 /* 16px: phones don't zoom in on it */
  color: var(--hc-ink);
  background: var(--hc-soft);
  border: 1.5px solid transparent;
  border-radius: 999px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.hc-input:focus { background: #fff; border-color: var(--hc-ink); }
.hc-input::placeholder { color: var(--hc-muted); }

.hc-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  font-size: 1.1rem;
  color: #fff;
  background: var(--hc-walnut);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.hc-send:disabled { opacity: 0.45; cursor: default; }

.hc-note {
  flex: none;
  margin: 0;
  padding: 0 16px 10px;
  font-size: 0.72rem;
  color: var(--hc-muted);
  text-align: center;
}

/* ---------- phones: a round button, and a sheet from the bottom ---------- */
@media (max-width: 560px) {
  .hc-toggle { width: 56px; padding: 0; justify-content: center; }
  .hc-toggle-text { display: none; }
  .hc-toggle[aria-expanded="true"] { display: none; }    /* the sheet has its own close button */

  .hc-panel {
    right: 0;
    bottom: var(--hc-kb, 0px);     /* above the on-screen keyboard */
    left: 0;
    width: auto;
    height: min(82dvh / var(--fit, 1), calc(100dvh / var(--fit, 1) - var(--hc-kb, 0px) - 30px));
    padding-bottom: env(safe-area-inset-bottom);
    border-radius: 22px 22px 0 0;
    transform-origin: bottom center;
    animation: hcSheet 0.28s var(--bl-ease, ease) both;
  }
}

@keyframes hcPop { from { opacity: 0; transform: translateY(16px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes hcOpen { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes hcSheet { from { transform: translateY(100%); } to { transform: none; } }
@keyframes hcBubble { from { opacity: 0; transform: translateY(6px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes hcDot { 0%, 60%, 100% { opacity: 0.45; transform: none; } 30% { opacity: 1; transform: translateY(-4px); } }

@media (prefers-reduced-motion: reduce) {
  .hc-toggle, .hc-panel, .hc-bubble { animation: none; }
  .hc-typing i { animation: none; }
}

@media print { .hc { display: none; } }
