/* ===== Chat widget (all pages) =====
   A floating "Chat" button that opens a short message form; messages go to Formspree and are
   answered by email. Self-contained: every rule is scoped under .pv-chat and uses its own tokens,
   so it looks the same on pages that don't load style.css. Markup is added by /js/chat-widget.js. */
.pv-chat {
  --pv-ink: #211F20;
  --pv-ink-soft: #6B6866;
  --pv-paper: #FAFAF9;
  --pv-fill: #EDEBE7;
  --pv-red: #E8323D;
  --pv-red-dark: #cf2830;
  --pv-dark: #141314;
  --pv-green: #1a7f46;
  --pv-gap: clamp(16px, 2.4vw, 28px);

  position: fixed;
  right: var(--pv-gap);
  bottom: var(--pv-gap);
  z-index: 900;                        /* above the nav (100), below the photo lightbox and toasts */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--pv-ink);
  -webkit-font-smoothing: antialiased;
}
.pv-chat *, .pv-chat *::before, .pv-chat *::after { box-sizing: border-box; }
.pv-chat [hidden] { display: none !important; }

/* ---- Launcher ---- */
.pv-chat__fab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 8px 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--pv-dark);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 30px -12px rgba(20,19,20,0.55), 0 2px 6px rgba(20,19,20,0.18);
  transition: transform .25s ease, box-shadow .25s ease, padding .3s ease, gap .3s ease;
}
.pv-chat__fab:hover { transform: translateY(-2px); box-shadow: 0 18px 34px -12px rgba(20,19,20,0.6), 0 2px 6px rgba(20,19,20,0.18); }
.pv-chat__fab:focus-visible { outline: 2px solid var(--pv-red); outline-offset: 3px; }
.pv-chat__fab-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--pv-red);
  flex-shrink: 0;
}
.pv-chat__fab-icon svg { width: 20px; height: 20px; transition: opacity .2s ease, transform .3s ease; }
.pv-chat__fab-icon .pv-chat__ico-close { position: absolute; opacity: 0; transform: rotate(-90deg) scale(.6); }
/* Open: the label folds away and the icon turns into a close cross */
.pv-chat.is-open .pv-chat__fab { padding: 0 8px; gap: 0; }
.pv-chat.is-open .pv-chat__fab-label { max-width: 0; opacity: 0; }
.pv-chat.is-open .pv-chat__ico-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.pv-chat.is-open .pv-chat__ico-close { opacity: 1; transform: none; }
.pv-chat__fab-label {
  max-width: 80px;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width .3s ease, opacity .2s ease;
}

/* ---- Panel ---- */
.pv-chat__panel {
  width: min(360px, calc(100vw - 2 * var(--pv-gap)));
  max-height: calc(100vh - 120px);
  max-height: calc(100dvh - 120px);
  overflow: auto;
  background: #fff;
  border: 1px solid rgba(33,31,32,0.08);
  border-radius: 18px;
  box-shadow: 0 30px 60px -24px rgba(20,19,20,0.45), 0 4px 14px rgba(20,19,20,0.08);
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(12px) scale(.97);
  transition: opacity .22s ease, transform .28s cubic-bezier(.215,.61,.355,1);
}
.pv-chat.is-open .pv-chat__panel { opacity: 1; transform: none; }

.pv-chat__head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 52px 18px 18px;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(232,50,61,0.28), transparent 60%),
    var(--pv-dark);
  color: #fff;
}
.pv-chat__avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--pv-red);
  flex-shrink: 0;
}
.pv-chat__avatar svg { width: 20px; height: 20px; }
.pv-chat__title { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; color: #fff; }

/* "Online" status: green dot with a soft ping, as on propservia.com */
.pv-chat__online {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: auto;                     /* sits next to the title; spare space goes before the close button */
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(250,250,249,0.85);
  white-space: nowrap;
}
.pv-chat__dot {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}
.pv-chat__dot::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #4ade80;
  animation: pv-chat-ping 1.4s ease-out infinite;
}
@keyframes pv-chat-ping {
  0%   { transform: scale(1);   opacity: .65; }
  75%, 100% { transform: scale(2.4); opacity: 0; }
}
.pv-chat__close {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);              /* centred on the title row */
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: rgba(250,250,249,0.08);
  color: rgba(250,250,249,0.85);
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.pv-chat__close:hover { background: rgba(250,250,249,0.16); color: #fff; }
.pv-chat__close:focus-visible { outline: 2px solid var(--pv-red); outline-offset: 2px; }
.pv-chat__close svg { width: 16px; height: 16px; }

.pv-chat__body { padding: 18px; }
.pv-chat__field { margin-bottom: 14px; }
.pv-chat__label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 600; color: var(--pv-ink); }
.pv-chat__req { color: var(--pv-red); }
.pv-chat__input {
  display: block;
  width: 100%;
  margin: 0;
  font: inherit;
  font-size: 15px;
  color: var(--pv-ink);
  background: var(--pv-paper);
  border: 1px solid rgba(33,31,32,0.16);
  border-radius: 10px;
  padding: 11px 14px;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.pv-chat__input::placeholder { color: rgba(33,31,32,0.38); }
.pv-chat__input:hover { border-color: rgba(33,31,32,0.28); }
.pv-chat__input:focus { outline: none; border-color: var(--pv-red); background: #fff; box-shadow: 0 0 0 3px rgba(232,50,61,0.12); }
.pv-chat__input[aria-invalid="true"] { border-color: var(--pv-red); }
textarea.pv-chat__input { min-height: 112px; resize: vertical; line-height: 1.55; }

.pv-chat__hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.pv-chat__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--pv-red);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}
.pv-chat__send:hover { background: var(--pv-red-dark); box-shadow: 0 10px 20px -10px rgba(232,50,61,0.6); }
.pv-chat__send:active { transform: scale(.98); }
.pv-chat__send:focus-visible { outline: 2px solid var(--pv-ink); outline-offset: 3px; }
.pv-chat__send:disabled { opacity: .7; cursor: progress; }
.pv-chat__send svg { width: 16px; height: 16px; }

/* Centred under the full-width send button */
.pv-chat__status { min-height: 1.4em; margin: 12px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--pv-ink-soft); text-align: center; }
.pv-chat__status.is-error { color: var(--pv-red); }
.pv-chat__status.is-success { color: var(--pv-green); font-weight: 600; }

/* Phones: the button shrinks to an icon so it covers less of the page */
@media (max-width: 600px) {
  .pv-chat__fab { padding: 0 8px; gap: 0; height: 52px; }
  .pv-chat__fab-label { max-width: 0; opacity: 0; }
  .pv-chat__fab-icon { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .pv-chat__fab, .pv-chat__panel, .pv-chat__fab-icon svg, .pv-chat__fab-label { transition: none; }
  .pv-chat__dot::before { animation: none; opacity: 0; }   /* steady green dot, no pulse */
}

@media print { .pv-chat { display: none; } }
