/* =====================================================================
   static/wait/wait.css —— 全站等待动画（2026-11-12）

   前后台共用：颜色全部走变量回退链，后台用 --accent、前台用 --edu-brand，
   都拿不到时回落品牌橙，保证任何页面都不会出现透明或黑色的等待层。

   组成：
   .swait-bar      顶部细进度条（所有异步请求，300ms 后才出现，避免闪现）
   .swait-mask     全屏等待遮罩（长耗时操作：AI 回复、计划调整…）
   .swait-dots     对话里的「正在输入」三点动画
   ===================================================================== */

:root {
    --swait-accent: var(--accent, var(--edu-brand, #FF6B18));
    --swait-ink: var(--text-1, var(--edu-ink, #17233F));
    --swait-ink-2: var(--text-2, var(--edu-ink-2, #475569));
    --swait-ink-3: var(--text-3, var(--edu-ink-3, #94A3B8));
    --swait-card: var(--bg-card, #ffffff);
    --swait-border: var(--border, #E2E8F0);
}

/* ---------- 顶部进度条 ---------- */
.swait-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 2147483000;
    background: transparent;
    pointer-events: none;
    opacity: 0;
    transition: opacity .18s ease;
}

.swait-bar.is-on {
    opacity: 1;
}

.swait-bar__fill {
    height: 100%;
    width: 35%;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(90deg,
        rgba(255, 107, 24, 0) 0%,
        var(--swait-accent) 45%,
        #FFB27A 100%);
    box-shadow: 0 0 8px rgba(255, 107, 24, .45);
    animation: swait-bar-run 1.15s cubic-bezier(.4, 0, .2, 1) infinite;
}

@keyframes swait-bar-run {
    0%   { transform: translateX(-40%); }
    100% { transform: translateX(300%); }
}

/* ---------- 全屏等待遮罩 ---------- */
.swait-mask {
    position: fixed;
    inset: 0;
    z-index: 2147483100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(23, 35, 63, .32);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    animation: swait-fade .18s ease;
}

@keyframes swait-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.swait-card {
    width: min(360px, 88vw);
    padding: 28px 24px 22px;
    border-radius: 16px;
    background: var(--swait-card);
    box-shadow: 0 18px 48px rgba(23, 35, 63, .22);
    text-align: center;
    font-family: var(--font, var(--edu-font, -apple-system, 'Noto Sans SC', sans-serif));
    color: var(--swait-ink);
}

.swait-card__ring {
    position: relative;
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
}

/* 外圈脉冲光晕 + 内圈缺口旋转环，两层叠加让等待「看起来在动」 */
.swait-card__ring::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 107, 24, .18) 0%, rgba(255, 107, 24, 0) 70%);
    animation: swait-pulse 1.6s ease-in-out infinite;
}

.swait-card__ring::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(255, 107, 24, .16);
    border-top-color: var(--swait-accent);
    border-right-color: var(--swait-accent);
    animation: swait-spin .85s linear infinite;
}

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

@keyframes swait-pulse {
    0%, 100% { transform: scale(.86); opacity: .55; }
    50%      { transform: scale(1.12); opacity: 1; }
}

.swait-card__label {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--swait-ink);
}

.swait-card__sub {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--swait-ink-3);
}

.swait-card__sub b {
    font-weight: 600;
    color: var(--swait-ink-2);
    font-variant-numeric: tabular-nums;
}

/* ---------- 对话「正在输入」三点 ---------- */
.swait-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 18px;
    vertical-align: middle;
}

.swait-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--swait-ink-3);
    animation: swait-dot 1.2s ease-in-out infinite;
}

.swait-dots i:nth-child(2) { animation-delay: .16s; }
.swait-dots i:nth-child(3) { animation-delay: .32s; }

@keyframes swait-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* ---------- 轻提示 ---------- */
.swait-toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%) translateY(8px);
    z-index: 2147483200;
    max-width: 78vw;
    padding: 10px 18px;
    border-radius: 10px;
    background: rgba(23, 35, 63, .92);
    color: #fff;
    font-size: 13px;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

.swait-toast.is-on {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- 浮动等待角标 ----------
   用于「任务在别的页面发起、当前页不需要被挡住」的情况：
   例如在社区看帖时，智能助教还在回答上一个问题。
   不遮挡操作，只说明「后台还在跑」，点它回到对应页面。 */
.swait-chip {
    position: fixed;
    right: 20px;
    bottom: 24px;
    z-index: 2147483000;
    display: none;
    align-items: center;
    gap: 9px;
    max-width: min(320px, 82vw);
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--swait-card);
    border: 1px solid var(--swait-border);
    box-shadow: 0 10px 26px rgba(23, 35, 63, .16);
    font-family: var(--font, var(--edu-font, -apple-system, 'Noto Sans SC', sans-serif));
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--swait-ink-2);
    text-decoration: none;
    animation: swait-fade .2s ease;
}

.swait-chip.is-on { display: inline-flex; }

.swait-chip__ring {
    flex: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid rgba(255, 107, 24, .2);
    border-top-color: var(--swait-accent);
    animation: swait-spin .8s linear infinite;
}

.swait-chip__text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- 页面内等待条（局部区块用） ---------- */
.swait-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 12px;
    border: 1px dashed var(--swait-border);
    border-radius: 10px;
    background: rgba(255, 107, 24, .04);
    font-size: 12px;
    color: var(--swait-ink-2);
}

.swait-inline__ring {
    flex: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 107, 24, .2);
    border-top-color: var(--swait-accent);
    animation: swait-spin .8s linear infinite;
}

/* 尊重「减少动态效果」的系统设置：动画降级为静态提示，信息不丢 */
@media (prefers-reduced-motion: reduce) {
    .swait-bar__fill,
    .swait-card__ring::before,
    .swait-card__ring::after,
    .swait-inline__ring,
    .swait-dots i {
        animation-duration: 2.4s;
    }
}

@media (max-width: 640px) {
    .swait-card { padding: 22px 18px 18px; border-radius: 14px; }
    .swait-card__label { font-size: 14px; }
}
