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

body {
  font-family: Arial, sans-serif;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Page layout ───────────────────────────────────────────── */
.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid #ddd;
}

.site-logo { font-size: 1.1rem; font-weight: bold; }

nav a {
  margin-left: 20px;
  color: #333;
  text-decoration: none;
  font-size: 0.9rem;
}
nav a:hover { text-decoration: underline; }

main { padding: 40px 0; }

h1 { font-size: 1.8rem; margin-bottom: 10px; }

.intro { color: #555; margin-bottom: 24px; }

/* ── Verify button ─────────────────────────────────────────── */
.btn-verify {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 24px;
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 32px;
}
.btn-verify:hover { background: #1d4ed8; }
.btn-verify:disabled { background: #93c5fd; cursor: default; }

/* ── Protected wrapper ─────────────────────────────────────── */
.protected-wrapper {
  position: relative;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
}

.lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(245,245,245,0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.95rem;
  color: #555;
  z-index: 5;
  transition: opacity 0.5s;
}
.lock-overlay span { font-size: 2rem; }
.lock-overlay.unlocking { opacity: 0; pointer-events: none; }

.protected-content { padding: 28px; }
.protected-content h2 { margin-bottom: 12px; font-size: 1.3rem; }
.protected-content > p { color: #555; margin-bottom: 20px; line-height: 1.6; }

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.content-card {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 16px;
  background: #fff;
}
.content-card p { color: #666; font-size: 0.875rem; margin-top: 6px; line-height: 1.5; }

/* ── Success banner ────────────────────────────────────────── */
.success-banner {
  margin-top: 16px;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 0.95rem;
}

footer {
  text-align: center;
  padding: 20px 0;
  color: #888;
  font-size: 0.8rem;
  border-top: 1px solid #ddd;
  margin-top: 40px;
}

/* ── Modal overlay ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

/* ── Modal box ─────────────────────────────────────────────── */
.modal-box {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 560px;
  max-height: 95vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}
.modal-title { font-size: 1.05rem; font-weight: bold; }
.attempts-badge { font-size: 0.85rem; color: #555; }
.attempts-badge strong { color: #2563eb; }

/* ── Challenge row ─────────────────────────────────────────── */
.challenge-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #f0f4ff;
  border: 1px solid #c7d7fd;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.ch-icon { font-size: 2.2rem; flex-shrink: 0; }

.ch-text { flex: 1; }
.ch-label { font-size: 0.68rem; color: #2563eb; font-weight: bold; letter-spacing: 0.8px; text-transform: uppercase; margin-bottom: 2px; }
.ch-name  { font-size: 1rem; font-weight: bold; color: #111; margin-bottom: 2px; }
.ch-hint  { font-size: 0.8rem; color: #555; }

/* ── Timer box ─────────────────────────────────────────────── */
.timer-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 2px solid #2563eb;
  border-radius: 8px;
  padding: 6px 12px;
  min-width: 52px;
  flex-shrink: 0;
}
.timer-num {
  font-size: 1.6rem;
  font-weight: bold;
  color: #2563eb;
  line-height: 1;
}
.timer-num.warn   { color: #d97706; }
.timer-num.danger { color: #dc2626; }
.timer-label { font-size: 0.65rem; color: #888; text-transform: uppercase; }

/* ── Timer bar ─────────────────────────────────────────────── */
.timer-bar-track {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  margin-bottom: 14px;
  overflow: hidden;
}
.timer-bar-fill {
  height: 100%;
  width: 100%;
  background: #2563eb;
  border-radius: 2px;
  transition: width 1s linear, background 0.3s;
}
.timer-bar-fill.warn   { background: #d97706; }
.timer-bar-fill.danger { background: #dc2626; }

/* ── Video ─────────────────────────────────────────────────── */
.video-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  margin-bottom: 10px;
  aspect-ratio: 4/3;
  border: 1px solid #ddd;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

.video-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
  pointer-events: none;
}

.status-pill {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: 100px;
  white-space: nowrap;
}

/* ── Hold progress ─────────────────────────────────────────── */
.hold-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: #444;
  margin-bottom: 8px;
}
.hold-track {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}
.hold-fill {
  height: 100%;
  width: 0%;
  background: #2563eb;
  border-radius: 4px;
  transition: width 0.15s;
}
#holdPct { font-weight: bold; color: #2563eb; min-width: 34px; text-align: right; }

/* ── Liveness row ──────────────────────────────────────────── */
.liveness-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  background: #f0f4ff;
  border: 1px solid #c7d7fd;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 8px;
}
.liveness-row span:first-child { flex-shrink: 0; }
#livenessInstruction { flex: 1; color: #444; }

.liveness-badge {
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: bold;
  flex-shrink: 0;
}
.liveness-badge.pending { background: #fef9c3; color: #854d0e; }
.liveness-badge.passed  { background: #dcfce7; color: #166534; }
.liveness-badge.failed  { background: #fee2e2; color: #991b1b; }

/* ── Result message ────────────────────────────────────────── */
.result-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-top: 8px;
}
.result-msg.success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.result-msg.error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.result-msg.warn    { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }

/* ── Blocked box ───────────────────────────────────────────── */
.blocked-box {
  text-align: center;
  max-width: 380px;
}
.blocked-box h2 { margin: 12px 0 8px; font-size: 1.3rem; color: #dc2626; }
.blocked-box p  { color: #555; margin-bottom: 20px; line-height: 1.6; }
