/* Floating Caterpillar Contact Button */
.caterpillar-btn {
    position: fixed;
    right: 30px;
    bottom: 100px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.caterpillar-body {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.caterpillar-segment {
    width: 50px;
    height: 40px;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    border-radius: 20px;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    animation: segmentPulse 2s ease-in-out infinite;
}

.caterpillar-segment:nth-child(2) {
    animation-delay: 0.2s;
    width: 48px;
    height: 38px;
}

.caterpillar-segment:nth-child(3) {
    animation-delay: 0.4s;
    width: 46px;
    height: 36px;
}

.caterpillar-segment:nth-child(4) {
    animation-delay: 0.6s;
    width: 44px;
    height: 34px;
}

.caterpillar-segment:nth-child(5) {
    animation-delay: 0.8s;
    width: 42px;
    height: 32px;
}

.caterpillar-head {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
    border-radius: 25px 25px 20px 20px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 5px 10px;
}

.caterpillar-eye {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

.caterpillar-eye::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: #2c3e50;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    animation: eyeBlink 4s infinite;
}

@keyframes eyeBlink {
    0%, 48%, 52%, 100% {
        transform: scaleY(1);
    }
    50% {
        transform: scaleY(0.1);
    }
}

.caterpillar-tracks {
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 55px;
    display: flex;
    justify-content: space-between;
}

.track {
    width: 22px;
    height: 12px;
    background: #34495e;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}

.track::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        #7f8c8d 0px,
        #7f8c8d 3px,
        transparent 3px,
        transparent 6px
    );
    top: 50%;
    transform: translateY(-50%);
    animation: trackMove 1s linear infinite;
}

@keyframes trackMove {
    0% {
        transform: translateY(-50%) translateX(0);
    }
    100% {
        transform: translateY(-50%) translateX(-6px);
    }
}

@keyframes segmentPulse {
    0%, 100% {
        transform: scaleY(1);
    }
    50% {
        transform: scaleY(0.95);
    }
}

.caterpillar-text {
    background: var(--color-secondary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    transition: all 0.3s ease;
}

/* Hover Effects */
.caterpillar-btn:hover .caterpillar-body {
    animation: caterpillarWiggle 0.5s ease-in-out infinite;
}

@keyframes caterpillarWiggle {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-3deg);
    }
    75% {
        transform: rotate(3deg);
    }
}

.caterpillar-btn:hover .caterpillar-text {
    background: var(--color-primary);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.caterpillar-btn:hover .caterpillar-segment {
    animation: segmentBounce 0.3s ease-in-out;
}

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

/* Animation de montée/descente selon le scroll */
.caterpillar-btn.moving-up {
    animation: moveUp 0.6s ease-out forwards;
}

.caterpillar-btn.moving-down {
    animation: moveDown 0.6s ease-out forwards;
}

@keyframes moveUp {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-20px) rotate(-5deg);
    }
    100% {
        transform: translateY(0) rotate(0deg);
    }
}

@keyframes moveDown {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(20px) rotate(5deg);
    }
    100% {
        transform: translateY(0) rotate(0deg);
    }
}

/* Effet de vibration pour attirer l'attention */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

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

/* Responsive */
@media (max-width: 768px) {
    .caterpillar-btn {
        right: 15px;
        bottom: 80px;
    }

    .caterpillar-segment {
        width: 40px;
        height: 32px;
    }

    .caterpillar-segment:nth-child(2) {
        width: 38px;
        height: 30px;
    }

    .caterpillar-segment:nth-child(3) {
        width: 36px;
        height: 28px;
    }

    .caterpillar-segment:nth-child(4) {
        width: 34px;
        height: 26px;
    }

    .caterpillar-segment:nth-child(5) {
        width: 32px;
        height: 24px;
    }

    .caterpillar-text {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }

    .track {
        width: 18px;
        height: 10px;
    }

    .caterpillar-eye {
        width: 6px;
        height: 6px;
    }

    .caterpillar-eye::after {
        width: 3px;
        height: 3px;
    }
}

/* Hide on very small screens */
@media (max-width: 480px) {
    .caterpillar-text {
        display: none;
    }
}
