/* =====================================================
   MedMatch - Animations & Effects
   ===================================================== */

/* Hero Text Animation */
@keyframes wordFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    20% {
        opacity: 1;
        transform: translateY(0);
    }
    80% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.dynamic-text {
    position: relative;
    display: block;
    min-height: 1.5em;
    width: 100%;
}

.dynamic-text .word {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    visibility: hidden;
}

.dynamic-text .word.active {
    opacity: 1;
    visibility: visible;
    animation: wordFadeIn 3s ease-in-out;
}

.dynamic-text .word:nth-child(1) {
    animation-delay: 0s;
}

.dynamic-text .word:nth-child(2) {
    animation-delay: 3s;
}

.dynamic-text .word:nth-child(3) {
    animation-delay: 6s;
}

.dynamic-text .word:nth-child(4) {
    animation-delay: 9s;
}

/* Entrance Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes fadeInRight {
    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);
    }
}

/* Hero Floating Cards Animation */
@keyframes float-1 {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(10px, -15px) rotate(2deg);
    }
    50% {
        transform: translate(-5px, -20px) rotate(-1deg);
    }
    75% {
        transform: translate(15px, -10px) rotate(1deg);
    }
}

@keyframes float-2 {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(-15px, -10px) rotate(-2deg);
    }
    50% {
        transform: translate(-10px, -15px) rotate(1deg);
    }
    75% {
        transform: translate(-5px, -5px) rotate(-1deg);
    }
}

@keyframes float-3 {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(5px, -20px) rotate(1deg);
    }
    50% {
        transform: translate(10px, -15px) rotate(-2deg);
    }
    75% {
        transform: translate(-10px, -10px) rotate(1deg);
    }
}

.float-card.card-1 {
    animation: float-1 6s ease-in-out infinite;
}

.float-card.card-2 {
    animation: float-2 8s ease-in-out infinite;
}

.float-card.card-3 {
    animation: float-3 7s ease-in-out infinite;
}

/* Background Patterns Animation */
@keyframes patternMove {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 100% 100%;
    }
}

.hero::before {
    animation: patternMove 30s linear infinite;
}

/* Pulse Animation for CTAs */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(58, 138, 100, 0.4);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(58, 138, 100, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(58, 138, 100, 0);
    }
}

.btn-primary:hover {
    animation: pulse 2s infinite;
}

/* Loading States */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.loading {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* Scroll Reveal Animations */
.reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

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

.reveal-left.active {
    opacity: 1;
    transform: translateX(0);
}

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

.reveal-right.active {
    opacity: 1;
    transform: translateX(0);
}

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

.reveal-scale.active {
    opacity: 1;
    transform: scale(1);
}

/* Stagger Animation for Lists */
.stagger-item {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
}

.stagger-container.active .stagger-item {
    opacity: 1;
    transform: translateY(0);
}

.stagger-container.active .stagger-item:nth-child(1) {
    transition-delay: 0.1s;
}

.stagger-container.active .stagger-item:nth-child(2) {
    transition-delay: 0.2s;
}

.stagger-container.active .stagger-item:nth-child(3) {
    transition-delay: 0.3s;
}

.stagger-container.active .stagger-item:nth-child(4) {
    transition-delay: 0.4s;
}

/* Counter Animation */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.counter {
    display: inline-block;
    animation: countUp 0.5s ease-out;
}

/* Hover Effects */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.hover-grow {
    transition: transform 0.3s ease;
}

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

.hover-rotate {
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

/* Gradient Animation */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.animated-gradient {
    background: linear-gradient(
        -45deg,
        var(--primary),
        var(--primary-light),
        var(--accent),
        var(--primary-dark)
    );
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

/* Icon Animations */
@keyframes iconBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.icon-bounce:hover {
    animation: iconBounce 0.6s ease;
}

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

.icon-spin:hover {
    animation: iconSpin 0.6s linear;
}

/* Card Flip Animation */
.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.card-back {
    transform: rotateY(180deg);
}

/* Progress Bar Animation */
@keyframes progressFill {
    from {
        width: 0%;
    }
    to {
        width: var(--progress);
    }
}

.progress-bar {
    position: relative;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    animation: progressFill 2s ease-out forwards;
}

/* Typewriter Effect */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

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

.typewriter {
    overflow: hidden;
    white-space: nowrap;
    animation: typewriter 3s steps(40) forwards;
}

.typewriter::after {
    content: '|';
    animation: blink 1s infinite;
}

/* Mobile Menu Animation */
.menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Navigation Slide In */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.nav-links.mobile-active {
    animation: slideInRight 0.3s ease-out;
}

/* Notification Animation */
@keyframes slideInTop {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.notification {
    animation: slideInTop 0.5s ease-out;
}

/* Skeleton Loading */
@keyframes skeleton {
    0% {
        background-color: #e2e5e7;
    }
    100% {
        background-color: #f0f3f5;
    }
}

.skeleton {
    animation: skeleton 1s ease-in-out infinite alternate;
}

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

.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
}

.ripple:active::before {
    width: 100px;
    height: 100px;
    animation: ripple 0.6s ease-out;
}

/* Parallax Scrolling */
.parallax {
    transform: translateY(var(--parallax-offset, 0));
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus Animations */
input:focus,
textarea:focus {
    animation: focusPulse 0.3s ease;
}

@keyframes focusPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(58, 138, 100, 0.4);
    }
    100% {
        box-shadow: 0 0 0 4px rgba(58, 138, 100, 0.1);
    }
}

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

.checkmark-circle {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: checkmark 0.6s ease-out forwards;
}

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

.error-shake {
    animation: shake 0.5s ease;
}

/* =====================================================
   Horizontal Steps Animations
   ===================================================== */

/* Step fade in animation */
@keyframes stepFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Progress line fill animation */
@keyframes progressFill {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

/* Step number pulse on hover */
@keyframes stepPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.step-item:hover .step-circle {
    animation: stepPulse 0.6s ease;
}

/* Mobile step line animation */
@keyframes stepLineGrow {
    from {
        transform: scaleY(0);
        transform-origin: top;
    }
    to {
        transform: scaleY(1);
    }
}

@media (max-width: 768px) {
    .step-item.visible::before {
        animation: stepLineGrow 0.5s ease-out forwards;
        animation-delay: 0.3s;
    }
}