/* ═══════════════════════════════════════════
   新手引导 Onboarding · 极光蓝玻璃拟态
   ═══════════════════════════════════════════ */

.onboarding-root {
    position: fixed;
    inset: 0;
    z-index: 8000;
    pointer-events: none;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.onboarding-root[hidden] { display: none; }

/* ── 整屏压暗（欢迎页 / 完成页） ── */
.onboarding-veil {
    position: absolute;
    inset: 0;
    opacity: 0;
    background:
        radial-gradient(circle at 50% 42%, rgba(24, 56, 116, 0.56), rgba(5, 14, 30, 0.82)),
        rgba(5, 14, 30, 0.2);
    backdrop-filter: blur(5px) saturate(1.15);
    -webkit-backdrop-filter: blur(5px) saturate(1.15);
    transition: opacity 0.5s ease;
}

.onboarding-root.is-visible .onboarding-veil { opacity: 1; }
.onboarding-root.is-targeted .onboarding-veil { opacity: 0; }

/* ── 四块目标挖空遮罩 ── */
.onboarding-pane {
    position: absolute;
    opacity: 0;
    background: rgba(6, 17, 36, 0.7);
    backdrop-filter: blur(4px) saturate(0.9);
    -webkit-backdrop-filter: blur(4px) saturate(0.9);
    transition:
        opacity 0.45s ease,
        top 0.62s cubic-bezier(0.22, 1, 0.36, 1),
        left 0.62s cubic-bezier(0.22, 1, 0.36, 1),
        width 0.62s cubic-bezier(0.22, 1, 0.36, 1),
        height 0.62s cubic-bezier(0.22, 1, 0.36, 1);
}

.onboarding-root.is-targeted.is-visible .onboarding-pane { opacity: 1; }

/* ── 点击拦截层 ── */
.onboarding-blocker {
    position: absolute;
    inset: 0;
    pointer-events: auto;
}

/* ── 高亮光斑 ── */
.onboarding-spotlight {
    position: fixed;
    z-index: 8004;
    opacity: 0;
    pointer-events: none;
    border-radius: 20px;
    box-shadow:
        0 0 0 1.5px rgba(132, 195, 255, 0.9),
        0 0 36px rgba(63, 125, 255, 0.42),
        0 0 96px rgba(63, 125, 255, 0.24),
        inset 0 0 28px rgba(63, 125, 255, 0.08);
    transition:
        opacity 0.35s ease,
        top 0.62s cubic-bezier(0.22, 1, 0.36, 1),
        left 0.62s cubic-bezier(0.22, 1, 0.36, 1),
        width 0.62s cubic-bezier(0.22, 1, 0.36, 1),
        height 0.62s cubic-bezier(0.22, 1, 0.36, 1),
        border-radius 0.3s ease;
}

.onboarding-root.is-targeted .onboarding-spotlight { opacity: 1; }

.onboarding-spotlight-ring {
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    border: 1px solid rgba(170, 220, 255, 0.6);
    animation: obRingPulse 2.8s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

.onboarding-spotlight::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    padding: 1.5px;
    background: conic-gradient(
        from 0deg,
        transparent 0 62%,
        rgba(126, 190, 255, 0.75) 76%,
        rgba(255, 255, 255, 0.9) 84%,
        transparent 92%
    );
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    animation: obSpin 5s linear infinite;
    opacity: 0.85;
}

/* ── 引导卡片 ── */
.onboarding-card {
    --ob-ink: #0f2b52;
    --ob-soft: #5d7699;
    --ob-line: rgba(63, 125, 255, 0.14);
    --ob-card-solid: #ffffff;
    --ob-arrow-x: 50%;
    --ob-arrow-y: 50%;

    position: fixed;
    z-index: 8010;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    overflow: visible;
    padding: 22px 22px 18px;
    border-radius: 24px;
    color: var(--ob-ink);
    background:
        radial-gradient(circle at 12% 0%, rgba(116, 178, 255, 0.16), transparent 34%),
        linear-gradient(160deg, rgba(255, 255, 255, 0.99), rgba(240, 247, 255, 0.97));
    border: 1px solid rgba(255, 255, 255, 0.92);
    box-shadow:
        0 32px 80px rgba(7, 24, 54, 0.36),
        0 2px 0 rgba(255, 255, 255, 0.9) inset,
        0 0 0 1px rgba(63, 125, 255, 0.06);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    pointer-events: auto;
    outline: none;
}

.onboarding-card::before {
    content: "";
    position: absolute;
    left: 20px;
    right: 20px;
    top: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(63, 125, 255, 0.75), transparent);
    pointer-events: none;
}

.onboarding-card.is-scrollable {
    overflow-y: auto;
    overscroll-behavior: contain;
}

.onboarding-root:not(.is-visible) .onboarding-card { opacity: 0; }

[data-theme="dark"] .onboarding-card {
    --ob-ink: #eef6ff;
    --ob-soft: #a9c3e3;
    --ob-line: rgba(120, 175, 255, 0.16);
    --ob-card-solid: #0f1c32;
    background:
        radial-gradient(circle at 12% 0%, rgba(63, 125, 255, 0.18), transparent 38%),
        linear-gradient(160deg, rgba(20, 33, 57, 0.99), rgba(12, 23, 42, 0.98));
    border-color: rgba(120, 175, 255, 0.22);
    box-shadow:
        0 32px 80px rgba(0, 0, 0, 0.55),
        0 1px 0 rgba(255, 255, 255, 0.06) inset,
        0 0 0 1px rgba(120, 175, 255, 0.08);
}

/* 卡片指向箭头 */
.ob-card-arrow {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--ob-card-solid);
    border: 1px solid var(--ob-line);
    transform: rotate(45deg);
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.onboarding-card.is-placed-bottom .ob-card-arrow {
    top: -7px;
    left: var(--ob-arrow-x);
    margin-left: -7px;
    border-right: 0;
    border-bottom: 0;
}

.onboarding-card.is-placed-top .ob-card-arrow {
    bottom: -7px;
    left: var(--ob-arrow-x);
    margin-left: -7px;
    border-left: 0;
    border-top: 0;
}

.onboarding-card.is-placed-left .ob-card-arrow {
    right: -7px;
    top: var(--ob-arrow-y);
    margin-top: -7px;
    border-left: 0;
    border-bottom: 0;
}

.onboarding-card.is-placed-right .ob-card-arrow {
    left: -7px;
    top: var(--ob-arrow-y);
    margin-top: -7px;
    border-right: 0;
    border-top: 0;
}

/* 进度 */
.ob-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.ob-progress-count {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--blue);
    font-variant-numeric: tabular-nums;
}

.ob-progress-segs {
    flex: 1;
    display: flex;
    gap: 5px;
}

.ob-progress-segs i {
    flex: 1;
    height: 3px;
    border-radius: 999px;
    background: rgba(63, 125, 255, 0.14);
    transition: background 0.35s ease, box-shadow 0.35s ease, transform 0.35s ease;
}

.ob-progress-segs i.is-done {
    background: rgba(63, 125, 255, 0.5);
}

.ob-progress-segs i.is-active {
    background: linear-gradient(90deg, #3f7dff, #7cc8ff);
    box-shadow: 0 0 10px rgba(63, 125, 255, 0.55);
    transform: scaleY(1.5);
}

.ob-progress-total {
    font-size: 10px;
    font-weight: 700;
    color: var(--ob-soft);
    opacity: 0.6;
    font-variant-numeric: tabular-nums;
}

/* 文案 */
.ob-eyebrow {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--blue);
}

.ob-eyebrow::before {
    content: "";
    width: 18px;
    height: 1px;
    background: currentColor;
    opacity: 0.5;
}

.ob-title {
    margin: 10px 0 8px;
    font-size: 22px;
    line-height: 1.28;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ob-ink);
}

.onboarding-card.is-step .ob-title { font-size: 19px; }

.ob-text {
    font-size: 13px;
    line-height: 1.75;
    color: var(--ob-soft);
}

.ob-hint {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(63, 125, 255, 0.07);
    border: 1px solid var(--ob-line);
    font-size: 11.5px;
    line-height: 1.6;
    color: #4c6f9f;
}

[data-theme="dark"] .ob-hint {
    background: rgba(63, 125, 255, 0.12);
    color: #b7cdea;
}

.ob-hint svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--blue);
}

/* 操作区 */
.ob-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
}

.ob-skip {
    padding: 8px 2px;
    border: 0;
    background: none;
    font: inherit;
    font-size: 11.5px;
    color: var(--ob-soft);
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.ob-skip:hover {
    opacity: 1;
    color: var(--blue);
}

.ob-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ob-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 17px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.ob-btn:active { transform: scale(0.97); }

.ob-btn svg { flex-shrink: 0; }

.ob-btn--ghost {
    background: rgba(63, 125, 255, 0.08);
    color: var(--blue-deep);
}

.ob-btn--ghost:hover { background: rgba(63, 125, 255, 0.15); }

[data-theme="dark"] .ob-btn--ghost {
    background: rgba(63, 125, 255, 0.16);
    color: #9dc8ff;
}

[data-theme="dark"] .ob-btn--ghost:hover { background: rgba(63, 125, 255, 0.24); }

.ob-btn--primary {
    position: relative;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(135deg, #4b8cff, #1d56c9);
    box-shadow:
        0 10px 22px rgba(29, 86, 201, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.ob-btn--primary::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.42) 46%, transparent 62%);
    transform: translateX(-130%);
    transition: transform 0.65s ease;
    pointer-events: none;
}

.ob-btn--primary:hover::after { transform: translateX(130%); }

.ob-btn--sm {
    height: 32px;
    padding: 0 13px;
    font-size: 11px;
}

/* ── 欢迎页视觉 ── */
.ob-hero {
    position: relative;
    height: 122px;
    margin: 2px 0 18px;
    border-radius: 18px;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 58%, rgba(63, 125, 255, 0.16), transparent 56%),
        linear-gradient(160deg, rgba(238, 246, 255, 0.95), rgba(255, 255, 255, 0.62));
    border: 1px solid rgba(63, 125, 255, 0.12);
    isolation: isolate;
}

[data-theme="dark"] .ob-hero {
    background:
        radial-gradient(circle at 50% 58%, rgba(63, 125, 255, 0.25), transparent 58%),
        linear-gradient(160deg, rgba(22, 38, 66, 0.95), rgba(13, 24, 43, 0.7));
    border-color: rgba(120, 175, 255, 0.16);
}

.ob-hero::before {
    content: "";
    position: absolute;
    inset: -45%;
    z-index: -1;
    background:
        radial-gradient(circle at 32% 42%, rgba(99, 167, 255, 0.55), transparent 32%),
        radial-gradient(circle at 70% 58%, rgba(126, 232, 255, 0.4), transparent 30%),
        radial-gradient(circle at 56% 18%, rgba(255, 255, 255, 0.8), transparent 24%);
    filter: blur(16px);
    animation: obAurora 14s ease-in-out infinite alternate;
}

[data-theme="dark"] .ob-hero::before {
    background:
        radial-gradient(circle at 32% 42%, rgba(63, 125, 255, 0.55), transparent 34%),
        radial-gradient(circle at 70% 58%, rgba(30, 180, 255, 0.35), transparent 30%),
        radial-gradient(circle at 56% 18%, rgba(150, 210, 255, 0.3), transparent 24%);
}

.ob-orbit {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 92px;
    height: 92px;
    transform: translate(-50%, -50%);
}

.ob-orbit-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid rgba(90, 150, 255, 0.32);
    animation: obSpin 16s linear infinite;
}

.ob-orbit-ring:nth-child(2) {
    inset: 9px;
    border-style: dashed;
    border-color: rgba(90, 150, 255, 0.22);
    animation-duration: 24s;
    animation-direction: reverse;
}

.ob-orbit-ring::after {
    content: "";
    position: absolute;
    top: -2.5px;
    left: 50%;
    width: 5px;
    height: 5px;
    margin-left: -2.5px;
    border-radius: 50%;
    background: #7cc8ff;
    box-shadow: 0 0 10px rgba(124, 200, 255, 0.9);
}

.ob-logo {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(145deg, #6bb6ff, #2f6bff 52%, #1b4fc0);
    box-shadow:
        0 14px 26px rgba(47, 107, 255, 0.34),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    animation: obFloat 4.2s ease-in-out infinite;
}

.ob-logo svg {
    width: 25px;
    height: 25px;
    filter: drop-shadow(0 2px 5px rgba(10, 40, 90, 0.25));
}

.ob-chip {
    position: absolute;
    z-index: 2;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(63, 125, 255, 0.16);
    box-shadow: 0 6px 14px rgba(63, 125, 255, 0.1);
    font-size: 10px;
    font-weight: 700;
    color: #3f6cae;
    white-space: nowrap;
    animation: obFloat 4.6s ease-in-out infinite;
}

[data-theme="dark"] .ob-chip {
    background: rgba(24, 42, 72, 0.9);
    border-color: rgba(120, 175, 255, 0.2);
    color: #a9c2e2;
}

.ob-chip--a { left: 14px; top: 22px; animation-delay: -1.2s; }
.ob-chip--b { right: 14px; top: 36px; animation-delay: -2.6s; }
.ob-chip--c { left: 24px; bottom: 18px; animation-delay: -0.7s; }

.ob-spark {
    position: absolute;
    width: 10px;
    height: 10px;
    background: rgba(99, 167, 255, 0.85);
    clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
    animation: obTwinkle 3.2s ease-in-out infinite;
}

.ob-spark--1 { left: 26%; top: 18%; width: 8px; height: 8px; animation-delay: -0.4s; }
.ob-spark--2 { right: 24%; bottom: 20%; width: 12px; height: 12px; animation-delay: -1.6s; opacity: 0.7; }
.ob-spark--3 { right: 16%; top: 18%; width: 6px; height: 6px; animation-delay: -2.4s; opacity: 0.6; }

.ob-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.ob-meta span {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(63, 125, 255, 0.07);
    border: 1px solid var(--ob-line);
    font-size: 10.5px;
    font-weight: 600;
    color: #5b7aa5;
}

[data-theme="dark"] .ob-meta span { color: #a9c3e3; }

.ob-meta b {
    color: var(--blue-deep);
    font-weight: 800;
}

[data-theme="dark"] .ob-meta b { color: #8cc2ff; }

/* ── 完成页 ── */
.ob-finish-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 70px;
    margin: 2px 0 10px;
}

.ob-finish-mark {
    position: relative;
    z-index: 2;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(140deg, #63b3ff, #2f6bff 55%, #1d56c9);
    box-shadow:
        0 16px 32px rgba(47, 107, 255, 0.32),
        inset 0 1px 0 rgba(255, 255, 255, 0.38);
    animation: obPop 0.72s cubic-bezier(0.18, 1.25, 0.3, 1) both;
}

.ob-finish-mark svg { width: 28px; height: 28px; }

.ob-finish-mark::after {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 1px solid rgba(99, 167, 255, 0.4);
    animation: obRingPulse 2.6s ease-out infinite;
}

.ob-burst {
    position: absolute;
    left: 50%;
    top: 35px;
    width: 0;
    height: 0;
    pointer-events: none;
}

.ob-burst i {
    position: absolute;
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    animation: obBurst 0.95s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}

.ob-recap {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.ob-recap span {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 12px;
    background: rgba(63, 125, 255, 0.06);
    border: 1px solid var(--ob-line);
    font-size: 11.5px;
    font-weight: 600;
    color: #47668f;
}

[data-theme="dark"] .ob-recap span {
    background: rgba(63, 125, 255, 0.1);
    color: #b7cdea;
}

.ob-recap i {
    font-style: normal;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--blue);
}

/* ── 入口按钮 ── */
.nav-link.ob-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-link.ob-trigger svg {
    opacity: 0.65;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-link.ob-trigger:hover svg {
    opacity: 1;
    transform: rotate(18deg) scale(1.12);
}

/* ── 屏幕阅读器播报 ── */
.onboarding-live {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ── 移动端 ── */
@media (max-width: 768px) {
    .onboarding-pane,
    .onboarding-veil { backdrop-filter: none; -webkit-backdrop-filter: none; }

    .onboarding-pane { background: rgba(6, 17, 36, 0.72); }

    .onboarding-card {
        padding: 18px 18px 14px;
        border-radius: 21px;
        max-height: 56vh;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .ob-card-arrow { display: none; }

    .onboarding-card.is-step .ob-title { font-size: 18px; }

    .ob-title { font-size: 20px; }

    .ob-actions { margin-top: 16px; }

    .ob-btn {
        height: 36px;
        padding: 0 15px;
    }

    .ob-hero { height: 108px; }
}

/* ── 动效 ── */
@keyframes obRingPulse {
    0% { transform: scale(1); opacity: 0.75; }
    70% { transform: scale(1.055); opacity: 0; }
    100% { transform: scale(1.055); opacity: 0; }
}

@keyframes obSpin {
    to { transform: rotate(360deg); }
}

@keyframes obFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes obTwinkle {
    0%, 100% { opacity: 0.35; transform: scale(0.8) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.15) rotate(18deg); }
}

@keyframes obAurora {
    0% { transform: translate3d(-4%, -2%, 0) scale(1); }
    50% { transform: translate3d(4%, 3%, 0) scale(1.08); }
    100% { transform: translate3d(-1%, 4%, 0) scale(1.02); }
}

@keyframes obPop {
    0% { opacity: 0; transform: scale(0.55); }
    60% { opacity: 1; transform: scale(1.06); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes obBurst {
    0% {
        opacity: 1;
        transform: rotate(var(--a)) translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: rotate(var(--a)) translateY(calc(-1 * var(--d))) scale(0.4);
    }
}

@media (prefers-reduced-motion: reduce) {
    .onboarding-root,
    .onboarding-root *,
    .onboarding-root *::before,
    .onboarding-root *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
