/* ═══════════════════════════════════════════════════════════════════════════
   DARK LUXE ANIMATIONS
   Premium animation system with accent-aware effects
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   Core Keyframe Animations
   ───────────────────────────────────────────────────────────────────────────── */

/* Floating Animation for Ambient Elements */
@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(30px, -30px) scale(1.1);
    }
    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }
    75% {
        transform: translate(40px, 10px) scale(1.05);
    }
}

/* Gentle Drift - More subtle float */
@keyframes drift {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-15px) rotate(2deg);
    }
}

/* Pulse Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.08);
    }
}

/* Accent Glow Pulse - Uses CSS variable */
@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 20px var(--accent-glow, rgba(0, 212, 255, 0.2));
    }
    50% {
        box-shadow: 0 0 50px var(--accent-glow, rgba(0, 212, 255, 0.4)),
                    0 0 100px var(--accent-glow, rgba(0, 212, 255, 0.2));
    }
}

/* Text Glow Pulse */
@keyframes text-glow-pulse {
    0%, 100% {
        text-shadow: 0 0 10px var(--accent-glow, rgba(0, 212, 255, 0.3));
    }
    50% {
        text-shadow: 0 0 20px var(--accent-glow, rgba(0, 212, 255, 0.5)),
                     0 0 40px var(--accent-glow, rgba(0, 212, 255, 0.3));
    }
}

/* Spin */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Reverse Spin */
@keyframes spin-reverse {
    from {
        transform: rotate(360deg);
    }
    to {
        transform: rotate(0deg);
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Fade Animations
   ───────────────────────────────────────────────────────────────────────────── */

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

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

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-down {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-left {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fade-in-right {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale In with Fade */
@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scale-in-bounce {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Slide Animations
   ───────────────────────────────────────────────────────────────────────────── */

@keyframes slide-in-left {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slide-in-right {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Motion Effects
   ───────────────────────────────────────────────────────────────────────────── */

/* Bounce */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(-15px);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

/* Shake */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Wobble */
@keyframes wobble {
    0%, 100% {
        transform: translateX(0) rotate(0);
    }
    15% {
        transform: translateX(-10px) rotate(-5deg);
    }
    30% {
        transform: translateX(8px) rotate(3deg);
    }
    45% {
        transform: translateX(-6px) rotate(-3deg);
    }
    60% {
        transform: translateX(4px) rotate(2deg);
    }
    75% {
        transform: translateX(-2px) rotate(-1deg);
    }
}

/* Ripple Effect */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Premium Dark Luxe Effects
   ───────────────────────────────────────────────────────────────────────────── */

/* Aurora Glow - Ambient background effect */
@keyframes aurora {
    0%, 100% {
        opacity: 0.3;
        transform: translate(0, 0) scale(1);
        filter: hue-rotate(0deg);
    }
    33% {
        opacity: 0.5;
        transform: translate(30px, -20px) scale(1.1);
        filter: hue-rotate(30deg);
    }
    66% {
        opacity: 0.4;
        transform: translate(-20px, 30px) scale(0.95);
        filter: hue-rotate(-20deg);
    }
}

/* Gradient Flow - For gradient borders */
@keyframes gradient-flow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Border Glow Animation - Accent aware */
@keyframes border-glow {
    0%, 100% {
        border-color: var(--accent-soft, rgba(0, 212, 255, 0.2));
        box-shadow: 0 0 10px var(--accent-glow, rgba(0, 212, 255, 0.1));
    }
    50% {
        border-color: var(--accent, #00d4ff);
        box-shadow: 0 0 25px var(--accent-glow, rgba(0, 212, 255, 0.3));
    }
}

/* Shimmer Effect */
@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Scanning Line */
@keyframes scan-line {
    0% {
        top: 0%;
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        top: 100%;
        opacity: 0;
    }
}

/* Noise Flicker */
@keyframes noise-flicker {
    0%, 100% {
        opacity: 0.03;
    }
    50% {
        opacity: 0.05;
    }
}

/* Grain Animation */
@keyframes grain {
    0%, 100% {
        transform: translate(0, 0);
    }
    10% {
        transform: translate(-5%, -10%);
    }
    30% {
        transform: translate(3%, -15%);
    }
    50% {
        transform: translate(12%, 9%);
    }
    70% {
        transform: translate(9%, 4%);
    }
    90% {
        transform: translate(-1%, 7%);
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Neural Network Visualizations
   ───────────────────────────────────────────────────────────────────────────── */

/* Data Flow Animation - For network connections */
@keyframes data-flow {
    0% {
        stroke-dashoffset: 20;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* Reverse Data Flow */
@keyframes data-flow-reverse {
    0% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: 20;
    }
}

/* Neuron Activation */
@keyframes neuron-activate {
    0% {
        transform: scale(1);
        filter: brightness(1);
        box-shadow: 0 0 0 var(--accent-glow, rgba(0, 212, 255, 0.3));
    }
    50% {
        transform: scale(1.3);
        filter: brightness(1.5);
        box-shadow: 0 0 30px var(--accent-glow, rgba(0, 212, 255, 0.6));
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
        box-shadow: 0 0 0 var(--accent-glow, rgba(0, 212, 255, 0.3));
    }
}

/* Signal Propagation */
@keyframes signal-propagate {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(100px) scale(0.5);
    }
}

/* Weight Update Flash */
@keyframes weight-update {
    0% {
        stroke: var(--accent, #00d4ff);
        stroke-width: 3px;
    }
    100% {
        stroke: var(--text-tertiary, #4a5568);
        stroke-width: 1px;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Training State Animations
   ───────────────────────────────────────────────────────────────────────────── */

/* Training Pulse */
@keyframes training-pulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 20px var(--accent-glow, rgba(0, 212, 255, 0.2));
    }
    50% {
        opacity: 0.8;
        box-shadow: 0 0 40px var(--accent-glow, rgba(0, 212, 255, 0.4));
    }
}

/* Progress Bar Fill */
@keyframes progress-fill {
    from {
        width: 0%;
    }
    to {
        width: 100%;
    }
}

/* Indeterminate Progress */
@keyframes indeterminate {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(400%);
    }
}

/* Counter Bump */
@keyframes counter-bump {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
        color: var(--accent, #00d4ff);
    }
    100% {
        transform: scale(1);
    }
}

/* Success Checkmark */
@keyframes checkmark {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Modal & Overlay Animations
   ───────────────────────────────────────────────────────────────────────────── */

/* Modal Enter */
@keyframes modal-enter {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Modal Exit */
@keyframes modal-exit {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
}

/* Backdrop Fade */
@keyframes backdrop-fade {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(10px);
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Animation Utility Classes
   ───────────────────────────────────────────────────────────────────────────── */

.animate-fade-in {
    animation: fade-in 0.3s ease-out forwards;
}

.animate-fade-in-up {
    animation: fade-in-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-in-down {
    animation: fade-in-down 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-in-left {
    animation: fade-in-left 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-in-right {
    animation: fade-in-right 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-scale-in {
    animation: scale-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-scale-in-bounce {
    animation: scale-in-bounce 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-slide-in-left {
    animation: slide-in-left 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-slide-in-right {
    animation: slide-in-right 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-bounce {
    animation: bounce 1s infinite;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

.animate-wobble {
    animation: wobble 0.8s ease-in-out;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-glow {
    animation: glow-pulse 2s ease-in-out infinite;
}

.animate-text-glow {
    animation: text-glow-pulse 2s ease-in-out infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-spin-slow {
    animation: spin 3s linear infinite;
}

.animate-drift {
    animation: drift 4s ease-in-out infinite;
}

.animate-aurora {
    animation: aurora 8s ease-in-out infinite;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Hover Effects
   ───────────────────────────────────────────────────────────────────────────── */

.hover-lift {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4),
                0 0 30px var(--accent-glow, rgba(0, 212, 255, 0.1));
}

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px var(--accent-glow, rgba(0, 212, 255, 0.3)),
                0 0 60px var(--accent-glow, rgba(0, 212, 255, 0.1));
}

.hover-scale {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-brighten {
    transition: filter 0.3s ease;
}

.hover-brighten:hover {
    filter: brightness(1.2);
}

.hover-accent {
    transition: color 0.3s ease, border-color 0.3s ease;
}

.hover-accent:hover {
    color: var(--accent, #00d4ff);
    border-color: var(--accent, #00d4ff);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Network Visualization Animation Classes
   ───────────────────────────────────────────────────────────────────────────── */

/* Neuron Node */
.neuron-node {
    transition: all 0.2s ease;
}

.neuron-node:hover {
    filter: brightness(1.4);
    cursor: pointer;
}

.neuron-node--active {
    animation: neuron-activate 0.4s ease-out;
}

.neuron-node--pulsing {
    animation: glow-pulse 1.5s ease-in-out infinite;
}

/* Connection Line */
.connection-line {
    transition: stroke-width 0.2s ease, opacity 0.2s ease, stroke 0.2s ease;
}

.connection-line--active {
    stroke-dasharray: 8 4;
    animation: data-flow 0.4s linear infinite;
}

.connection-line--highlight {
    stroke: var(--accent, #00d4ff) !important;
    filter: drop-shadow(0 0 6px var(--accent-glow, rgba(0, 212, 255, 0.5)));
}

/* Weight Indicator */
.weight-indicator {
    transition: all 0.3s ease;
}

.weight-indicator--updating {
    animation: weight-update 0.5s ease-out;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Training State Classes
   ───────────────────────────────────────────────────────────────────────────── */

.training-active {
    position: relative;
}

.training-active::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, var(--accent, #00d4ff), transparent, var(--accent, #00d4ff));
    background-size: 200% 200%;
    border-radius: inherit;
    z-index: -1;
    opacity: 0.3;
    animation: gradient-flow 3s ease infinite;
}

/* Button Training State */
.btn--training {
    position: relative;
    overflow: hidden;
}

.btn--training::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Page Load Animations
   ───────────────────────────────────────────────────────────────────────────── */

.header {
    animation: fade-in-down 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar--left {
    animation: slide-in-left 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.sidebar--right {
    animation: slide-in-right 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.visualization {
    animation: scale-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.metrics-bar {
    animation: fade-in-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

/* Tab Panel Entry */
.tab-panel--active {
    animation: fade-in 0.3s ease-out;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Micro-interactions
   ───────────────────────────────────────────────────────────────────────────── */

/* Button Click Ripple */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.btn-ripple:active::after {
    animation: ripple 0.6s ease-out;
}

/* Input Focus Effect */
.input-focus-effect {
    position: relative;
}

.input-focus-effect::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent, #00d4ff), transparent);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.input-focus-effect:focus-within::after {
    left: 0;
    width: 100%;
}

/* Toggle Switch Animation */
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    box-shadow: 0 0 10px var(--accent-glow, rgba(0, 212, 255, 0.5));
}

/* ─────────────────────────────────────────────────────────────────────────────
   Stagger Animation Helpers
   ───────────────────────────────────────────────────────────────────────────── */

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }
.stagger-7 { animation-delay: 0.35s; }
.stagger-8 { animation-delay: 0.4s; }
.stagger-9 { animation-delay: 0.45s; }
.stagger-10 { animation-delay: 0.5s; }

/* Initial hidden state for staggered elements */
[class*="stagger-"] {
    opacity: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Counter Animations
   ───────────────────────────────────────────────────────────────────────────── */

.counter {
    display: inline-block;
    transition: transform 0.2s ease, color 0.2s ease;
}

.counter--changed {
    animation: counter-bump 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.counter--increasing {
    color: var(--color-success, #10b981);
}

.counter--decreasing {
    color: var(--color-error, #ef4444);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Loading States
   ───────────────────────────────────────────────────────────────────────────── */

/* Skeleton Loading */
@keyframes skeleton-pulse {
    0%, 100% {
        background-position: 200% 0;
    }
    50% {
        background-position: -200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card, #0e111c) 0%,
        var(--bg-elevated, #141826) 50%,
        var(--bg-card, #0e111c) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 2s ease-in-out infinite;
    border-radius: 4px;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    border-top-color: var(--accent, #00d4ff);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner--large {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

/* Dots Loading */
@keyframes dots-loading {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.dots-loading span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background: var(--accent, #00d4ff);
    border-radius: 50%;
    animation: dots-loading 1.4s ease-in-out infinite both;
}

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

/* ─────────────────────────────────────────────────────────────────────────────
   Special Effects
   ───────────────────────────────────────────────────────────────────────────── */

/* Glitch Effect */
@keyframes glitch {
    0%, 100% {
        transform: translate(0);
        opacity: 1;
    }
    20% {
        transform: translate(-2px, 2px);
        opacity: 0.8;
    }
    40% {
        transform: translate(2px, -2px);
        opacity: 0.9;
    }
    60% {
        transform: translate(-1px, -1px);
        opacity: 0.85;
    }
    80% {
        transform: translate(1px, 1px);
        opacity: 0.95;
    }
}

.glitch-effect {
    animation: glitch 0.3s ease-in-out;
}

/* Typing Cursor */
@keyframes blink-cursor {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

.typing-cursor::after {
    content: '|';
    animation: blink-cursor 1s step-end infinite;
    color: var(--accent, #00d4ff);
}

/* Attention Pulse - For important notifications */
@keyframes attention-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 var(--accent-glow, rgba(0, 212, 255, 0.4));
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px transparent;
    }
}

.attention {
    animation: attention-pulse 2s ease-in-out infinite;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Reduced Motion
   ───────────────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .animate-aurora,
    .animate-drift,
    .animate-pulse,
    .animate-glow,
    .animate-spin,
    .animate-bounce {
        animation: none !important;
    }

    [class*="stagger-"] {
        opacity: 1;
        animation-delay: 0s !important;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Print Styles
   ───────────────────────────────────────────────────────────────────────────── */

@media print {
    * {
        animation: none !important;
        transition: none !important;
    }
}
