/* ===== Дизайн-токены =====
   Тема: официальная регистрационная форма для системы контроля доступа (Perco).
   Палитра отсылает к документам/пропускам: холодная бумага, чернильный тёмно-синий,
   тёплое золото как цвет "печати/штампа" на статусах.
*/
:root {
  --ink: #16233d;
  --ink-soft: #3c4a63;
  --paper: #eef1f5;
  --paper-raised: #ffffff;
  --line: #d7dae0;
  --gold: #b8863b;
  --gold-soft: #f1e4cc;
  --green: #2f6f4e;
  --green-soft: #e3efe8;
  --red: #a23b3b;
  --red-soft: #f5e6e4;

  --font-display: 'Fraunces', Georgia, serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-s: 4px;
  --radius-m: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

.masthead {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 20px;
  margin-bottom: 36px;
}

.masthead .org {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}

.masthead .subtitle {
  color: var(--ink-soft);
  font-size: 15px;
  margin: 0;
}

.progress {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
}

.progress .seg {
  flex: 1;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  transition: background 0.25s ease;
}

.progress .seg.done { background: var(--gold); }
.progress .seg.current { background: var(--ink); }

.panel {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 32px;
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
}

.panel p.hint {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 24px;
}

.field { margin-bottom: 20px; }

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="tel"],
.field select {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font-ui);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--paper-raised);
  color: var(--ink);
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
  border-color: var(--ink);
}

.field .error-msg {
  color: var(--red);
  font-size: 13px;
  margin-top: 6px;
  display: none;
}

.field.invalid input,
.field.invalid select { border-color: var(--red); }
.field.invalid .error-msg { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #223151; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }

.btn-block { width: 100%; }

.btn-row { display: flex; gap: 12px; margin-top: 28px; }

/* ---- Блок фото ---- */
.photo-guide {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--gold-soft);
  border-radius: var(--radius-s);
}

.photo-guide img {
  width: 84px;
  height: 108px;
  object-fit: cover;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.photo-guide .txt { font-size: 14px; color: var(--ink); }
.photo-guide .txt strong { display: block; margin-bottom: 4px; }

.capture-area {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-width: 320px;
  margin: 0 auto 16px;
  background: #0d1524;
  border-radius: var(--radius-m);
  overflow: hidden;
}

.capture-area video,
.capture-area canvas,
.capture-area img.preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.capture-area .frame-guide {
  position: absolute;
  inset: 8%;
  border: 2px dashed rgba(255, 255, 255, 0.45);
  border-radius: 50% 50% 40% 40% / 55% 55% 45% 45%;
  pointer-events: none;
}

.face-status {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  min-height: 20px;
}

.face-status.ok { color: var(--green); }
.face-status.bad { color: var(--red); }
.face-status.wait { color: var(--ink-soft); }

.capture-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

input[type="file"].file-input { display: none; }

/* ---- Результат ---- */
.result {
  text-align: center;
  padding: 20px 0;
}

.result .sticker {
  max-width: 220px;
  margin: 0 auto 20px;
  display: block;
}

/* ---- Анимация успеха: галочка + конфетти (свои, без внешних файлов) ---- */
.success-anim {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 20px;
}

.success-anim .circle {
  stroke: var(--green);
  stroke-width: 4;
  fill: none;
  stroke-dasharray: 214;
  stroke-dashoffset: 214;
  animation: draw-circle 0.5s ease-out forwards;
}

.success-anim .check {
  stroke: var(--green);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: draw-check 0.35s ease-out 0.45s forwards;
}

@keyframes draw-circle {
  to { stroke-dashoffset: 0; }
}
@keyframes draw-check {
  to { stroke-dashoffset: 0; }
}

.confetti-piece {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  opacity: 0;
  animation: confetti-burst 0.9s ease-out 0.5s forwards;
}

@keyframes confetti-burst {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) translateY(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--rot)) translateY(-70px); }
}

@media (prefers-reduced-motion: reduce) {
  .success-anim .circle, .success-anim .check, .confetti-piece { animation: none !important; stroke-dashoffset: 0 !important; opacity: 1 !important; }
}

.result h2 { font-family: var(--font-display); font-size: 24px; margin-bottom: 8px; }
.result.success h2 { color: var(--green); }
.result.fail h2 { color: var(--red); }
.result p { color: var(--ink-soft); font-size: 15px; }

.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footnote {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  margin-top: 28px;
}
