/* Guided face enrollment (face_register.php, admin/face_register.php).
   Loaded after atlas-login.css (and atlas-admin-login.css on the admin page), so it only uses the
   theme tokens (--atl-*) and works on both the light sky theme and the dark admin theme. */

.atl-enroll [hidden] { display: none !important; }

/* ---------- verify stage ---------- */
.atl-enroll .en-verify-note { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--atl-ink-2); }
.atl-enroll .en-who {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px;
  background: var(--atl-ok-bg); color: var(--atl-ok); font-size: 14px;
}
.atl-enroll .en-who b { font-weight: 500; }

/* ---------- camera with oval guide ----------
   Fixed 4:5 frame (never taller than about half the screen). The camera image is cropped to fill it,
   so portrait (iPad upright) and landscape cameras look the same and the oval always fits the face. */
.atl-enroll .cam-wrap { position: relative; }
.atl-enroll .cam-wrap.en-cam {
  width: min(100%, calc(min(54vh, 520px) * 0.8));
  aspect-ratio: 4 / 5;
  margin-inline: auto;
}
.atl-enroll .cam-wrap.en-cam #video { width: 100%; height: 100%; object-fit: cover; }
.atl-enroll .en-guide { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.atl-enroll .en-guide .en-shade { fill: rgba(8, 16, 32, .5); }
.atl-enroll .en-guide .en-oval { fill: none; stroke: rgba(255, 255, 255, .55); stroke-width: 1.2; stroke-dasharray: 3 3; }
.atl-enroll .en-guide .en-ring {
  fill: none; stroke: #5aa2f5; stroke-width: 2.6; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .12s linear, stroke .2s;
  filter: drop-shadow(0 0 3px rgba(90, 162, 245, .8));
}
.atl-enroll .en-guide[data-state="ready"] .en-oval { stroke: rgba(255, 255, 255, .9); stroke-dasharray: none; }
.atl-enroll .en-guide[data-state="hold"] .en-ring { stroke: #7cc4ff; }
.atl-enroll .en-guide[data-state="capture"] .en-ring,
.atl-enroll .en-guide[data-state="done"] .en-ring { stroke: #34d399; filter: drop-shadow(0 0 4px rgba(52, 211, 153, .9)); }

.atl-enroll .en-tip {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 3;
  max-width: 88%; padding: 8px 16px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(8, 16, 32, .72); color: #fff; font-size: 14.5px; font-weight: 400;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .7);
}
.atl-enroll .en-num {
  position: absolute; left: 12px; top: 12px; z-index: 3; padding: 4px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, .85); color: #0f1c33; font-family: var(--atl-mono); font-size: 12px;
}

/* how far the head has turned/tilted toward the pose: fills up, turns green when enough */
.atl-enroll .en-meter {
  position: absolute; z-index: 3; left: 50%; top: 12px; transform: translateX(-50%);
  width: 46%; height: 10px; border-radius: 999px; overflow: hidden;
  background: rgba(8, 16, 32, .55); border: 1px solid rgba(255, 255, 255, .55);
}
.atl-enroll .en-meter i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #7cc4ff, #5aa2f5); transition: width .15s linear; }
.atl-enroll .en-meter.full i { background: linear-gradient(90deg, #4ade80, #22c55e); }

/* direction arrow that nudges toward the pose (screen direction = mirror of the person) */
.atl-enroll .en-arrow {
  position: absolute; z-index: 3; width: 46px; height: 46px; border-radius: 50%; display: none;
  place-items: center; background: rgba(90, 162, 245, .92); color: #fff; box-shadow: 0 10px 24px -10px rgba(15, 28, 51, .8);
}
.atl-enroll .en-arrow::before { content: ""; width: 14px; height: 14px; border: solid #fff; border-width: 0 3px 3px 0; }
.atl-enroll .en-arrow.is-left { display: grid; left: 10%; top: 50%; margin-top: -23px; animation: en-nudge-x 1.1s ease-in-out infinite; --d: -1; }
.atl-enroll .en-arrow.is-left::before { transform: translateX(3px) rotate(135deg); }
.atl-enroll .en-arrow.is-right { display: grid; right: 10%; top: 50%; margin-top: -23px; animation: en-nudge-x 1.1s ease-in-out infinite; --d: 1; }
.atl-enroll .en-arrow.is-right::before { transform: translateX(-3px) rotate(-45deg); }
.atl-enroll .en-arrow.is-up { display: grid; left: 50%; top: 9%; margin-left: -23px; animation: en-nudge-y 1.1s ease-in-out infinite; --d: -1; }
.atl-enroll .en-arrow.is-up::before { transform: translateY(3px) rotate(-135deg); }
.atl-enroll .en-arrow.is-down { display: grid; left: 50%; bottom: 58px; margin-left: -23px; animation: en-nudge-y 1.1s ease-in-out infinite; --d: 1; }
.atl-enroll .en-arrow.is-down::before { transform: translateY(-3px) rotate(45deg); }
@keyframes en-nudge-x { 50% { transform: translateX(calc(var(--d) * 8px)); } }
@keyframes en-nudge-y { 50% { transform: translateY(calc(var(--d) * 8px)); } }

/* ---------- pose header + chips ---------- */
.atl-enroll .en-pose { display: flex; flex-direction: column; gap: 2px; text-align: center; }
.atl-enroll .en-pose-title { margin: 0; font-family: var(--atl-thai); font-size: 22px; font-weight: 500; color: var(--atl-ink); }
.atl-enroll .en-pose-hint { margin: 0; font-size: 13.5px; color: var(--atl-ink-2); }

.atl-enroll .en-chips { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.atl-enroll .en-chips li {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 4px; border-radius: 14px;
  font-size: 12px; color: var(--atl-ink-3); background: rgba(255, 255, 255, .22); border: 1px solid rgba(255, 255, 255, .45);
  transition: background .2s, color .2s;
}
.atl-enroll .en-chips li.now { color: var(--atl-ink); background: rgba(255, 255, 255, .6); border-color: var(--atl-accent); box-shadow: 0 0 0 3px rgba(90, 162, 245, .22); }
.atl-enroll .en-chips li.done { color: var(--atl-ok); background: var(--atl-ok-bg); border-color: transparent; }
.atl-enroll .en-chips li.skip { opacity: .5; text-decoration: line-through; }
.atl-enroll .en-skip { color: var(--atl-accent); font-weight: 400; }
.atl-enroll .en-chip-ic {
  position: relative; width: 26px; height: 26px; border-radius: 50%; border: 1.6px solid currentColor;
}
/* a nose dot that shows which way to look */
.atl-enroll .en-chip-ic::after { content: ""; position: absolute; width: 6px; height: 6px; border-radius: 50%; background: currentColor; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.atl-enroll .en-chip-ic[data-dir="left"]::after { transform: translate(-170%, -50%); }
.atl-enroll .en-chip-ic[data-dir="right"]::after { transform: translate(70%, -50%); }
.atl-enroll .en-chip-ic[data-dir="up"]::after { transform: translate(-50%, -170%); }
.atl-enroll .en-chip-ic[data-dir="down"]::after { transform: translate(-50%, 70%); }
.atl-enroll .en-chips li.done .en-chip-ic { background: var(--atl-ok); border-color: var(--atl-ok); }
.atl-enroll .en-chips li.done .en-chip-ic::after {
  width: 10px; height: 6px; border-radius: 0; background: none; border: solid #fff; border-width: 0 0 2px 2px;
  transform: translate(-50%, -65%) rotate(-45deg);
}

/* ---------- quality checklist ---------- */
.atl-enroll .en-checks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.atl-enroll .en-checks li {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 6px; border-radius: 12px;
  font-size: 12.5px; color: var(--atl-ink-3); background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .35);
  transition: color .2s, background .2s;
}
.atl-enroll .en-checks li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .2); }
.atl-enroll .en-checks li.ok { color: var(--atl-ok); background: var(--atl-ok-bg); border-color: transparent; }
.atl-enroll .en-checks li.ok::before { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .25); }

/* captured thumbnails */
.atl-enroll .en-strip { display: flex; gap: 6px; min-height: 0; }
.atl-enroll .en-strip:empty { display: none; }
.atl-enroll .en-strip img { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; border: 2px solid #fff; box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .6); animation: en-pop .3s ease; }
@keyframes en-pop { from { transform: scale(.6); opacity: 0; } }

.atl-enroll .en-link { background: none; border: 0; padding: 4px; cursor: pointer; font-family: var(--atl-thai); font-size: 13.5px; color: var(--atl-ink-2); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- review ---------- */
.atl-enroll .en-review { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.atl-enroll .en-review figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.atl-enroll .en-review img { width: 100%; aspect-ratio: 1; border-radius: 16px; object-fit: cover; border: 2px solid #fff; box-shadow: 0 10px 20px -12px rgba(0, 0, 0, .6); }
.atl-enroll .en-review figcaption { font-size: 12px; color: var(--atl-ink-2); text-align: center; }
.atl-enroll .en-actions { display: flex; flex-direction: column; gap: 8px; }
.atl-enroll .en-safe { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--atl-ink-3); text-align: center; }
body.en-reviewing.atl-enroll .cam-wrap { display: none; }

.atl-enroll .btn-main-lg { width: 100%; }

/* tablets / phones: keep the camera on screen — smaller header, no step list */
@media (max-width: 1100px) {
  .atl-enroll .atl-hero { min-height: 0; }
  .atl-enroll .atl-lede, .atl-enroll .atl-steps { display: none; }
  .atl-enroll .atl-h1 { font-size: clamp(40px, 7vw, 64px); }
  .atl-enroll .atl-sub { font-size: clamp(22px, 3.4vw, 32px); }
}
@media (max-width: 880px) {
  .atl-enroll .atl-hero { min-height: 170px; }
  .atl-enroll .atl-robot { width: 38%; max-width: 230px; right: 0; bottom: -24px; }
  .atl-enroll .atl-panel { padding: 18px; gap: 12px; }
  .atl-enroll .cam-wrap.en-cam { width: min(100%, calc(min(50vh, 480px) * 0.8)); }
}

@media (max-width: 560px) {
  .atl-enroll .en-chips { gap: 4px; }
  .atl-enroll .en-chips li { font-size: 11px; padding: 7px 2px; }
  .atl-enroll .en-checks { grid-template-columns: repeat(2, 1fr); }
  .atl-enroll .en-review { grid-template-columns: repeat(3, 1fr); }
  .atl-enroll .en-pose-title { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .atl-enroll .en-arrow { animation: none !important; }
}

/* ---------- "preparing" card: what is loading + countdown (built by atlas-face-enroll.js) ---------- */
.atl-enroll .en-prep {
  margin: 0 0 14px; padding: 14px 16px; border-radius: 18px;
  background: rgba(255, 255, 255, .42); border: 1px solid rgba(255, 255, 255, .6);
  transition: opacity .4s, transform .4s;
}
.atl-enroll .en-prep.is-gone { opacity: 0; transform: translateY(-6px); }
.atl-enroll .en-prep-head { display: flex; align-items: center; gap: 12px; }
.atl-enroll .en-prep-spin {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(90, 162, 245, .25); border-top-color: var(--atl-accent);
  animation: en-prep-spin .8s linear infinite;
}
@keyframes en-prep-spin { to { transform: rotate(360deg); } }
.atl-enroll .en-prep-ttl { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.atl-enroll .en-prep-ttl b { font-family: var(--atl-thai); font-weight: 500; font-size: 15px; color: var(--atl-ink); }
.atl-enroll .en-prep-ttl small { font-size: 12.5px; line-height: 1.45; color: var(--atl-ink-2); }
.atl-enroll .en-prep-cd { flex: none; display: flex; flex-direction: column; align-items: center; line-height: 1; color: var(--atl-ink-2); font-size: 11.5px; }
.atl-enroll .en-prep-cd b {
  margin: 2px 0; min-width: 52px; padding: 6px 8px; border-radius: 12px; text-align: center;
  background: var(--atl-accent); color: #fff; font-family: var(--atl-mono); font-size: 24px; font-weight: 400;
}
.atl-enroll .en-prep-bar { margin: 12px 0 10px; height: 6px; border-radius: 6px; background: rgba(90, 162, 245, .18); overflow: hidden; }
.atl-enroll .en-prep-bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--atl-accent); transition: width .25s linear; }
.atl-enroll .en-prep-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.atl-enroll .en-prep-list li { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--atl-ink-3); }
.atl-enroll .en-prep-dot { flex: none; position: relative; width: 16px; height: 16px; border-radius: 50%; border: 1.6px solid currentColor; opacity: .7; }
.atl-enroll .en-prep-lb { flex: 1; min-width: 0; }
.atl-enroll .en-prep-ms { flex: none; font-family: var(--atl-mono); font-size: 11.5px; }
.atl-enroll .en-prep-list li.now { color: var(--atl-ink); font-weight: 500; }
.atl-enroll .en-prep-list li.now .en-prep-dot { opacity: 1; border-color: var(--atl-accent); border-top-color: transparent; animation: en-prep-spin .8s linear infinite; }
.atl-enroll .en-prep-list li.done { color: var(--atl-ok); }
.atl-enroll .en-prep-list li.done .en-prep-dot { opacity: 1; background: var(--atl-ok); border-color: var(--atl-ok); }
.atl-enroll .en-prep-list li.done .en-prep-dot::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 7px; height: 4px;
  border: solid #fff; border-width: 0 0 1.6px 1.6px; transform: translate(-50%, -65%) rotate(-45deg);
}
.atl-enroll .en-prep.is-ready { background: var(--atl-ok-bg); border-color: transparent; }
.atl-enroll .en-prep.is-ready .en-prep-spin { animation: none; border-color: var(--atl-ok); background: var(--atl-ok); }
.atl-enroll .en-prep.is-fail .en-prep-spin { animation: none; border-color: #ef4444; }
.atl-enroll .en-prep.is-ready .en-prep-list,
.atl-enroll .en-prep.is-ready .en-prep-bar { display: none; }
/* dark admin theme */
.atl-admin.atl-enroll .en-prep { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); }
.atl-admin.atl-enroll .en-prep-list li.done { color: #4ade80; }
.atl-admin.atl-enroll .en-prep-list li.done .en-prep-dot { background: #22c55e; border-color: #22c55e; }
.atl-admin.atl-enroll .en-prep-cd b { background: linear-gradient(135deg, #c9a24a, #f3d98b); color: #1a1407; }
.atl-admin.atl-enroll .en-prep-bar i { background: linear-gradient(90deg, #c9a24a, #f3d98b); }
.atl-admin.atl-enroll .en-prep-bar { background: rgba(243, 217, 139, .15); }
.atl-admin.atl-enroll .en-prep-spin, .atl-admin.atl-enroll .en-prep-list li.now .en-prep-dot { border-color: rgba(243, 217, 139, .25); border-top-color: #f3d98b; }
.atl-admin.atl-enroll .en-prep-list li.now .en-prep-dot { border-color: #f3d98b; border-top-color: transparent; }
.atl-admin.atl-enroll .en-prep.is-ready { background: rgba(34, 197, 94, .14); }
.atl-admin.atl-enroll .en-prep.is-ready .en-prep-ttl small { color: #86efac; }
.atl-enroll .en-prep.is-ready .en-prep-spin { position: relative; }
.atl-enroll .en-prep.is-ready .en-prep-spin::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 5px;
  border: solid #fff; border-width: 0 0 2px 2px; transform: translate(-50%, -70%) rotate(-45deg);
}
.atl-admin.atl-enroll .en-prep.is-ready .en-prep-spin { background: #22c55e; border-color: #22c55e; }
