/* Чат на сайте: кнопка в углу, облачко, окно переписки. Подключается только при включённом чате
   (next/content/chat.json → enabled). Цвета и шрифты — токены сайта из site.css. */

/* ---------- Кнопка в углу ---------- */
/* Фокус с клавиатуры и переходы по якорям не уходят под плавающую кнопку чата (WCAG 2.4.11) */
html { scroll-padding-bottom: 88px; }
.chat-launcher { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 40;
  display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; padding: 0; border: 2px solid var(--ink); border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow-launcher); cursor: pointer; transition: opacity 0.15s; }
.chat-launcher img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; object-position: 50% 20%; }
/* Кнопка приподнимается при наведении только без настройки «уменьшить движение»; постоянно горящая красная точка
   на аватаре убрана — она не показывала никакого состояния (аудит Hallmark 28.10.2026, правила 27 и 63) */
@media (prefers-reduced-motion: no-preference) {
  .chat-launcher { transition: opacity 0.15s, transform 0.15s; }
  .chat-launcher:hover { transform: translateY(-1px); }
}
.chat-launcher.is-tucked { opacity: 0; pointer-events: none; visibility: hidden; }
@media (max-width: 699px) { .chat-launcher { width: 54px; height: 54px; } .chat-launcher img { width: 46px; height: 46px; } }

/* ---------- Облачко ---------- */
.chat-teaser { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 72px); z-index: 40;
  display: flex; align-items: stretch; max-width: min(300px, calc(100vw - 32px)); border: 2px solid var(--ink); background: var(--card);
  box-shadow: var(--shadow-float); font: 500 15px/1.4 var(--sans); color: var(--ink); }
.chat-teaser__open { flex: 1; min-height: 44px; padding: 12px 4px 12px 14px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.chat-teaser__close { flex: none; width: 44px; min-height: 44px; border: 0; background: none; color: var(--muted); font: 400 24px/1 var(--sans); cursor: pointer; }
.chat-teaser__close:hover, .chat-teaser__open:hover { color: var(--accent); }

/* ---------- Окно ---------- */
.chat-panel { position: fixed; right: 16px; bottom: 16px; z-index: 45; display: flex; flex-direction: column;
  width: 390px; height: min(640px, calc(100dvh - 32px)); border: 2px solid var(--ink); background: var(--paper);
  box-shadow: var(--shadow-panel); font: 400 16px/1.5 var(--sans); color: var(--ink); }
@media (max-width: 699px) {
  .chat-panel { inset: 0 0 auto 0; width: 100%; height: var(--chat-vh, 100dvh); border: 0; box-shadow: none; }
  html.chat-open, html.chat-open body { overflow: hidden; }
}
.chat-head { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 14px; border-bottom: 2px solid var(--ink); background: var(--card); }
.chat-head img { flex: none; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; object-position: 50% 20%; }
.chat-head__name { margin: 0; font: 600 17px/1.25 var(--sans); }
.chat-head__sub { margin: 0; font: 400 14px/1.3 var(--sans); color: var(--muted); }
.chat-head__close { flex: none; margin-left: auto; width: 44px; height: 44px; border: 0; background: none; color: var(--ink); font: 400 28px/1 var(--sans); cursor: pointer; }
.chat-head__close:hover { color: var(--accent); }

.chat-log { position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 86%; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.45; }
.chat-msg--bot { align-self: flex-start; border: 1px solid var(--hair); background: var(--card); }
.chat-msg--visitor { align-self: flex-end; background: var(--ink); color: var(--paper); }
.chat-msg--pending { opacity: 0.75; }
.chat-note { align-self: stretch; padding: 8px 10px; border-left: 3px solid var(--hair); font-size: 14px; line-height: 1.45; color: var(--muted); }
.chat-note--error { border-left-color: var(--error); color: var(--ink); }
.chat-note--ok { border-left-color: var(--ok); color: var(--ink); }
.chat-note button { margin-top: 6px; }
.chat-typing { align-self: flex-start; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px dashed var(--hair); font-size: 14px; color: var(--muted); }
.chat-typing__dots { display: inline-flex; gap: 3px; }
.chat-typing__dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .chat-typing__dots span { animation: chat-blink 1.2s infinite ease-in-out; }
  .chat-typing__dots span:nth-child(2) { animation-delay: 0.2s; }
  .chat-typing__dots span:nth-child(3) { animation-delay: 0.4s; }
}
@keyframes chat-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.chat-card { align-self: stretch; padding: 12px; border: 1px solid var(--ink); background: var(--card); font-size: 15px; line-height: 1.45; }
.chat-card p { margin: 0 0 10px; }
.chat-card__title { font-weight: 600; }
.chat-card label { display: block; margin-bottom: 8px; font-size: 14px; }
.chat-card input[type="tel"], .chat-card input[type="text"] { display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--field); border-radius: 0; background: var(--field-bg); font: 400 16px/1.3 var(--sans); color: var(--ink); }
.chat-card .chat-check { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; }
.chat-card .chat-check input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); }
.chat-card .chat-err { display: block; min-height: 0; margin: -4px 0 8px; color: var(--error); font-size: 14px; }
.chat-card .chat-err:empty { display: none; }
.chat-card a { color: inherit; }

.chat-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border: 2px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink); font: 600 15px/1.2 var(--sans); text-decoration: none; cursor: pointer; }
.chat-btn--accent { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.chat-btn--accent:hover { border-color: var(--accent-hover); background: var(--accent-hover); color: var(--on-accent); }
.chat-btn:disabled { opacity: 0.55; cursor: default; }

.chat-new { position: sticky; bottom: 4px; align-self: center; min-height: 36px; padding: 0 14px; border: 1px solid var(--ink); background: var(--card); font: 600 14px/1 var(--sans); cursor: pointer; }

.chat-foot { border-top: 2px solid var(--ink); background: var(--card); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chat-chip { min-height: 36px; padding: 0 12px; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); font: 500 14px/1 var(--sans); cursor: pointer; }
.chat-chip:hover { border-color: var(--accent); color: var(--accent); }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-form textarea { flex: 1; min-height: 44px; max-height: 132px; padding: 10px; border: 1px solid var(--field); border-radius: 0; background: var(--field-bg); font: 400 16px/1.4 var(--sans); color: var(--ink); resize: none; }
.chat-form textarea:disabled { background: var(--paper-2); }
.chat-send { flex: none; width: 48px; height: 44px; border: 2px solid var(--accent); background: var(--accent); color: var(--on-accent); font: 600 20px/1 var(--sans); cursor: pointer; }
.chat-send:disabled { opacity: 0.45; cursor: default; }
.chat-count { margin: 4px 0 0; font-size: 12px; color: var(--muted); text-align: right; }
.chat-count:empty { display: none; }
.chat-contacts { display: flex; gap: 8px; margin-top: 8px; }
.chat-contacts .chat-btn { flex: 1; min-height: 44px; padding: 0 8px; font-size: 15px; }
.chat-forget { display: inline; min-height: 0; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }
