/* ===========================================================================
   扫码页（/）
   整屏竖排：顶部提示 / 中间方形取景框 / 底部状态文字 / 右下角手动输入入口。
   共享导航固定在屏幕顶端，不占取景框的布局空间。
   =========================================================================== */

/* ★ 页面不允许被拖动、也不许"橡皮筋"。
   视频被放大到 200vw 显示（见 js/scan.js），一旦外层没有裁切，整页就能横向拖动，
   手指在取景框上滑动时页面会跟着晃、二维码也就永远对不进框。
   overscroll-behavior 挡住安卓 Chrome 的整页下拉刷新 —— 扫码时的误触下拉
   会让页面重新加载，等于白扫一次。 */
html,
body {
  overscroll-behavior: none;
}

.scan-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  position: relative;
  overflow: hidden;              /* 放大后的 video 不许把整页撑出可拖动区域 */
  background: #000;
}

/* Keep the shared controls in the scan layout so they cannot cover the prompt. */
.scan-page > .shell-nav {
  position: relative;
  top: auto;
  left: auto;
  flex: 0 0 auto;
}

.scan-page > .shell-nav .shell-menu {
  position: absolute;
  top: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  max-height: calc(100dvh - var(--nav-h) - env(safe-area-inset-top, 0px));
}

/* ── 顶部提示 ───────────────────────────────────────────────────────────── */
.scan-top {
  display: flex;
  flex-grow: 1;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  background: #fff;
}

.scan-instructions {
  display: flex;
  flex-direction: row;
  justify-content: center;
  margin: 1.4rem 2rem;
}

.scan-instruction-text {
  margin: auto;
  text-align: center;
  font-size: 2.2rem;
  line-height: 1.4;
  color: #000;
}

/* ── 取景框 ─────────────────────────────────────────────────────────────── */
.camera-container {
  /* 46vh 而不是 50vh：加上顶部品牌条与上下两段提示文字，50vh 在矮屏手机上
     会把底部提示挤出可视区，而 .scan-page 是 overflow:hidden，挤出去就看不见了。 */
  width: 46vh;
  height: 46vh;
  max-height: 88vw;
  max-width: 88vw;
  border-radius: 16px;
  display: flex;
  position: relative;
  overflow: hidden;              /* 裁掉放大后溢出的画面 */
  align-items: center;
  justify-content: center;
  background: #000;
  flex: 0 0 auto;
  /* 取景框里的任何手势（拖动、双指缩放、双击缩放）都没有意义，
     而且会把 video 的显示区域记忆成一个偏移状态 —— 直接关掉。 */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* 视频被缩放并居中：object-fit:cover 保证不变形，放大倍数由 JS 按 CFG.cameraZoom 设。
   放大是必要的 —— 1:1 显示时二维码在画面里只占很小一块，解不出来。 */
.camera-video {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  object-fit: cover;
  background: #000;
  pointer-events: none;
}

/* ── 取景框内的准星 ─────────────────────────────────────────────────────── */
.reticle {
  position: absolute;
  width: 62%;
  height: 62%;
  border-width: 2px;
  box-sizing: border-box;
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  pointer-events: none;
}

/* ── 验证中 spinner ─────────────────────────────────────────────────────── */
.scan-spinner {
  position: absolute;
  width: 72px;
  height: 72px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── 底部状态区 ─────────────────────────────────────────────────────────── */
.scan-bottom {
  display: flex;
  flex-grow: 1;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  background: #fff;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.scan-bottom-text {
  text-align: center;
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--dark-grey);
  padding: 0 24px 8px;
}

.scan-user-prompt {
  font-size: 1.8rem;
  line-height: 2.4rem;
  color: var(--dark-grey);
  min-height: 2.6rem;
  margin: 0;
  padding: 0 24px;
}

/* 状态文字轮播：两行叠在一个 2.9rem 高的窗口里，靠 margin-top 切换 */
.scan-status-window {
  height: 2.9rem;
  overflow: hidden;
  margin-top: 6px;
}

.scan-status-line {
  color: var(--navy);
  margin: 0;
  font-weight: bold;
  font-size: 1.7rem;
  line-height: 2.9rem;
  text-transform: uppercase;
  transition: margin-top 0.5s;
}

/* 进入"发送验证"状态时，把第一行顶上去 */
.scan-status-window.sending .scan-status-line.first {
  margin-top: -2.9rem;
}

.scan-ellipsis-holder {
  width: 2.1rem;
  display: inline-block;
  height: 2.9rem;
  text-align: start;
}

.scan-ellipsis {
  display: inline-flex;
  overflow: hidden;
  width: 0;
  color: var(--navy);
  font-weight: bold;
  font-size: 1.7rem;
  line-height: 2.9rem;
  vertical-align: bottom;
  animation: ellipsis-grow 1.5s steps(4, end) infinite;
}

@keyframes ellipsis-grow {
  to { width: 2.1rem; }
}

/* ── 应用内浏览器指引条（样式基座在 base.css）─────────────────────────────
   扫码页是整屏的、没有文档流，所以这一页的指引条必须**固定**在顶部；
   其余页面（超时页）它是文档流里的一条。 */
.inapp-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1500;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

/* ── 手动输入 / 上传 ────────────────────────────────────────────────────── */
.manual-toggle {
  position: fixed;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  border: none;
  border-radius: 3.35rem;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  z-index: 1200;
}

.manual-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  margin: 0 auto;
  width: min(92vw, 420px);
  background: rgba(255, 255, 255, 0.98);
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
  padding: 14px 16px;
  font-size: 14px;
  z-index: 1200;
  /* 面板要能滚动，而 .camera-container 的 touch-action:none 只作用于它自己，
     所以这里不必再改 —— 留一条注释以免以后有人"顺手"加到 body 上。 */
}

.manual-title {
  font-weight: 700;
  color: #000;
}

.manual-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.manual-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--mid-grey);
  border-radius: 6px;
  padding: 10px;
  font-size: 16px;   /* 16px 以下 iOS Safari 聚焦时会把整页放大 */
  letter-spacing: 0.06em;
}

.manual-btn {
  border: none;
  border-radius: 6px;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  white-space: nowrap;
}

.manual-btn.ghost {
  background: var(--light-grey);
  color: #333;
}

.manual-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.manual-hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--dark-grey);
}

.manual-error {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--red);
  font-weight: 600;
}

/* ── 摄像头错误弹窗 ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  max-width: 440px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  color: #000;
}

.modal-title {
  font-weight: 600;
  font-size: 1.9rem;
  line-height: 2.4rem;
  margin: 0 0 12px;
}

.modal-content {
  line-height: 2.3rem;
  color: var(--dark-grey);
  font-weight: 400;
  font-size: 1.5rem;
  margin-bottom: 2rem;
}

.modal-content ol {
  list-style: none;
  counter-reset: item;
  padding-left: 0;
  margin: 0;
}

.modal-content li {
  counter-increment: item;
  display: flex;
  margin-bottom: 6px;
}

.modal-content li::before {
  content: counter(item) '.';
  margin-right: 14px;
  color: var(--navy);
  font-weight: 700;
  flex: 0 0 auto;
}

.modal-hr {
  border: none;
  height: 1px;
  background: var(--mid-grey);
  margin: 17px 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-actions .btn-primary {
  flex: 1 1 auto;
}

/* 原始错误单独一行，方便排查时不必再开控制台 */
.modal-detail {
  margin: 18px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--light-grey);
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--dark-grey);
  word-break: break-word;
  font-family: Menlo, Consolas, monospace;
}

/* 诊断页是排查摄像头问题的入口，弹窗里给一条直达链接 */
.modal-diag {
  margin: 14px 0 0;
  font-size: 1.4rem;
}
