/* ==========================================================================
   滑动验证码组件样式（注册 / 找回密码页共用）
   由 public/static/captcha.js 注入标记，这里只负责外观。

   组件形态：默认收在表单里的一个挂载点（只放隐藏域），
   点「注册 / 发送重置链接」时弹出对话框，验证通过后自动提交表单。

   历史坑（务必不要再踩）：
   - style.css 里曾有一块「滑动验证占位」(.slide-captcha { height:42px; display:flex } + ::before 假文案)，
     会把组件压成 42px 一条、子元素横向排布，拼图块溢出到滑轨上。该块已删除。
   - 旧配色直接用 Element 蓝 #409eff + 荧光绿 #7CFC00，与本站红色主色脱节。
   - 尺寸不能写死 300px（认证卡窄屏内容区约 256px），也不能只靠 aspect-ratio：
     背景高度用 padding-top 撑（160/300 = 53.3333%），不依赖图片是否加载完成，
     也不依赖浏览器是否支持 aspect-ratio。
   ========================================================================== */

/* 表单里的挂载点：默认不可见，只承载隐藏域
   （组件视觉部分被搬进对话框，但隐藏域必须留在 form 内才能随表单提交） */
.slide-captcha {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- 对话框 ---------- */
.sc-modal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.sc-modal.show { display: flex; }

.sc-modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, .55);
  backdrop-filter: blur(3px);
}

.sc-modal-box {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(17, 24, 39, .28);
  padding: 24px;
  animation: sc-pop var(--dur) var(--ease-out);
}
@keyframes sc-pop {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sc-modal-box { animation: none; }
}

.sc-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.sc-modal-title {
  font-size: 17px;
  font-weight: 800;
  font-family: var(--font-serif);
  color: var(--ink);
  line-height: 1.3;
}
.sc-modal-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-4);
  line-height: 1.6;
}
.sc-modal-close {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-4);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.sc-modal-close:hover { background: var(--bg-soft); color: var(--ink); }
.sc-modal-close:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* 组件本体在弹窗里居中，宽度自适应 */
.sc-modal-body .sc-wrap {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- 背景图：用 padding-top 撑高，不依赖图片/浏览器特性 ---------- */
.sc-bg {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-soft);
  border: 1px solid var(--line-light);
}
.sc-bg::before {
  content: '';
  display: block;
  /* 160 / 300 = 53.3333%：背景是 300x160 位图，缩放后缺口也跟着缩，
     拼图块由 JS 按同一比例换算尺寸与位置 */
  padding-top: 53.3333%;
}
.sc-bgimg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.sc-piece {
  position: absolute;
  left: 0;
  top: 0;
  width: 100px;
  height: 100px;
  filter: drop-shadow(0 2px 6px rgba(17, 24, 39, .45));
  will-change: left;
}

/* ---------- 校验通过遮罩 ---------- */
.sc-success {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(17, 24, 39, .58);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
}
.sc-success.show { display: flex; }
.sc-success svg { display: block; color: var(--success); }

/* ---------- 换一张 ---------- */
.sc-refresh {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  background: rgba(17, 24, 39, .45);
  transition: background var(--dur-fast) var(--ease), transform var(--dur) var(--ease-out);
}
.sc-refresh:hover { background: var(--brand); transform: rotate(-90deg); }
.sc-refresh:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sc-refresh svg { display: block; }

/* ---------- 滑轨 ---------- */
.sc-track {
  position: relative;
  width: 100%;
  height: 42px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  overflow: hidden;
}

.sc-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: var(--brand-soft-2);
  border-right: 1px solid var(--brand-border);
}

.sc-tip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 52px;
  font-size: 13px;
  color: var(--ink-4);
  transition: opacity var(--dur) var(--ease);
  pointer-events: none;
}

.sc-handle {
  position: absolute;
  left: 0; top: 0;
  width: 44px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--brand);
  cursor: grab;
  z-index: 2;
  /* 触摸拖动时不要让浏览器把手势当成滚动 */
  touch-action: none;
  transition: background var(--dur-fast) var(--ease);
}
.sc-handle:hover { background: var(--brand-hover); }
.sc-handle:active { cursor: grabbing; }
.sc-handle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sc-handle svg { display: block; pointer-events: none; }

.sc-modal.is-verified .sc-track { border-color: var(--success); background: var(--success-soft); }
.sc-modal.is-verified .sc-handle { background: var(--success); cursor: default; }
.sc-modal.is-verified .sc-fill { background: transparent; border-right-color: transparent; }

/* 加载/失败提示 */
.sc-status {
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-4);
  text-align: center;
  min-height: 18px;
}
.sc-status.error { color: var(--error); }
