/* scan.css — styles for /scan (card scanning flow).
   Reuses theme tokens from style.css (var(--bg), var(--panel), …). */

.scan-main {
  padding: 1.25rem;
  max-width: 900px;
  margin: 0 auto;
}

.scan-back {
  color: var(--ink);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}
.scan-back:hover { border-color: var(--accent); }

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.stage[hidden] { display: none; }

.stage-title {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Viewfinder = dark box + <video> filling it + dashed frame overlaying.
   The video is object-fit: cover so it always fills the box regardless of
   the camera's native aspect ratio. The dashed frame is a 5:7 window inside
   the box that shows the user where to place the card. */
.viewfinder {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 3 / 4;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.viewfinder video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.viewfinder .frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70%;
  aspect-ratio: 5 / 7;
  border: 3px dashed #4c9dff;
  border-radius: 6px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
}
.capture-badge {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(53, 98, 214, 0.85);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 2;
}

/* Frozen shot displayed after the shutter fires. Absolutely positioned inside
   the viewfinder so it perfectly covers the live video during review. */
.review-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
  z-index: 1;
}
.review-image[hidden] { display: none; }

/* Retake / Use-this pair — same visual weight as the shutter row it replaces. */
.review-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
}
.review-row[hidden] { display: none; }

/* Desktop-visitor fallback shown when someone opens /scan on a non-touch
   device. Mirrors the .saved block visually so the page still feels intentional. */
.desktop-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink);
}
.desktop-notice p { margin: 0; }
.desktop-notice p:last-of-type { color: var(--ink-dim); }

.shutter-row {
  display: flex;
  justify-content: center;
}
.shutter {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shutter:disabled { opacity: 0.4; cursor: not-allowed; }
.shutter-inner {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: var(--ink);
  display: block;
  transition: transform 0.1s ease;
}
.shutter:active:not(:disabled) .shutter-inner { transform: scale(0.9); }
.shutter:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.hint {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.85rem;
  text-align: center;
}
.scan-error {
  margin: 0;
  padding: 0.6rem 0.8rem;
  background: var(--danger-tint);
  color: var(--danger-fg-strong);
  border: 1px solid var(--danger-line);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* Processing spinner. Simple CSS keyframe ring, no libraries. */
.processing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 0;
}
.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: scan-spin 0.8s linear infinite;
}
@keyframes scan-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Confirm layout: image previews on the left, form on the right. Stacks
   on narrow screens. */
.confirm-grid {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 1.5rem;
  width: 100%;
  align-items: start;
}
.previews {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.preview {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.preview img {
  width: 100%;
  aspect-ratio: 5 / 7;
  object-fit: contain;
  background: var(--panel-inset);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.preview figcaption {
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.confirm-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}
.confirm-form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.confirm-form input[type="text"] {
  font: 0.9rem/1.35 inherit;
  color: var(--ink);
  background: var(--panel-inset);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  text-transform: none;
  letter-spacing: normal;
  width: 100%;
}
.confirm-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.confirm-form .field-row {
  display: grid;
  gap: 0.75rem;
}
.confirm-form .field-row.cols-1 { grid-template-columns: 1fr; }
.confirm-form .field-row.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.confirm-form .field-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.confirm-form .flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.25rem;
}
.confirm-form .flag {
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--ink);
  text-transform: none;
  letter-spacing: normal;
}

.confirm-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.btn {
  font: inherit;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }

/* Saved stage */
.saved {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
}
.saved-check {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.saved-summary {
  color: var(--ink-dim);
  font-size: 0.9rem;
  margin: 0;
  text-align: center;
}

@media (max-width: 700px) {
  .confirm-grid { grid-template-columns: 1fr; }
  .previews { flex-direction: row; }
  .preview { flex: 1; }
  .confirm-form .field-row.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .confirm-form .field-row.cols-2,
  .confirm-form .field-row.cols-3 { grid-template-columns: 1fr; }
}
