/* Barcode scanner (web/static/scan.js). Self-contained; uses the site tokens with fallbacks. */

/* button next to the search input; overrides the generic `.search button` look */
.search .scan-btn,
.scan-btn {
  flex: none;
  align-self: center;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted, #5b6a67);
  cursor: pointer;
}
.search .scan-btn:hover,
.scan-btn:hover { color: var(--ink, var(--fg, #16201e)); background: var(--soft, #f3f7f6); }
.scan-btn svg { display: block; }

/* full-screen dialog with the camera view */
.scan-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: #000;
  color: var(--ink, var(--fg, #16201e));
  font: inherit;
}
.scan-dialog[open] { display: flex; flex-direction: column; }
.scan-dialog::backdrop { background: rgba(0, 0, 0, .6); }

.scan-view { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.scan-view video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* centred guide for the barcode; the shadow dims the rest of the picture */
.scan-guide {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(80%, 380px);
  aspect-ratio: 5 / 2;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45);
}

.scan-msg {
  margin: 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-weight: 500;
  background: var(--bg, #fff);
  color: var(--ink, var(--fg, #16201e));
}
.scan-msg.is-warn { color: var(--warn-fg, #7a4a00); background: var(--warn-bg, #fdf0dc); }

.scan-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 12px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--bg, #fff);
  color: var(--ink, var(--fg, #16201e));
  box-shadow: var(--shadow, 0 4px 16px rgba(0, 0, 0, .25));
  cursor: pointer;
}
.scan-close:hover { background: var(--soft, #f3f7f6); }

/* larger screens: a centred panel instead of the whole window */
@media (min-width: 700px) and (min-height: 560px) {
  .scan-dialog {
    inset: 0;
    width: min(560px, 92vw);
    height: min(640px, 86vh);
    margin: auto;
    border-radius: 16px;
    box-shadow: var(--shadow, 0 12px 40px rgba(0, 0, 0, .35));
  }
}
