/* ============================================
   MOTION PRIMITIVES - Advanced Animation System
   Inspired by motion-primitives.com
   ============================================ */

/* ====== TEXT SHIMMER EFFECT ====== */
.text-shimmer {
    background: linear-gradient(
        120deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0) 40%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(255, 255, 255, 0) 60%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: text-shimmer 3s ease-in-out infinite;
}

@keyframes text-shimmer {
    0% { background-position: 200% center; }
    100% { background-position: -200% center; }
}

/* Gradient Text with Shimmer */
.text-gradient-shimmer {
    background: linear-gradient(
        90deg,
        #a78bfa 0%,
        #ec4899 25%,
        #f59e0b 50%,
        #ec4899 75%,
        #a78bfa 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-flow 4s ease infinite;
}

@keyframes gradient-flow {
    0% { background-position: 0% center; }
    50% { background-position: 100% center; }
    100% { background-position: 0% center; }
}

/* ====== TEXT SCRAMBLE EFFECT ====== */
.text-scramble {
    position: relative;
    display: inline-block;
}

.text-scramble::after {
    content: attr(data-scramble);
    position: absolute;
    left: 0;
    top: 0;
    color: var(--accent-purple);
    opacity: 0;
    animation: scramble-flash 0.1s ease;
}

/* ====== TEXT LOOP EFFECT ====== */
.text-loop-container {
    display: inline-flex;
    overflow: hidden;
    height: 1.2em;
    vertical-align: bottom;
}

.text-loop {
    display: flex;
    flex-direction: column;
    animation: text-loop 8s ease-in-out infinite;
}

.text-loop-item {
    height: 1.2em;
    display: flex;
    align-items: center;
}

@keyframes text-loop {
    0%, 20% { transform: translateY(0); }
    25%, 45% { transform: translateY(-1.2em); }
    50%, 70% { transform: translateY(-2.4em); }
    75%, 95% { transform: translateY(-3.6em); }
    100% { transform: translateY(0); }
}

/* ====== BORDER TRAIL EFFECT ====== */
.border-trail {
    position: relative;
    overflow: hidden;
}

.border-trail::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--accent-purple) 25%,
        var(--accent-pink) 50%,
        var(--accent-purple) 75%,
        transparent 100%
    );
    background-size: 300% 100%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: border-trail 3s linear infinite;
    pointer-events: none;
}

@keyframes border-trail {
    0% { background-position: 300% center; }
    100% { background-position: 0% center; }
}

/* Border Trail on Hover Only */
.border-trail-hover::before {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.border-trail-hover:hover::before {
    opacity: 1;
}

/* ====== ANIMATED BACKGROUND ====== */
.animated-bg {
    position: relative;
    overflow: hidden;
}

.animated-bg::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle at center,
        rgba(139, 92, 246, 0.15) 0%,
        transparent 50%
    );
    animation: bg-pulse 8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes bg-pulse {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.5; }
    50% { transform: translate(25%, 25%) scale(1.5); opacity: 0.8; }
}

/* ====== CURSOR GLOW EFFECT ====== */
.cursor-glow {
    position: relative;
}

.cursor-glow::after {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    background: radial-gradient(
        circle,
        rgba(139, 92, 246, 0.25) 0%,
        transparent 70%
    );
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease;
    opacity: 0;
}

.cursor-glow:hover::after {
    opacity: 1;
}

/* ====== INFINITE SLIDER ====== */
.infinite-slider {
    display: flex;
    width: 100%;
    overflow: hidden;
    mask-image: linear-gradient(
        to right,
        transparent 0%,
        black 10%,
        black 90%,
        transparent 100%
    );
    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0%,
        black 10%,
        black 90%,
        transparent 100%
    );
}

.infinite-slider-track {
    display: flex;
    animation: infinite-scroll 30s linear infinite;
}

.infinite-slider-track:hover {
    animation-play-state: paused;
}

@keyframes infinite-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.infinite-slider.slow .infinite-slider-track {
    animation-duration: 40s;
}

.infinite-slider.fast .infinite-slider-track {
    animation-duration: 20s;
}

/* ====== MORPHING CARD ====== */
.morph-card {
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.morph-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-radius: 32px;
}

.morph-card:active {
    transform: translateY(-4px) scale(0.98);
}

/* ====== IN-VIEW ANIMATIONS ====== */
.animate-in {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-in.in-view {
    opacity: 1;
    transform: translateY(0);
}

.animate-in-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-in-left.in-view {
    opacity: 1;
    transform: translateX(0);
}

.animate-in-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-in-right.in-view {
    opacity: 1;
    transform: translateX(0);
}

.animate-in-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-in-scale.in-view {
    opacity: 1;
    transform: scale(1);
}

/* Staggered animations */
.stagger-1 { transition-delay: 0.1s; }
.stagger-2 { transition-delay: 0.2s; }
.stagger-3 { transition-delay: 0.3s; }
.stagger-4 { transition-delay: 0.4s; }
.stagger-5 { transition-delay: 0.5s; }
.stagger-6 { transition-delay: 0.6s; }

/* ====== LIQUID GLASS CARD (Kokonut UI Inspired) ====== */
.liquid-glass {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        rgba(255, 255, 255, 0.02) 100%
    );
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.liquid-glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
}

.liquid-glass:hover {
    transform: translateY(-4px);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.15),
        0 0 60px rgba(139, 92, 246, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

/* Light mode liquid glass */
body.light-mode .liquid-glass {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 255, 255, 0.7) 100%
    );
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

body.light-mode .liquid-glass:hover {
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.12),
        0 0 60px rgba(139, 92, 246, 0.1);
}

/* ====== GLOW BUTTON (Cult UI Inspired) ====== */
.glow-button {
    position: relative;
    padding: 16px 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
}

.glow-button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.3) 0%,
        transparent 60%
    );
    opacity: 0;
    transform: scale(0);
    transition: all 0.5s ease;
}

.glow-button:hover {
    transform: translateY(-3px);
    box-shadow:
        0 10px 40px rgba(102, 126, 234, 0.4),
        0 0 80px rgba(118, 75, 162, 0.3);
}

.glow-button:hover::before {
    opacity: 1;
    transform: scale(1);
}

.glow-button:active {
    transform: translateY(-1px);
}

/* ====== MAGNETIC BUTTON ====== */
.magnetic-button {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====== THINKING BAR (Prompt Kit Inspired) ====== */
.thinking-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--glass-white);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-purple);
    border-radius: 50%;
    animation: thinking-bounce 1.4s ease-in-out infinite;
}

.thinking-dot:nth-child(1) { animation-delay: 0s; }
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-bounce {
    0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
    40% { transform: scale(1.3); opacity: 1; }
}

/* ====== AI MESSAGE BUBBLE (Prompt Kit Inspired) ====== */
.ai-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.ai-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-avatar svg {
    width: 20px;
    height: 20px;
    color: white;
}

.ai-content {
    flex: 1;
    background: var(--glass-white);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    border-top-left-radius: 4px;
    padding: 16px;
}

.user-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-direction: row-reverse;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--glass-white);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-content {
    flex: 1;
    background: var(--gradient-primary);
    border-radius: 16px;
    border-top-right-radius: 4px;
    padding: 16px;
    color: white;
    max-width: 80%;
}

/* ====== PROMPT INPUT (Prompt Kit Inspired) ====== */
.prompt-input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 12px;
    background: var(--glass-white);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.prompt-input-container:focus-within {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

.prompt-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    min-height: 24px;
    max-height: 200px;
    line-height: 1.5;
}

.prompt-textarea::placeholder {
    color: var(--text-tertiary);
}

.prompt-actions {
    display: flex;
    gap: 8px;
}

.prompt-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--gradient-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.prompt-action-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}

.prompt-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ====== EXPANDABLE TOOLBAR (Cult UI Inspired) ====== */
.expandable-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: var(--glass-white);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.expandable-toolbar.expanded {
    padding: 8px 16px;
    gap: 8px;
}

.toolbar-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.toolbar-item:hover {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-purple);
}

.toolbar-item.active {
    background: var(--gradient-primary);
    color: white;
}

.toolbar-item-label {
    position: absolute;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
}

.expandable-toolbar.expanded .toolbar-item {
    width: auto;
    padding: 8px 16px;
    gap: 8px;
}

.expandable-toolbar.expanded .toolbar-item-label {
    position: relative;
    opacity: 1;
    transform: translateX(0);
}

/* ====== COUNTER ANIMATION ====== */
.counter-animate {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

/* ====== FLOATING ELEMENTS ====== */
.float {
    animation: float 6s ease-in-out infinite;
}

.float-delayed {
    animation: float 6s ease-in-out infinite;
    animation-delay: -3s;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(2deg); }
}

/* ====== PULSE GLOW ====== */
.pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.3); }
    50% { box-shadow: 0 0 40px rgba(139, 92, 246, 0.6); }
}

/* ====== RIPPLE EFFECT ====== */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease, opacity 0.6s ease;
    opacity: 0;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
    opacity: 0;
}

/* ====== SKELETON LOADING ====== */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--glass-white) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        var(--glass-white) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ====== TYPEWRITER EFFECT ====== */
.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--accent-purple);
    white-space: nowrap;
    animation:
        typewriter 3s steps(40, end),
        blink-caret 0.75s step-end infinite;
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--accent-purple); }
}

/* ====== SPOTLIGHT EFFECT ====== */
.spotlight {
    position: relative;
    overflow: hidden;
}

.spotlight::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%
    );
    transform: skewX(-25deg);
    transition: left 0.7s ease;
}

.spotlight:hover::before {
    left: 150%;
}

/* ====== PARTICLE BACKGROUND ====== */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-purple);
    border-radius: 50%;
    opacity: 0.3;
    animation: particle-float 15s linear infinite;
}

@keyframes particle-float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% { opacity: 0.3; }
    90% { opacity: 0.3; }
    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ====== NOISE TEXTURE OVERLAY ====== */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.03;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ====== REDUCED MOTION ====== */
@media (prefers-reduced-motion: reduce) {
    .text-shimmer,
    .text-gradient-shimmer,
    .border-trail::before,
    .infinite-slider-track,
    .thinking-dot,
    .float,
    .pulse-glow,
    .particle {
        animation: none !important;
    }

    .animate-in,
    .animate-in-left,
    .animate-in-right,
    .animate-in-scale {
        opacity: 1;
        transform: none;
    }
}
