/**
 * Minifig AR scanner — full-viewport camera with absolute-positioned
 * thumbnail overlays pinned to detected DataMatrix codes.
 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: #000; color: #fff;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.mfx-body { touch-action: none; }

.mfx-stage {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; height: 100dvh;
  overflow: hidden;
}
.mfx-stage video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
}
.mfx-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 5;
}

/* Per-code AR thumb — JS positions and sizes via inline style. */
.mfx-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
  pointer-events: none;
  transition: opacity 200ms ease, transform 80ms ease-out;
  will-change: left, top, width, height, opacity;
}
.mfx-pin.is-fading { opacity: 0; }
.mfx-pin .mfx-pin-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: rgba(0,0,0,0.55);
  border: 3px solid #ffcc02;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  object-fit: cover;
  background-size: cover; background-position: center;
}
.mfx-pin .mfx-pin-img.is-loading {
  border-color: rgba(255,204,2,0.4);
  border-style: dashed;
}
.mfx-pin .mfx-pin-img.is-missing {
  border-color: #d92027;
}
.mfx-pin .mfx-pin-label {
  background: rgba(0,0,0,0.78);
  color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
  white-space: nowrap; max-width: 180px;
  overflow: hidden; text-overflow: ellipsis;
}
.mfx-pin .mfx-pin-spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(255,204,2,0.3);
  border-top-color: #ffcc02;
  border-radius: 50%;
  animation: mfx-spin 800ms linear infinite;
}
@keyframes mfx-spin {
  to { transform: rotate(360deg); }
}

/* Topbar — translucent floating */
.mfx-topbar {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.65), rgba(0,0,0,0));
  z-index: 10;
}
.mfx-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff;
  text-decoration: none; font-size: 22px; line-height: 1;
}
.mfx-back:hover { background: rgba(0,0,0,0.85); }
.mfx-title { flex: 1; min-width: 0; }
.mfx-title strong {
  display: block; font-size: 16px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.mfx-counts {
  display: block; font-size: 12px; color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Tray — small thumbnail stack of recently identified figures */
.mfx-tray {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,0.7), rgba(0,0,0,0));
  z-index: 10;
}
.mfx-recent {
  list-style: none; display: flex; gap: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.mfx-recent li {
  flex-shrink: 0;
  width: 88px;
  background: rgba(0,0,0,0.55);
  border-radius: 6px; padding: 6px;
  text-align: center;
}
.mfx-recent li > a {
  display: block; color: inherit; text-decoration: none;
}
.mfx-recent li img {
  width: 100%; aspect-ratio: 1/1; object-fit: cover;
  border-radius: 4px; background: rgba(255,255,255,0.04);
}
.mfx-recent li:hover { background: rgba(0,0,0,0.75); }
.mfx-recent li .mfx-recent-name {
  margin-top: 4px; font-size: 11px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mfx-recent li .mfx-recent-set {
  font-size: 10px; color: rgba(255,255,255,0.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.mfx-toast {
  position: absolute; left: 50%; bottom: 30%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8); color: #fff;
  padding: 12px 18px; border-radius: 8px;
  font-size: 14px; max-width: 80vw; text-align: center;
  z-index: 20;
}
