/* ===== 简库 AI - Iridescent Glowing Border Animation ===== */

/*
 * 注册可动画的角度属性
 * 旋转 conic-gradient 起始角度实现流光，元素形状固定贴合圆角
 * —— 饱和光谱沿卡片边缘流转，形成定义清晰的彩色发光边框（参考苹果 AI）
 */
@property --ai-angle-a {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* AI trigger button */
.ai-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--jk-radius, 12px);
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.ai-trigger-btn:hover {
    color: #6366f1;
    border-color: #c7d2fe;
    background: #eef2ff;
}

.ai-trigger-btn .ai-icon {
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #6366f1, #ec4899, #06b6d4);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
}

/* 按钮内文字/图标提升层级，让涟漪在下方晕染，文字始终清晰 */
.ai-trigger-btn > * {
    position: relative;
    z-index: 1;
}

/* AI container - when active, shows iridescent border */
.ai-container {
    position: relative;
    border-radius: var(--jk-radius-lg, 16px);
    overflow: visible;
    isolation: isolate;
}

/*
 * 彩色流光边框层
 * 设计：饱和光谱 conic-gradient 旋转起始角度（元素形状固定贴合圆角）
 *       内容白卡覆盖中心，仅留边缘一圈彩色发光，定义清晰不糊
 * 性能：filter:blur 使伪元素独立合成层，仅该小尺寸层每帧重绘，不波及页面
 */
.ai-glow-border {
    position: absolute;
    inset: -10px;
    border-radius: calc(var(--jk-radius-lg, 16px) + 10px);
    z-index: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
}

.ai-glow-border.active {
    opacity: 1;
}

/*
 * 流光层 —— 饱和光谱沿卡片边缘匀速流转
 * 蓝→靛→紫→粉→橙→黄→绿→青 闭环，色彩鲜明通透，柔焦弥散为发光边框
 */
.ai-glow-border::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: conic-gradient(
        from var(--ai-angle-a),
        #2997FF,
        #5E5CE6,
        #BF5AF2,
        #FF2D55,
        #FF9F0A,
        #FFD60A,
        #34C759,
        #64D2FF,
        #2997FF
    );
    filter: blur(16px);
    opacity: 0.85;
    animation: ai-spin-a 5s linear infinite;
}

/* 角度旋转 —— linear 匀速流转，如光沿边缘平稳流动 */
@keyframes ai-spin-a {
    to { --ai-angle-a: 360deg; }
}

/* AI content area - sits above glow, clean white with soft lift */
.ai-content {
    position: relative;
    z-index: 1;
    border-radius: var(--jk-radius-lg, 16px);
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.06);
    animation: ai-content-in 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 内容卡片首次显现时轻微浮现，让按钮→卡片的切换更自然 */
@keyframes ai-content-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Typewriter cursor */
.ai-typing-cursor::after {
    content: '▊';
    animation: ai-blink 0.8s infinite;
    color: #8b5cf6;
    font-weight: normal;
}

@keyframes ai-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* AI loading dots */
.ai-loading-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.ai-loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8b5cf6;
    animation: ai-bounce 1.4s infinite ease-in-out both;
}

.ai-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-loading-dots span:nth-child(2) { animation-delay: -0.16s; }

/* AI 结果统一标识标签 */
.ai-result-label {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: transparent;
    background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
}

/* AI 结果入场动画 — 带自然回弹的非线性缓动 */
@keyframes ai-result-enter {
    0% {
        opacity: 0;
        transform: translateY(16px) scale(0.92);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-enter {
    opacity: 0;
    animation: ai-result-enter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes ai-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Ripple effect from click position */
.ai-ripple {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.3) 0%, rgba(99, 102, 241, 0.1) 40%, transparent 70%);
    transform: scale(0);
    animation: ai-ripple-expand 0.8s ease-out forwards;
    pointer-events: none;
    z-index: 2;
}

@keyframes ai-ripple-expand {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Fade out animation for glow border - soft scale + opacity dissolve */
.ai-glow-border.fading {
    animation: ai-fade-out 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes ai-fade-out {
    to {
        opacity: 0;
        transform: translateZ(0) scale(1.04);
    }
}

/* AI search optimization panel */
.ai-search-panel {
    position: relative;
    overflow: hidden;
}

.ai-keyword-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: linear-gradient(135deg, #eef2ff, #fce7f3);
    color: #6366f1;
    border: 1px solid #e0e7ff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-keyword-tag:hover {
    background: linear-gradient(135deg, #6366f1, #ec4899);
    color: white;
    border-color: transparent;
    transform: translateY(-1px);
}

/* Reduced motion fallback - static colorful halo, no rotation */
@media (prefers-reduced-motion: reduce) {
    .ai-glow-border::before {
        animation: none;
        background: conic-gradient(
            #2997FF, #5E5CE6, #BF5AF2, #FF2D55,
            #FF9F0A, #FFD60A, #34C759, #64D2FF, #2997FF
        );
        opacity: 0.8;
    }
}
