/* ==========================================================================
   auth.css —— 登录 · 邀请注册 · 密码重置 共用样式
   概念：表单即星座。没有登录框——字段是一颗颗星，
   星线是输入的下划线，左侧一条星轨把节点串成星座。
   夜空纵深与星光由 auth.js 的 Canvas 层绘制。
   ========================================================================== */

@font-face {
  font-family: "LXGW WenKai Lite";
  src: url("../assets/fonts/LXGWWenKaiLite-Regular.subset.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --night: #131433;
  --dusk: #2b2154;
  --cream: #fdf6ec;
  --gold: #ffe9c4;
  --lamp: #ffd98f;
  --pink: #f6c6d0;
  --lav: #a99cc9;
  --lav-dim: #8d81b3;
  --line: rgba(255, 233, 196, .22);
  --err: #ffb1a6;
  --accent: var(--gold);
}

/* 每一页都有自己的 accent：登录暖金 / 注册雾樱 / 重置灯光橙 */
body[data-page="login"] { --accent: #ffe9c4; }
body[data-page="register"] { --accent: #f6c6d0; }
body[data-page="reset"] { --accent: #ffd98f; }

* { margin: 0; padding: 0; box-sizing: border-box; }

button {
  font-family: inherit;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
}

html { height: 100%; }

body {
  min-height: 100%;
  overflow-x: hidden;
  background: linear-gradient(180deg, #10112c 0%, #17183a 52%, #242047 100%);
  background-attachment: fixed;
  color: var(--cream);
  font-family: "LXGW WenKai Lite", "LXGW WenKai", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 星空画布与暗角 ---------- */

#auth-sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(118% 92% at 50% 42%, transparent 56%, rgba(9, 9, 26, .34) 100%);
}

/* ---------- 内容 ---------- */

.wrap {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
}

/* 宽屏：表单列偏左，把右侧夜空让给星云与轨道线 */
@media (min-width: 1024px) {
  .wrap {
    padding-left: clamp(48px, 12vw, 220px);
    padding-right: clamp(40px, 18vw, 320px);
  }
}

/* ---------- 面板：不是框，是一团融进夜空的星云雾霭 ---------- */

.panel {
  width: min(430px, 100%);
  padding: 34px 34px 28px;
  position: relative;
  border-radius: 8px;
  background: radial-gradient(115% 88% at 44% 30%,
    rgba(29, 26, 66, .62) 0%,
    rgba(29, 26, 66, .36) 48%,
    rgba(29, 26, 66, 0) 78%);
}

body[data-page="register"] .panel { width: min(458px, 100%); }

/* ---------- 星座标识（每页不同，装饰） ---------- */

.asterism {
  position: absolute;
  top: 22px;
  right: 4px;
  width: 128px;
  height: auto;
  pointer-events: none;
}

/* ---------- 品牌与标题（左对齐的编辑式排版） ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--gold);
  font-size: 13.5px;
  letter-spacing: .3em;
}

.brand svg { filter: drop-shadow(0 0 5px rgba(255, 233, 196, .4)); flex: none; }

h1 {
  margin: 15px 0 7px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .08em;
  text-wrap: balance;
  color: var(--cream);
}

.sub {
  font-size: 14px;
  line-height: 1.9;
  letter-spacing: .05em;
  text-wrap: pretty;
  color: #bdb0de;
}

/* ---------- 状态区：固定预留高度 ---------- */

.status {
  min-height: 24px;
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.7;
  letter-spacing: .05em;
}

.status.err { color: var(--err); }
.status.ok { color: var(--gold); }

/* ---------- 字段：一颗颗星，一线到底 ---------- */

form { margin-top: 4px; }

.fields { position: relative; margin-top: 2px; }

/* 星轨脊柱：把各字段的星节点串起来 */
.fields::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 12px;
  bottom: 28px;
  width: 1px;
  background: linear-gradient(180deg,
    rgba(255, 233, 196, 0),
    rgba(255, 233, 196, .22) 12%,
    rgba(255, 233, 196, .22) 88%,
    rgba(255, 233, 196, 0));
}

.field { margin-top: 22px; position: relative; }
.field:first-of-type { margin-top: 4px; }

/* 星节点：安静时是淡紫小星，聚焦时点亮成本页专属色 */
.field::before {
  content: "";
  position: absolute;
  left: -20px;
  bottom: 22px;
  width: 9px;
  height: 9px;
  background: rgba(169, 156, 201, .72);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  transition: background .3s, filter .3s;
}

.field:focus-within::before {
  background: var(--accent);
  filter: drop-shadow(0 0 5px rgba(255, 217, 143, .75));
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13.5px;
  letter-spacing: .14em;
  color: rgba(253, 246, 236, .72);
  transition: color .3s;
}

.field:focus-within label { color: var(--accent); }

/* 输入框：没有框，只有一条两端渐隐的星线 */
.field input {
  width: 100%;
  height: 50px;
  padding: 0 54px 0 2px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 233, 196, .18);
  border-radius: 0;
  color: var(--cream);
  font-family: inherit;
  font-size: 16px;
  letter-spacing: .04em;
  transition: border-color .3s, box-shadow .3s;
}

.field input:focus,
.field:focus-within input {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: 0 12px 22px -16px color-mix(in srgb, var(--accent) 55%, transparent);
}

/* 密码显示切换（触控区 ≥ 44×44） */

.pw-wrap { position: relative; }

.pw-wrap input { padding-right: 54px; }

.pw-toggle {
  position: absolute;
  right: -8px;
  top: 1px;
  bottom: 1px;
  width: 46px;
  display: grid;
  place-items: center;
  color: var(--lav-dim);
  transition: color .25s;
}

.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--cream); }

.pw-toggle .ic-eye-off { display: none; }
.pw-toggle[aria-pressed="true"] .ic-eye { display: none; }
.pw-toggle[aria-pressed="true"] .ic-eye-off { display: block; }

/* ---------- 主按钮：星座终点的暖灯 ---------- */

.btn-primary {
  width: 100%;
  height: 50px;
  margin-top: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f6d3a4 0%, #eec3c4 100%);
  color: #472a2c;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .2em;
  text-indent: .1em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .42),
    inset 0 -1px 0 rgba(120, 60, 60, .18),
    0 8px 22px rgba(238, 195, 196, .15),
    0 2px 8px rgba(8, 8, 26, .38);
  transition: transform .18s ease, filter .25s ease, box-shadow .25s ease;
}

.btn-primary::before {
  content: "✦";
  margin-right: 10px;
  font-size: 13px;
  vertical-align: 1px;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(.96);
}

.btn-primary:disabled {
  filter: saturate(.55) brightness(.92);
  cursor: default;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .2),
    0 2px 6px rgba(8, 8, 26, .3);
}

.btn-primary.is-busy { letter-spacing: .1em; }

.btn-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px 0 0;
  color: var(--lav);
  font-size: 13.5px;
  letter-spacing: .12em;
  text-decoration: none;
  transition: color .25s;
}

.btn-link:hover { color: var(--gold); text-decoration: underline; text-underline-offset: 4px; }

.aux { margin-top: 6px; }

.aux-note {
  margin-top: 16px;
  font-size: 12px;
  letter-spacing: .18em;
  color: var(--lav-dim);
}

/* ---------- 邀请 / 链接无效状态（轻提示） ---------- */

.token-notice {
  margin-top: 24px;
  padding: 4px 8px 4px 16px;
  border-left: 2px solid rgba(255, 177, 166, .45);
}

.token-notice h2 {
  margin: 0 0 8px;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--err);
}

.token-notice p {
  font-size: 13.5px;
  line-height: 1.95;
  letter-spacing: .05em;
  color: var(--lav);
}

.token-notice .btn-link { margin-top: 4px; color: var(--gold); }

/* ---------- 键盘焦点 ---------- */

:focus-visible {
  outline: 2px solid rgba(255, 233, 196, .8);
  outline-offset: 2px;
}

.field input:focus-visible {
  outline: none; /* 输入框用金色星线 + 点亮星节点，不叠加外框 */
}

/* ---------- 一次协调的入场（仅在允许动效时） ---------- */

@media (prefers-reduced-motion: no-preference) {
  .panel { animation: panel-rise .5s cubic-bezier(.22, .7, .3, 1) both; }
  .brand { animation: soft-rise .4s ease-out .18s both; }
  h1 { animation: soft-rise .4s ease-out .27s both; }
  .sub { animation: soft-rise .4s ease-out .36s both; }
  #auth-form, #token-notice { animation: soft-rise .45s ease-out .45s both; }
  .asterism .tw { animation: node-breathe 4.6s ease-in-out infinite; }
}

@keyframes panel-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes soft-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes node-breathe {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; }
}

/* ---------- 紧凑屏幕 ---------- */

@media (max-width: 480px) {
  .wrap { padding: 20px 14px calc(20px + env(safe-area-inset-bottom)); align-items: flex-start; padding-top: max(6vh, 26px); }
  .panel { padding: 26px 22px 24px; }
  h1 { margin-top: 12px; font-size: 24px; }
  .asterism { top: 14px; right: 0; width: 94px; }
}
