/* ==========================================================================
   The Ponsbourne — web concierge widget
   ========================================================================== */

.chat {
  position: relative;
  z-index: 140;
}

.chat__launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 140;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 20px;
  border: 1px solid rgba(246, 241, 231, 0.24);
  border-radius: 999px;
  background: var(--green);
  color: var(--cream);
  box-shadow: 0 14px 40px rgba(12, 20, 15, 0.24);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background 0.3s, transform 0.3s var(--ease), box-shadow 0.3s;
}
.chat__launcher:hover {
  background: var(--green-soft);
  transform: translateY(-2px);
  box-shadow: 0 18px 46px rgba(12, 20, 15, 0.3);
}
.chat__launcher svg { width: 18px; height: 18px; flex: none; }
.chat__launcher .chat__launcher-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brass-light);
  box-shadow: 0 0 0 4px rgba(200, 168, 116, 0.18);
}

.chat__panel {
  position: fixed;
  right: 24px;
  bottom: 88px;
  z-index: 141;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(12, 20, 15, 0.26);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.985);
  transform-origin: bottom right;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease), visibility 0.3s;
}
.chat__panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: var(--green);
  color: var(--cream);
  border-bottom: 1px solid var(--line-light);
}
.chat__brand { display: flex; align-items: center; gap: 11px; }
.chat__mark {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(246, 241, 231, 0.5);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1;
  padding-top: 2px;
}
.chat__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.03em;
}
.chat__subtitle {
  display: block;
  margin-top: 4px;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(246, 241, 231, 0.62);
}
.chat__close {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(246, 241, 231, 0.28);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--cream);
  transition: background 0.25s, color 0.25s;
}
.chat__close:hover { background: var(--cream); color: var(--green); }
.chat__close svg { width: 14px; height: 14px; }

.chat__messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--paper);
  scroll-behavior: smooth;
}
.chat__message { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; max-width: 100%; }
.chat__message--user { align-items: flex-end; }
.chat__bubble {
  max-width: 88%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px 12px 12px 3px;
  background: var(--paper-light);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat__message--user .chat__bubble {
  border-color: var(--green);
  border-radius: 12px 12px 3px 12px;
  background: var(--green);
  color: var(--cream);
}
.chat__bubble a { border-bottom: 1px solid currentColor; color: inherit; }
.chat__bubble a:hover { color: var(--brass-deep); }
.chat__message--user .chat__bubble a:hover { color: var(--brass-pale); }

.chat__sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  max-width: 88%;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.chat__sources span { color: var(--brass-deep); }
.chat__sources a { border-bottom: 1px solid var(--line); padding-bottom: 1px; color: var(--ink-soft); }
.chat__sources a:hover { border-color: currentColor; color: var(--brass-deep); }

.chat__handoff {
  width: 100%;
  margin-top: 3px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--paper-deep);
}
.chat__handoff h4 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  margin-bottom: 5px;
}
.chat__handoff p { font-size: 12px; line-height: 1.5; color: var(--ink-soft); margin-bottom: 10px; }
.chat__handoff-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.chat__handoff-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}
.chat__handoff-actions a:first-child { background: var(--brass); border-color: var(--brass); color: var(--green-deep); }
.chat__handoff-actions a:hover { background: var(--green); border-color: var(--green); color: var(--cream); }

.chat__chips { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; }
.chat__chip {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 10px;
  line-height: 1.2;
  color: var(--ink-soft);
  text-align: left;
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}
.chat__chip:hover { background: var(--green); border-color: var(--green); color: var(--cream); }

.chat__typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px 12px 12px 3px;
  background: var(--paper-light);
}
.chat__typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: chatTyping 1.2s infinite ease-in-out;
}
.chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.chat__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatTyping {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.chat__form {
  border-top: 1px solid var(--line);
  background: var(--paper-light);
  padding: 10px 12px 8px;
}
.chat__input-row { display: flex; align-items: center; gap: 8px; }
.chat__input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 10px 12px;
  font-size: 13px;
  border-radius: 999px;
  color: var(--ink);
}
.chat__input::placeholder { color: var(--muted); }
.chat__input:focus { outline: none; border-color: var(--brass-deep); box-shadow: 0 0 0 1px var(--brass-deep); }
.chat__send {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--green);
  color: var(--cream);
  display: grid;
  place-items: center;
  transition: background 0.25s, opacity 0.25s;
}
.chat__send:hover { background: var(--green-soft); }
.chat__send:disabled { opacity: 0.45; pointer-events: none; }
.chat__send svg { width: 15px; height: 15px; }
.chat__note {
  margin-top: 6px;
  font-size: 9px;
  line-height: 1.45;
  color: var(--muted);
}
.chat__note a { border-bottom: 1px solid var(--line); }
.chat__note a:hover { color: var(--brass-deep); }

.chat__error { border-color: #a4462f; }
.chat__error .chat__bubble { border-color: #a4462f; }

@media (max-width: 760px) {
  .chat__launcher {
    right: 14px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    min-height: 46px;
    padding: 0 16px;
    font-size: 10px;
    gap: 8px;
  }
  .chat__launcher svg { width: 16px; height: 16px; }
  .chat__panel {
    left: 12px;
    right: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    width: auto;
    height: min(70vh, 560px);
    max-height: calc(100dvh - 100px);
  }
  .chat__messages { padding: 14px; }
  .chat__bubble { font-size: 13px; }
}

@media (max-width: 380px) {
  .chat__launcher span:not(.chat__launcher-dot) { display: none; }
  .chat__launcher { width: 48px; padding: 0; justify-content: center; }
}

body.is-menu-open .chat__launcher,
body.is-menu-open .chat__panel { display: none; }

@media (prefers-reduced-motion: reduce) {
  .chat__panel,
  .chat__launcher,
  .chat__typing span { transition: none; animation: none; }
  .chat__messages { scroll-behavior: auto; }
}

@media print {
  .chat__launcher,
  .chat__panel { display: none !important; }
}

/* Full manor line-art mark in the chat header */
.chat__mark--logo {
  width: 72px;
  height: 26px;
  border: 0;
  border-radius: 0;
  padding: 0;
  display: block;
}
.chat__mark--logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
