/* Standalone scan page */
#scan-page .page-header {
  margin-bottom: 1.25rem;
}

#scan-page .page-header h1 {
  font-size: 2rem;
  line-height: 1.04;
}

@media (min-width: 681px) {
  #scan-page .page-header {
    position: relative;
  }

  #scan-page .page-header::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 108px;
    height: 1px;
    background: linear-gradient(90deg, var(--gold), transparent);
  }
}

#scan-page .bv-scan-panel {
  max-width: 500px;
}

/* Shared scan panel component - used on /scan page and in the search overlay */
.bv-scan-panel {
  display: flex;
  flex-direction: column;
  gap: .9rem;
}

.bv-scan-drop {
  border: 2px dashed var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 2.25rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .65rem;
}

.bv-scan-drop:hover,
.bv-scan-drop.is-dragover {
  border-color: var(--gold);
  background: rgba(201, 168, 76, .05);
}

.bv-scan-camera-icon {
  width: 2.75rem;
  height: 2.75rem;
  color: var(--text-muted);
}

.bv-scan-drop-text {
  font-family: var(--font-display);
  font-size: .75rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.4;
}

.bv-scan-drop-text-touch {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .bv-scan-drop-text-touch {
    display: block;
  }
  .bv-scan-drop-text-mouse {
    display: none;
  }
}

.bv-scan-actions {
  display: flex;
  gap: .55rem;
}

.bv-scan-actions .btn {
  flex: 1 1 0;
  gap: .45rem;
  justify-content: center;
}

/* capture="environment" does nothing on desktop - hide the Take Photo button there */
.bv-scan-take-photo {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .bv-scan-take-photo {
    display: flex;
  }
}

.bv-scan-preview {
  display: none;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--border);
}

.bv-scan-preview canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 340px;
  object-fit: contain;
}

.bv-scan-progress {
  display: none;
  align-items: center;
  gap: .75rem;
}

.bv-scan-progress-bar-wrap {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-raised);
  overflow: hidden;
}

.bv-scan-progress-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--gold);
  width: 0%;
  transition: width .12s;
}

.bv-scan-progress-pct {
  font-family: var(--font-display);
  font-size: .7rem;
  letter-spacing: .06em;
  color: var(--gold);
  white-space: nowrap;
  min-width: 2.5rem;
  text-align: right;
}

.bv-scan-result {
  display: none;
  flex-direction: column;
  gap: .65rem;
  padding: 1rem;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}

.bv-scan-result-label {
  font-family: var(--font-display);
  font-size: .6rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.bv-scan-result-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--gold);
  letter-spacing: .03em;
  line-height: 1.2;
  word-break: break-word;
}

.bv-scan-result-actions {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
}

.bv-scan-result-actions .btn {
  flex: 1 1 auto;
  justify-content: center;
  text-align: center;
}

.bv-scan-error {
  display: none;
  padding: .65rem .9rem;
  border-radius: 10px;
  background: rgba(255, 80, 80, .08);
  border: 1px solid rgba(255, 80, 80, .22);
  color: var(--text-muted);
  font-size: .85rem;
  line-height: 1.45;
}

/* Camera icon button inside search input */
.bv-scan-input-btn {
  position: absolute;
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s;
  flex-shrink: 0;
}

.bv-scan-input-btn:hover {
  color: var(--gold);
}

.bv-scan-input-btn svg {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  pointer-events: none;
}

/* Give the name input room for the camera button */
.as-name-wrap input#search-input {
  padding-right: 2.4rem;
}

/* Scan overlay (modal on search page) */
.bv-scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  display: none;
}

.bv-scan-overlay.is-open {
  display: block;
}

.bv-scan-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 14, 19, .52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 0;
  width: 100%;
  height: 100%;
  cursor: default;
}

.bv-scan-overlay-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 2rem));
  max-height: min(680px, calc(100dvh - 2rem));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1.35rem 1.45rem 1.3rem;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-card) 94%, white 6%), var(--bg-card));
  box-shadow: 0 34px 90px rgba(0, 0, 0, .34), 0 0 0 1px rgba(255, 255, 255, .04) inset;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bv-scan-overlay.is-open .bv-scan-overlay-panel {
  animation: bvScanOverlayIn .2s ease;
}

.bv-scan-overlay-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  flex-shrink: 0;
}

.bv-scan-overlay-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: .95rem;
  letter-spacing: .07em;
  color: var(--gold);
  text-transform: uppercase;
}

.bv-scan-overlay-close {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s;
}

.bv-scan-overlay-close:hover {
  color: var(--text);
}

[data-theme="light"] .bv-scan-overlay-panel {
  background: linear-gradient(180deg, #fffdf8, #f7f1e5);
  box-shadow: 0 24px 54px rgba(80, 58, 18, .16), 0 0 0 1px rgba(255, 255, 255, .65) inset;
}

@keyframes bvScanOverlayIn {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 14px));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@media (max-width: 680px) {
  #scan-page .bv-scan-panel {
    max-width: 100%;
  }

  .bv-scan-drop {
    padding: 1.75rem 1.25rem;
  }

  .bv-scan-overlay-panel {
    width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
    border-radius: 20px;
    padding: .9rem .9rem 1rem;
  }

  .bv-scan-preview canvas {
    max-height: 240px;
  }
}
