/* Back to Top Button Styles */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #B22222;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: url('images/redrighthand.png'), pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 9999;
    box-shadow: 0 0 10px rgba(178, 34, 34, 0.3);
    padding: 8px;
    animation: pulse 2s infinite;
}

/* Tooltip */
.back-to-top::after {
    content: "Back to Top";
    position: absolute;
    right: 60px;
    padding: 8px 15px;
    background: rgba(0, 0, 0, 0.9);
    color: #B22222;
    font-family: 'Broken Console Bold', monospace;
    font-size: 0.9rem;
    white-space: nowrap;
    border: 1px solid #B22222;
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 10px rgba(178, 34, 34, 0.2),
                inset 0 0 5px rgba(178, 34, 34, 0.2);
    text-shadow: 0 0 5px rgba(178, 34, 34, 0.5);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: rgba(178, 34, 34, 0.15);
    transform: translateY(-3px) rotate(360deg);
    box-shadow: 0 0 15px rgba(178, 34, 34, 0.4), inset 0 0 8px rgba(178, 34, 34, 0.3);
    border-color: rgba(255, 0, 64, 0.8);
}

.back-to-top:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    animation: tooltipGlitch 3s infinite;
}

@keyframes tooltipGlitch {
    0% {
        clip-path: inset(0 0 0 0);
        transform: translateX(0);
    }
    2% {
        clip-path: inset(20% 0 20% 0);
        transform: translateX(-2px);
    }
    4% {
        clip-path: inset(40% 0 40% 0);
        transform: translateX(2px);
    }
    6% {
        clip-path: inset(60% 0 60% 0);
        transform: translateX(-2px);
    }
    8% {
        clip-path: inset(0 0 0 0);
        transform: translateX(0);
    }
    100% {
        clip-path: inset(0 0 0 0);
        transform: translateX(0);
    }
}

.back-to-top .eye-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: invert(18%) sepia(97%) saturate(3836%) hue-rotate(343deg) brightness(85%) contrast(93%);
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    animation: randomBlink 10s linear infinite, float 3s ease-in-out infinite;
}

.back-to-top:hover .eye-icon {
    transform: scale(1.1);
    filter: invert(18%) sepia(97%) saturate(3836%) hue-rotate(343deg) brightness(100%) contrast(93%);
}

@keyframes randomBlink {
    0%, 96%, 98% {
        opacity: 1;
    }
    97% {
        opacity: 0;
    }
    97.5% {
        opacity: 1;
    }
    97.75% {
        opacity: 0;
    }
}

/* Add a slight delay to the eye-icon animation */
.back-to-top.visible .eye-icon {
    animation-delay: 0.5s;
}

/* Pulse animation */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(178, 34, 34, 0.2);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(178, 34, 34, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(178, 34, 34, 0);
    }
}

/* Floating animation */
@keyframes float {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
    100% {
        transform: translateY(0);
    }
}

/* Subtle glitch effect on hover */
.back-to-top:hover::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background: linear-gradient(45deg, rgba(178, 34, 34, 0.4), rgba(255, 0, 64, 0.3));
    z-index: -1;
    border-radius: 50%;
    animation: glitch 2s linear infinite;
    opacity: 0.6;
}

@keyframes glitch {
    0% {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
    25% {
        clip-path: polygon(0 15%, 100% 0, 100% 85%, 0 100%);
    }
    50% {
        clip-path: polygon(15% 0, 85% 0, 85% 100%, 15% 100%);
    }
    75% {
        clip-path: polygon(0 0, 100% 15%, 100% 100%, 0 85%);
    }
    100% {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
}
