/* Support chat: a button in the bottom corner that opens a chat panel (a full-screen sheet on phones). */
.chat-launch {
  position: fixed; z-index: 45; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: .5rem; min-height: 3.25rem; padding: .7rem 1.15rem .7rem .95rem;
  border: 0; border-radius: 999px; background: var(--espresso); color: var(--on-ink); cursor: pointer;
  font-weight: 650; box-shadow: 0 10px 28px rgb(23 18 16 / .28), 0 2px 6px rgb(23 18 16 / .18);
  transition: transform .15s var(--ease-out), background-color .15s;
}
.chat-launch:hover { background: var(--brown); }
.chat-launch:active { transform: scale(.97); }
.chat-launch:focus-visible { outline: 3px solid var(--oak-deep); outline-offset: 3px; }
.chat-launch svg { width: 1.4rem; height: 1.4rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.chat-launch__dot { position: absolute; top: .35rem; right: .45rem; width: .7rem; height: .7rem; border-radius: 50%;
  background: var(--bulb); box-shadow: 0 0 0 2px var(--espresso); }
.chat-launch__dot[hidden] { display: none; }
.chat.is-open:not(.is-animating) .chat-launch { visibility: hidden; }

.chat-panel {
  position: fixed; z-index: 70; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; width: min(24rem, calc(100vw - 2rem)); height: min(38rem, calc(100dvh - 2rem));
  background: var(--paper); color: var(--brown); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 60px rgb(23 18 16 / .32), 0 4px 12px rgb(23 18 16 / .16);
  transform-origin: 0 0; /* chat.js grows it out of the chat button */
}
.chat-panel[hidden] { display: none; }
/* While the panel grows out of the button, a cover in the button's colour fades away to show the chat. */
.chat-panel__morph { position: absolute; inset: 0; z-index: 1; background: var(--espresso); opacity: 0; pointer-events: none; }
.chat-panel__head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem;
  padding: 1rem 1rem .85rem 1.15rem; background: var(--espresso); color: var(--on-ink); }
.chat-panel__title { margin: 0; font-size: 1.1rem; font-weight: 750; line-height: 1.2; }
.chat-panel__sub { margin: .2rem 0 0; font-size: var(--step--1); opacity: .82; line-height: 1.35; }
.chat-panel__close { flex: none; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; margin: -.35rem -.35rem 0 0;
  border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.chat-panel__close:hover { background: rgb(255 255 255 / .12); }
.chat-panel__close:focus-visible { outline: 3px solid var(--bulb); outline-offset: 1px; }
.chat-panel__close svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.chat-panel__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 1rem 1.15rem; }

.chat-start { display: grid; gap: .8rem; }
.chat-start[hidden] { display: none; }
.chat-start__intro { margin: 0; padding: .75rem .9rem; border-radius: 12px; background: var(--plaster); font-size: var(--step--1); line-height: 1.45; }
.chat-start .field input, .chat-start .field textarea { width: 100%; }
.chat-start textarea { resize: vertical; min-height: 4.5rem; }
.chat-optional { font-weight: 400; color: var(--brown-soft); }
.chat-start__go { justify-self: start; }
.chat-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.chat-thread { list-style: none; margin: 0; padding: 0; display: grid; gap: .85rem; }
.chat-thread[hidden] { display: none; }
.chat-msg { display: grid; gap: .25rem; max-width: 88%; justify-self: start; }
.chat-msg--customer { justify-self: end; justify-items: end; }
.chat-msg__who { font-size: .72rem; font-weight: 600; color: var(--brown-soft); }
.chat-msg__text { margin: 0; padding: .6rem .85rem; border-radius: 14px 14px 14px 4px; background: var(--plaster);
  font-size: .95rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg--customer .chat-msg__text { border-radius: 14px 14px 4px 14px; background: var(--espresso); color: var(--on-ink); }
.chat-msg--owner .chat-msg__text { background: var(--selected); }
.chat-msg__text a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.chat-msg--typing .chat-msg__text { padding: .8rem 1rem; }
.chat-msg__team { display: inline-block; padding: .05rem .4rem; border-radius: 999px; background: var(--tint-ok); color: var(--ok);
  font-size: .68rem; font-weight: 700; }
.chat-note { justify-self: center; max-width: 90%; padding: .35rem .8rem; border-radius: 999px; background: var(--tint-ok); color: var(--ok);
  font-size: .78rem; font-weight: 650; text-align: center; }
.chat-dots { display: inline-flex; align-items: center; gap: .3rem; height: 1rem; vertical-align: middle; }
.chat-dots span { width: .45rem; height: .45rem; border-radius: 50%; background: var(--brown-soft); opacity: .45;
  animation: chat-dot 1.2s ease-in-out infinite; }
.chat-dots span:nth-child(2) { animation-delay: .15s; }
.chat-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-.25rem); opacity: 1; }
}
.chat-faq__typing { margin: 0; padding: .1rem .85rem .8rem; }
.chat-faq__typing[hidden], .chat-faq__answer[hidden] { display: none; }

.chat-error { margin: 0; padding: .55rem 1.15rem; background: var(--tint-danger); color: var(--danger); font-size: var(--step--1); font-weight: 500; }
.chat-error[hidden] { display: none; }
.chat-compose { display: flex; align-items: flex-end; gap: .5rem; padding: .7rem .75rem .7rem 1rem; border-top: 1px solid var(--line); }
.chat-compose[hidden] { display: none; }
.chat-compose textarea { flex: 1; min-width: 0; min-height: 2.75rem; max-height: 8.75rem; padding: .6rem .8rem; resize: none;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--plaster); color: var(--brown); line-height: 1.4; }
.chat-compose textarea:focus-visible { outline: none; border-color: var(--oak-deep); }
.chat-compose__send { flex: none; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50%;
  background: var(--espresso); color: var(--on-ink); cursor: pointer; }
.chat-compose__send:hover { background: var(--brown); }
.chat-compose__send:focus-visible { outline: 3px solid var(--oak-deep); outline-offset: 2px; }
.chat-compose__send svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.chat-foot { margin: 0; padding: 0 1rem .7rem; font-size: .78rem; color: var(--brown-soft); }
.chat-foot[hidden] { display: none; }
.chat-foot__new { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }

/* Phones: a round button, and the chat fills the screen. */
@media (max-width: 559px) {
  .chat-launch { padding: 0; width: 3.5rem; height: 3.5rem; justify-content: center; }
  .chat-launch__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .chat-panel { inset: 0; width: auto; height: 100dvh; border: 0; border-radius: 0; }
  .chat-panel__head { padding-top: max(1rem, env(safe-area-inset-top)); }
  .chat-compose { padding-bottom: max(.7rem, env(safe-area-inset-bottom)); }
  body.chat-locked { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-launch { transition: none; }
  .chat-dots span { animation-name: chat-dot-fade; }
}
@keyframes chat-dot-fade { 0%, 100% { opacity: .35; } 40% { opacity: 1; } }
@media print { .chat { display: none; } }

/* Common questions: tap to open an answer before chatting, or send one as a quick question during a chat. */
.chat-panel:focus { outline: none; }
.chat-faq { margin-top: 1.25rem; border: 1px solid var(--line); border-radius: 12px; }
.chat-faq[hidden] { display: none; }
.chat-faq__toggle { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem .9rem;
  font-weight: 700; font-size: .95rem; color: var(--espresso); cursor: pointer; list-style: none; border-radius: 12px; }
.chat-faq__toggle::-webkit-details-marker { display: none; }
.chat-faq__toggle::after { content: "▾"; font-size: .85rem; color: var(--oak-deep); transition: transform .15s; }
.chat-faq[open] > .chat-faq__toggle::after { transform: rotate(180deg); }
.chat-faq__toggle:focus-visible { outline: 3px solid var(--oak-deep); outline-offset: 1px; }
.chat-faq[open] > .chat-faq__list { padding: 0 .6rem .6rem; }
.chat-faq__title { margin: 0 0 .5rem; font-size: .95rem; font-weight: 750; color: var(--espresso); }
.chat-faq__list { display: grid; gap: .4rem; }
.chat-faq__loading { margin: 0; color: var(--brown-soft); font-size: var(--step--1); }
.chat-faq__item { border: 1px solid var(--line); border-radius: 10px; background: var(--plaster); }
.chat-faq__item summary { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem .85rem;
  font-weight: 600; font-size: .92rem; line-height: 1.35; cursor: pointer; list-style: none; border-radius: 10px; }
.chat-faq__item summary::-webkit-details-marker { display: none; }
.chat-faq__item summary::after { content: "+"; flex: none; font-size: 1.15rem; font-weight: 500; color: var(--oak-deep); }
.chat-faq__item[open] summary::after { content: "−"; }
.chat-faq__item summary:focus-visible { outline: 3px solid var(--oak-deep); outline-offset: 1px; }
.chat-faq__answer { margin: 0; padding: 0 .85rem .75rem; font-size: .9rem; line-height: 1.5; }
.chat-faq__answer a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.chat-start .chat-faq__title { margin: 0; }

.chat-quick { margin-top: -.3rem; }
.chat-quick[hidden] { display: none; }
.chat-quick__toggle { display: flex; align-items: center; gap: .4rem; width: 100%; padding: .55rem 1rem; border: 0; background: none;
  color: var(--oak-deep); font: inherit; font-size: var(--step--1); font-weight: 650; text-align: left; cursor: pointer; }
.chat-quick__toggle::after { content: "▾"; font-size: .8rem; transition: transform .15s; }
.chat-quick__toggle[aria-expanded="true"]::after { transform: rotate(180deg); }
.chat-quick__toggle:focus-visible { outline: 3px solid var(--oak-deep); outline-offset: -3px; }
.chat-quick__list { display: flex; flex-wrap: wrap; gap: .4rem; max-height: 9.5rem; overflow-y: auto; padding: 0 1rem .7rem; }
.chat-quick__list[hidden] { display: none; }
.chat-quick__q { padding: .4rem .75rem; border: 1.5px solid var(--line); border-radius: 999px; background: var(--plaster); color: var(--brown);
  font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.chat-quick__q:hover { border-color: var(--brown); }
.chat-quick__q:focus-visible { outline: 3px solid var(--oak-deep); outline-offset: 2px; }
.chat-start .chat-faq { margin-top: 0; }
