/* ============================================================
   PathCaptcha v48 — Стили + прелоадер
   ============================================================ */

/* ─── Оверлей капчи ─── */
.kb-captcha-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.98);
  z-index: 999999;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  font-family: 'Inter', Arial, sans-serif;
  opacity: 0;
  visibility: hidden;
  transform: scale(1);
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              visibility 0.45s;
}

.kb-captcha-overlay.kb-visible {
  opacity: 1;
  visibility: visible;
}

/* ─── Инструкция ─── */
.kb-captcha-instruction {
  color: #2D2D2D;
  font-size: clamp(13px, 4vw, 17px);
  margin-bottom: 24px;
  text-align: center;
  padding: 0 32px;
  line-height: 1.5;
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* ─── Canvas ─── */
.kb-captcha-canvas {
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(78, 205, 180, 0.12),
              0 4px 12px rgba(0, 0, 0, 0.04);
  background: #FFFFFF;
  border: none;
  cursor: grab;
  touch-action: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
}

.kb-captcha-canvas:hover {
  box-shadow: 0 20px 48px rgba(78, 205, 180, 0.18),
              0 6px 16px rgba(0, 0, 0, 0.06);
}

.kb-captcha-canvas:active {
  cursor: grabbing;
  transform: scale(0.99);
}

/* ─── Анимация ошибки ─── */
.kb-captcha-canvas.kb-error-shake {
  animation: kbShake 0.4s ease;
}

@keyframes kbShake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(3px); }
}

/* ─── Прелоадер (пока запрашивается nonce) ─── */
.kb-captcha-loader {
  position: fixed;
  inset: 0;
  z-index: 999998;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.98);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.kb-captcha-loader.kb-loader-visible {
  opacity: 1;
  visibility: visible;
}

.kb-captcha-loader::before {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid rgba(78, 205, 180, 0.15);
  border-top-color: #4ECDB4;
  border-radius: 50%;
  animation: kbSpin 0.7s linear infinite;
}

.kb-captcha-loader-text {
  font-family: 'Inter', Arial, sans-serif;
  font-size: 14px;
  color: #666;
  font-weight: 400;
}

@keyframes kbSpin {
  to { transform: rotate(360deg); }
}

/* ─── Сообщение об ошибке сети ─── */
.kb-captcha-error {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.98);
  font-family: 'Inter', Arial, sans-serif;
}

.kb-captcha-error-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #FFF0F0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #E53935;
  font-size: 24px;
  font-weight: 700;
}

.kb-captcha-error-text {
  font-size: 15px;
  color: #333;
  text-align: center;
  max-width: 280px;
  line-height: 1.5;
}

.kb-captcha-error-btn {
  margin-top: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: #4ECDB4;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

.kb-captcha-error-btn:hover {
  background: #3DBAA2;
}