/* ========== CAPTCHA IMAGE CHALLENGE ========== */

#captcha-view {
  z-index: 3;
}

.rc-imageselect {
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.15), 0 2px 12px rgba(0, 0, 0, 0.1);
  width: 400px;
  max-width: 95vw;
  overflow: hidden;
  animation: wobbleIn 0.5s var(--ease-spring);
  position: relative;
}

.rc-imageselect.shaking {
  animation: shake 0.5s ease;
}

/* Header */
.rc-imageselect-header {
  background: var(--captcha-blue);
  padding: 16px 20px 12px;
  color: #fff;
  position: relative;
  transition: background-color 0.4s;
}

.rc-imageselect-header.flash-error {
  animation: flashRed 0.6s ease;
}

.rc-imageselect-header.success {
  background: var(--captcha-green);
  transition: background-color 0.5s var(--ease-material);
}

.rc-imageselect-desc {
  font-family: var(--font-system);
  font-size: 13px;
  font-weight: 400;
  opacity: 0.95;
  line-height: 1.3;
}

.rc-imageselect-target {
  font-family: var(--font-system);
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0 2px;
  line-height: 1.2;
}

.rc-imageselect-hint {
  font-family: var(--font-system);
  font-size: 11px;
  opacity: 0.75;
}

/* Error toast */
.rc-imageselect-error {
  background: var(--captcha-red);
  color: #fff;
  font-family: var(--font-system);
  font-size: 12px;
  font-weight: 500;
  padding: 8px 16px;
  text-align: center;
  display: none;
  animation: slideDown 0.3s var(--ease-material);
}

.rc-imageselect-error.visible {
  display: block;
}

/* Image Grid */
.rc-imageselect-table {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
  background: #fff;
}

.rc-imageselect-tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  background: #e0e0e0;
  transition: transform 0.15s var(--ease-material);
}

.rc-imageselect-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s var(--ease-material);
  pointer-events: none;
}

.rc-imageselect-tile:hover img {
  transform: scale(1.03);
}

.rc-imageselect-tile:active {
  transform: scale(0.96);
}

/* Selection overlay */
.rc-imageselect-tile .tile-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(74, 140, 247, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 6px;
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
}

.rc-imageselect-tile.selected .tile-overlay {
  opacity: 1;
  transform: scale(1);
  animation: checkIn 0.25s var(--ease-spring);
}

.rc-imageselect-tile.selected img {
  transform: scale(0.88);
}

.rc-imageselect-tile.deselecting .tile-overlay {
  animation: checkOut 0.2s var(--ease-material) forwards;
}

.tile-check {
  width: 24px;
  height: 24px;
  background: var(--captcha-blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tile-check svg {
  width: 14px;
  height: 14px;
}

/* Image flip animation for shuffle */
.rc-imageselect-tile.flipping-out {
  animation: flipOut 0.2s ease-in forwards;
}

.rc-imageselect-tile.flipping-in {
  animation: flipIn 0.2s ease-out forwards;
}

/* Footer */
.rc-imageselect-footer {
  background: var(--captcha-bg);
  border-top: 1px solid #e0e0e0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
}

.rc-footer-actions {
  display: flex;
  gap: 8px;
}

.rc-footer-btn {
  background: none;
  border: none;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
  cursor: pointer;
}

.rc-footer-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.rc-footer-btn:active {
  background: rgba(0, 0, 0, 0.1);
}

/* Refresh button spin animation */
.rc-footer-btn.spinning svg {
  animation: spinRefresh 0.6s ease-in-out;
}

@keyframes spinRefresh {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Refresh toast notification */
.refresh-toast {
  position: absolute;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-family: var(--font-system);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 16px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 10;
}

.refresh-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.rc-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rc-btn-skip {
  font-family: var(--font-system);
  font-size: 13px;
  font-weight: 500;
  color: var(--captcha-blue);
  background: none;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s;
}

.rc-btn-skip:hover {
  background: rgba(74, 140, 247, 0.08);
}

.rc-btn-verify {
  font-family: var(--font-system);
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
  background: var(--captcha-blue);
  border: none;
  border-radius: 2px;
  padding: 10px 24px;
  transition: background-color 0.15s, transform 0.1s;
  min-width: 90px;
}

.rc-btn-verify:hover {
  background: var(--captcha-blue-dark);
}

.rc-btn-verify:active {
  background: #2D6BC9;
  transform: translateY(1px);
}

.rc-btn-verify:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Audio modal easter egg */
.audio-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-lift);
  text-align: center;
  z-index: 10;
  animation: fadeSlideUp 0.3s var(--ease-spring);
}

.audio-modal p {
  font-family: var(--font-system);
  font-size: 13px;
  color: var(--charcoal);
  margin-bottom: var(--space-md);
}

.audio-modal button {
  font-family: var(--font-system);
  font-size: 12px;
  color: var(--captcha-blue);
  background: none;
  border: none;
  padding: 6px 12px;
}

/* Success transition for CAPTCHA widget */
.rc-imageselect.success-exit {
  animation: shrinkAway 0.8s var(--ease-material) forwards;
}

/* Responsive */
@media (max-width: 480px) {
  .rc-imageselect {
    width: 95vw;
    max-width: 360px;
  }

  .rc-imageselect-target {
    font-size: 20px;
  }

  .rc-btn-verify {
    padding: 8px 16px;
    font-size: 13px;
  }
}