/* ===================== ВЕНТО 3D — НОВЫЙ МАСКОТ =====================
   Изолированные стили сцены, речевого облака и попадания клика.
   Сама модель — WebGL (robot-3d.js), поэтому здесь только рамка и UI. */

.robot3d-host {
  /* на десктопе маскот чуть меньше, на телефоне — свои размеры ниже в медиазапросах */
  --robot-w: 216px;
  --robot-h: 270px;
  position: relative;
  width: var(--robot-w);
  height: var(--robot-h);
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .35s ease, opacity .3s ease, visibility .3s;
}
[data-robot-home] {
  position: fixed;
  right: 14px;
  bottom: 16px;
  z-index: 1300;
  width: var(--robot-w);
  height: var(--robot-h);
  --robot-dx: 0px;
  --robot-dy: 0px;
  --robot-consent-y: 0px;
  transform: translate3d(var(--robot-dx), calc(var(--robot-dy) + var(--robot-consent-y)), 0);
  transition: transform .75s cubic-bezier(.22, .9, .24, 1), opacity .3s ease, visibility .3s;
  will-change: transform;
}
/* когда открыт диалог, робот подлетает к его левому краю */
.robot3d-docked { z-index: 1301; }
.robot3d-talking-mobile { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; }
.robot3d-host.robot3d-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.robot3d-host.robot3d-unavailable { display: none !important; }

.robot3d-canvas { position: absolute; inset: 0; pointer-events: none; }
.robot3d-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity .55s ease;
}
.robot3d-ready .robot3d-canvas canvas { opacity: 1; }

/* кликабельная зона только по фигуре, а не по всему прямоугольнику */
.robot3d-hit {
  position: absolute;
  left: 25%;
  top: 12%;
  width: 50%;
  height: 74%;
  padding: 0;
  border: 0;
  border-radius: 46%;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  z-index: 2;
  outline: none;
}
.robot3d-hit:focus-visible {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .45);
}
.robot3d-hit:hover { background: radial-gradient(ellipse at center, rgba(94, 234, 212, .08), transparent 68%); }

/* --- речевое облако --- */
.robot3d-bubble {
  position: absolute;
  right: 2px;
  bottom: calc(100% - 12px);
  z-index: 4;
  width: 258px;
  max-width: 78vw;
  padding: 12px 30px 12px 14px;
  border: 1px solid var(--line, #e6e9ed);
  border-radius: 16px;
  background: var(--panel, #fff);
  color: var(--text, #1c1e21);
  box-shadow: 0 18px 46px rgba(10, 38, 40, .18), 0 2px 8px rgba(10, 38, 40, .06);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 500;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(.97);
  transform-origin: 88% 100%;
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
  pointer-events: none;
}
.robot3d-bubble.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.robot3d-bubble::after {
  content: '';
  position: absolute;
  right: 44px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: var(--panel, #fff);
  border-right: 1px solid var(--line, #e6e9ed);
  border-bottom: 1px solid var(--line, #e6e9ed);
  transform: rotate(45deg);
}
.robot3d-bubble-text { display: block; }
.robot3d-bubble-action {
  display: block;
  margin-top: 9px;
  padding: 7px 12px;
  border: 0;
  border-radius: 9px;
  background: var(--brand, #0f766e);
  color: #fff;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.robot3d-bubble-action:hover { background: var(--brand-hover, #115e59); }
.robot3d-bubble-close {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 21px;
  height: 21px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted, #6a7078);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.robot3d-bubble-close:hover { background: var(--bg, #f4f5f7); color: var(--text, #1c1e21); }

.robot3d-badge {
  position: absolute;
  top: 17%;
  right: 20%;
  z-index: 5;
  width: 11px;
  height: 11px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .16);
}

/* --- подсветка поля (используется vento-errors.js) --- */
.vento-field-hl {
  position: fixed;
  z-index: 1288;
  pointer-events: none;
  border: 3px solid #f59e0b;
  border-radius: 10px;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .22);
  animation: ventoHlPulse 1.2s ease-in-out infinite;
}
@keyframes ventoHlPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(245, 158, 11, .22); }
  50% { box-shadow: 0 0 0 7px rgba(245, 158, 11, .32), 0 0 22px rgba(245, 158, 11, .45); }
}

/* --- демонстрационная страница --- */
.robot3d-demo { width: 100%; height: 100%; }
.robot3d-demo .robot3d-bubble { right: 50%; transform: translate(50%, 8px) scale(.97); }
.robot3d-demo .robot3d-bubble.show { transform: translate(50%, 0) scale(1); }
.robot3d-demo .robot3d-bubble::after { right: 50%; margin-right: -6px; }

/* не перекрываем баннер cookie */
body.consent-open .robot3d-host { --robot-consent-y: -132px; }

@media (max-width: 560px) {
  .robot3d-host { --robot-w: 164px; --robot-h: 206px; }
  [data-robot-home] { right: 6px; bottom: 62px; }
  .robot3d-bubble { width: 216px; font-size: 12.5px; padding: 10px 27px 10px 12px; }
  .robot3d-bubble::after { right: 34px; }
  body.consent-open .robot3d-host { opacity: 0; visibility: hidden; pointer-events: none; }
}

@media (max-width: 380px) {
  .robot3d-host { --robot-w: 146px; --robot-h: 184px; }
  .robot3d-bubble { width: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  .robot3d-host { transition-duration: .01s; }
  .vento-field-hl { animation: none; }
}

@media print {
  [data-robot-home] { display: none !important; }
}


/* ---------- Скрытие маскота по желанию пользователя ---------- */
.robot3d-dismiss {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 6;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(15, 118, 110, .16);
  background: rgba(255, 255, 255, .92);
  color: #4b5563;
  font: 600 16px/1 system-ui, sans-serif;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .7;
  transition: opacity .2s ease;
}
.robot3d-dismiss:hover,
.robot3d-dismiss:focus-visible { opacity: 1; }

body.dark-theme .robot3d-dismiss {
  background: rgba(31, 32, 39, .92);
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, .16);
}

.robot-restore {
  position: fixed;
  right: 14px;
  bottom: 24px;
  z-index: 1300;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(15, 118, 110, .16);
  background: #fff;
  box-shadow: 0 8px 20px rgba(17, 24, 39, .18);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.robot-restore:hover { transform: translateY(-1px); }
.robot-restore img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

body.dark-theme .robot-restore {
  background: var(--panel, #1f2027);
  border-color: rgba(255, 255, 255, .12);
}

/* Кнопка «наверх» стоит ровно над кружком свёрнутого робота */
body.robot-off .scroll-top-btn { right: 15px; bottom: 82px; }

@media (max-width: 560px) {
  /* Кружок робота всегда виден и всегда выше плашки: на iPhone плашка
     выше на safe-area-inset-bottom, поэтому считаем от реальной высоты. */
  .robot-restore {
    right: 6px;
    bottom: calc(62px + env(safe-area-inset-bottom, 0px) + 14px);
  }
}
