/* ── Anteomnio Intent CAPTCHA ────────────────────────────────────────────────── */
/* Premium drag-to-align verification — Anteomnio design system.                */

/* ── Card ───────────────────────────────────────────────────────────────────── */
.ao-captcha {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, var(--color-bg-soft) 0%, var(--color-surface) 100%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 4px 16px rgba(0, 0, 0, 0.03);
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
  overflow: hidden;
}

/* ── Header: brand badge + refresh ──────────────────────────────────────────── */
.ao-captcha__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.ao-captcha__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent);
  user-select: none;
}
.ao-captcha__brand svg { flex-shrink: 0; opacity: 0.7; }

.ao-captcha__refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-4);
  cursor: pointer;
  transition: border-color var(--ease-fast), color var(--ease-fast);
}
.ao-captcha__refresh:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.ao-captcha__refresh.is-spinning svg {
  animation: ao-spin 0.5s ease;
}

@keyframes ao-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Instruction text ───────────────────────────────────────────────────────── */
.ao-captcha__prompt {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-2);
  line-height: var(--leading-snug);
  margin: 0;
}

/* ── Arena (drag surface) ───────────────────────────────────────────────────── */
.ao-captcha__arena {
  position: relative;
  height: 180px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(ellipse at 70% 50%, rgba(26, 63, 168, 0.025) 0%, transparent 65%),
    var(--color-bg-muted);
  border: 1px solid var(--color-border-soft);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: default;
}

/* Subtle dot grid */
.ao-captcha__arena::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--color-border) 0.8px, transparent 0.8px);
  background-size: 24px 24px;
  opacity: 0.35;
  pointer-events: none;
}

/* ── Target ghost ───────────────────────────────────────────────────────────── */
.ao-captcha__target {
  position: absolute;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.25s ease;
}
.ao-captcha__target svg {
  width: 100%;
  height: 100%;
  color: var(--color-accent);
  opacity: 0.18;
  fill: currentColor;
  transition: opacity 0.25s ease;
}
/* Ghost dashed outline */
.ao-captcha__target-outline {
  position: absolute;
  inset: 0;
}
.ao-captcha__target-outline svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 2;
  stroke-dasharray: 7 5;
  opacity: 0.35;
  transition: opacity 0.25s ease;
}

/* Glow when piece is near */
.ao-captcha__target.is-near svg {
  opacity: 0.35;
}
.ao-captcha__target.is-near .ao-captcha__target-outline svg {
  opacity: 0.6;
  stroke-dasharray: none;
}

/* Gentle pulse on the target to guide attention */
.ao-captcha__target-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid var(--color-accent);
  opacity: 0;
  animation: ao-target-pulse 2.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes ao-target-pulse {
  0%, 100% { opacity: 0; transform: scale(0.85); }
  50%      { opacity: 0.2; transform: scale(1.1); }
}

/* ── Draggable piece ────────────────────────────────────────────────────────── */
.ao-captcha__piece {
  position: absolute;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%);
  z-index: 3;
  cursor: grab;
  filter: drop-shadow(0 2px 6px rgba(26, 63, 168, 0.2));
  transition: filter 0.2s ease;
  will-change: left, top;
}
.ao-captcha__piece svg {
  width: 100%;
  height: 100%;
  fill: var(--color-accent);
  transition: fill 0.2s ease;
}
/* Inner accent detail */
.ao-captcha__piece-inner svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: rgba(255, 255, 255, 0.15);
  pointer-events: none;
  transform: scale(0.55);
}

.ao-captcha__piece.is-dragging {
  cursor: grabbing;
  filter: drop-shadow(0 6px 20px rgba(26, 63, 168, 0.3));
}

.ao-captcha__piece.is-snapping {
  transition:
    left 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    top 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    filter 0.45s ease;
  cursor: default;
  filter: drop-shadow(0 2px 8px rgba(26, 63, 168, 0.15));
}

/* ── Snap ring effect ───────────────────────────────────────────────────────── */
.ao-captcha__snap-ring {
  position: absolute;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid var(--color-accent);
  pointer-events: none;
  z-index: 4;
  animation: ao-snap-ring 0.6s ease-out forwards;
}
@keyframes ao-snap-ring {
  0%   { opacity: 0.5; transform: translate(-50%, -50%) scale(0.8); }
  100% { opacity: 0;   transform: translate(-50%, -50%) scale(2.2); }
}

/* Second ring (delayed) */
.ao-captcha__snap-ring--delay {
  animation-delay: 0.1s;
  opacity: 0;
}

/* ── Merged / verified shape glow ───────────────────────────────────────────── */
.ao-captcha__piece.is-merged svg {
  fill: var(--color-success);
  transition: fill 0.4s ease;
}

/* ── Status bar ─────────────────────────────────────────────────────────────── */
.ao-captcha__status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  min-height: 20px;
  color: var(--color-text-4);
  transition: color 0.3s ease;
}

.ao-captcha__status-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ao-captcha__status-icon--ok {
  background: var(--color-success);
  color: #fff;
}
.ao-captcha__status-icon--err {
  background: var(--color-danger);
  color: #fff;
}

/* ── Verified state ─────────────────────────────────────────────────────────── */
.ao-captcha.is-verified {
  border-color: var(--color-success);
  background: linear-gradient(145deg, #f0fdf4 0%, #fff 100%);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.08);
}
.ao-captcha.is-verified .ao-captcha__arena,
.ao-captcha.is-verified .ao-captcha__prompt,
.ao-captcha.is-verified .ao-captcha__refresh {
  display: none;
}
.ao-captcha.is-verified .ao-captcha__status {
  color: var(--color-success);
  font-size: var(--text-sm);
}

/* ── Error state ────────────────────────────────────────────────────────────── */
.ao-captcha.is-error {
  border-color: var(--color-danger);
}
.ao-captcha.is-error .ao-captcha__status {
  color: var(--color-danger);
}

/* ── Loading skeleton ───────────────────────────────────────────────────────── */
.ao-captcha__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  height: 180px;
  color: var(--color-text-4);
  font-size: var(--text-sm);
}
.ao-captcha__loading-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--color-accent-muted);
  animation: ao-dot-pulse 1s ease infinite;
}
.ao-captcha__loading-dot:nth-child(2) { animation-delay: 0.15s; }
.ao-captcha__loading-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes ao-dot-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1;   transform: scale(1); }
}

/* ── Verifying overlay ──────────────────────────────────────────────────────── */
.ao-captcha__verifying {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-lg);
  z-index: 10;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-3);
  letter-spacing: 0.02em;
  gap: var(--space-2);
}
.ao-captcha__verifying-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: ao-spin 0.6s linear infinite;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ao-captcha {
    padding: var(--space-4);
    gap: var(--space-3);
  }
  .ao-captcha__arena {
    height: 160px;
  }
  .ao-captcha__piece,
  .ao-captcha__target {
    width: 46px;
    height: 46px;
  }
}
