/* ============================================================
   Animated OTP 聚合验证动画组件（独立样式，供用户中心等页面引入）
   提取自 auth.css：弹窗 + 方格动画 + 已通过验证徽章
   流程：逐格输入(单格SVG描边发光) → 方框之间连线动态绘制成回路
        → 方框旋转缩放向中心聚拢消失 → 切换成功对勾视图
   删除任意字符自动重置回初始状态
   格子尺寸由 JS 按可用宽度自适应写入 --aotp-box（34~56px）
   ============================================================ */
:root{
    --tblue:#2563eb;
    --tdanger:#ef4444;
}

/* 外层（页面标记）：组件 + 发送按钮纵向排列 */
.aotp-row{display:flex;flex-direction:column;align-items:stretch;gap:12px;}

.aotp{
    --aotp-box:56px;
    --aotp-gap:12px;
    --aotp-radius:13px;
    position:relative;
    width:100%;
}

/* 唯一真实输入框：视觉隐藏但可聚焦（移动端键盘 / iOS 短信自动填充） */
.aotp-src{
    position:absolute;left:0;top:0;
    width:1px;height:1px;
    opacity:0;border:none;padding:0;
    background:transparent;outline:none;
    font-size:16px; /* iOS 聚焦不缩放 */
}

/* 重叠层容器：格子区 / 连线层 / 成功视图 叠在同一格 */
.aotp-grid{
    display:grid;
    width:fit-content;
    max-width:100%;
    margin:0 auto;
    padding:8px;
}
.aotp-grid>*{grid-area:1/1;}

.aotp-cells{
    position:relative;
    z-index:1;
    display:flex;flex-wrap:wrap;justify-content:center;
    gap:var(--aotp-gap);
}
/* 强制换行分隔：6位=3+3，7位=4+3（不依赖宽度自动换行） */
.aotp-break{flex-basis:100%;height:0;}

.aotp-cell{
    flex:none;
    width:var(--aotp-box);height:var(--aotp-box);
    position:relative;
    transition:transform .65s cubic-bezier(.5,-.15,.75,.35),opacity .5s ease;
    will-change:transform,opacity;
}
/* 展示方格：数字由隐藏输入框同步写入 */
.aotp-val{
    display:flex;align-items:center;justify-content:center;
    width:100%;height:100%;
    background:#0d1526;
    border:1px solid rgba(148,163,184,.28);
    border-radius:var(--aotp-radius);
    color:#eaf6ff;
    font-size:18px;
    font-size:max(16px, calc(var(--aotp-box)*.36));
    font-weight:700;font-family:inherit;
    box-shadow:inset 0 2px 8px rgba(2,8,23,.45);
    transition:border-color .25s,box-shadow .25s,background .25s,color .25s;
}
.aotp-cell.filled .aotp-val{
    border-color:rgba(34,211,238,.12);
    box-shadow:0 0 16px rgba(34,211,238,.25),inset 0 2px 8px rgba(2,8,23,.4);
}

/* 单格 SVG 描边：输入数字时沿方框画出 */
.aotp-trace{
    position:absolute;left:-1px;top:-1px;
    width:calc(100% + 2px);height:calc(100% + 2px);
    pointer-events:none;overflow:visible;
}
.aotp-trace rect{
    fill:none;stroke:#22d3ee;stroke-width:2;stroke-linecap:round;
    stroke-dasharray:100;stroke-dashoffset:100;
    filter:drop-shadow(0 0 4px rgba(34,211,238,.55));
}
.aotp-cell.filled .aotp-trace rect{animation:aotpDraw .55s ease forwards;}

/* 模拟闪烁光标（仅空且聚焦的格子） */
.aotp-cell.active::after{
    content:"";
    position:absolute;left:50%;top:50%;
    width:2px;height:calc(var(--aotp-box)*.4);
    transform:translate(-50%,-50%);
    border-radius:1px;
    background:#22d3ee;
    animation:aotpBlink 1.1s steps(1,end) infinite;
    pointer-events:none;
}
.aotp-cell.filled.active::after,
.aotp.complete .aotp-cell::after,
.aotp.collapse .aotp-cell::after{display:none;}

/* 方框之间的连线：输满后按回路逐段绘制（两端缩进到格子边缘外） */
.aotp-lines{
    z-index:3;
    width:100%;height:100%;
    pointer-events:none;overflow:visible;
}
.aotp-lines line{
    stroke:#22d3ee;stroke-width:2.5;stroke-linecap:round;
    stroke-dasharray:1;stroke-dashoffset:1;opacity:0;
    filter:drop-shadow(0 0 4px rgba(34,211,238,.7));
}
.aotp.complete .aotp-lines line{
    stroke-dashoffset:0;opacity:.95;
    transition:stroke-dashoffset .16s ease var(--ld,0ms),opacity .15s linear var(--ld,0ms);
}

/* 阶段二：方框旋转缩放向中心聚拢，连线淡出 */
.aotp.collapse .aotp-cell{
    transform:translate(var(--tx,0px),var(--ty,0px)) rotate(var(--rot,0deg)) scale(.06);
    opacity:0;
    transition-delay:var(--d,0ms);
    pointer-events:none;
}
.aotp.collapse .aotp-lines line{opacity:0;transition:opacity .3s ease;}

/* 阶段三：验证成功视图（绿色对勾方块） */
.aotp-done{
    z-index:2;
    display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;
    opacity:0;transform:scale(.7);
    pointer-events:none;cursor:pointer;
    transition:opacity .35s ease,transform .55s cubic-bezier(.34,1.56,.64,1);
}
.aotp.success .aotp-done{opacity:1;transform:none;pointer-events:auto;}
.aotp-done-box{
    width:64px;height:64px;
    width:min(64px, calc(var(--aotp-box) + 16px));
    height:min(64px, calc(var(--aotp-box) + 16px));
    border-radius:32%;
    display:flex;align-items:center;justify-content:center;
    background:#0b1626;
    border:2px solid rgba(74,222,128,.85);
    box-shadow:0 0 22px rgba(74,222,128,.35),inset 0 0 14px rgba(74,222,128,.12);
}
.aotp-done-box svg{width:48%;height:48%;}
.aotp-done-box path{
    fill:none;stroke:#4ade80;stroke-width:2.6;
    stroke-linecap:round;stroke-linejoin:round;
    stroke-dasharray:1;stroke-dashoffset:1;
}
.aotp.success .aotp-done-box path{
    stroke-dashoffset:0;
    transition:stroke-dashoffset .45s ease .25s;
}
.aotp-done-pill{
    display:inline-flex;align-items:center;gap:6px;
    padding:4px 12px;border-radius:999px;
    background:rgba(74,222,128,.12);
    border:1px solid rgba(74,222,128,.35);
    font-size:11.5px;font-weight:600;color:#15803d;
    white-space:nowrap;
}
.aotp-done-pill i{font-size:10px;}

/* 瞬时复位：删除字符时所有动画立即回到初始状态 */
.aotp.resetting .aotp-cell,
.aotp.resetting .aotp-lines line,
.aotp.resetting .aotp-done,
.aotp.resetting .aotp-done-box path{transition:none!important;}
.aotp.resetting .aotp-trace rect{animation:none!important;}

/* 组件下方的发送按钮（覆盖 .code-btn 的绝对定位） */
.aotp-send{
    position:static;transform:none;
    width:100%;height:42px;
    white-space:nowrap;
}

/* 校验错误抖动 */
.aotp.aotp-error{animation:aotpShake .4s;}
.aotp.aotp-error .aotp-val{border-color:var(--tdanger);}

@keyframes aotpDraw{to{stroke-dashoffset:0;}}
@keyframes aotpBlink{
    0%,55%{opacity:1;}
    56%,100%{opacity:0;}
}
@keyframes aotpShake{
    0%,100%{transform:translateX(0);}
    20%{transform:translateX(-5px);}
    40%{transform:translateX(5px);}
    60%{transform:translateX(-3px);}
    80%{transform:translateX(3px);}
}

/* ============================================================
   白色验证码弹窗：点击「获取验证码」后弹出
   ============================================================ */
.otp-modal{
    position:fixed;left:0;top:0;right:0;bottom:0;
    /* 需高于 layui layer（z-index 从 19891014 起递增），否则弹窗会被 layer 遮罩盖住 */
    z-index:2147483647;
    visibility:hidden;
    pointer-events:none;
}
.otp-modal.open{visibility:visible;pointer-events:auto;}
.otp-modal-mask{
    position:absolute;left:0;top:0;right:0;bottom:0;
    background:rgba(15,23,42,.55);
    -webkit-backdrop-filter:blur(4px);
    backdrop-filter:blur(4px);
    opacity:0;
    transition:opacity .32s ease;
}
.otp-modal.open .otp-modal-mask{opacity:1;}

.otp-modal-card{
    position:absolute;left:50%;top:42%;
    width:min(340px, calc(100vw - 48px));
    padding:30px 22px 20px;
    background:#ffffff;
    border-radius:22px;
    text-align:center;
    box-shadow:0 24px 64px rgba(15,23,42,.30),0 4px 16px rgba(15,23,42,.12);
    opacity:0;
    transform:translate(-50%,-46%) scale(.84);
    transition:opacity .3s ease,transform .45s cubic-bezier(.34,1.56,.64,1);
}
.otp-modal.open .otp-modal-card{
    opacity:1;
    transform:translate(-50%,-50%) scale(1);
}

.otp-modal-close{
    position:absolute;right:12px;top:12px;
    width:30px;height:30px;
    border:none;border-radius:50%;
    background:#f1f5f9;color:#64748b;
    font-size:14px;line-height:1;
    cursor:pointer;
    transition:background .2s,color .2s,transform .2s;
}
.otp-modal-close:hover{background:#e2e8f0;color:#334155;transform:rotate(90deg);}

.otp-modal-ico{
    width:54px;height:54px;
    margin:0 auto 14px;
    border-radius:17px;
    display:flex;align-items:center;justify-content:center;
    background:linear-gradient(135deg,#60a5fa,#2563eb);
    color:#fff;font-size:24px;
    box-shadow:0 10px 22px rgba(37,99,235,.35);
}
.otp-modal-title{
    font-size:18px;font-weight:800;
    color:#0f172a;letter-spacing:1px;
}
.otp-modal-tip{
    margin-top:7px;
    font-size:12.5px;color:#64748b;
    letter-spacing:.4px;
}
.otp-modal-tip i{margin-right:5px;color:#2563eb;}

/* 状态提示行：校验中 / 正确 / 错误 */
.otp-modal-status{
    min-height:20px;margin-top:12px;
    font-size:13px;font-weight:600;
    opacity:0;transform:translateY(4px);
    transition:opacity .25s ease,transform .25s ease;
}
.otp-modal-status.show{opacity:1;transform:none;}
.otp-modal-status.checking{color:#64748b;}
.otp-modal-status.ok{color:#16a34a;}
.otp-modal-status.err{color:#dc2626;}
.otp-modal-status i{margin-right:5px;}

/* ---------- 弹窗内组件白色主题 ---------- */
.otp-modal .aotp-grid{padding:8px 8px 2px;}
.otp-modal .aotp-val{
    background:#f4f7fc;
    border-color:#dbe4f0;
    color:#0f2540;
    box-shadow:inset 0 2px 6px rgba(15,35,64,.05);
}
.otp-modal .aotp-cell.filled .aotp-val{
    background:#ffffff;
    border-color:rgba(37,99,235,.4);
    box-shadow:0 4px 14px rgba(37,99,235,.16),inset 0 1px 3px rgba(15,35,64,.04);
}
.otp-modal .aotp-trace rect{
    stroke:#2563eb;
    filter:drop-shadow(0 0 4px rgba(37,99,235,.45));
}
.otp-modal .aotp-cell.active::after{background:#2563eb;}
.otp-modal .aotp-lines line{
    stroke:#2563eb;
    filter:drop-shadow(0 0 4px rgba(37,99,235,.6));
}
.otp-modal .aotp-done-box{
    background:#f0fdf4;
    border-color:rgba(34,197,94,.85);
    box-shadow:0 10px 26px rgba(34,197,94,.28);
}
.otp-modal .aotp-done-box path{stroke:#16a34a;}
.otp-modal .aotp-done-pill{
    background:rgba(34,197,94,.1);
    border-color:rgba(34,197,94,.35);
    color:#15803d;
}
.otp-modal .aotp.aotp-error .aotp-val{
    border-color:#ef4444;
    background:#fef2f2;
    color:#dc2626;
}

/* 弹窗打开时格子逐个弹出入场（backwards 填充：延迟期内隐藏，结束即交还过渡控制） */
.otp-modal.open .aotp-cell{
    animation:aotpPop .5s cubic-bezier(.34,1.56,.64,1) backwards;
    animation-delay:calc(var(--i,0)*55ms + 140ms);
}
@keyframes aotpPop{
    from{opacity:0;transform:translateY(14px) scale(.5);}
    to{opacity:1;transform:translateY(0) scale(1);}
}

/* 已通过验证标记（内联状态）
   注意不用 hidden 属性控制显隐：作者样式里的 display:flex 会覆盖 UA 的
   display:none，所以用 .show 类切换 */
.code-done{
    display:none;align-items:center;gap:7px;
    padding:10px 14px;border-radius:12px;
    background:rgba(34,197,94,.08);
    border:1px solid rgba(34,197,94,.35);
    color:#15803d;font-size:13px;font-weight:600;
}
.code-done.show{display:flex;}
.code-done i{color:#16a34a;}
.code-done a{margin-left:auto;font-size:12px;color:var(--tblue);text-decoration:none;}
.code-done a:hover{text-decoration:underline;}

/* 弹窗内双组件切换（手机6位 / 邮箱7位） */
.aotp.hide{display:none!important;}
