/* =====================================================================
   バーコード読取（assets/barcode.js）の見た目。
   スマホ（iPhone）での片手操作を前提に、ボタンは十分な当たり判定を取る。
   ===================================================================== */

/* 入力欄の横に置く読取ボタン。端末の対応可否で出し分けないので常に見える。 */
.bc-scan {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 0 6px;
  border: 0;
  background: none;
  color: var(--ns-title, #3a7);
  cursor: pointer;
  line-height: 1;
}
.bc-scan svg { width: 20px; height: 20px; display: block; }
.bc-scan:active { opacity: .6; }

/* コード欄（.codecell）の中に入れたときは仕切り線を出す */
.codecell > .bc-scan { border-left: 1px solid #ccc; }

@media (max-width: 640px) {
  .bc-scan { min-width: 44px; }        /* タップ目標 44px（iOS の推奨） */
  .bc-scan svg { width: 24px; height: 24px; }
}

/* ------------------------------------------------------- オーバーレイ */

body.bc-lock { overflow: hidden; }

.bc-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, .82);
}

.bc-sheet {
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
  background: #14171b;
  border: 1px solid var(--ns-border, #333);
  border-radius: 8px;
  color: #e8eef0;
  /* iPhone のノッチ／ホームバーを避ける */
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ns-border, #333);
}
.bc-title { flex: 1; font-size: 14px; color: var(--ns-title, #3a7); }
.bc-close {
  width: 34px; height: 34px;
  border: 0; border-radius: 50%;
  background: none; color: #cdd;
  font-size: 16px; cursor: pointer;
}

.bc-stage {
  position: relative;
  overflow: hidden;             /* ガイド枠の外側を暗くする影をステージ内に収める */
  background: #000;
  min-height: 240px;            /* aspect-ratio 未対応（iOS 14 以前）でも潰れないように */
  aspect-ratio: 4 / 3;
}
.bc-stage.is-off { display: none; }     /* カメラが使えないときは枠ごと隠す */
.bc-video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 読取エリアの目安。js 側の切り出し範囲（幅92% / 高さ50%）と揃えている。 */
.bc-guide {
  position: absolute;
  left: 4%; top: 25%;
  width: 92%; height: 50%;
  border: 2px solid var(--ns-title, #3a7);
  border-radius: 4px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45);
  pointer-events: none;
}
.bc-laser {
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 2px;
  background: #e74c3c;
  opacity: .85;
  animation: bc-sweep 2s ease-in-out infinite alternate;
}
@keyframes bc-sweep {
  from { transform: translateY(-42px); }
  to   { transform: translateY(42px); }
}
@media (prefers-reduced-motion: reduce) {
  .bc-laser { animation: none; }
}

.bc-status {
  margin: 0;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  color: #cdd;
}
.bc-status.is-error { color: #ffb4a8; }

.bc-foot {
  display: flex;
  gap: 10px;
  padding: 0 12px 12px;
}
.bc-btn {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--ns-border, #333);
  border-radius: 4px;
  background: #1f242a;
  color: #e8eef0;
  font-size: 14px;
  cursor: pointer;
}
.bc-btn:active { background: #2a3138; }
.bc-btn.bc-photo { background: var(--ns-teal, #1c8b9b); border-color: var(--ns-teal, #1c8b9b); color: #fff; }
.bc-btn.bc-torch.is-on { background: #a67c00; border-color: #a67c00; color: #fff; }
