/* 行为验证码 widget 样式 v3 — 灵动弹出动画 */

.kd-captcha {
  --kc-primary: #4f46e5;
  --kc-success: #10b981;
  --kc-danger: #ef4444;
  --kc-bg: #f9fafb;
  --kc-border: #e5e7eb;
  --kc-text: #374151;
  --kc-text-light: #6b7280;
  --kc-radius: 12px;
  position: relative;
  display: inline-block;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 14px;
  color: var(--kc-text);
  background: #fff;
  border: 1px solid var(--kc-border);
  border-radius: var(--kc-radius);
  padding: 18px 16px 16px;
  width: 360px;
  max-width: 100%;
  box-sizing: border-box;
  user-select: none;
  overflow: hidden;
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.08),
    0 2px 8px rgba(15, 23, 42, 0.04);
  transform-origin: 50% 40%;
}

.kd-captcha--enter {
  opacity: 0;
  transform: translateY(14px) scale(0.92);
  filter: blur(2px);
}

.kd-captcha--visible {
  animation: kd-pop-in 0.55s cubic-bezier(0.22, 1.4, 0.36, 1) forwards;
}

.kd-captcha--success {
  animation: kd-success-glow 0.7s ease-out;
}

.kd-captcha__glow {
  position: absolute;
  inset: -40% -20% auto;
  height: 120px;
  background: radial-gradient(ellipse at center, rgba(79, 70, 229, 0.16), transparent 70%);
  pointer-events: none;
  animation: kd-glow-drift 3.2s ease-in-out infinite;
}

.kd-captcha * { box-sizing: border-box; }

.kd-captcha__hint {
  position: relative;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--kc-text);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.kd-captcha__stage {
  position: relative;
  margin-bottom: 12px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--kc-bg);
}

.kd-captcha__stage--enter {
  opacity: 0;
  transform: scale(0.97);
}

.kd-captcha__stage--visible {
  animation: kd-stage-in 0.45s 0.08s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

.kd-captcha__stage svg {
  display: block;
  width: 100%;
  height: auto;
}

.kd-captcha__piece {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  will-change: transform;
}

.kd-captcha__piece svg {
  display: block;
  width: 100%;
  height: 100%;
}

.kd-captcha__inner-disc {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform-origin: center center;
  will-change: transform;
}

.kd-captcha__click-mark {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--kc-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%) scale(0.4);
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
  animation: kd-mark-pop 0.35s cubic-bezier(0.22, 1.5, 0.36, 1) forwards;
}

.kd-captcha__track {
  position: relative;
  height: 42px;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border: 1px solid var(--kc-border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.kd-captcha__track-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.55), rgba(79, 70, 229, 0.55));
  opacity: 0.45;
  transition: none;
}

.kd-captcha__knob {
  position: absolute;
  top: 0;
  left: 0;
  width: 54px;
  height: 42px;
  background: linear-gradient(180deg, #6366f1, var(--kc-primary));
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  cursor: grab;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  z-index: 2;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.kd-captcha__knob--pulse {
  animation: kd-knob-pulse 1.6s ease-in-out infinite;
}

.kd-captcha__knob--dragging {
  transform: scale(1.04);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.45);
  animation: none;
}

.kd-captcha__knob:active { cursor: grabbing; }
.kd-captcha__knob--disabled { cursor: not-allowed; opacity: 0.6; }

.kd-captcha__knob--success {
  background: linear-gradient(180deg, #34d399, var(--kc-success));
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
  animation: kd-knob-success 0.5s cubic-bezier(0.22, 1.5, 0.36, 1);
}

.kd-captcha__knob--error {
  background: linear-gradient(180deg, #f87171, var(--kc-danger));
  animation: kd-shake 0.4s ease-in-out;
}

.kd-captcha__status {
  margin-top: 10px;
  font-size: 12px;
  color: var(--kc-text-light);
  text-align: center;
  min-height: 18px;
  transition: color 0.2s ease, transform 0.25s ease;
}

.kd-captcha__status--success {
  color: var(--kc-success);
  font-weight: 600;
  animation: kd-status-in 0.35s ease-out;
}

.kd-captcha__status--error {
  color: var(--kc-danger);
  animation: kd-status-in 0.35s ease-out;
}

.kd-captcha__refresh {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  color: var(--kc-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  z-index: 3;
  transition: background 0.2s, transform 0.2s;
}

.kd-captcha__refresh:hover {
  background: #fff;
  color: var(--kc-primary);
  transform: rotate(45deg);
}

.kd-captcha__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(4px);
  font-size: 13px;
  color: var(--kc-text-light);
  z-index: 4;
  border-radius: var(--kc-radius);
  animation: kd-fade-in 0.25s ease-out;
}

.kd-captcha__spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--kc-border);
  border-top-color: var(--kc-primary);
  border-radius: 50%;
  animation: kd-spin 0.7s linear infinite;
  margin-right: 8px;
}

.kd-captcha--hidden { display: none; }

@keyframes kd-pop-in {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.9);
    filter: blur(3px);
  }
  60% {
    opacity: 1;
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes kd-stage-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes kd-knob-pulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.5);
    transform: scale(1.03);
  }
}

@keyframes kd-knob-success {
  0% { transform: scale(0.9); }
  55% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

@keyframes kd-mark-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
  }
  70% {
    transform: translate(-50%, -50%) scale(1.12);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

@keyframes kd-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@keyframes kd-status-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes kd-success-glow {
  0% { box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08); }
  40% { box-shadow: 0 12px 36px rgba(16, 185, 129, 0.28); }
  100% { box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08); }
}

@keyframes kd-glow-drift {
  0%, 100% { transform: translateX(-6%) scale(1); opacity: 0.75; }
  50% { transform: translateX(8%) scale(1.05); opacity: 1; }
}

@keyframes kd-spin { to { transform: rotate(360deg); } }

@keyframes kd-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .kd-captcha--enter,
  .kd-captcha--visible,
  .kd-captcha__stage--enter,
  .kd-captcha__stage--visible,
  .kd-captcha__knob--pulse,
  .kd-captcha__glow,
  .kd-captcha__click-mark,
  .kd-captcha--success {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}
