/* Гравик — клиентский маскот-гид. Самодостаточный виджет, работает на любом сайте ГРАВИУМ.
   Тёмная бренд-гамма, золото #c8a85a. Уважает prefers-reduced-motion. */

:root {
  --gc-gold: #c8a85a;
  --gc-gold-soft: rgba(200, 168, 90, .5);
}

#gravik-client {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
#gravik-client * { box-sizing: border-box; }
#gravik-client.gc-hidden { display: none; }

/* Робот */
.gc-launcher {
  position: relative;
  width: 84px; height: 84px;
  border: none; padding: 0; margin: 0;
  background: none; cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 10px 22px rgba(0,0,0,.4));
  transition: transform .25s ease;
  -webkit-tap-highlight-color: transparent;
}
.gc-launcher:hover { transform: translateY(-3px) scale(1.04); }
.gc-launcher:active { transform: scale(.96); }
.gc-robot { width: 100%; height: 100%; position: relative; z-index: 2; }
.gc-robot svg { width: 100% !important; height: 100% !important; }

/* Векторный маскот ГРАВИУМ (собственный SVG) */
.gc-vec { overflow: visible; filter: drop-shadow(0 6px 14px rgba(0,0,0,.4)); }
.gc-vec .gc-eyes { transform-box: fill-box; transform-origin: 50% 50%; animation: gc-blink 5.2s ease-in-out infinite; }
@keyframes gc-blink { 0%, 90%, 100% { transform: scaleY(1); } 94% { transform: scaleY(.12); } }
.gc-vec .gc-eye { animation: gc-eyeglow 2.6s ease-in-out infinite; }
@keyframes gc-eyeglow { 0%, 100% { opacity: .9; } 50% { opacity: 1; } }
.gc-vec .gc-tip { transform-box: fill-box; transform-origin: center; animation: gc-tip 2.2s ease-in-out infinite; }
@keyframes gc-tip { 0%, 100% { opacity: .55; transform: scale(.82); } 50% { opacity: 1; transform: scale(1.15); } }
/* Реакция при речи — быстрый радостный подскок */
.gc-launcher.gc-react .gc-robot { animation: gc-react-bounce .6s ease; }
@keyframes gc-react-bounce { 0%,100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-7px) rotate(-4deg); } 60% { transform: translateY(0) rotate(3deg); } }
@media (prefers-reduced-motion: reduce) {
  .gc-vec .gc-eyes, .gc-vec .gc-eye, .gc-vec .gc-tip, .gc-launcher.gc-react .gc-robot { animation: none; }
}

/* Аура-свечение под роботом */
.gc-aura {
  position: absolute; inset: -10%;
  z-index: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(200,168,90,.32), rgba(200,168,90,0) 62%);
  opacity: .0;
  animation: gc-aura 3.4s ease-in-out infinite;
}
@keyframes gc-aura { 0%,100%{opacity:.35;transform:scale(.9);} 50%{opacity:.75;transform:scale(1.08);} }

/* Плавающая анимация всего маскота в покое */
.gc-launcher.gc-float { animation: gc-float 4.2s ease-in-out infinite; }
@keyframes gc-float { 0%,100%{transform:translateY(0);} 50%{transform:translateY(-6px);} }

/* Точка-уведомление */
.gc-dot {
  position: absolute; top: 6px; right: 6px; z-index: 3;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--gc-gold); border: 2px solid #0b0b0d;
  opacity: 0; transform: scale(.4); transition: .25s;
}
.gc-dot.gc-on { opacity: 1; transform: scale(1); animation: gc-pulse 1.8s ease-in-out infinite; }
@keyframes gc-pulse { 0%,100%{box-shadow:0 0 0 0 rgba(200,168,90,.5);} 50%{box-shadow:0 0 0 7px rgba(200,168,90,0);} }

/* Речевой пузырь — карточка с заголовком (имя + крестик), текстом и, опционально, CTA.
   Заголовок и крестик — отдельная строка (flex), а не абсолютное позиционирование поверх
   текста: раньше крестик мог зрительно наезжать на имя/первую строку сообщения. */
.gc-bubble {
  pointer-events: auto;
  max-width: min(320px, calc(100vw - 40px));
  background: linear-gradient(160deg, #17151a, #0d0d10);
  border: 1px solid var(--gc-gold-soft);
  border-radius: 18px 18px 6px 18px;
  padding: 12px 13px 14px;
  color: #f3efe6; font-size: 14px; line-height: 1.5;
  box-shadow: 0 16px 44px rgba(0,0,0,.48);
  opacity: 0; transform: translateY(8px) scale(.96);
  transition: opacity .28s ease, transform .28s ease;
  position: relative;
  display: flex; flex-direction: column;
}
.gc-bubble.gc-show { opacity: 1; transform: translateY(0) scale(1); }
.gc-bubble-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.gc-bubble .gc-name { color: var(--gc-gold); font-weight: 700; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; }
.gc-bubble .gc-close {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 7px;
  color: #8a867d; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.gc-bubble .gc-close:hover { color: #f3efe6; background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.16); }
.gc-bubble-text { display: block; }
.gc-cta {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px; margin-top: 11px;
  background: linear-gradient(135deg, #d8b45f, #b98f36);
  color: #1a1408; font-weight: 700; font-size: 13px;
  padding: 8px 15px; border-radius: 10px;
  border: none; cursor: pointer; text-decoration: none;
  transition: filter .2s;
}
.gc-cta:hover { filter: brightness(1.08); }

/* Иконки вместо эмодзи */
.gc-ic { width: 1.05em; height: 1.05em; vertical-align: -0.16em; color: var(--gc-gold); display: inline-block; margin: 0 .12em; }
.gc-bubble .gc-ic { filter: drop-shadow(0 0 5px rgba(200,168,90,.35)); }

/* Меню быстрых действий */
.gc-menu {
  pointer-events: auto;
  display: none; flex-direction: column; gap: 5px;
  background: linear-gradient(160deg, #1a181e, #0c0c0f);
  border: 1px solid var(--gc-gold-soft);
  border-radius: 16px; padding: 8px;
  box-shadow: 0 18px 46px rgba(0,0,0,.5);
  min-width: 234px;
}
.gc-menu.gc-open { display: flex; animation: gc-menu-in .22s ease; }
@keyframes gc-menu-in { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }

.gc-menu-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; border-bottom: 1px solid rgba(200,168,90,.16); margin-bottom: 4px; }
.gc-menu-ava { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(200,168,90,.22), rgba(200,168,90,.06)); border: 1px solid var(--gc-gold-soft); }
.gc-menu-ava .gc-ic { width: 20px; height: 20px; margin: 0; }
.gc-menu-ttl { color: #f3efe6; font-weight: 700; font-size: 14px; line-height: 1.15; display: flex; flex-direction: column; }
.gc-menu-ttl small { color: #8a867d; font-weight: 500; font-size: 11.5px; letter-spacing: .02em; }

.gc-mrow {
  display: flex; align-items: center; gap: 11px;
  text-align: left; background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06); border-radius: 11px;
  color: #f3efe6; font-size: 13.5px; padding: 10px 11px; cursor: pointer;
  text-decoration: none; transition: background .18s, border-color .18s, transform .12s;
}
.gc-mrow:hover { background: rgba(200,168,90,.13); border-color: var(--gc-gold-soft); transform: translateX(2px); }
.gc-mic { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: rgba(200,168,90,.12); border: 1px solid rgba(200,168,90,.22); }
.gc-mic .gc-ic { width: 17px; height: 17px; margin: 0; }
.gc-menu-mute { color: #8a867d; font-size: 12px; text-align: center; background: none; border: none; cursor: pointer; padding: 8px 0 4px; margin-top: 2px; }
.gc-menu-mute:hover { color: #c4bfb4; }

@media (max-width: 560px) {
  .gc-launcher { width: 66px; height: 66px; }
  .gc-bubble { font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .gc-launcher.gc-float, .gc-aura, .gc-dot.gc-on { animation: none; }
}

/* ===== v4: живой Гравик ===== */

/* Глаза следят за курсором (JS двигает .gc-look) */
.gc-vec .gc-look { transition: transform .18s ease-out; }

/* Антенна — плавные повороты (сон/танец) */
.gc-vec .gc-antenna { transform-box: fill-box; transform-origin: 50% 100%; transition: transform .7s ease; }

/* Сон при бездействии */
.gc-sleep .gc-vec .gc-eyes { animation: none; transform: scaleY(.12); }
.gc-sleep .gc-vec .gc-antenna { transform: rotate(-16deg); }
.gc-sleep .gc-aura { animation: none; opacity: .12; }
.gc-sleep .gc-vec .gc-tip { animation: none; opacity: .4; }
.gc-sleep.gc-float { animation-duration: 7.5s; }
.gc-zzz-ov { position: absolute; top: -6px; right: -4px; z-index: 4; width: 34px; height: 40px; opacity: 0; transition: opacity .5s; pointer-events: none; }
.gc-sleep .gc-zzz-ov { opacity: 1; }
.gc-zzz-ov i { position: absolute; color: #e8c775; font: 700 13px/1 -apple-system, system-ui, sans-serif; font-style: normal; opacity: 0; animation: gc-zzz 2.6s ease-in-out infinite; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.gc-zzz-ov i:nth-child(1) { left: 0; bottom: 2px; }
.gc-zzz-ov i:nth-child(2) { left: 11px; bottom: 14px; animation-delay: .9s; font-size: 11px; }
.gc-zzz-ov i:nth-child(3) { left: 21px; bottom: 26px; animation-delay: 1.8s; font-size: 9px; }
@keyframes gc-zzz { 0% { opacity: 0; transform: translateY(5px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-7px); } }

/* Ночной режим — глаза чуть тусклее */
.gc-night .gc-vec .gc-eye { opacity: .72; }

/* Танец (пасхалка) */
.gc-launcher.gc-dance .gc-robot { animation: gc-dance 2s ease; }
.gc-launcher.gc-dance .gc-vec .gc-antenna { transform: rotate(18deg); }
@keyframes gc-dance {
  0%, 100% { transform: rotate(0) translateY(0); }
  12% { transform: rotate(-10deg) translateY(-8px); }
  25% { transform: rotate(9deg) translateY(0); }
  38% { transform: rotate(-9deg) translateY(-9px); }
  50% { transform: rotate(10deg) translateY(0) scale(1.06); }
  64% { transform: rotate(-8deg) translateY(-7px); }
  78% { transform: rotate(7deg) translateY(0); }
  90% { transform: rotate(-4deg) translateY(-3px); }
}

/* Конфетти */
.gc-confetti { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: visible; }
.gc-confetti i {
  position: absolute; left: 50%; top: 38%;
  width: 7px; height: 11px; border-radius: 2px;
  transform: translate(-50%, -50%);
  animation: gc-cf 1.9s ease-out forwards;
}
@keyframes gc-cf {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(0); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 60px)), 130px) rotate(var(--rot, 260deg)); }
}

/* Поле знакомства в пузыре */
.gc-namebox { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.gc-namebox input {
  width: 120px; padding: 7px 10px; font-size: 13px; color: #f3efe6;
  background: #0c0c0f; border: 1px solid var(--gc-gold-soft); border-radius: 9px; outline: none;
}
.gc-namebox input:focus { border-color: var(--gc-gold); box-shadow: 0 0 0 2px rgba(200,168,90,.18); }
.gc-name-ok {
  background: linear-gradient(135deg, #d8b45f, #b98f36); color: #1a1408;
  font-weight: 700; font-size: 13px; padding: 7px 14px; border: none; border-radius: 9px; cursor: pointer;
}
.gc-name-ok:hover { filter: brightness(1.08); }
.gc-name-no { background: none; border: none; color: #8a867d; font-size: 12px; cursor: pointer; padding: 4px 2px; }
.gc-name-no:hover { color: #c4bfb4; }

/* Секция «ещё в ГРАВИУМ» в меню */
.gc-menu-sep { color: #8a867d; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; padding: 8px 8px 3px; }
.gc-mrow-dim { opacity: .88; }

@media (prefers-reduced-motion: reduce) {
  .gc-vec .gc-look, .gc-launcher.gc-dance .gc-vec, .gc-confetti i, .gc-vec .gc-zzz text { animation: none; transition: none; }
}

/* Сон/ночь: приглушение работает для любого робота */
.gc-robot { transition: filter .6s ease, transform .18s ease-out; }
.gc-sleep .gc-robot { filter: brightness(.85) saturate(.8); }
.gc-night .gc-robot { filter: brightness(.88); }

/* Новогодняя шапка поверх робота (оверлей — и для lottie, и для вектора) */
.gc-hat-ov { position: absolute; top: -10px; left: 50%; z-index: 4; width: 44px; transform: translateX(-42%) rotate(-9deg); pointer-events: none; filter: drop-shadow(0 3px 6px rgba(0,0,0,.35)); }
.gc-hat-ov svg { width: 100%; height: auto; display: block; }
