/* ============================================
   伏尔加 · 认证页面样式（登录/注册/忘记密码/重置密码/OAuth关联）
   ============================================ */

/* ---------- 背景 ---------- */
#particle-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.5;
}

.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.25;
    z-index: 0;
    pointer-events: none;
}

.bg-orb.orb-1 {
    width: 480px;
    height: 480px;
    top: -120px;
    left: -120px;
    background: var(--accent);
}

.bg-orb.orb-2 {
    width: 360px;
    height: 360px;
    bottom: -80px;
    right: -80px;
    background: var(--success);
}

.bg-orb.orb-3 {
    width: 260px;
    height: 260px;
    top: 50%;
    left: 60%;
    background: var(--warning);
}

/* ---------- 容器与卡片 ---------- */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    position: relative;
    z-index: 1;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 16px);
    box-shadow: var(--shadow-lg);
    padding: 32px 28px;
    backdrop-filter: blur(8px);
    overflow: hidden;
}

/* V96 152 号：注册页把表单改成两列后，卡片必须一起变宽 —— 否则「两列」是假的。
   算一下就清楚：`.auth-card` 原 max-width 420px、padding 32px 28px
   ⇒ 内容区只有 420 − 56 = **364px**，减列间距 18px 后两列各 **173px**。
   173px 里放 `<img width="150">` 只剩 23px 余量，任何 label 换行都会挤爆；
   placeholder「3-50字符，仅限字母数字下划线连字符」在 173px 下只显示得下 8 个字。
   两列要成立，内容区至少 2×240+18 = 498px，加 padding 后 ≈ 554px。取 560px。

   ⚠️ 只作用于注册页；登录/找回/重置三页保持 420px —— 它们只有 1 列内容，
   拉宽会让输入框长得不像输入框。
   ⚠️ 必须写在 `.auth-card` **之后**：同为单类选择器，优先级相同，
   写在前面的会被后面的 `max-width: 420px` 直接覆盖（写成 560 却不生效，且不报错）。 */
.auth-card--wide {
    max-width: 560px;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 16px;
    right: 16px;
    height: 1px;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 40%, transparent), transparent);
    opacity: 0.8;
}

.auth-header {
    text-align: center;
    margin-bottom: 20px;
}

.auth-icon {
    font-size: 2.2rem;
    display: block;
    margin-bottom: 8px;
}

.auth-header h1 {
    font-family: var(--font-mono, monospace);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin: 0 0 4px;
}

.auth-header p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ---------- 状态栏 ---------- */
.auth-status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.68rem;
    color: var(--text-muted);
    padding: 8px 0;
    margin-bottom: 16px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.auth-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: auth-pulse 2s ease-in-out infinite;
}

@keyframes auth-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---------- 提示条 ---------- */
.auth-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    padding: 10px 14px;
    border-radius: var(--radius-sm, 8px);
    margin-bottom: 14px;
}

.auth-alert-error {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--danger);
}

.auth-alert-success {
    background: color-mix(in srgb, var(--success) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
    color: var(--success);
}

/* ---------- 表单 ---------- */
/* V96 152 号：注册页由单列 1×7 改为 2 列网格（用户反馈第 3 条）。
   `minmax(0, 1fr)` 而不是 `1fr`：grid 项默认 `min-width: auto`，会被内容撑破 ——
   注册页 captcha 那格里有 `<img width="150" height="50">`，用 `1fr` 时右列会被它撑宽，
   左列跟着变窄，整行塌掉。`minmax(0, 1fr)` 允许格子收缩到 0，是这类布局的必要写法。
   `align-items: start`：左右两格的 label 高度可能不同（长文案会换行），
   不加这一条会把另一格的输入框往下拽，看起来像没对齐。
   ⚠️ 登录/找回/重置三个页面也是 `.auth-form`，但它们只有 1 列内容 ——
   由下面的 `.auth-form:not(.auth-form--grid)` 兜住，不会被强行分列。 */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-form--grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
    align-items: start;
}

/* 跨满整行的格子：邀请码、turnstile、提交按钮 */
.form-group--full {
    grid-column: 1 / -1;
}

/* 「邀请码靠左单独一行」—— 跨满行但它自己是靠左的短宽度，
   不写这条会跟着整行拉满，看起来像是主要字段。
   `justify-self: start` + `max-width` 两条都要：前者管网格内定位，后者管它别太宽。 */
.form-group--full .input-wrapper,
.form-group--full input {
    max-width: 320px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* V96 152 号：`.input-icon` 整块删除 —— 用户反馈第 1 条要求去掉输入框里的
   👤/🔑/📧/🔒 小图标。删除而不是换 SVG 的理由：这四个字段**本来就有可见且绑定 for 的
   <label>**，图标是同一信息的第二份副本；而用户的原话是「不太好看」＝要去掉，
   换成另一个图标并没有回应这个诉求。
   连带把下面 input 的左内边距从 40px 收到 12px —— 图标没了还留着 40px 空白，
   会让文字看起来「悬在框中间」，是典型的伪修复。 */

.input-wrapper input {
    width: 100%;
    /* 左右对称：无图标后左侧不再需要预留空间 */
    padding: 10px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 8px);
    color: var(--text);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

/* 只有带显隐按钮的密码框才在右侧留出 40px。
   为什么用显式 class 而不是 `:has(.password-toggle)`：`:has()` 在不支持的浏览器上
   会**整条规则失效**且不报错，后果是密码文字被按钮压住 —— 失败静默且难看。
   显式 class 多写一处，但行为在所有浏览器里一致。 */
.input-wrapper--pw input {
    padding-right: 40px;
}

.input-wrapper input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

/* V96 152 号：按钮内容从「一个字形」换成 inline SVG（由 /js/password-toggle.js 注入）。
   因此这里必须补 flex 居中 —— 原先靠 `font-size` + 文本基线对齐，SVG 没有文本基线，
   不居中的话 18×18 的图标会贴在按钮左上角。`line-height: 0` 去掉行盒带来的额外高度，
   否则按钮会比图标高出一截，在右侧看起来没对齐输入框的中线。 */
.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    background: none;
    border: none;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 6px;
    color: var(--text-muted);
    border-radius: 6px;
}

.password-toggle:hover {
    color: var(--text);
    background: var(--accent-soft);
}

/* SVG 不吃点击：它只是按钮里的颜料，命中区域必须是按钮本身 */
.password-toggle svg {
    pointer-events: none;
    display: block;
}

/* 键盘可达性：显隐按钮虽然 tabindex="-1"（不抢 Tab 序列），
   但用 Tab 之外的路径聚焦到它时（例如读屏软件移动光标）必须看得见焦点框。 */
.password-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* ---------- 验证码 ---------- */
/* V96 152 号：注册页的验证码从「挤在 .input-wrapper 里」拆成独立一行。
   原先 <img width="150" height="50"> 直接放在 flex 的 .input-wrapper 里，
   而 input 是 width:100% ⇒ 两者抢宽度，图片被压扁或溢出到格子外
   （2 列网格下每列只有约 300px，150px 图片 + 输入框根本排不开）。
   现在输入框与图片各占一行：输入框照常 100%，图片在下方左对齐、点它刷新。 */
.auth-captcha-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

/* 2026-11-08（165 F-12）：`hidden` 属性会被上面的 display:flex 覆盖，
   导致拼图显示后字符码仍留在页面上。必须显式压掉。 */
.auth-captcha-row[hidden] {
    display: none;
}

.auth-captcha-row input {
    width: 100%;
}

.auth-captcha-row img {
    border-radius: var(--radius-sm, 8px);
    border: 1px solid var(--border);
    cursor: pointer;
    height: 50px;
    width: auto;
    /* 图片是高对比的浅底噪点图，在深色卡片里会发光 —— 压一点亮度更协调，
       同时保持文字可读（不要压到看不清字符） */
    opacity: 0.92;
}

.auth-captcha-row img:hover {
    opacity: 1;
    border-color: var(--accent);
}

/* ⚠️ V96 152 号：原 `.auth-login-captcha { display: none }` **必须保留**。
   login.html:101 的 `#loginCaptcha` 只有服务端 `showCaptcha` 为真时才追加 `.visible`，
   默认是隐藏的；删掉这条基础规则等于把验证码常驻显示在登录页上。 */
.auth-login-captcha {
    display: none;
}

.auth-login-captcha.visible {
    display: block;
}

/* 2026-11-08（165 F-12 / 148）：拼图验证码 */
.puzzle-captcha {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.puzzle-captcha[hidden] {
    display: none;
}

.puzzle-stage {
    position: relative;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 2 / 1;
    border-radius: var(--radius-sm, 8px);
    overflow: hidden;
    background: var(--paper-1);
    border: 1px solid var(--border);
    touch-action: none;
}

#puzzleBg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    user-select: none;
    -webkit-user-drag: none;
}

#puzzlePiece {
    position: absolute;
    left: 0;
    top: 0;
    width: 13.75%;
    height: 27.5%;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    filter: drop-shadow(0 2px 4px color-mix(in srgb, var(--overlay-ink) 45%, transparent));
}

.puzzle-slider {
    width: 100%;
    max-width: 320px;
}

.puzzle-track {
    position: relative;
    height: 40px;
    border-radius: 20px;
    background: color-mix(in srgb, var(--text-on-solid) 6%, transparent);
    border: 1px solid var(--border);
}

.puzzle-thumb {
    position: absolute;
    left: 0;
    top: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--text-on-solid);
    cursor: grab;
    touch-action: none;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--overlay-ink) 35%, transparent);
}

.puzzle-thumb:active {
    cursor: grabbing;
}

.puzzle-thumb:focus-visible {
    outline: 2px solid var(--text-on-solid);
    outline-offset: 2px;
}

.puzzle-hint {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.puzzle-hint--error {
    color: var(--danger);
}

.auth-captcha {
    display: flex;
    gap: 10px;
    align-items: center;
}

.auth-captcha input {
    flex: 1;
}

.auth-captcha-img {
    border-radius: var(--radius-sm, 8px);
    border: 1px solid var(--border);
    cursor: pointer;
    height: 50px;
}

/* ---------- 表单选项 ---------- */
.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-wrapper input {
    accent-color: var(--accent);
}

.forgot-link {
    color: var(--accent);
    text-decoration: none;
}

.forgot-link:hover {
    text-decoration: underline;
}

/* ---------- 提交按钮 ---------- */
.btn-submit {
    position: relative;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-to));
    border: none;
    border-radius: var(--radius-sm, 8px);
    color: var(--text-on-solid);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
}

.btn-submit:hover {
    opacity: 0.92;
}

.btn-submit:active {
    transform: translateY(1px);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-submit .btn-loading {
    display: none;
}

.btn-submit.loading .btn-text {
    display: none;
}

.btn-submit.loading .btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--overlay-caption);
    border-top-color: var(--text-on-solid);
    border-radius: 50%;
    animation: auth-spin 0.8s linear infinite;
}

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

/* ---------- 分隔线与 OAuth ---------- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.72rem;
    margin: 18px 0 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-oauth {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-oauth {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 8px);
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 500;
    text-decoration: none;
    transition: border-color 0.2s, background 0.2s;
}

.btn-oauth:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* ---------- 页脚 ---------- */
.auth-footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 18px;
}

.auth-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ---------- OAuth 关联页 ---------- */
.oauth-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 8px);
    margin-bottom: 10px;
}

.oauth-item .oauth-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text);
}

.btn-unlink {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
    background: transparent;
    color: var(--danger);
    font-size: 0.76rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-unlink:hover {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.btn-link {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--text-on-solid);
    font-size: 0.76rem;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-link:hover {
    opacity: 0.88;
}

/* ---------- 密码强度（注册页） ---------- */
/* V96 152 号：强度条三处契约修复。
   修复前的实际状态（三处互不匹配，从上线起**从未显示过任何颜色**）：
     · 模板 `#pwBar` 是**空的**，没有任何子元素
     · CSS 要 `.auth-pw-bar span{flex:1;height:4px}` ⇒ 选择器永不命中
     · 脚本给**父元素**加 weak/fair/good/strong ⇒ CSS 里 weak/fair/good 根本没有规则，
       唯一同名的 strong 也要 `.auth-pw-bar span.strong`（要求 span 后代）⇒ 同样不命中
   现在的契约（唯一）：**模板静态给 4 个 `.pw-seg`，脚本只写父元素的 `data-level`**，
   CSS 按 `[data-level="X"]` 着色。三处各司其职、互不猜测：
     · 段数属于结构 ⇒ 归模板（SSR 首屏即有，不依赖 JS 跑完）
     · 颜色映射属于表现 ⇒ 归 CSS
     · 评级计算属于逻辑 ⇒ 归脚本（只改一个属性，不改结构也不改 class 列表） */
.auth-pw-bar {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.auth-pw-bar .pw-seg {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    /* 未着色时的底槽：浅到不抢视线，但能看到「一共会有几段」 */
    background: var(--border);
    transition: background 0.3s;
}

/* none（空输入）：只有底槽，整块由 #pwStrength 的 hidden 属性藏起来，
   这里仍给一条兜底，防止有值但评级为 none 的边界情况露出一根彩色条 */
.auth-pw-bar[data-level="none"] .pw-seg {
    background: var(--border);
}

.auth-pw-bar[data-level="weak"] .pw-seg {
    background: var(--danger);
}

.auth-pw-bar[data-level="fair"] .pw-seg {
    background: var(--warning);
}

.auth-pw-bar[data-level="good"] .pw-seg {
    background: var(--blue);
}

.auth-pw-bar[data-level="strong"] .pw-seg {
    background: var(--success);
}

/* 分级胜出：分数越高点亮越多段。全亮读起来才是「满格」，
   而不是「一根整条变色」—— 后者无法表达「4 段里亮到第 2 段」。 */
.auth-pw-bar[data-level="weak"] .pw-seg:nth-child(n+2),
.auth-pw-bar[data-level="fair"] .pw-seg:nth-child(n+3),
.auth-pw-bar[data-level="good"] .pw-seg:nth-child(n+4) {
    background: var(--border);
}

.auth-pw-strength {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---------- 随机强密码（注册页，V96 148 号） ---------- */
.pw-gen-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.pw-gen-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.78rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.pw-gen-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.pw-gen-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* 生成结果提示：role=status 区域，空时高度为 0 以免占位跳动 */
.pw-gen-note {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
    min-height: 0;
    line-height: 1.5;
}

.pw-gen-note:empty {
    display: none;
}

/* ---------- 返回链接 ---------- */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-decoration: none;
    margin-bottom: 16px;
}

.back-link:hover {
    color: var(--accent);
}

/* ---------- 响应式 ---------- */
/* V96 152 号：640px 单列回退。
   为什么不是复用下面的 480px：`auth-card` 在 480px 才有 `padding: 24px 18px`，
   若到 480px 才回单列，则 480–640px 区间（常见平板竖屏）会是**两列各约 200px** ——
   而注册页 captcha 那格里有 `<img width="150" height="50">` 加输入框，根本放不下，
   会被压成一条或直接溢出。640px 让「两列放得下」成为回单列的唯一依据。 */
@media (max-width: 640px) {
    .auth-form--grid {
        grid-template-columns: 1fr;
    }

    /* 单列下所有格子本来就占满一行，跨列声明失去意义，
       但留着会让 `max-width: 320px` 之外的行为产生歧义（跨 1 列 vs 跨 -1 列），
       因此显式归零，让单列布局只有一套解释。 */
    .form-group--full {
        grid-column: auto;
    }

    .form-group--full .input-wrapper,
    .form-group--full input {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 24px 18px;
    }

    .auth-container {
        padding: 16px 10px;
    }
}
