/* Квиз-диалог для посадочных: плавающая кнопка + окно чата, в котором бот задаёт
   вопросы и в конце собирает контакты. Разметку строит /js/lead-quiz.js, здесь только вид.

   Стиль настраивается переменными на .fcq (посадочная задаёт свои цвета и шрифт),
   поэтому один файл обслуживает все страницы. Всё под классами .fcq-*, чтобы вёрстка
   посадочной и виджет не задевали друг друга. */

.fcq {
  --fcq-main: #3767f6;
  --fcq-main-dark: #2855df;
  --fcq-ink: #15151b;
  --fcq-muted: #777786;
  --fcq-line: #e5e5ec;
  --fcq-bot: #f2f2f7;
  --fcq-paper: #fff;
  --fcq-radius: 18px;
  --fcq-font: inherit;
}

.fcq, .fcq * { box-sizing: border-box; }
.fcq button, .fcq input { font: inherit; }

/* ── Плавающая кнопка ──────────────────────────────────────────────────── */

.fcq-launcher {
  position: fixed; right: 18px; bottom: 18px; z-index: 99998;
  display: none; align-items: flex-end; gap: 10px;
  border: 0; padding: 0; background: none; cursor: pointer;
  font-family: var(--fcq-font);
}
.fcq-launcher.fcq-on { display: flex; animation: fcq-pop .35s ease; }

.fcq-tip {
  position: relative; max-width: 210px; padding: 11px 26px 11px 13px;
  border-radius: 14px; background: var(--fcq-paper); color: var(--fcq-ink);
  box-shadow: 0 12px 30px rgba(20, 22, 48, .16);
  font-size: 12px; font-weight: 700; line-height: 1.3; text-align: left;
}
.fcq-tip b { display: block; font-weight: 800; }
.fcq-tip-note { display: block; margin-top: 3px; color: var(--fcq-muted); font-size: 11px; }
.fcq-tip-x {
  position: absolute; top: 3px; right: 5px; padding: 2px 5px;
  color: #a6a6b4; font-size: 15px; line-height: 1;
}
/* Крестик закрывает подсказку, но не кнопку: диалог остаётся в одном клике. */
.fcq-launcher.fcq-quiet .fcq-tip { display: none; }

.fcq-bubble {
  position: relative; flex: none; display: grid; place-items: center;
  width: 60px; height: 60px; border-radius: 50%; color: #fff; font-size: 26px;
  background: var(--fcq-main); box-shadow: 0 14px 34px rgba(52, 91, 221, .38);
}
/* Пульс привлекает внимание, но только если человек не просил убрать анимации. */
@media (prefers-reduced-motion: no-preference) {
  .fcq-bubble::after {
    content: ""; position: absolute; inset: -6px; border-radius: 50%;
    border: 2px solid var(--fcq-main); opacity: .5; animation: fcq-pulse 2.4s ease-out infinite;
  }
}

/* ── Окно диалога ──────────────────────────────────────────────────────── */

.fcq-backdrop {
  position: fixed; inset: 0; z-index: 99998; display: none;
  background: rgba(12, 12, 20, .55);
}
.fcq-backdrop.fcq-on { display: block; }

/* Высота фиксированная, а не по содержимому: иначе окно прыгало бы на каждой реплике
   и на каждом наборе кнопок. Панель — контейнер позиционирования для блока ответов. */
.fcq-panel {
  position: fixed; right: 18px; bottom: 18px; z-index: 99999;
  display: none; flex-direction: column; overflow: hidden;
  width: min(100% - 36px, 380px); height: min(78vh, 640px);
  border-radius: 22px; background: var(--fcq-paper); color: var(--fcq-ink);
  box-shadow: 0 30px 80px rgba(15, 17, 40, .35);
  font-family: var(--fcq-font); text-align: left;
}
.fcq-panel.fcq-on { display: flex; animation: fcq-pop .3s ease; }

.fcq-head {
  display: flex; align-items: center; gap: 11px; flex: none;
  padding: 14px 16px; color: #fff; background: var(--fcq-main);
}
.fcq-ava {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, .2); font-size: 21px;
}
.fcq-name { font-size: 15px; font-weight: 800; }
.fcq-status { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 11px; font-weight: 600; opacity: .9; }
.fcq-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }
.fcq-min {
  margin-left: auto; flex: none; width: 32px; height: 32px;
  border: 0; border-radius: 50%; cursor: pointer;
  color: #fff; background: rgba(255, 255, 255, .18); font-size: 17px; line-height: 1;
}

.fcq-progress { flex: none; height: 3px; background: var(--fcq-line); }
.fcq-progress i { display: block; height: 100%; width: 0; background: var(--fcq-main); transition: width .35s ease; }

/* min-height:0 обязателен: без него флекс-элемент не даёт себя сжать и лента выдавливает
   панель за пределы экрана вместо прокрутки. Отступ снизу проставляет скрипт — по высоте
   блока ответов, чтобы последняя реплика не пряталась под ним. */
.fcq-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 16px 6px; }
.fcq-row { display: flex; margin-bottom: 9px; }
.fcq-row.fcq-me { justify-content: flex-end; }
.fcq-msg {
  max-width: 84%; padding: 10px 13px; border-radius: var(--fcq-radius);
  background: var(--fcq-bot); font-size: 14px; font-weight: 600; line-height: 1.4;
  animation: fcq-in .25s ease;
}
.fcq-row.fcq-bot .fcq-msg { border-bottom-left-radius: 6px; }
.fcq-row.fcq-me .fcq-msg { border-bottom-right-radius: 6px; color: #fff; background: var(--fcq-main); }
.fcq-msg b { font-weight: 800; }
.fcq-msg ul { margin: 8px 0 0; padding-left: 18px; }
.fcq-msg li { margin-top: 5px; }

.fcq-typing { display: flex; gap: 4px; padding: 14px 15px; }
.fcq-typing i { width: 6px; height: 6px; border-radius: 50%; background: #b6b6c4; animation: fcq-blink 1.2s infinite; }
.fcq-typing i:nth-child(2) { animation-delay: .18s; }
.fcq-typing i:nth-child(3) { animation-delay: .36s; }

/* ── Ответы ────────────────────────────────────────────────────────────── */

/* Блок ответов лежит поверх ленты, а не в потоке: размер окна от него не зависит,
   длинный список кнопок прокручивается внутри себя и закрывает старую переписку. */
.fcq-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  max-height: 62%; overflow-y: auto;
  padding: 6px 16px 16px; background: var(--fcq-paper);
}
.fcq-controls:empty { display: none; }
/* Мягкий переход к ленте — видно, что под блоком есть продолжение. */
.fcq-controls::before {
  content: ""; position: absolute; left: 0; right: 0; top: -18px; height: 18px;
  pointer-events: none; background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--fcq-paper));
}
.fcq-opts { display: grid; gap: 8px; }
.fcq-opt {
  width: 100%; min-height: 46px; padding: 11px 14px;
  border: 1px solid var(--fcq-line); border-radius: 14px; cursor: pointer;
  color: var(--fcq-ink); background: var(--fcq-paper);
  font-size: 14px; font-weight: 700; line-height: 1.25; text-align: left;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.fcq-opt:hover { border-color: var(--fcq-main); background: #f7f9ff; }
.fcq-opt:focus-visible { outline: 3px solid rgba(55, 103, 246, .25); outline-offset: 2px; }
.fcq-opt.fcq-sel { border-color: var(--fcq-main); background: #eef2ff; }
.fcq-opt.fcq-dim { opacity: .45; }
/* Подсказка «ответьте», если человек завис на вопросе. */
.fcq-nudge { animation: fcq-nudge .6s ease; }

.fcq-field {
  width: 100%; height: 50px; margin-bottom: 9px; padding: 0 14px;
  border: 1px solid #dcdce5; border-radius: 13px; outline: 0;
  color: var(--fcq-ink); background: var(--fcq-paper); font-size: 14px; font-weight: 700;
}
.fcq-field:focus { border-color: var(--fcq-main); }
.fcq-field.fcq-bad { border-color: #ef4444; }
.fcq-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.fcq-cta {
  display: block; width: 100%; min-height: 52px; padding: 14px 18px;
  border: 0; border-radius: 14px; cursor: pointer;
  color: #fff; background: var(--fcq-main);
  font-size: 15px; font-weight: 800; text-align: center; text-decoration: none;
}
.fcq-cta:hover { background: var(--fcq-main-dark); }
.fcq-cta[disabled] { opacity: .7; cursor: default; }
.fcq-tiny { margin: 9px 0 0; color: var(--fcq-muted); font-size: 11px; font-weight: 600; line-height: 1.35; }
.fcq-err { margin: 9px 0 0; color: #dc2626; font-size: 12px; font-weight: 700; }

/* ── Телефон ───────────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  .fcq-panel {
    right: 0; bottom: 0; left: 0;
    width: 100%; height: 100%;
    /* dvh учитывает выехавшую клавиатуру и панель браузера — иначе кнопка отправки
       оказывается за краем экрана. */
    height: 100dvh;
    border-radius: 0;
  }
  /* На телефоне кнопка и подсказка задаются от ширины экрана: в пикселях они выглядели
     мелкими рядом с крупной вёрсткой посадочной, а на узких экранах текст рвался на строки.
     clamp держит размер в разумных границах на маленьких и больших телефонах. */
  .fcq-launcher { right: 14px; bottom: 14px; gap: 8px; }
  .fcq-bubble {
    width: clamp(64px, 17vw, 84px); height: clamp(64px, 17vw, 84px);
    font-size: clamp(27px, 7vw, 35px);
  }
  .fcq-tip {
    max-width: min(58vw, 270px); padding: 13px 30px 13px 14px; border-radius: 16px;
    font-size: clamp(13px, 3.6vw, 15px);
  }
  .fcq-tip b { font-size: clamp(14px, 3.9vw, 16px); }
  .fcq-tip-note { margin-top: 4px; font-size: clamp(11px, 3.2vw, 13px); }
  /* Крестик — попадание пальцем, а не мышью: увеличиваем саму цель, а не только значок. */
  .fcq-tip-x { top: 1px; right: 2px; padding: 6px 9px; font-size: 17px; }
}

@keyframes fcq-pop { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes fcq-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fcq-blink { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
@keyframes fcq-pulse { 0% { transform: scale(1); opacity: .5; } 70% { transform: scale(1.25); opacity: 0; } 100% { opacity: 0; } }
@keyframes fcq-nudge { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

@media (prefers-reduced-motion: reduce) {
  .fcq-panel, .fcq-launcher, .fcq-msg { animation: none; }
  .fcq-typing i { animation: none; opacity: .6; }
}
