/* ============================================
   TRANSFORMER TUTORIAL - ANIMATIONS
   Smooth transitions and effects
   ============================================ */

/* ============================================
   KEYFRAME ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(0, 212, 255, 0.6);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   ATTENTION ANIMATION VISUALIZATION
   ============================================ */

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

.token-highlight {
    animation: glow 1.5s ease-in-out infinite;
}

.weight-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawLine 1.5s ease-in-out forwards;
}

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

/* ============================================
   INTERACTIVE HOVER EFFECTS
   ============================================ */

.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.hover-scale {
    transition: transform var(--transition-base);
}

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

.hover-glow {
    transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid var(--accent-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

/* ============================================
   PROGRESS ANIMATIONS
   ============================================ */

.progress-step {
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
}

.progress-step:nth-child(1) {
    animation-delay: 0.1s;
}

.progress-step:nth-child(2) {
    animation-delay: 0.2s;
}

.progress-step:nth-child(3) {
    animation-delay: 0.3s;
}

.progress-step:nth-child(4) {
    animation-delay: 0.4s;
}

/* ============================================
   TOKEN FLOW ANIMATION
   ============================================ */

.token-flow-container {
    position: relative;
    overflow: hidden;
}

.token-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: flowPath 3s ease-in-out infinite;
}

@keyframes flowPath {
    0% {
        transform: translateX(0) translateY(0);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateX(400px) translateY(0);
        opacity: 0;
    }
}

/* ============================================
   MATRIX CALCULATION ANIMATION
   ============================================ */

.matrix-calc-highlight {
    background: rgba(0, 212, 255, 0.2);
    animation: highlightPulse 1s ease-in-out;
}

@keyframes highlightPulse {

    0%,
    100% {
        background: rgba(0, 212, 255, 0.2);
    }

    50% {
        background: rgba(0, 212, 255, 0.4);
    }
}

/* ============================================
   ATTENTION HEATMAP
   ============================================ */

.heatmap-cell {
    transition: all var(--transition-base);
}

.heatmap-cell:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.8);
}

/* ============================================
   SCROLL ANIMATIONS
   ============================================ */

.scroll-fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   TEXT ANIMATIONS
   ============================================ */

.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--accent-primary);
    white-space: nowrap;
    animation: typing 3s steps(40) 1s forwards, blink 0.75s step-end infinite;
}

@keyframes typing {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

/* ============================================
   GRADIENT ANIMATIONS
   ============================================ */

.animated-gradient {
    background: linear-gradient(45deg,
            #667eea,
            #764ba2,
            #f093fb,
            #4facfe);
    background-size: 400% 400%;
    animation: gradientShift 10s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* ============================================
   CANVAS ANIMATION HELPERS
   ============================================ */

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.animation-label {
    position: absolute;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 10;
    animation: fadeIn 0.3s ease-out;
}

/* ============================================
   BUTTON CLICK EFFECTS
   ============================================ */

.btn-click-effect {
    position: relative;
    overflow: hidden;
}

.btn-click-effect::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-click-effect:active::before {
    width: 300px;
    height: 300px;
}

/* ============================================
   EXAMPLE TRANSITIONS
   ============================================ */

.example-transition-enter {
    opacity: 0;
    transform: scale(0.95);
}

.example-transition-enter-active {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.3s, transform 0.3s;
}

.example-transition-exit {
    opacity: 1;
    transform: scale(1);
}

.example-transition-exit-active {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s, transform 0.3s;
}

/* ============================================
   POSITIONAL ENCODING WAVE
   ============================================ */

.pe-wave {
    animation: wave 2s ease-in-out infinite;
}

@keyframes wave {

    0%,
    100% {
        d: path("M 0,50 Q 25,30 50,50 T 100,50");
    }

    50% {
        d: path("M 0,50 Q 25,70 50,50 T 100,50");
    }
}

/* ============================================
   RESPONSIVE ANIMATIONS
   ============================================ */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}