/* The slider-puzzle CAPTCHA (templates/auth/_captcha.html + js/captcha.js).
 *
 * It opens as a MODAL when the user presses Sign in / Register, so everything here is either
 * the overlay or the puzzle inside it. Self-contained on purpose: it is mounted on the
 * Tailwind-era auth pages, but the geometry has to be exact — the stage is drawn at the
 * 320x180 the server cut the notch at, 1:1, because the x the browser reports IS the x the
 * server compares. Nothing here may scale .cap-stage.
 */
.cap { font-size: 13px; color: #374151; }

/* ---------------------------------------------------------------- the dialog and its backdrop */
.cap-modal {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center;
  justify-content: center; padding: 12px;
}
.cap-modal[hidden] { display: none; }
.cap-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .55); }
.cap-card {
  position: relative; width: 348px; max-width: 100%; box-sizing: border-box; padding: 14px;
  background: #fff; border-radius: 12px; box-shadow: 0 20px 45px rgba(0, 0, 0, .28);
  animation: cap-pop .16s ease-out both;
}
@keyframes cap-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
/* While the dialog is open the page behind it does not scroll. */
.cap-locked { overflow: hidden; }

.cap-stage {
  position: relative; width: 320px; height: 180px; border-radius: 8px; overflow: hidden;
  background: #e5e7eb; border: 1px solid #d1d5db; user-select: none; -webkit-user-select: none;
}
.cap-bg { position: absolute; inset: 0; width: 320px; height: 180px; display: block; }
/* The piece rides on top at the y the server chose; only its left ever changes. */
.cap-piece {
  position: absolute; left: 0; top: 0; width: 52px; height: 52px; display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .45)); pointer-events: none;
}
.cap-veil {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(249, 250, 251, .92); color: #6b7280; font-size: 12.5px; text-align: center;
  padding: 0 16px;
}
.cap-veil[hidden] { display: none; }

/* The track. The knob is a real <button> so it is reachable by keyboard and announced. */
.cap-track {
  position: relative; height: 38px; margin-top: 10px; border-radius: 19px;
  background: #f3f4f6; border: 1px solid #d1d5db; overflow: hidden;
}
.cap-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #dbeafe; }
.cap-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #9ca3af; font-size: 12.5px; pointer-events: none;
}
.cap-knob {
  position: absolute; left: 0; top: 0; width: 52px; height: 36px; border: 1px solid #d1d5db;
  border-radius: 18px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
  cursor: grab; display: flex; align-items: center; justify-content: center; padding: 0;
  color: #4b5563; touch-action: none;
}
.cap-knob:active { cursor: grabbing; }
.cap-knob:disabled { cursor: default; color: #9ca3af; }
.cap-knob:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }

.cap-msg { min-height: 18px; margin-top: 8px; font-size: 12.5px; color: #6b7280; }

/* Cancel and refresh, the two ways out an exchange slider gives, plus what to do. */
.cap-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.cap-icon {
  background: none; border: 0; padding: 2px; color: #9ca3af; cursor: pointer; line-height: 0;
  border-radius: 999px;
}
.cap-icon:hover { color: #4b5563; }
.cap-icon:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }
.cap-note { margin-left: auto; font-size: 11.5px; color: #9ca3af; }

/* Solved: the track goes green and the knob stops being draggable. */
.cap[data-state="passed"] .cap-track { background: #dcfce7; border-color: #86efac; }
.cap[data-state="passed"] .cap-fill { background: #bbf7d0; }
.cap[data-state="passed"] .cap-msg { color: #15803d; }
.cap[data-state="failed"] .cap-track { background: #fee2e2; border-color: #fca5a5; }
.cap[data-state="failed"] .cap-msg, .cap[data-state="error"] .cap-msg { color: #b91c1c; }

/* Failure shakes the card, the same tell an exchange slider gives. */
.cap-shake { animation: cap-shake .42s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes cap-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
@media (prefers-reduced-motion: reduce) {
  .cap-shake, .cap-card { animation: none; }
}
