/* Scanner "Rozpoznat kartu" as glass over a full-screen camera (pack.js scanner(), non-live).
   The camera fills the whole screen; the top bar, the status, the candidates, the manual search
   and the shutter float over it as frosted glass, so there is more room for the picture and the
   screen looks calmer. Scoped to .scan-glass: Live view and the Grading tab keep app.css. */

.scan-glass {
  --sg-bg: rgba(18, 10, 36, 0.42);
  --sg-bg-strong: rgba(18, 10, 36, 0.62);
  --sg-line: rgba(255, 255, 255, 0.18);
  --sg-blur: blur(18px) saturate(1.5);
  display: block;
  height: calc(100dvh - 2 * var(--s-3));
  min-height: 520px;
  padding: 0;
}
.page[data-view='scanner']:has(.scan-glass) {
  padding-bottom: 0;
}
@media (max-width: 767px) {
  .page[data-view='scanner'] .scan-glass {
    height: 100dvh;
    min-height: 0;
    margin-top: calc(var(--s-3) * -1);
    border-radius: 0;
  }
  .app:has(.scan-glass) main#main {
    padding-bottom: 0;
  }
}

/* The camera is the background of the whole screen. */
.scan-glass .scan-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  height: auto;
  max-height: none;
  aspect-ratio: auto;
}
.scan-glass .scan-stage .camera-guide {
  top: 40%;
  width: min(58%, 300px, 42dvh);
}
.scan-glass .scan-stage .camera-message {
  inset: 40% 24px auto;
}
.scan-glass .cam-switch {
  top: calc(env(safe-area-inset-top, 0px) + 62px);
}
.scan-glass .cam-torch {
  top: calc(env(safe-area-inset-top, 0px) + 114px);
}

/* One glass material for every overlay. */
.scan-glass .scan-modes,
.scan-glass .scan-close,
.scan-glass .cam-switch,
.scan-glass .cam-torch,
.scan-glass .scan-status,
.scan-glass .sg-sheet,
.scan-glass .sg-search .searchbox,
.scan-glass .sg-narrow summary,
.scan-glass .sg-narrow-body,
.scan-glass .scan-upload {
  border: 1px solid var(--sg-line);
  background: var(--sg-bg);
  color: #fff;
  backdrop-filter: var(--sg-blur);
  -webkit-backdrop-filter: var(--sg-blur);
  box-shadow: 0 10px 30px -14px rgba(0, 0, 0, 0.55);
}
.scan-glass .scan-top {
  padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
  background: none;
}

/* Bottom dock: status, candidates, search and shutter stacked over the camera. */
.sg-dock {
  position: absolute;
  inset: auto 0 0;
  z-index: 4;
  display: grid;
  gap: 10px;
  max-height: 82%;
  padding: 28px 12px calc(env(safe-area-inset-bottom, 0px) + 14px);
  background: linear-gradient(transparent, rgba(8, 4, 20, 0.42) 40%);
}
@media (min-width: 768px) {
  .sg-dock {
    left: 50%;
    right: auto;
    width: min(560px, 100%);
    transform: translateX(-50%);
    background: none;
  }
}
.scan-glass .scan-status {
  justify-self: center;
  max-width: 100%;
  margin: 0;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  text-align: center;
}
.scan-glass .scan-status:empty {
  display: none;
}

/* Candidates and search results: a glass sheet that scrolls on its own. */
.scan-glass .sg-sheet {
  min-height: 0;
  max-height: 44dvh;
  margin: 0;
  padding: 12px;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: 20px;
  animation: sg-up var(--dur-2, 0.25s) var(--ease, ease-out);
}
.scan-glass .sg-sheet:empty {
  display: none;
}
@keyframes sg-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .scan-glass .sg-sheet {
    animation: none;
  }
}
.scan-glass .sg-sheet .scan-pick {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.scan-glass .sg-sheet .scan-pick:not(:has(> .scan-photo)) {
  grid-template-columns: minmax(0, 1fr);
}
.scan-glass .sg-sheet .scan-photo {
  margin: 0;
}
.scan-glass .sg-sheet .quote-print {
  margin-top: 0 !important;
  color: rgba(255, 255, 255, 0.85);
}
.scan-glass .sg-sheet .list,
.scan-glass .sg-sheet .row {
  border-color: rgba(255, 255, 255, 0.12);
  background: transparent;
  color: #fff;
}
.scan-glass .sg-sheet .row:hover {
  background: rgba(255, 255, 255, 0.08);
}
.scan-glass .sg-sheet .row-sub,
.scan-glass .sg-sheet .fineprint,
.scan-glass .sg-sheet .muted,
.scan-glass .sg-sheet .empty p {
  color: rgba(255, 255, 255, 0.72);
}
.scan-glass .sg-sheet .empty {
  padding: 8px 0;
  background: none;
  color: #fff;
}

/* Manual search: one glass field over the viewfinder, the filter behind an icon. */
.sg-search {
  display: grid;
  gap: 6px;
  margin: 0;
}
.sg-searchrow {
  display: flex;
  gap: 8px;
  align-items: center;
}
.scan-glass .sg-search .searchbox {
  flex: 1;
  min-width: 0;
  border-radius: var(--r-pill);
}
.scan-glass .sg-search .searchbox .i {
  color: rgba(255, 255, 255, 0.8);
}
.scan-glass .sg-search .input {
  border: 0;
  background: transparent;
  color: #fff;
  box-shadow: none;
}
.scan-glass .sg-search .input::placeholder {
  color: rgba(255, 255, 255, 0.68);
}
.scan-glass .sg-search .searchbox:focus-within {
  border-color: rgba(255, 255, 255, 0.5);
  background: var(--sg-bg-strong);
}
.sg-narrow {
  position: relative;
  flex: none;
}
.scan-glass .sg-narrow summary {
  display: grid;
  place-items: center;
  width: var(--h-md);
  height: var(--h-md);
  border-radius: 50%;
  list-style: none;
  cursor: pointer;
}
.sg-narrow summary::-webkit-details-marker {
  display: none;
}
.scan-glass .sg-narrow[open] summary {
  background: #fff;
  color: #1a1030;
}
.scan-glass .sg-narrow-body {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 2;
  display: grid;
  gap: 8px;
  width: min(300px, calc(100vw - 24px));
  padding: 10px;
  border-radius: 16px;
  background: var(--sg-bg-strong);
}
.scan-glass .sg-narrow-body .select {
  width: 100%;
}
.scan-glass .scan-read {
  margin: 0 8px;
  color: rgba(255, 255, 255, 0.78);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

/* Shutter row. */
.scan-glass .scan-controls {
  padding: 0 4px;
}
.scan-glass .scan-shutter {
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.7);
}
