/* ===== Base layout (safe, minimal) ===== */
body {
  background: #000;
  color: #f4f4f4;
  font-family: Arial, sans-serif;
  text-align: center;
  padding: 1rem;
}

/* The scan containers (by id, so we don't rely on a generic .video-container class) */
#backContainer,
#frontContainer {
  position: relative;
  width: 100%;
  max-width: 540px;   /* tweak as you like */
  margin: 0 auto;
  /* Shared sizing variables for the ROI (used by box + blur hole) */
  --ar: 1.586;                /* credit-card ratio: 3.375 / 2.125 */
  --bw: min(88%, 560px);      /* box width relative to displayed video/container */
  --bh: calc(var(--bw) / var(--ar));
  --box-radius: 10px;
  --blur: 8px;
}

/* Videos fill the container width, keep natural aspect ratio */
#backVideo,
#frontVideo {
  width: 100%;
  height: auto;
  display: block;
  background: #000;
  border: 2px solid #222;     /* neutral border; adjust or remove */
}

/* ===== Neutralize any global .overlay rule conflicts ===== */
.overlay {
  position: absolute;
  pointer-events: none;
  box-sizing: border-box;
  /* intentionally NO top/left/width/height/aspect-ratio here */
}

/* ===== The visible red ROI boxes (exact crop regions) ===== */
#backOverlay,
#frontOverlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: var(--bw) !important;
  height: var(--bh) !important;
  /* keep explicit width/height; do NOT set aspect-ratio here */
  border: 3px solid #e53935;
  border-radius: var(--box-radius);
  box-shadow: 0 0 0 1px rgba(229,57,53,.25), inset 0 0 18px rgba(229,57,53,.2);
  z-index: 2;
}

/* ===== Optional: blur layers with a hole matching the box =====
   Add <div id="backBlurLayer"></div> or <div id="frontBlurLayer"></div>
   inside each container (sibling to the overlay box) if you want the blur. */
#backBlurLayer,
#frontBlurLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  /* Four-sided mask that leaves a centered rectangle transparent */
  mask:
    linear-gradient(#fff 0 0) top    / 100% calc((100% - var(--bh)) / 2) no-repeat,
    linear-gradient(#fff 0 0) bottom / 100% calc((100% - var(--bh)) / 2) no-repeat,
    linear-gradient(#fff 0 0) left   / calc((100% - var(--bw)) / 2) var(--bh) no-repeat,
    linear-gradient(#fff 0 0) right  / calc((100% - var(--bw)) / 2) var(--bh) no-repeat;
  -webkit-mask:
    linear-gradient(#fff 0 0) top    / 100% calc((100% - var(--bh)) / 2) no-repeat,
    linear-gradient(#fff 0 0) bottom / 100% calc((100% - var(--bh)) / 2) no-repeat,
    linear-gradient(#fff 0 0) left   / calc((100% - var(--bw)) / 2) var(--bh) no-repeat,
    linear-gradient(#fff 0 0) right  / calc((100% - var(--bw)) / 2) var(--bh) no-repeat;
}

/* Fallback when backdrop-filter isn't supported */
@supports not ((backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px))) {
  #backBlurLayer,
  #frontBlurLayer {
    background: rgba(0, 0, 0, 0.45);
  }
}

/* ===== Result / utility styles (carryovers, adjusted) ===== */
#resultContainer {
  margin-top: 1rem;
  background: #111;
  padding: 1rem;
  border: 1px solid #333;
  font-size: 0.95rem;
  text-align: left;
}

pre {
  white-space: pre-wrap;
  background: #000;
  padding: 0.5rem;
  border: 1px dashed #444;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #ddd;
}

button {
  margin-top: 1rem;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  background: #222;
  color: #eee;
  border: 1px solid #444;
  cursor: pointer;
  border-radius: 8px;
}
button:hover { background: #333; }

/* Mirror for liveness view only */
#livenessContainer video,
#livenessContainer canvas {
  transform: scaleX(-1);
}
