/* ============================================================
 * NURSX 面板 · 动态透明玻璃 + 摇摆按压 v13「Glass & Tilt」
 * ------------------------------------------------------------
 * 加载顺序：panel-v10.css → panel-v11.css → panel-v12.css → 本文件
 *
 * 三件事：
 *   ① 动态透明玻璃——柔和低饱和极光缓慢漂移；玻璃面用「低白色填充 +
 *      高模糊 + 细高光边 + 一道斜向高光」做出通透感，而不是奶白磨砂。
 *   ② 摇摆按压——按下长方形面时不再整体缩小，而是：
 *      摁哪边哪边下沉、对边翘起（按落点算 rotateX / rotateY），
 *      松手由 spring 过冲弹回。打点由 /assets/vx-press.js 负责。
 *   ③ 触点柔光——按下处一圈很淡的柔光，不抢戏。
 *
 * 约定：
 *   · 不在 :root 上重声明 v12 的 --glass-*：媒体查询里的 :root 与普通
 *     :root 同特异度，源码序在后的会连触屏降级一起盖掉。改为在
 *     body.has-sidebar / body.auth-body-page 作用域内声明。
 *   · 不给已有组件加 border / 改盒模型（用 inset box-shadow 画高光边），
 *     避免任何布局位移。
 *
 * 回滚 = 去掉页面里的本文件 <link> 与 vx-press.js 的 <script>。
 * ============================================================ */

/* ── 1. 令牌 ─────────────────────────────────────────────── */
:root {
    /* 极光：低饱和柔光，避免整片浓紫 */
    --nd-aurora-1: rgba(99, 102, 241, 0.30);   /* 靛蓝 */
    --nd-aurora-2: rgba(56, 189, 248, 0.24);   /* 天青 */
    --nd-aurora-3: rgba(244, 114, 182, 0.13);  /* 一点暖粉提亮 */
    /* 触点柔光 */
    --nd-touch-core: rgba(79, 70, 229, 0.16);
    --nd-touch-edge: rgba(79, 70, 229, 0.06);
    /* 摇摆按压 */
    --nd-tilt: 5deg;          /* 落点靠在边角时的最大翘起角 */
    --nd-tilt-scale: 0.993;   /* 整体再压一点点，增加「按实」的实感 */
}

/* 完全通透档（深色玻璃）里触点改用白光 */
body.user-bg-clear {
    --nd-touch-core: rgba(255, 255, 255, 0.20);
    --nd-touch-edge: rgba(255, 255, 255, 0.07);
}

/* ── 2. 动态极光背景 ─────────────────────────────────────────
 * 两块超大柔光斑固定在视口，只用 transform 漂移（合成层动画，
 * 不触发重排）。自定义背景（glass / sheer / clear 三档）时整块关掉。
 * ------------------------------------------------------------ */
body::before,
body::after {
    content: "";
    position: fixed;
    z-index: -1;
    pointer-events: none;
    border-radius: 50%;
    filter: blur(50px);
    opacity: 0.55;
    will-change: transform;
}
body::before {
    width: 58vmax; height: 58vmax;
    left: -18vmax; top: -24vmax;
    background:
        radial-gradient(circle at 34% 34%, var(--nd-aurora-1), transparent 64%),
        radial-gradient(circle at 68% 60%, var(--nd-aurora-3), transparent 58%);
    animation: ndAuroraA 28s ease-in-out infinite alternate;
}
body::after {
    width: 50vmax; height: 50vmax;
    right: -16vmax; bottom: -22vmax;
    background: radial-gradient(circle at 44% 44%, var(--nd-aurora-2), transparent 66%);
    animation: ndAuroraB 34s ease-in-out infinite alternate;
}
@keyframes ndAuroraA {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(7vmax, 5vmax, 0) scale(1.10); }
    100% { transform: translate3d(-4vmax, 8vmax, 0) scale(0.97); }
}
@keyframes ndAuroraB {
    0%   { transform: translate3d(0, 0, 0) scale(1.05); }
    50%  { transform: translate3d(-8vmax, -6vmax, 0) scale(0.95); }
    100% { transform: translate3d(5vmax, -3vmax, 0) scale(1.12); }
}
body.user-bg::before, body.user-bg::after,
body.user-bg-sheer::before, body.user-bg-sheer::after,
body.user-bg-clear::before, body.user-bg-clear::after { display: none; }

/* ── 3. 通透玻璃令牌 ─────────────────────────────────────────
 * 作用域比 v12 的 :root 更具体，避开「媒体查询 :root vs 普通 :root」
 * 的层叠陷阱；只在未使用自定义背景时生效，自定义背景仍交给 v11。
 * ------------------------------------------------------------ */
body.has-sidebar:not(.user-bg):not(.user-bg-sheer):not(.user-bg-clear),
body.auth-body-page {
    --glass-bg: rgba(255, 255, 255, 0.30);
    --glass-bg-strong: rgba(255, 255, 255, 0.50);
    --glass-border: rgba(255, 255, 255, 0.55);
    --glass-shadow: 0 8px 30px rgba(15, 23, 42, 0.07);
    --glass-shadow-hover: 0 16px 46px rgba(15, 23, 42, 0.11);
    --glass-blur: 22px;
    --glass-backdrop: blur(var(--glass-blur)) saturate(140%);
}

body.auth-body-page { padding: 26px; }

/* ── 4. 认证页（登录 / 注册 / 绑定）─────────────────────────── */
.auth-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0.22));
    backdrop-filter: var(--glass-backdrop);
    -webkit-backdrop-filter: var(--glass-backdrop);
    border-color: var(--glass-border);
    box-shadow: 0 30px 70px -42px rgba(15, 23, 42, 0.30),
                0 6px 20px -14px rgba(15, 23, 42, 0.10),
                inset 0 1px 0 rgba(255, 255, 255, 0.60);
}
.auth-header {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.02));
    border-bottom-color: var(--glass-border);
}
body.auth-body-page input[type="text"],
body.auth-body-page input[type="password"],
body.auth-body-page input[type="number"],
body.auth-body-page input[type="email"],
body.auth-body-page input[type="search"],
body.auth-body-page input[type="url"],
body.auth-body-page input[type="tel"],
body.auth-body-page select,
body.auth-body-page textarea,
body.auth-body-page input[type="file"] {
    background: rgba(255, 255, 255, 0.42);
    border-color: var(--glass-border);
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
body.auth-body-page input[type="text"]:focus,
body.auth-body-page input[type="password"]:focus,
body.auth-body-page input[type="number"]:focus,
body.auth-body-page input[type="email"]:focus,
body.auth-body-page input[type="search"]:focus,
body.auth-body-page input[type="url"]:focus,
body.auth-body-page input[type="tel"]:focus,
body.auth-body-page select:focus,
body.auth-body-page textarea:focus {
    background: rgba(255, 255, 255, 0.70);
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* ── 5. 分段控件（顶部页签 / 角色切换）玻璃 ─────────────────── */
.tabs,
.role-switch {
    background: rgba(255, 255, 255, 0.26);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.46),
                inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.tabs button.active,
.role-switch button.active {
    background: rgba(255, 255, 255, 0.74);
    box-shadow: 0 6px 16px -8px rgba(15, 23, 42, 0.24),
                inset 0 0 0 1px rgba(79, 70, 229, 0.12);
}
.tabs button:not(.active):hover,
.role-switch button:not(.active):hover { background: rgba(255, 255, 255, 0.44); }

/* ── 6. 主按钮：保留品牌实心，只柔化投影 ───────────────────── */
.login-btn {
    border-radius: 16px;
    box-shadow: 0 14px 30px -16px var(--brand-glow),
                inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.login-btn:hover {
    transform: translateY(-2px) scale(1.012);
    box-shadow: 0 20px 40px -18px var(--brand-glow),
                inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

/* ── 7. 玻璃面：斜向高光 + 细描边 ────────────────────────────
 * ① 一道 150° 的白色斜向高光（很淡），让「玻璃」有厚度而不是一块白；
 * ② 内顶边白光 + 一圈极淡描边，接住 v12 的投影定义。
 * 表头不加模糊（避免横向滚动反复重采样），只用半透明白 + 顶边高光。
 * ------------------------------------------------------------ */
.card, .stat-item, .row-card, .project-item, .modal, .search-bar, .batch-bar,
.alert-box, .alert-info, .alert-warning, .log-row, .tag-filter-bar, .font-dial,
.tilt-card, .record-bar {
    background-image: linear-gradient(150deg,
        rgba(255, 255, 255, 0.30) 0%,
        rgba(255, 255, 255, 0.05) 46%,
        rgba(255, 255, 255, 0.18) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.50),
                var(--glass-shadow),
                0 0 0 1px rgba(255, 255, 255, 0.26);
}
.card:hover, .stat-item:hover, .row-card:hover, .project-item:hover,
.search-bar:hover, .batch-bar:hover, .alert-box:hover, .alert-info:hover,
.alert-warning:hover, .log-row:hover {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.66),
                var(--glass-shadow-hover),
                0 0 0 1px rgba(255, 255, 255, 0.32);
}

.card table th {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(255, 255, 255, 0.26));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.sb-item {
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.10));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38),
                inset 0 1px 0 rgba(255, 255, 255, 0.44);
}
.sb-item:hover {
    background: rgba(255, 255, 255, 0.60);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55),
                inset 0 1px 0 rgba(255, 255, 255, 0.64);
}

/* 侧栏 / 顶栏（未使用自定义背景时） */
body.has-sidebar:not(.user-bg):not(.user-bg-sheer):not(.user-bg-clear) .sidebar {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.40));
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.45),
                18px 0 46px -34px rgba(15, 23, 42, 0.26);
}
body.has-sidebar:not(.user-bg):not(.user-bg-sheer):not(.user-bg-clear) .topbar {
    background: rgba(255, 255, 255, 0.46);
    backdrop-filter: var(--glass-backdrop);
    -webkit-backdrop-filter: var(--glass-backdrop);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

/* ── 8. 松手回弹：给目标补 spring 过渡 ───────────────────────
 * 按下由 .nd-tilt 切成 0.09s 的快节奏（见 §9），松手回到这里的
 * 0.44s spring 曲线，过冲量让翘起的一边「弹」回原位。
 * ------------------------------------------------------------ */
button, a[href], [role="button"], summary,
.btn-action, .btn, .btn-info, .btn-danger, .btn-success, .btn-warning,
.btn-secondary, .btn-copy, .btn-select-mode, .btn-select-all,
.login-btn, .sb-item, .sb-user, .sb-out, .sb-close, .tb-mini, .tb-menu,
.tabs button, .role-switch button, .bg-fab, .bg-mode-opt, .bg-seg-opt,
.pst, .star-btn, .sw, .tag-chip, .tag-deletable, .password-toggle,
.autocomplete-item, .fd-btn, .font-dial .fd-thumb {
    transition: transform 0.44s var(--ease-spring),
                background-color var(--t-fast) var(--ease-out),
                border-color var(--t-fast) var(--ease-out),
                color var(--t-fast) var(--ease-out),
                box-shadow 0.30s var(--ease-out);
}
.card, .stat-item, .row-card, .project-item, .auth-card, .modal, .search-bar,
.batch-bar, .log-row, .alert-box, .alert-info, .alert-warning, .tag-filter-bar,
.tilt-card, .record-bar, .font-dial, .tabs, .role-switch {
    transition: transform 0.44s var(--ease-spring),
                box-shadow 0.34s var(--ease-out),
                background-color 0.30s var(--ease-out),
                border-color 0.30s var(--ease-out);
}
/* 输入框聚焦时轻轻上浮（只在有鼠标的设备上，避免手机键盘弹出跳动） */
@media (hover: hover) and (pointer: fine) {
    input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus,
    input[type="email"]:focus, input[type="search"]:focus, input[type="url"]:focus,
    input[type="tel"]:focus, select:focus, textarea:focus {
        transform: translateY(-1px);
    }
}

/* ── 9. 摇摆按压（由 vx-press.js 打点 / 摘除） ───────────────
 * JS 按落点直接写内联 transform：
 *   perspective(1000px) rotateX(-dy*k) rotateY(dx*k) scale(s)
 * —— 摁左边 → 左边向下沉、右边翘起；摁右下 → 右下沉、左上翘。
 * 内联样式优先于 v10 的 button:active / v12 §18 的 :hover 归零，不会被吃掉。
 * 这里只负责「按下要快」这一段节奏，松手用 §8 的 spring。
 * ------------------------------------------------------------ */
.nd-tilt {
    transition: transform 0.09s var(--ease-out) !important;
}

/* ── 10. 触点柔光 ────────────────────────────────────────────
 * 覆盖层固定铺满视口、pointer-events:none，光斑画在里面：
 * 不改动任何元素的布局、定位、overflow，也不影响点击落点。
 * ------------------------------------------------------------ */
#ndTouchLayer {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    pointer-events: none;
    overflow: hidden;
}
.nd-touch {
    position: absolute;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--nd-touch-core) 0%, var(--nd-touch-edge) 46%, transparent 68%);
    animation: ndTouchBloom 0.55s var(--ease-out) forwards;
    will-change: transform, opacity;
}
@keyframes ndTouchBloom {
    from { transform: scale(0.5); opacity: 0.9; }
    to   { transform: scale(4.2); opacity: 0; }
}

/* ── 11. 无障碍：尊重「减弱动态效果」 ──────────────────────── */
@media (prefers-reduced-motion: reduce) {
    body::before, body::after { animation: none; }
    .nd-touch { display: none; }
    .nd-tilt { transition: none !important; }
    button, a[href], [role="button"], summary,
    .card, .stat-item, .row-card, .project-item, .auth-card, .modal, .search-bar,
    .batch-bar, .log-row, .alert-box, .alert-info, .alert-warning, .tag-filter-bar,
    .tilt-card, .record-bar, .font-dial, .sb-item, .tabs button, .role-switch button,
    .btn-action, .btn, .btn-info, .btn-danger, .btn-success, .btn-warning,
    .btn-secondary, .btn-copy, .btn-select-mode, .btn-select-all, .login-btn {
        transition: none !important;
    }
}

/* ── 12. 窄屏 / 触屏：保玻璃、停动画 ─────────────────────────
 * 触屏同样保留真实磨砂玻璃（旧版这里把模糊整层关掉，手机上完全
 * 看不到玻璃）。只做两件代价控制：
 *   ① 极光停掉动画——无限动画 + 每帧重采样背后内容正是安卓滚动
 *      闪烁的根因（v12 §16 记录过）；静态极光保留颜色不重绘。
 *   ② 模糊半径降到 12px，降低逐帧重采样开销。
 * 随内容滚动的卡片不挂 backdrop-filter（避免滚动反复重采样），
 * 改用半透明玻璃渐变 + v13 §7 的高光边，观感仍是玻璃。
 * 想在触屏上强制「全量模糊」：给 <body> 加类 nd-glass-all。
 * ------------------------------------------------------------ */
@media (max-width: 900px), (hover: none) and (pointer: coarse) {
    body.has-sidebar:not(.user-bg):not(.user-bg-sheer):not(.user-bg-clear),
    body.auth-body-page {
        --glass-blur: 12px;
        --glass-backdrop: blur(var(--glass-blur)) saturate(135%);
        --glass-bg: rgba(255, 255, 255, 0.46);
        --glass-bg-strong: rgba(255, 255, 255, 0.64);
    }

    /* 极光：留色、停动画（消除持续重绘） */
    body::before, body::after { animation: none; opacity: 0.46; filter: blur(44px); }

    /* ① 保留真实模糊：认证面 + 固定外壳（不随内容滚动）
     *    同特异度 + 本文件后加载 => 盖掉 v12 §16 的 none !important */
    .auth-card, .auth-header, .tabs, .role-switch,
    body.auth-body-page input[type="text"],
    body.auth-body-page input[type="password"],
    body.auth-body-page input[type="number"],
    body.auth-body-page input[type="email"],
    body.auth-body-page input[type="search"],
    body.auth-body-page input[type="url"],
    body.auth-body-page input[type="tel"],
    body.auth-body-page input[type="file"],
    body.auth-body-page select,
    body.auth-body-page textarea,
    .appbar, .topbar, .bottomnav, .sidebar {
        backdrop-filter: var(--glass-backdrop) !important;
        -webkit-backdrop-filter: var(--glass-backdrop) !important;
    }

    /* ② 滚动内容里的卡片：不模糊，用玻璃渐变 + 高光边补玻璃观感 */
    .card, .card-row, .stat-item, .row-card, .project-item, .search-bar,
    .batch-bar, .log-row, .alert-box, .alert-info, .alert-warning,
    .modal, .upload-modal, .tilt-card, .tag-filter-bar, .font-dial, .record-bar,
    .tag-chip, .tag-deletable, .autocomplete-panel {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    .card, .stat-item, .row-card, .project-item, .modal, .search-bar, .batch-bar,
    .alert-box, .alert-info, .alert-warning, .log-row {
        background-image: linear-gradient(152deg,
            rgba(255, 255, 255, 0.58) 0%,
            rgba(255, 255, 255, 0.26) 52%,
            rgba(255, 255, 255, 0.44) 100%);
    }

    /* ③ 可选开关：触屏也全量模糊（审美优先于滚动帧率时使用） */
    body.nd-glass-all .card, body.nd-glass-all .stat-item, body.nd-glass-all .row-card,
    body.nd-glass-all .project-item, body.nd-glass-all .search-bar, body.nd-glass-all .batch-bar,
    body.nd-glass-all .log-row, body.nd-glass-all .modal, body.nd-glass-all .alert-box,
    body.nd-glass-all .alert-info, body.nd-glass-all .alert-warning,
    body.nd-glass-all input[type="text"], body.nd-glass-all input[type="password"],
    body.nd-glass-all input[type="number"], body.nd-glass-all input[type="email"],
    body.nd-glass-all select, body.nd-glass-all textarea {
        backdrop-filter: var(--glass-backdrop) !important;
        -webkit-backdrop-filter: var(--glass-backdrop) !important;
    }
}
