/* ═══════════════════════════════════════════
   Document Signing — style.css
   ═══════════════════════════════════════════ */

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

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --error: #ef4444;
  --error-light: #fef2f2;
  --text: #111827;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --bg: #f8fafc;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

/* ── Pages ── */
.page {
  width: 100%;
  max-width: 480px;
  padding: 20px;
  animation: fadeUp 0.4s ease;
}

.page.hidden { display: none; }

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

/* ── Card ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.card-narrow { text-align: center; }

h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
}

.desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 28px;
}

/* ── Progress Dots ── */
.progress-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s, box-shadow 0.3s;
}

.dot.active {
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.dot.done {
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-light);
}

.dot-line {
  width: 48px;
  height: 2px;
  background: var(--border);
  margin: 0 6px;
  transition: background 0.3s;
}

.dot-line.done {
  background: var(--success);
}

/* ── Icon wraps ── */
.icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.icon-error {
  background: var(--error-light);
  color: var(--error);
}

/* ── Canvas ── */
.canvas-area {
  position: relative;
  margin-bottom: 24px;
}

canvas {
  display: block;
  width: 100%;
  height: 200px;
  background: #fafbfc;
  border: 2px dashed var(--border);
  border-radius: 12px;
  touch-action: none;
  cursor: crosshair;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}

canvas.active {
  border-color: var(--primary);
  border-style: solid;
  background: #fff;
  box-shadow: 0 0 0 4px var(--primary-light);
}

.canvas-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #c9cdd5;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  transition: opacity 0.3s;
}

.canvas-hint.hidden { opacity: 0; }

.canvas-baseline {
  position: absolute;
  bottom: 40px;
  left: 24px;
  right: 24px;
  height: 1px;
  background: #e8eaef;
  pointer-events: none;
  opacity: 0.6;
}

/* ── Buttons ── */
.btn-row {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border: none;
  border-radius: 11px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-primary {
  flex: 1;
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 13px 16px;
}

.btn-ghost:hover:not(:disabled) { background: #f3f4f6; }

.btn-ghost:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Spinner ── */
.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner.visible { display: block; }

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

/* ── Success ── */
.card-success .desc { margin-bottom: 0; }

.checkmark-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success-light);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 100;
  animation: slideUp 0.3s ease;
  max-width: calc(100% - 40px);
}

.toast.hidden { display: none; }

.toast.toast-error { background: #991b1b; }

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .card { padding: 24px 20px; }
  h1 { font-size: 19px; }
  canvas { height: 170px; }
}

@media (min-height: 800px) {
  canvas { height: 240px; }
}
