/**
 * 扫描线动画效果 - TNO仪器美学
 * 只在鼠标悬停时显示扫描线动画
 */

/* 扫描线容器 */
.scanline-container {
    position: relative;
    overflow: hidden;
}

/* 横向扫描线（从上到下） - 默认隐藏 */
.scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0.125rem;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--primary-color, var(--c-00ff00)) 50%,
        transparent 100%
    );
    box-shadow: 0 0 8px var(--primary-color, var(--c-00ff00));
    animation: scanline-move 2s linear infinite;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    display: none;
}

/* 竖向扫描线（从左到右） - 默认隐藏 */
.scanline-vertical {
    position: absolute;
    top: 0;
    left: 0;
    width: 0.125rem;
    height: 100%;
    background: linear-gradient(
        180deg,
        transparent 0%,
        var(--primary-color, var(--c-00ff00)) 50%,
        transparent 100%
    );
    box-shadow: 0 0 8px var(--primary-color, var(--c-00ff00));
    animation: scanline-move-vertical 3s linear infinite;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    display: none;
}

/* hover 扫线唯一入口是 _17e tno-scanline-hover (transform)。
   禁止本文件再用 top 关键帧盖掉 button::before. */

/* 扫描线动画 - 水平 */
/* Phase 417-V8: calc(100%-2px) 确保扫描线绝不溢出父容器，
   消除 overflow 向祖先滚动容器传播导致的滚动条闪现+布局抽搐。
   淡入淡出让循环边界平滑不可见。 */
@keyframes scanline-move {
    0% {
        top: 0%;
        opacity: 0;
    }
    8% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
    92% {
        opacity: 0.8;
    }
    100% {
        top: calc(100% - 0.125rem);
        opacity: 0;
    }
}

/* 扫描线动画 - 垂直 */
/* Phase 417-V8: 同水平扫描线，calc(100%-2px) + 淡入淡出 */
@keyframes scanline-move-vertical {
    0% {
        left: 0%;
        opacity: 0;
    }
    8% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
    92% {
        opacity: 0.8;
    }
    100% {
        left: calc(100% - 0.125rem);
        opacity: 0;
    }
}

/* 脉冲扫描效果（边框） */
.scanline-pulse {
    position: relative;
    animation: border-pulse 2s ease-in-out infinite;
}

@keyframes border-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 0, 0.7);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(0, 255, 0, 0);
    }
}

/* 栅格扫描效果（CRT屏幕风格） */
.scanline-grid {
    position: relative;
}

.scanline-grid::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1) 0rem,
        transparent 1px,
        transparent 2px,
        rgba(0, 0, 0, 0.1) 3px
    );
    pointer-events: none;
    z-index: 9998;
    animation: scanline-grid-move 8s linear infinite;
}

@keyframes scanline-grid-move {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(3px);
    }
}

/* 应用到工作中的面板 */
.panel.working .scanline,
.card.working .scanline,

/* ═══════════════════════════════════════════════════════════════
 * Phase 421-FIX: 事件卡片出现动画 (复刻 LEUV01 过渡效果)
 *   每个 SSE 事件卡片 (步骤卡 / 折叠事件卡 / 工具卡) 从下方滑入 + 淡入,
 *   避免"突然蹦出一大堆"的视觉卡顿.
 * ═══════════════════════════════════════════════════════════════ */

/* 通用卡片滑入动画 */
@keyframes wfCardSlideIn {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 淡入动画 (用于更轻量的元素) */
@keyframes wfFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* 应用到所有步骤卡片和事件卡片 — 仅实时模式 (历史回放由 JS inline style 控制) */
/* Phase 636-DESIGN: 默认不设动画. 实时模式的 wfCardSlideIn 由 JS (_appendCollapsibleEventCard,
   _renderTodoList) 通过 inline style 添加. 历史回放通过 inline style animation:none!important
   或 DOM 祖先 .wf-history-replay 检测来抑制. CSS 级默认动画无法与异步 L2 回放 timing 协调. */
/*
.wf-step-card,
.wf-collapsible-event-card,
.leucs-cev-card,
.wf-tool-call-card,
.wf-decision-card,
.wf-6d-scorecard,
.leucs-api-call-card,
.leucs-prompt-inject-card,
.wf-todolist-inline,
.leucs-context-inject-card,
.wf-ht-summary-card,
.wf-hc-summary-card,
.wf-archive-proposal-card,
.wf-interrupt-card {
    animation: wfCardSlideIn 0.3s ease-out;
}
*/

/* Phase 636-DESIGN: 聊天消息淡入也改为 JS 控制 (默认不设动画) */
/*
.wf-chat-msg {
    animation: wfFadeIn 0.25s ease-out;
}
*/

/* ── Phase 436: 历史回放模式 —— 禁止所有逐行动画 ──
 *   历史对话内容已经完整, 不应再逐条弹出。
 *   L1(HTML快照) / L2(事件回放) 一律瞬间显示全部内容。
 *   铁律6: 历史回放必须与实时渲染共用同一套渲染逻辑,
 *   仅动画行为不同 — 此处通过父级类名一键关闭所有动画。
 */
.wf-history-replay .wf-step-card,
.wf-history-replay .wf-collapsible-event-card,
.wf-history-replay .leucs-cev-card,
.wf-history-replay .wf-tool-call-card,
.wf-history-replay .wf-decision-card,
.wf-history-replay .wf-6d-scorecard,
.wf-history-replay .leucs-api-call-card,
.wf-history-replay .leucs-prompt-inject-card,
.wf-history-replay .wf-todolist-inline,
.wf-history-replay .leucs-context-inject-card,
.wf-history-replay .wf-ht-summary-card,
.wf-history-replay .wf-hc-summary-card,
.wf-history-replay .wf-archive-proposal-card,
.wf-history-replay .wf-interrupt-card {
    animation: none !important;
}
.wf-history-replay .wf-chat-msg {
    animation: none !important;
}

/* ── S2c-T2 落籍 (律㉓③): 中断选项容器, 原为零规则裸 div ── */
.wf-interrupt-options { margin-block-start: 0.375rem; }
.wf-history-replay .leucs-stream-card-reveal,
.wf-history-replay .leucs-stream-card-reveal.is-visible {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
    transition-delay: 0ms !important;
}
.wf-history-replay .leucs-card-queued {
    display: revert !important;
}
.wf-history-replay .leucs-type-caret,
.wf-history-replay .leucs-ime-preview {
    display: none !important;
}

/* 窄屏侧边栏展开时确保内容可见 */
.wf-tchat-sidebar.wf-sidebar-open {
    z-index: 100 !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4) !important;
}
.wf-tchat-sidebar.wf-sidebar-open .wf-tchat-conv-list {
    /* HC/HT 双区独立滚动: 保持列向 flex (旧 display:block 会让 zone-body 的
       flex 收缩失效, 两区挤爆列表); 可见性由 sidebar-open 自身保证 */
    display: flex !important;
    flex-direction: column;
    max-height: calc(100vh - 120px) !important;
}
/* responsive 横排覆盖: compact 时取消 block, 由 _42a 接管为 flex row */
.wf-r-compact .wf-tchat-sidebar.wf-sidebar-open .wf-tchat-conv-list,
.wf-r-dense .wf-tchat-sidebar.wf-sidebar-open .wf-tchat-conv-list {
    display: flex !important;
    overflow-y: hidden !important;
    overflow-x: auto !important;
    max-height: none !important;
}
.llm-api-item.testing .scanline {
    display: block;
}

/* 应用到测试中的API卡片 */
.llm-api-item.testing {
    position: relative;
    border-color: var(--primary-color);
    animation: border-pulse 2s ease-in-out infinite;
}

/* 添加扫描线到测试中的卡片 */
.llm-api-item.testing::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0.125rem;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--c-ffcc00) 50%,
        transparent 100%
    );
    box-shadow: 0 0 8px var(--c-ffcc00);
    animation: scanline-move 1.5s linear infinite;
    pointer-events: none;
}

/* Dashboard面板工作状态 */
.dashboard-panel.working {
    position: relative;
}

.dashboard-panel.working::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0.125rem;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--primary-color) 50%,
        transparent 100%
    );
    box-shadow: 0 0 8px var(--primary-color);
    animation: scanline-move 2s linear infinite;
    pointer-events: none;
    z-index: 10;
}

/* 工具库按钮激活状态 */
.tool-btn.active {
    position: relative;
    border-color: var(--primary-color);
}

.tool-btn.active::after {
    content: "";
    position: absolute;
    top: -0.25vh;
    left: 0;
    width: 100%;
    height: 0.125rem;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--primary-color) 50%,
        transparent 100%
    );
    animation: scanline-move-fast 1s linear infinite;
}

@keyframes scanline-move-fast {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* 黑白主题适配 */
body[data-theme="blackwhite"] .scanline,
body[data-theme="blackwhite"] .llm-api-item.testing::after {
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--c-ffffff) 50%,
        transparent 100%
    );
    box-shadow: 0 0 8px var(--c-ffffff);
}

/* 工作态指示器配合扫描线 */
.status-indicator.working {
    animation: indicator-pulse 1.5s ease-in-out infinite;
}

@keyframes indicator-pulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

html.leucs-scrolling .scanline,
html.leucs-scrolling .scanline-vertical,
html.leucs-scrolling .scanline-grid::before,
html.leucs-scrolling .scanline-pulse,
html.leucs-scrolling .llm-api-item.testing,
html.leucs-scrolling .llm-api-item.testing::after,
html.leucs-scrolling .dashboard-panel.working::before,
html.leucs-scrolling .tool-btn.active::after,
html.leucs-scrolling .status-indicator.working {
    animation-play-state: paused;
}
