/* ═══════════════════════════════════════════════════════════════════════
   📷 camera.css — IG-style in-app camera modal（v69, 2026-05-17）
   ─────────────────────────────────────────────────────────────────────────
   Fullscreen overlay：z-index 200（蓋過 quick-add 121，但低於 dialogs 999）。
   黑底 + video object-fit cover + glass top/bottom bar。

   Mobile-first：所有控制靠下方拇指區（thumb zone）— Apple Camera / IG / Snapchat
   標準。桌面 also works（瀏覽器 webcam）但目標是手機 PWA。
   ═══════════════════════════════════════════════════════════════════════ */

.nexa-camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* iOS safe area — top notch + bottom home indicator */
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ─── Live preview — 蓋滿，object-fit cover 不變形 ─── */
.nexa-camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  /* touch-action: none 讓自定義 swipe / pinch 手勢能 preventDefault，
     不會跟 browser pinch-to-zoom / 雙擊放大 打架（IG/Snapchat 同設定） */
  touch-action: none;
}

/* ─── Top bar — glass overlay + ✕ / 標題 / ⚡ / ⟳ ─── */
.nexa-camera-topbar {
  position: absolute;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  z-index: 2;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0) 100%);
}

.nexa-camera-mode-title {
  /* v71: 取代成 .nexa-camera-topmode segmented control。保留 class 為了相容 */
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
}

/* ─── v71: Top-mode segmented control [拍照 ↔ 掃 QR]（iOS Settings 風）─── */
.nexa-camera-topmode {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.nexa-camera-topmode-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.22s cubic-bezier(0.32, 0.72, 0, 1),
              color 0.22s cubic-bezier(0.32, 0.72, 0, 1),
              transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.nexa-camera-topmode-tab .ico { width: 15px; height: 15px; }
.nexa-camera-topmode-tab:active { transform: scale(0.96); }
.nexa-camera-topmode-tab.is-active {
  background: #fff;
  color: #000;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.nexa-camera-topbar-right {
  display: flex;
  gap: 8px;
}

.nexa-camera-iconbtn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}
.nexa-camera-iconbtn:hover { background: rgba(0, 0, 0, 0.65); }
.nexa-camera-iconbtn:active { transform: scale(0.92); }
.nexa-camera-iconbtn.is-active {
  background: rgba(255, 204, 0, 0.85);  /* torch on = 黃 */
  color: #000;
}
.nexa-camera-iconbtn .ico { width: 22px; height: 22px; }

/* ─── Zoom slider — 右側中段，Android only ─── */
.nexa-camera-zoom {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 24px;
}
.nexa-camera-zoom input[type="range"] {
  -webkit-appearance: slider-vertical;
  writing-mode: bt-lr;  /* vertical for non-webkit */
  width: 24px;
  height: 140px;
  accent-color: var(--accent);
}
.nexa-camera-zoom-val {
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ─── Bottom bar — mode chips → shutter → escape ─── */
.nexa-camera-bottombar {
  position: absolute;
  bottom: env(safe-area-inset-bottom, 0);
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 20px;
  gap: 14px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 100%);
}

/* Mode chip row — IG filter switcher 風（拇指可滑切） */
.nexa-camera-modes {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  max-width: 100%;
  padding: 4px 8px;
}
.nexa-camera-modes::-webkit-scrollbar { display: none; }

.nexa-camera-mode {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.nexa-camera-mode .ico { width: 16px; height: 16px; }
.nexa-camera-mode:active { transform: scale(0.96); }
.nexa-camera-mode.is-active {
  background: #fff;
  color: #000;
  font-weight: 600;
}
.nexa-camera-mode-soon {
  font-size: 10px;
  opacity: 0.85;
  margin-left: 2px;
}

/* Shutter — 72px 雙圈（Apple Camera 標準）*/
.nexa-camera-shutter {
  width: 72px;
  height: 72px;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.nexa-camera-shutter-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.95);
}
.nexa-camera-shutter-core {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.12s ease, background 0.12s ease;
}
.nexa-camera-shutter:active .nexa-camera-shutter-core {
  transform: scale(0.86);
  background: rgba(255, 255, 255, 0.7);
}
.nexa-camera-shutter.is-capturing .nexa-camera-shutter-ring {
  border-color: rgba(255, 255, 255, 0.5);
}
.nexa-camera-shutter-spin {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: nexa-cam-spin 0.7s linear infinite;
}
@keyframes nexa-cam-spin {
  to { transform: rotate(360deg); }
}
.nexa-camera-shutter.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.nexa-camera-shutter.is-disabled .nexa-camera-shutter-core {
  background: rgba(255, 255, 255, 0.5);
}

/* Escape hatch — 「用系統相機 / 從相簿選」 */
.nexa-camera-escape {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.3);
  text-underline-offset: 3px;
}
.nexa-camera-escape:hover { color: #fff; }
.nexa-camera-escape .ico { width: 14px; height: 14px; }

/* ─── Loading state — spinner + 「啟動相機中…」 ─── */
.nexa-camera-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: rgba(255, 255, 255, 0.8);
  z-index: 3;
  background: rgba(0, 0, 0, 0.7);
}
.nexa-camera-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: nexa-cam-spin 0.7s linear infinite;
}

/* ═══════════════════════════════════════════════════════════════════════
   v70 (2026-05-17) IG-level polish
   ─────────────────────────────────────────────────────────────────────── */

/* ─── Capture flash — 拍下瞬間 220ms 白光 pulse 全屏 ─── */
.nexa-camera-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}
.nexa-camera-flash.is-flashing {
  animation: nexa-cam-flash 220ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes nexa-cam-flash {
  0%   { opacity: 0; }
  30%  { opacity: 0.92; }
  100% { opacity: 0; }
}

/* ─── QR scan reticle — Apple Wallet / IG Shop 風 4-corner bracket ─── */
.nexa-camera-reticle {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
  gap: 16px;
}
.nexa-camera-reticle-box {
  position: relative;
  width: min(70vw, 260px);
  aspect-ratio: 1;
  /* 微弱 inner glow + 周圍稍微暗化感（chip 用半透明 backdrop 替代） */
  border-radius: 12px;
  animation: nexa-cam-pulse 2.4s ease-in-out infinite;
}
.nexa-camera-reticle-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.95);
}
.nexa-camera-reticle-corner--tl { top: 0;    left: 0;    border-right: none; border-bottom: none; border-top-left-radius: 8px; }
.nexa-camera-reticle-corner--tr { top: 0;    right: 0;   border-left: none;  border-bottom: none; border-top-right-radius: 8px; }
.nexa-camera-reticle-corner--bl { bottom: 0; left: 0;    border-right: none; border-top: none;    border-bottom-left-radius: 8px; }
.nexa-camera-reticle-corner--br { bottom: 0; right: 0;   border-left: none;  border-top: none;    border-bottom-right-radius: 8px; }

.nexa-camera-reticle-hint {
  margin: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nexa-camera-reticle-soon {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.75;
  letter-spacing: 0.3px;
}

@keyframes nexa-cam-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.02); opacity: 0.85; }
}

/* ─── Shutter row 三角佈局：左 thumb / 中 shutter / 右 flip ─── */
.nexa-camera-shutter-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  width: 100%;
  max-width: 360px;
  gap: 12px;
}

/* 上一張 thumb — 44px 圓，IG 標準。tap → toast 顯示 mode。 */
.nexa-camera-thumb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  overflow: hidden;
  padding: 0;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease;
  justify-self: end;
  margin-right: 8px;
}
.nexa-camera-thumb:active { transform: scale(0.92); }
.nexa-camera-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nexa-camera-thumb-placeholder {
  width: 44px;
  height: 44px;
  justify-self: end;
  margin-right: 8px;
}

/* Flip 鈕 — 拇指區右側，iOS Camera 標準位置 */
.nexa-camera-flipbtn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  justify-self: start;
  margin-left: 8px;
}
.nexa-camera-flipbtn:hover { background: rgba(255, 255, 255, 0.28); }
.nexa-camera-flipbtn:active { transform: scale(0.92) rotate(180deg); }
.nexa-camera-flipbtn .ico { width: 22px; height: 22px; }

/* ─── Shutter iOS spring curve（取代普通 ease）─── */
.nexa-camera-shutter-core {
  transition: transform 0.16s cubic-bezier(0.32, 0.72, 0, 1),
              background 0.16s cubic-bezier(0.32, 0.72, 0, 1);
}

/* ═══════════════════════════════════════════════════════════════════════
   v71 QR scan UI — laser line / scan-orb / status pill / result card
   ─────────────────────────────────────────────────────────────────────── */

/* Reticle scan laser — is-scanning 時上下穿梭一條光線 */
.nexa-camera-reticle-laser {
  position: absolute;
  left: 6%;
  right: 6%;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(126, 226, 147, 0.1) 15%,
    rgba(126, 226, 147, 0.95) 50%,
    rgba(126, 226, 147, 0.1) 85%,
    transparent 100%);
  box-shadow: 0 0 12px rgba(126, 226, 147, 0.8);
  border-radius: 2px;
  animation: nexa-cam-laser 2s ease-in-out infinite;
}
@keyframes nexa-cam-laser {
  0%   { top: 8%;  opacity: 0.6; }
  50%  { top: 88%; opacity: 1; }
  100% { top: 8%;  opacity: 0.6; }
}

/* Reticle is-scanning → corners 變綠 + 微閃，視覺暗示 active scan */
.nexa-camera-reticle-box.is-scanning .nexa-camera-reticle-corner {
  border-color: rgba(126, 226, 147, 0.95);
  box-shadow: 0 0 8px rgba(126, 226, 147, 0.5);
}

/* Reticle sub-hint 副標 */
.nexa-camera-reticle-sub {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.78;
  letter-spacing: 0.2px;
}

/* Scan status pill — 取代「拍照 mode 的 mode chip row」位置 */
.nexa-camera-scan-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.nexa-camera-scan-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
}
.nexa-camera-scan-dot.is-pulsing {
  background: #7ee293;
  box-shadow: 0 0 6px rgba(126, 226, 147, 0.7);
  animation: nexa-cam-scan-pulse 1.4s ease-in-out infinite;
}
@keyframes nexa-cam-scan-pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.3); opacity: 0.7; }
}

/* Scan orb — 取代 shutter 中央位置（QR mode 不需快門按鈕） */
.nexa-camera-scan-orb {
  width: 72px;
  height: 72px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.9);
}
.nexa-camera-scan-orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(126, 226, 147, 0.4);
  border-top-color: rgba(126, 226, 147, 0.95);
  animation: nexa-cam-spin 1.2s linear infinite;
}

/* QR result card — 偵測到後浮出，半透 backdrop 蓋住預覽中央 */
.nexa-camera-qr-result {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: nexa-cam-fadein 0.2s ease-out;
}
@keyframes nexa-cam-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.nexa-camera-qr-card {
  background: var(--bg-surface, #1a1a1f);
  color: var(--text-primary, #fff);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: nexa-cam-pop 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes nexa-cam-pop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.nexa-camera-qr-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted, #94a3b8);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.nexa-camera-qr-card-icon { font-size: 16px; }
.nexa-camera-qr-card-value {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  word-break: break-all;
  color: var(--text-primary, #fff);
  max-height: 5.5em;
  overflow-y: auto;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.nexa-camera-qr-card-value.is-url {
  color: #80c4ff;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.nexa-camera-qr-card-note {
  font-size: 12px;
  color: var(--text-muted, #94a3b8);
  background: rgba(255, 184, 87, 0.08);
  padding: 8px 10px;
  border-radius: 8px;
  border-left: 3px solid rgba(255, 184, 87, 0.5);
}
.nexa-camera-qr-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.nexa-camera-qr-card-actions .btn {
  flex: 0 1 auto;
  min-width: 80px;
}

/* ─── Error state ─── */
.nexa-camera-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 3;
  color: #fff;
}
.nexa-camera-error-msg {
  font-size: 14px;
  line-height: 1.6;
  max-width: 320px;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
}
.nexa-camera-error-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
