/* ==========================================================================
   ld-auth.css — 悬浮登录 / 注册弹层
   需求：老板 2026-11-07
   - 不跳页，本页悬浮出现，背景虚影化
   - 登录 / 注册同层切换
   - 桌面居中卡片，≤640px 底部抽屉
   所有选择器以 .ld-auth 前缀隔离，不污染其它模块。
   ========================================================================== */

.ld-auth {
  --a-wine: #2b0612;
  --a-wine-deep: #1b0705;
  --a-gold: #d8b56c;
  --a-gold-lt: #f0d9a8;
  --a-cream: #f7efe6;
  --a-mute: #b9a48f;
  --a-line: rgba(216, 181, 108, .30);
  --a-line-strong: rgba(216, 181, 108, .72);
  --a-err: #f0a19a;
  --a-ok: #a8d5a2;

  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: "DM Sans", "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--a-cream);
  -webkit-font-smoothing: antialiased;
}

/* hidden 属性必须真正隐藏，否则会被上面的 display:flex 覆盖 */
.ld-auth[hidden] {
  display: none !important;
}

/* ---------- 背景虚影化 ---------- */
.ld-auth__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 3, 7, .58);
  -webkit-backdrop-filter: blur(16px) saturate(.82) brightness(.82);
  backdrop-filter: blur(16px) saturate(.82) brightness(.82);
  opacity: 0;
  transition: opacity .26s ease;
}

/* Firefox / 旧版 Safari 无 backdrop-filter：退化为更实的遮罩，保持可读性 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .ld-auth__backdrop {
    background: rgba(14, 3, 7, .93);
  }
}

/* ---------- 面板 ---------- */
.ld-auth__panel {
  position: relative;
  width: min(438px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 38px 36px 30px;
  border-radius: 22px;
  border: 1px solid var(--a-line);
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(216, 181, 108, .16) 0%, rgba(216, 181, 108, 0) 62%),
    linear-gradient(168deg, #350b18 0%, var(--a-wine) 44%, var(--a-wine-deep) 100%);
  box-shadow:
    0 40px 90px -24px rgba(0, 0, 0, .72),
    0 0 0 1px rgba(255, 240, 214, .05) inset,
    0 1px 0 rgba(255, 236, 204, .14) inset;
  opacity: 0;
  transform: translateY(18px) scale(.985);
  transition: opacity .28s ease, transform .34s cubic-bezier(.22, .9, .3, 1);
}

.ld-auth.is-open .ld-auth__backdrop { opacity: 1; }
.ld-auth.is-open .ld-auth__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ---------- 关闭按钮 ---------- */
.ld-auth__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--a-mute);
  cursor: pointer;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.ld-auth__close svg { width: 17px; height: 17px; }
.ld-auth__close:hover,
.ld-auth__close:focus-visible {
  color: var(--a-cream);
  background: rgba(216, 181, 108, .12);
  border-color: var(--a-line);
  outline: none;
}

/* ---------- 头部 ---------- */
.ld-auth__head {
  text-align: center;
  margin-bottom: 24px;
}

/* 站点金标（三行 lockup，透明底）。高度锁定、宽度自适应，避免与标题抢视觉 */
.ld-auth__logo {
  display: block;
  width: auto;
  height: 68px;
  margin: 0 auto 16px;
}

.ld-auth__title {
  margin: 0 0 8px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: .01em;
  color: var(--a-cream);
}

.ld-auth__sub {
  margin: 0 auto;
  max-width: 30ch;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--a-mute);
  /* 两行时均衡断行，避免末行只剩一个词 */
  text-wrap: balance;
}

/* ---------- Tab ---------- */
.ld-auth__tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-bottom: 22px;
  padding: 4px;
  border: 1px solid var(--a-line);
  border-radius: 999px;
  background: rgba(0, 0, 0, .26);
}

.ld-auth__tab {
  position: relative;
  z-index: 2;
  height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--a-mute);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: .02em;
  cursor: pointer;
  transition: color .2s ease;
  -webkit-appearance: none;
  appearance: none;
}
.ld-auth__tab:hover { color: var(--a-cream); }
.ld-auth__tab.is-on { color: var(--a-wine); }
.ld-auth__tab:focus-visible {
  outline: 2px solid var(--a-line-strong);
  outline-offset: 2px;
}

/* 滑块：靠 data-active 移动，避免 JS 反复测量宽度 */
.ld-auth__ind {
  position: absolute;
  z-index: 1;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f4dcae 0%, #e2c078 55%, #c9a45f 100%);
  box-shadow: 0 2px 10px rgba(216, 181, 108, .22);
  transition: transform .28s cubic-bezier(.22, .9, .3, 1);
}
.ld-auth__tabs[data-active="register"] .ld-auth__ind {
  transform: translateX(100%);
}

/* ---------- 表单 ---------- */
.ld-auth__form {
  display: block;
}
.ld-auth__form[hidden] {
  display: none !important;
}

.ld-auth__field {
  margin-bottom: 14px;
}

.ld-auth__label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--a-mute);
}

.ld-auth__input {
  display: block;
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid var(--a-line);
  border-radius: 12px;
  background: rgba(255, 246, 232, .045);
  color: var(--a-cream);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
  -webkit-appearance: none;
  appearance: none;
}
.ld-auth__input::placeholder {
  color: rgba(185, 164, 143, .68);
}
.ld-auth__input:hover {
  border-color: rgba(216, 181, 108, .5);
}
.ld-auth__input:focus {
  outline: none;
  border-color: var(--a-line-strong);
  background: rgba(255, 246, 232, .07);
  box-shadow: 0 0 0 3px rgba(216, 181, 108, .14);
}
.ld-auth__input[aria-invalid="true"] {
  border-color: #c4574f;
  box-shadow: 0 0 0 3px rgba(196, 87, 79, .16);
}

/* Chrome 自动填充时不要变成刺眼的白底 */
.ld-auth__input:-webkit-autofill,
.ld-auth__input:-webkit-autofill:hover,
.ld-auth__input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--a-cream);
  -webkit-box-shadow: 0 0 0 60px #2a0a15 inset;
  caret-color: var(--a-cream);
}

.ld-auth__hint {
  display: block;
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(185, 164, 143, .82);
}

/* ---------- 主按钮 ---------- */
.ld-auth__submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  margin-top: 6px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #f6dfb4 0%, #e4c37c 52%, #c9a45f 100%);
  color: var(--a-wine);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: filter .18s ease, transform .12s ease, box-shadow .18s ease;
  box-shadow: 0 6px 20px -8px rgba(216, 181, 108, .6);
  -webkit-appearance: none;
  appearance: none;
}
.ld-auth__submit:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: 0 8px 24px -8px rgba(216, 181, 108, .72);
}
.ld-auth__submit:active:not(:disabled) {
  transform: translateY(1px);
}
.ld-auth__submit:focus-visible {
  outline: 2px solid var(--a-cream);
  outline-offset: 3px;
}
.ld-auth__submit:disabled {
  cursor: progress;
  filter: saturate(.7) brightness(.94);
}

.ld-auth__submit-txt {
  transition: opacity .16s ease;
}
.ld-auth__submit.is-busy .ld-auth__submit-txt {
  opacity: 0;
}

.ld-auth__spin {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(43, 6, 18, .28);
  border-top-color: var(--a-wine);
  opacity: 0;
  animation: ld-auth-spin .7s linear infinite;
}
.ld-auth__submit.is-busy .ld-auth__spin {
  opacity: 1;
}

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

/* ---------- 提示 ---------- */
.ld-auth__msg {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--a-err);
}
.ld-auth__msg:not(:empty) {
  margin-top: 12px;
}
.ld-auth__msg.is-ok {
  color: var(--a-ok);
}

.ld-auth__msg-cta {
  display: inline;
  margin-left: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--a-gold-lt);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.ld-auth__msg-cta:hover {
  color: #fff;
}

/* 提交失败时轻微抖动，替代弹窗 */
@keyframes ld-auth-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.ld-auth__form.is-shake {
  animation: ld-auth-shake .42s cubic-bezier(.36, .07, .19, .97);
}

/* ---------- 切换提示 ---------- */
.ld-auth__switch {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--a-mute);
}
.ld-auth__switch button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--a-gold-lt);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.ld-auth__switch button:hover { color: #fff; }

.ld-auth__foot {
  margin: 22px 0 0;
  padding-top: 16px;
  border-top: 1px solid rgba(216, 181, 108, .16);
  text-align: center;
  font-size: 11.5px;
  line-height: 1.6;
  color: rgba(185, 164, 143, .72);
}
.ld-auth__foot a {
  color: rgba(240, 217, 168, .9);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- 头部触发按钮复位（原先是 <a>，现在是 <button>） ---------- */
html body .head button.header-login {
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
html body .head .header-login.is-signed-in span {
  max-width: 8ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 成功提示条 ---------- */
.ld-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 10000;
  transform: translate(-50%, -14px);
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  border: 1px solid rgba(216, 181, 108, .42);
  border-radius: 999px;
  background: rgba(30, 8, 15, .96);
  color: #f7efe6;
  font-family: "DM Sans", "Jost", sans-serif;
  font-size: 13.5px;
  line-height: 1.3;
  box-shadow: 0 16px 40px -14px rgba(0, 0, 0, .7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .26s ease, transform .3s cubic-bezier(.22, .9, .3, 1);
}
.ld-toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 阻止背景滚动 ----------
   只锁 body 不够：桌面浏览器仍保留 html 层的滚动条，会吃掉 15px 横向空间，
   导致底部抽屉与视口右缘之间露出一条缝。
   注意 ld-theme.css:679 有 html,body{overflow:auto!important}，
   这里必须带 !important 且靠 .ld-auth-lock 提高 specificity 才能压住。 */
html.ld-auth-lock,
html.ld-auth-lock body.ld-auth-open {
  overflow: hidden !important;
}

/* ==========================================================================
   ≤640px：底部抽屉
   ========================================================================== */
@media (max-width: 640px) {
  .ld-auth {
    padding: 0;
    align-items: flex-end;
  }

  .ld-auth__panel {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    padding: 30px 22px calc(22px + env(safe-area-inset-bottom, 0px));
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    transform: translateY(100%);
    box-shadow: 0 -30px 70px -20px rgba(0, 0, 0, .8);
  }

  .ld-auth.is-open .ld-auth__panel {
    transform: translateY(0);
  }

  /* 抽屉顶部抓手 */
  .ld-auth__panel::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 50%;
    width: 40px;
    height: 3px;
    margin-left: -20px;
    border-radius: 999px;
    background: rgba(216, 181, 108, .34);
  }

  .ld-auth__close {
    top: 16px;
    right: 12px;
    width: 36px;
    height: 36px;
  }

  .ld-auth__head {
    margin-bottom: 20px;
  }

  .ld-auth__logo {
    height: 58px;
    margin-bottom: 14px;
  }

  .ld-auth__title {
    font-size: 26px;
  }

  .ld-auth__sub {
    font-size: 13px;
    max-width: 100%;
  }

  .ld-auth__tabs {
    margin-bottom: 18px;
  }

  /* 移动端 16px 起，避免 iOS Safari 聚焦时自动放大页面 */
  .ld-auth__input {
    height: 52px;
    font-size: 16px;
  }

  .ld-auth__submit {
    height: 52px;
    font-size: 16px;
  }

  .ld-auth__foot {
    margin-top: 16px;
    padding-top: 13px;
    font-size: 11px;
  }
}

/* 尊重「减少动效」偏好 */
@media (prefers-reduced-motion: reduce) {
  .ld-auth__backdrop,
  .ld-auth__panel,
  .ld-auth__ind,
  .ld-toast {
    transition-duration: .01ms !important;
  }
  .ld-auth__form.is-shake {
    animation: none !important;
  }
}
