/* ══════════════════════════════════════════════════
   SCANNING WITH THE LIVE CAMERA (js/22-docscan.js)
   ══════════════════════════════════════════════════ */

/* "Scan with the camera" above the two photo buttons in the scan modal */
.scan-live { grid-column: 1 / -1; }
.scan-adds .scan-live svg { width: 21px; height: 21px; }

/* turn a page, in the page's caption */
.scan-mini.turn { font-size: 17px; }

/* the camera screen, over everything */
.ds {
  position: fixed; inset: 0; z-index: 400; background: #0d0c0a; color: #fff;
  display: none; flex-direction: column;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.ds.open { display: flex; }
html.ds-open, html.ds-open body { overflow: hidden; }

.ds-stage { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.ds-stage video, .ds-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.ds-stage video { object-fit: contain; background: #0d0c0a; }
.ds-stage canvas { pointer-events: none; }
.ds-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.ds-flash.go { animation: ds-flash .35s ease-out; }
@keyframes ds-flash { 0% { opacity: .85; } 100% { opacity: 0; } }

.ds-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  display: flex; align-items: flex-start; gap: 12px;
  padding: max(12px, var(--sat, 0px)) max(16px, var(--sar, 0px)) 22px max(16px, var(--sal, 0px));
  background: linear-gradient(rgba(13,12,10,.82), rgba(13,12,10,0));
}
.ds-head { flex: 1 1 auto; min-width: 0; }
.ds-title { font-family: var(--font-display); font-size: 19px; line-height: 1.25; }
.ds-hint { font-size: 14px; line-height: 1.4; color: rgba(255,255,255,.82); margin-top: 3px; min-height: 2.8em; }
.ds-auto {
  flex: none; height: 38px; padding: 0 14px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 500;
  color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); cursor: pointer;
}
.ds-auto.on { background: #C9A24A; border-color: #C9A24A; color: #16150F; }

.ds-bottom {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 16px max(20px, var(--sar, 0px)) max(18px, var(--sab, 0px)) max(20px, var(--sal, 0px));
  background: #0d0c0a;
}
.ds-thumb {
  justify-self: start; position: relative; width: 56px; height: 72px; padding: 0; border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,.35); background: rgba(255,255,255,.06); cursor: pointer; overflow: visible;
}
.ds-thumb img { display: none; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.ds-thumb.has img { display: block; }
.ds-thumb span {
  position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: #C9A24A; color: #16150F; font-size: 12px; font-weight: 700; line-height: 22px; text-align: center;
}
.ds-thumb:not(.has) span { display: none; }

.ds-shutter {
  position: relative; width: 84px; height: 84px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; cursor: pointer;
}
.ds-shutter svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ds-ring-bg { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 4; }
.ds-ring { fill: none; stroke: #C9A24A; stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset .09s linear; }
.ds-shutter span {
  position: absolute; inset: 11px; border-radius: 50%; background: #fff; transition: transform .12s, background .2s;
}
.ds-shutter.found span { background: #F3E6C4; }
.ds-shutter:active span { transform: scale(.92); }

.ds-done {
  justify-self: end; height: 46px; padding: 0 20px; border-radius: 999px; font: inherit; font-size: 15px; font-weight: 600;
  background: #fff; color: #16150F; border: 0; cursor: pointer;
}

/* an iPad or phone on its side: the buttons go down the right-hand edge */
@media (orientation: landscape) and (max-height: 600px) {
  .ds { flex-direction: row; }
  .ds-bottom {
    grid-template-columns: none; grid-template-rows: 1fr auto 1fr; justify-items: center;
    padding: max(14px, var(--sat, 0px)) max(16px, var(--sar, 0px)) max(14px, var(--sab, 0px)) 16px;
  }
  .ds-thumb { justify-self: center; align-self: end; order: 3; }
  .ds-done { justify-self: center; align-self: start; order: 1; }
  .ds-shutter { order: 2; }
  .ds-top { right: 140px; }
}

/* a page's caption: its number on top, its buttons sharing the row under it */
.scan-page figcaption { flex-wrap: wrap; row-gap: 6px; }
.scan-page figcaption span { flex: 1 1 100%; }
.scan-page figcaption .scan-mini { flex: 1 1 0; width: auto; min-width: 0; }
