/* =====================
   ANIMATIONS & TRANSITIONS
   ===================== */

/* =====================
   NODE ANIMATIONS
   ===================== */

@keyframes nodeAppear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes nodePopIn {
    0% {
        opacity: 0;
        r: 0;
    }
    50% {
        opacity: 1;
        r: 35px;
    }
    100% {
        opacity: 1;
        r: 30px;
    }
}

@keyframes nodePulse {
    0%, 100% {
        opacity: 1;
        r: 30px;
    }
    50% {
        opacity: 0.7;
        r: 35px;
    }
}

@keyframes nodeHighlight {
    0% {
        filter: drop-shadow(0 0 0px rgba(0, 217, 255, 0));
    }
    50% {
        filter: drop-shadow(0 0 8px rgba(0, 217, 255, 0.8));
    }
    100% {
        filter: drop-shadow(0 0 0px rgba(0, 217, 255, 0));
    }
}

/* =====================
   BRANCH ANIMATIONS
   ===================== */

@keyframes branchDraw {
    from {
        stroke-dashoffset: 1000;
        opacity: 0;
    }
    to {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

@keyframes branchFade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes pathGlow {
    0% {
        stroke-width: 2px;
        filter: drop-shadow(0 0 0px rgba(255, 255, 0, 0));
    }
    50% {
        stroke-width: 3px;
        filter: drop-shadow(0 0 6px rgba(255, 255, 0, 0.8));
    }
    100% {
        stroke-width: 2px;
        filter: drop-shadow(0 0 0px rgba(255, 255, 0, 0));
    }
}

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

@keyframes textFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes textSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================
   BUTTON ANIMATIONS
   ===================== */

@keyframes buttonPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(52, 152, 219, 0);
    }
}

.btn-primary:active {
    animation: buttonPulse 0.6s;
}

/* =====================
   LOADING ANIMATION
   ===================== */

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

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

.loading {
    animation: spin 1s linear infinite;
}

/* =====================
   SVG ELEMENT CLASSES
   ===================== */

.tree-node {
    cursor: pointer;
    transition: all 250ms ease-in-out;
}

.tree-node circle {
    transition: all 250ms ease-in-out;
}

.tree-node:hover circle {
    filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.3));
    r: 33px;
}

.tree-node.active circle {
    animation: nodeHighlight 0.6s ease-in-out;
}

.tree-node text {
    pointer-events: none;
    user-select: none;
}

.tree-branch {
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all 250ms ease-in-out;
}

.tree-branch:hover {
    stroke-width: 2.5px;
    opacity: 0.8;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.2));
}

.tree-branch.active-path {
    stroke: #f39c12;
    stroke-width: 2.5px;
    animation: pathGlow 1s ease-in-out;
}

/* =====================
   ANIMATED CLASSES
   ===================== */

.animate-node-appear {
    animation: nodeAppear 400ms ease-out forwards;
}

.animate-node-popin {
    animation: nodePopIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.animate-branch-draw {
    animation: branchDraw 600ms ease-out forwards;
    stroke-dasharray: 1000;
}

.animate-branch-fade {
    animation: branchFade 400ms ease-out forwards;
}

.animate-text-fade {
    animation: textFadeIn 400ms ease-out forwards;
}

.animate-text-slide-up {
    animation: textSlideUp 500ms ease-out forwards;
}

/* =====================
   TRANSITION CLASSES
   ===================== */

.transition-smooth {
    transition: all 250ms ease-in-out;
}

.transition-fast {
    transition: all 150ms ease-in-out;
}

.transition-slow {
    transition: all 350ms ease-in-out;
}

/* =====================
   HOVER & FOCUS STATES
   ===================== */

.hoverable:hover {
    opacity: 0.8;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.focusable:focus-within {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
    border-color: #3498db;
}

/* =====================
   STATE ANIMATIONS
   ===================== */

.fade-in {
    animation: fadeIn 300ms ease-out forwards;
}

.fade-out {
    animation: fadeOut 300ms ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.slide-up {
    animation: slideUp 400ms ease-out forwards;
}

.slide-down {
    animation: slideDown 400ms ease-out forwards;
}

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

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

/* =====================
   ATTENTION SEEKERS
   ===================== */

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

.bounce {
    animation: bounce 600ms ease-in-out;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.shake {
    animation: shake 400ms ease-in-out;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

/* =====================
   UTILITY ANIMATIONS
   ===================== */

.disabled-state {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.success-state {
    animation: successPulse 600ms ease-out forwards;
}

@keyframes successPulse {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.error-state {
    animation: shake 400ms ease-in-out;
    border-color: #e74c3c !important;
}

/* =====================
   SEQUENTIAL ANIMATIONS
   ===================== */

.sequence-animate-1 { animation-delay: 0ms; }
.sequence-animate-2 { animation-delay: 100ms; }
.sequence-animate-3 { animation-delay: 200ms; }
.sequence-animate-4 { animation-delay: 300ms; }
.sequence-animate-5 { animation-delay: 400ms; }
.sequence-animate-6 { animation-delay: 500ms; }
.sequence-animate-7 { animation-delay: 600ms; }
.sequence-animate-8 { animation-delay: 700ms; }
.sequence-animate-9 { animation-delay: 800ms; }
.sequence-animate-10 { animation-delay: 900ms; }

/* =====================
   ACCESSIBILITY
   ===================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

@media (prefers-color-scheme: dark) {
    .tree-svg {
        background: #1e1e1e;
    }
}
