/* ============================================================
   Age Verify — Face Detection v2  |  age-verification.css
   Two-step: Consent → Verification
   ============================================================ */

:root {
  --avf-bg:      #0f0f0f;
  --avf-accent:  #e63946;
  --avf-text:    #f1f1f1;
  --avf-muted:   #888;
  --avf-card:    rgba(255,255,255,.06);
  --avf-border:  rgba(255,255,255,.12);
  --avf-radius:  14px;
  --avf-font:    'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Overlay ─────────────────────────────────────────────── */
#avf-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: var(--avf-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--avf-font);
  color: var(--avf-text);
  opacity: 0;
  animation: avfFadeIn .4s ease forwards;
  overflow-y: auto;
  padding: 24px 16px;
  box-sizing: border-box;
}

@keyframes avfFadeIn { to { opacity: 1; } }

/* ── Card ────────────────────────────────────────────────── */
#avf-card {
  background: var(--avf-card);
  border: 1px solid var(--avf-border);
  border-radius: var(--avf-radius);
  padding: 40px 36px 36px;
  width: min(480px, 100%);
  box-sizing: border-box;
  backdrop-filter: blur(20px);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.04) inset,
    0 32px 80px rgba(0,0,0,.6);
  animation: avfSlideUp .45s cubic-bezier(.22,.61,.36,1) forwards;
}

@keyframes avfSlideUp {
  from { transform: translateY(28px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Brand ───────────────────────────────────────────────── */
#avf-brand {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--avf-accent);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#avf-brand::before {
  content: '';
  display: inline-block;
  width: 18px; height: 2px;
  background: var(--avf-accent);
}

/* ── Headings ────────────────────────────────────────────── */
#avf-headline {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 10px;
  letter-spacing: -.01em;
}

#avf-subtext {
  color: var(--avf-muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 24px;
}

/* ── Consent box ─────────────────────────────────────────── */
#avf-consent-box {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--avf-border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 20px;
}

#avf-declaration {
  font-size: 12px;
  color: var(--avf-muted);
  line-height: 1.5;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--avf-border);
  font-style: italic;
}

#avf-tos-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

#avf-tos-check {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid var(--avf-border);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  transition: background .2s, border-color .2s;
  margin-top: 1px;
  position: relative;
}

#avf-tos-check:checked {
  background: var(--avf-accent);
  border-color: var(--avf-accent);
}

#avf-tos-check:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

#avf-tos-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--avf-text);
}

#avf-tos-text a {
  color: var(--avf-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Step 2 header ───────────────────────────────────────── */
#avf-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

#avf-step-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--avf-accent);
}

.avf-btn-link {
  background: none;
  border: none;
  color: var(--avf-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  transition: color .15s;
}
.avf-btn-link:hover { color: var(--avf-text); }

/* ── Camera ──────────────────────────────────────────────── */
#avf-camera-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--avf-border);
  margin-bottom: 20px;
}

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

#avf-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  transform: scaleX(-1);
}

#avf-scan-line {
  position: absolute; inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--avf-accent), transparent);
  animation: avfScan 2s ease-in-out infinite;
  opacity: 0; pointer-events: none;
}
@keyframes avfScan {
  0%   { top: 0%;   opacity: 1; }
  100% { top: 100%; opacity: 0; }
}
#avf-scan-line.active { opacity: 1; }

#avf-camera-wrap::before, #avf-camera-wrap::after {
  content: ''; position: absolute;
  width: 20px; height: 20px;
  border-color: var(--avf-accent); border-style: solid;
  z-index: 2; pointer-events: none;
}
#avf-camera-wrap::before { top: 10px; left: 10px;   border-width: 2px 0 0 2px; }
#avf-camera-wrap::after  { bottom: 10px; right: 10px; border-width: 0 2px 2px 0; }

/* ── Status ──────────────────────────────────────────────── */
#avf-status {
  text-align: center; font-size: 13px;
  color: var(--avf-muted); min-height: 22px;
  margin-bottom: 16px; transition: color .3s;
}
#avf-status.detecting { color: var(--avf-text); }
#avf-status.success   { color: #4ade80; }
#avf-status.error     { color: var(--avf-accent); }

/* ── Ring ────────────────────────────────────────────────── */
#avf-progress-wrap { display: flex; justify-content: center; margin-bottom: 18px; }
#avf-ring { width: 56px; height: 56px; display: none; }
#avf-ring circle { cx: 28; cy: 28; r: 22; fill: none; stroke: var(--avf-border); stroke-width: 3; }
#avf-ring .track {
  stroke: var(--avf-accent);
  stroke-dasharray: 138.2;
  stroke-dashoffset: 138.2;
  stroke-linecap: round;
  transition: stroke-dashoffset .2s linear;
}
#avf-ring.visible { display: block; }

/* ── Buttons ─────────────────────────────────────────────── */
.avf-btn {
  display: block; width: 100%;
  padding: 14px; border: none; border-radius: 8px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .15s, opacity .15s;
  letter-spacing: .01em;
}
.avf-btn:active:not(:disabled) { transform: scale(.97); }

.avf-btn--primary {
  background: var(--avf-accent);
  color: #fff; margin-bottom: 10px;
}
.avf-btn--primary:hover:not(:disabled) { opacity: .9; }
.avf-btn--primary:disabled {
  opacity: .35; cursor: not-allowed;
}

.avf-btn--ghost {
  background: transparent;
  color: var(--avf-muted);
  border: 1px solid var(--avf-border);
  font-size: 13px; margin-bottom: 10px;
}
.avf-btn--ghost:hover { color: var(--avf-text); border-color: rgba(255,255,255,.25); }

/* ── Manual form ─────────────────────────────────────────── */
#avf-manual-form {
  display: none;
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--avf-border);
}
#avf-manual-form h3 { font-size: 14px; font-weight: 600; margin: 0 0 12px; }
#avf-dob-input {
  width: 100%; box-sizing: border-box;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--avf-border);
  border-radius: 8px; color: var(--avf-text);
  font-size: 15px; padding: 12px 14px; margin-bottom: 10px;
}
#avf-dob-input:focus { outline: none; border-color: var(--avf-accent); }

/* ── Blocked ─────────────────────────────────────────────── */
#avf-blocked { text-align: center; padding: 12px 0; }
#avf-blocked .avf-icon { font-size: 48px; margin-bottom: 16px; }
#avf-blocked h2 { font-size: 22px; font-weight: 700; margin: 0 0 10px; }
#avf-blocked p  { color: var(--avf-muted); font-size: 14px; line-height: 1.6; margin: 0 0 20px; }

/* ── Loader ──────────────────────────────────────────────── */
#avf-loader { text-align: center; padding: 24px 0; }
.avf-spinner {
  display: inline-block; width: 36px; height: 36px;
  border: 3px solid var(--avf-border); border-top-color: var(--avf-accent);
  border-radius: 50%; animation: avfSpin .8s linear infinite; margin-bottom: 12px;
}
@keyframes avfSpin { to { transform: rotate(360deg); } }
#avf-loader p { color: var(--avf-muted); font-size: 13px; margin: 0; }

/* ── Footer ──────────────────────────────────────────────── */
#avf-footer {
  margin-top: 24px; text-align: center;
  font-size: 11px; color: rgba(255,255,255,.22); line-height: 1.5;
}

/* ── Success flash ───────────────────────────────────────── */
#avf-overlay.avf-success-flash {
  animation: avfFlash .5s ease forwards;
}
@keyframes avfFlash {
  0%   { background: var(--avf-bg); }
  40%  { background: #052e16; }
  100% { background: var(--avf-bg); opacity: 0; }
}

/* ── Mobile-specific overrides ───────────────────────────── */
@media (max-width: 520px) {
  #avf-overlay {
    align-items: flex-start;
    padding: 16px 12px 32px;
  }

  #avf-card {
    padding: 28px 20px 24px;
    border-radius: 10px;
    /* Ensure the card never exceeds viewport height and is scrollable */
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #avf-headline { font-size: 21px; }

  /* Camera wrap: use a fixed height on short screens to prevent overflow */
  #avf-camera-wrap {
    aspect-ratio: unset;
    height: min(52vw, 220px);
  }

  .avf-btn {
    padding: 15px; /* slightly taller for thumb tap targets */
    font-size: 16px; /* prevent iOS zoom on tap */
  }

  #avf-dob-input {
    font-size: 16px; /* prevent iOS zoom on focus */
  }

  #avf-consent-box { padding: 14px; }

  #avf-tos-check { width: 24px; height: 24px; flex-shrink: 0; }
}

/* Landscape mobile: shrink camera to give room for buttons */
@media (max-height: 500px) and (orientation: landscape) {
  #avf-overlay { align-items: flex-start; padding: 8px; }
  #avf-card { padding: 16px; max-height: calc(100dvh - 16px); overflow-y: auto; }
  #avf-camera-wrap { height: 150px; aspect-ratio: unset; }
  #avf-headline { font-size: 18px; margin-bottom: 6px; }
  #avf-subtext  { margin-bottom: 12px; }
}

/* ── Language picker ─────────────────────────────────────── */
#avf-lang-picker {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-bottom: 20px;
}

#avf-lang-icon {
  font-size: 15px;
  margin-right: 4px;
  opacity: .7;
  user-select: none;
}

.avf-lang-btn {
  background: transparent;
  border: 1px solid var(--avf-border);
  color: var(--avf-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  padding: 4px 9px;
  border-radius: 20px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  line-height: 1;
}

.avf-lang-btn:hover {
  color: var(--avf-text);
  border-color: rgba(255,255,255,.3);
}

.avf-lang-btn.active {
  background: var(--avf-accent);
  border-color: var(--avf-accent);
  color: #fff;
}

/* Keep picker visible in Step 2 */
#avf-step-verify #avf-lang-picker { display: none; }
