/* ── Reset & base ─────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: #f0f0f0;
  color: #333;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding-top: 120px;
}

.demo-page {
  text-align: center;
}

.demo-page h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.demo-page p {
  margin-bottom: 24px;
  color: #555;
}

/* ── Checkbox widget ─────────────────────────────────── */

.captcha-widget {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 304px;
  height: 78px;
  background: #fafafa;
  border: 1px solid #d3d3d3;
  border-radius: 3px;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.08);
  padding: 0 12px;
  user-select: none;
  position: relative;
  transition: border-color 0.15s;
}

.captcha-widget:hover {
  border-color: #b0b0b0;
}

/* left: checkbox + label */
.captcha-widget__checkbox-area {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.captcha-widget__checkbox {
  width: 28px;
  height: 28px;
  border: 2px solid #c1c1c1;
  border-radius: 3px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.captcha-widget:hover .captcha-widget__checkbox {
  border-color: #a0a0a0;
  box-shadow: 0 0 0 3px rgba(0, 100, 122, 0.15);
}

.captcha-widget__checkmark {
  display: none;              /* shown via JS after verify */
  line-height: 0;
}

.captcha-widget__checkmark.visible {
  display: flex;
}

/* spinner inside checkbox */
.captcha-widget__spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 3px solid #ddd;
  border-top-color: #00647a;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  position: absolute;
}

.captcha-widget__spinner.visible {
  display: block;
}

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

.captcha-widget__label {
  font-size: 14px;
  color: #555;
  font-weight: 400;
}

/* right: branding */
.captcha-widget__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.captcha-widget__logo {
  line-height: 0;
  animation: logoSpinIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.captcha-widget__logo img {
  display: block;
}

@keyframes logoSpinIn {
  from {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.captcha-widget__brand-name {
  font-size: 10px;
  font-weight: 700;
  color: #555;
  letter-spacing: 0.04em;
}

.captcha-widget__brand-links {
  font-size: 8px;
  color: #888;
}

.captcha-widget__brand-links a {
  color: #888;
  text-decoration: none;
}

.captcha-widget__brand-links a:hover {
  text-decoration: underline;
}

/* "I AM A ROBOT" under brand */
.captcha-widget__robot-area {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
  transition: background 0.15s;
}

.captcha-widget__robot-area:hover {
  background: rgba(0, 0, 0, 0.06);
}

.captcha-widget__robot-area:active {
  background: rgba(0, 0, 0, 0.1);
}

.captcha-widget__robot-icon {
  flex-shrink: 0;
}

.captcha-widget__robot-label {
  font-size: 8px;
  font-weight: 600;
  color: #888;
  letter-spacing: 0.05em;
}

/* verified state */
.captcha-widget.verified {
  pointer-events: none;
}

.captcha-widget.verified .captcha-widget__checkbox {
  border-color: #00647a;
  box-shadow: 0 0 6px 2px #ceff0040;
}

.captcha-widget.verified .captcha-widget__label {
  color: #333;
}

.captcha-widget.verified .captcha-widget__logo {
  filter: drop-shadow(0 0 4px #ceff0050);
}

/* ── Overlay / popup ─────────────────────────────────── */

.captcha-overlay {
  display: none;                 /* shown via JS */
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 10000;
  justify-content: center;
  align-items: center;
}

.captcha-overlay.open {
  display: flex;
}

.captcha-popup {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  width: 420px;
  animation: popIn 0.18s ease-out;
}

@keyframes popIn {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* header */
.captcha-popup__header {
  background: #00647a;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.captcha-popup__instruction {
  font-size: 14px;
  font-weight: 500;
}

.captcha-popup__close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.captcha-popup__close:hover {
  opacity: 1;
}

/* body – holds the canvas */
.captcha-popup__body {
  background: #e8e8e8;
  padding: 10px;
  display: flex;
  justify-content: center;
}

#challengeCanvas {
  background: #fff;
  border: 1px solid #ccc;
  display: block;
  width: 400px;
  height: 300px;
  transition: opacity 0.2s ease-out;
}

#challengeCanvas.fade-out {
  opacity: 0.15;
}

#challengeCanvas.fade-in {
  animation: canvasFadeIn 0.3s ease-out;
}

@keyframes canvasFadeIn {
  from { opacity: 0.15; }
  to { opacity: 1; }
}

/* slider area */
.captcha-popup__slider-area {
  padding: 12px 16px 4px;
  background: #fafafa;
  border-top: 1px solid #e0e0e0;
}

.captcha-popup__slider-label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
  text-align: center;
}

.captcha-popup__slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #ddd;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.captcha-popup__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #00647a;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.captcha-popup__slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #00647a;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.captcha-popup__slider-wrap {
  position: relative;
}

.captcha-popup__ghost-slider {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  background: transparent !important;
}

.captcha-popup__ghost-slider::-webkit-slider-runnable-track {
  background: transparent;
  height: 6px;
}

.captcha-popup__ghost-slider::-moz-range-track {
  background: transparent;
  height: 6px;
}

.captcha-popup__ghost-slider.animate {
  opacity: 0.7;
  animation: ghostFade 0.6s ease-out forwards;
}

@keyframes ghostFade {
  0% { opacity: 0.8; }
  60% { opacity: 0.5; }
  100% { opacity: 0; }
}

.captcha-popup__slider-ticks {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px 0;
}

.captcha-popup__slider-ticks span {
  width: 2px;
  height: 6px;
  background: #ccc;
  border-radius: 1px;
}

/* footer */
.captcha-popup__footer {
  display: flex;
  justify-content: flex-end;
  padding: 10px 16px;
  background: #fafafa;
  border-top: 1px solid #e0e0e0;
}

.captcha-popup__verify {
  background: #00647a;
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 8px 28px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background 0.15s;
}

.captcha-popup__verify:hover {
  background: #005066;
}

.captcha-popup__verify:active {
  background: #004354;
}

.captcha-popup__verify.shake {
  animation: shake 0.4s ease-in-out;
}

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