/* ==========================================================
   认证模态框（登录 / 注册）
   复用登录页黑金设计语言，作为应用内浮层使用，避免页面跳转
   类名统一 am- 前缀，避免与 common.css / 页面样式冲突
   ========================================================== */

/* 遮罩：常驻布局，用 visibility + opacity 控制显隐，
   使打开与关闭都能走 transition（display 切换无法过渡，会导致关闭瞬间消失） */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  overscroll-behavior: contain;
  /* 关闭态 */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.24s ease, visibility 0s linear 0.24s;
}

.auth-modal-overlay.am-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.24s ease, visibility 0s linear 0s;
}

/* ---------- 卡片 ---------- */
.auth-modal {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--color-surface, #0f0f12);
  border: 1px solid rgba(212, 175, 55, 0.16);
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.72),
    0 0 0 1px rgba(0, 0, 0, 0.5);
  /* 关闭态：下沉 + 微缩，与遮罩同步渐隐 */
  opacity: 0;
  transform: translateY(26px) scale(0.98);
  transition:
    opacity 0.26s cubic-bezier(0.22, 0.7, 0.3, 1),
    transform 0.3s cubic-bezier(0.22, 0.7, 0.3, 1);
}

/* 打开态：由下向上浮起 */
.auth-modal-overlay.am-open .auth-modal {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ---------- 顶部区 ---------- */
.am-hero {
  position: relative;
  flex: none;
  padding: 24px 26px 22px;
  overflow: hidden;
  background:
    radial-gradient(118% 132% at 86% -12%, rgba(212, 175, 55, 0.15) 0%, transparent 58%),
    linear-gradient(168deg, #17140d 0%, #101014 72%, var(--color-surface, #0f0f12) 100%);
}

.am-rings {
  position: absolute;
  top: -70px;
  right: -70px;
  width: 220px;
  height: 220px;
  pointer-events: none;
}

.am-rings span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.13);
}

.am-rings span:nth-child(2) { inset: 32px; border-color: rgba(212, 175, 55, 0.09); }
.am-rings span:nth-child(3) { inset: 64px; border-color: rgba(212, 175, 55, 0.06); }

.am-mark {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(158deg, rgba(212, 175, 55, 0.2), rgba(212, 175, 55, 0.04));
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--color-accent, #efd67c);
  font-size: 15px;
  box-shadow: inset 0 1px 0 rgba(255, 236, 180, 0.18);
  margin-bottom: 14px;
}

.am-title {
  position: relative;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.34;
  letter-spacing: 0.8px;
  color: #f5f2ea;
}

.am-sub {
  position: relative;
  margin-top: 7px;
  font-size: 11px;
  letter-spacing: 1.6px;
  color: var(--color-text-light, #8a8578);
  text-transform: uppercase;
}

/* 关闭按钮 */
.am-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  color: var(--color-text-light, #8a8578);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.am-close:hover {
  color: var(--color-accent, #efd67c);
  border-color: rgba(212, 175, 55, 0.42);
  background: rgba(212, 175, 55, 0.08);
}

/* ---------- 表单区 ---------- */
.am-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 26px 24px;
  overscroll-behavior: contain;
}

.am-view { display: none; }
.am-view.am-active { display: block; animation: am-view-in 0.22s ease both; }

@keyframes am-view-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.am-msg {
  display: none;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 12.5px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.am-msg.am-error {
  display: block;
  background: rgba(224, 115, 106, 0.1);
  border: 1px solid rgba(224, 115, 106, 0.3);
  color: var(--color-error, #e0736a);
}

.am-msg.am-success {
  display: block;
  background: rgba(134, 192, 125, 0.1);
  border: 1px solid rgba(134, 192, 125, 0.3);
  color: var(--color-success, #86c07d);
}

.am-field {
  margin-bottom: 12px;
  padding: 11px 15px 12px;
  background: rgba(255, 255, 255, 0.026);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.am-field:focus-within {
  background: rgba(212, 175, 55, 0.04);
  border-color: rgba(212, 175, 55, 0.42);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.07);
}

.am-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: var(--color-text-light, #8a8578);
  margin-bottom: 3px;
}

.am-field input {
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text, #ece9e2);
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.4px;
}

.am-field input::placeholder { color: #5d594f; letter-spacing: 0.2px; }

.am-field input:-webkit-autofill,
.am-field input:-webkit-autofill:hover,
.am-field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--color-text, #ece9e2);
  -webkit-box-shadow: 0 0 0 1000px #15151a inset;
  transition: background-color 99999s ease-out 0s;
}

/* 验证码行 */
.am-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.am-field-row input { flex: 1; min-width: 0; }

.am-btn-code {
  flex: none;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.36);
  color: var(--color-accent, #efd67c);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.am-btn-code:hover:not(:disabled) {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.6);
}

.am-btn-code:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- 黑金主按钮 ---------- */
.am-btn-gold {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  margin-top: 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(180deg, #211c12 0%, #14110c 52%, #0c0b08 100%) padding-box,
    linear-gradient(180deg, #f2e0a2 0%, #cda94d 32%, #8e7026 66%, #5e4914 100%) border-box;
  color: #eeda92;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 3px;
  text-indent: 3px;
  text-shadow: 0 0 12px rgba(212, 175, 55, 0.25);
  cursor: pointer;
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.6),
    inset 0 0 18px rgba(212, 175, 55, 0.05);
  transition: color 0.22s, box-shadow 0.22s, transform 0.15s, background 0.22s;
}

.am-btn-gold:hover:not(:disabled) {
  background:
    linear-gradient(180deg, #2a2416 0%, #191510 52%, #0f0d09 100%) padding-box,
    linear-gradient(180deg, #faeec2 0%, #e0be63 32%, #a5832f 66%, #71571a 100%) border-box;
  color: #f8e9b4;
  text-shadow: 0 0 16px rgba(226, 193, 92, 0.4);
  transform: translateY(-1px);
  box-shadow:
    0 16px 30px rgba(0, 0, 0, 0.66),
    inset 0 0 22px rgba(212, 175, 55, 0.09);
}

.am-btn-gold:active:not(:disabled) { transform: translateY(0); }
.am-btn-gold:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 视图切换文字链 ---------- */
.am-alt {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-light, #8a8578);
  letter-spacing: 0.4px;
}

.am-alt button {
  background: none;
  border: none;
  padding: 0 0 1px;
  margin-left: 4px;
  color: var(--color-accent, #efd67c);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px solid rgba(212, 175, 55, 0.36);
  transition: color 0.2s, border-color 0.2s;
}

.am-alt button:hover {
  color: #f7ecc6;
  border-bottom-color: rgba(212, 175, 55, 0.72);
}

/* ---------- 协议 ---------- */
.am-agreement {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11.5px;
  line-height: 1.65;
  color: #6f6a5f;
  cursor: pointer;
}

.am-agreement input[type="checkbox"] {
  flex: none;
  width: 14px;
  height: 14px;
  margin-top: 2px;
  accent-color: var(--color-primary, #d4af37);
  cursor: pointer;
}

/* ---------- 移动端 ---------- */
@media (max-width: 520px) {
  .auth-modal-overlay { padding: 16px; }

  .auth-modal {
    max-width: none;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    border-radius: 20px;
  }

  .am-hero { padding: 20px 22px 18px; }
  .am-mark { width: 34px; height: 34px; margin-bottom: 12px; }
  .am-title { font-size: 18px; }
  .am-body { padding: 16px 22px 20px; }
}
