/* 
 * Ottmegastore.in - Scroll To Top Button Styles
 * Author: Ravi Shandilya
 * Version: 1.2
 * Updated: June 2, 2025
 * Compatible with Chrome 136+, Android 13+, iOS 15+
 */

/* CSS variables for scroll properties that can be used by JavaScript */
html {
    /* Remove scroll-behavior to prevent fast native scrolling */
    /* scroll-behavior: smooth; */
    /* -webkit-scroll-behavior: smooth; */
    
    /* Add CSS variables for scroll properties that can be used by JavaScript */
    --scroll-duration: 1500ms;
    --scroll-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.scroll-to-top {
    position: fixed;
    bottom: -60px; /* Start off-screen */
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color, #4f46e5);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 999;
    will-change: transform, opacity, bottom;
    -webkit-tap-highlight-color: transparent;
    appearance: none;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: visible;
}

/* Circular progress bar styles */
.scroll-progress-circle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    display: block;
    box-sizing: border-box;
}
.scroll-progress-circle .progress-bg,
.scroll-progress-circle .progress-bar {
    transition: stroke-dashoffset 0.2s linear, stroke 0.3s;
}
.scroll-progress-circle .progress-bg {
    stroke: #e0e7ff;
    opacity: 0.5;
}
.scroll-progress-circle .progress-bar {
    stroke: var(--primary-color, #4f46e5);
    transition: stroke 0.3s, stroke-dashoffset 0.2s linear;
}
.scroll-to-top:hover .scroll-progress-circle .progress-bar {
    stroke: var(--primary-dark, #3730a3);
}


.scroll-progress-circle .progress-bg {
    stroke: #e0e7ff;
    opacity: 0.5;
    transition: stroke 0.3s;
}
.scroll-progress-circle .progress-bar {
    stroke: var(--primary-dark, #3730a3);
    transition: stroke-dashoffset 0.2s linear, stroke 0.3s;
}

/* Ensure the arrow icon is above the progress circle */
.scroll-to-top-inner {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.scroll-to-top .arrow-icon {
    width: 50%;
    height: 50%;
    fill: #fff;
    z-index: 2;
    pointer-events: none;
    will-change: transform;
    display: block;
    left: 0;
    top: 0;
    transform: none;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
}

.scroll-to-top.visible {
    bottom: 20px;
    opacity: 1;
}

.scroll-to-top:hover {
    background-color: var(--primary-dark, #3730a3);
    -webkit-transform: translateY(-5px);
            transform: translateY(-5px);
    -webkit-box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
            box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

/* Remove default svg arrow styling, handled by .arrow-icon and .scroll-progress-circle */
.scroll-to-top svg:not(.scroll-progress-circle):not(.arrow-icon) {
    display: none;
}


/* Animation for the arrow - slower and more gentle */
@-webkit-keyframes bounce {
    0%, 10%, 30%, 50%, 70%, 90%, 100% {
        -webkit-transform: translateY(0);
                transform: translateY(0);
    }
    20% {
        -webkit-transform: translateY(-3px);
                transform: translateY(-3px);
    }
    40% {
        -webkit-transform: translateY(-4px);
                transform: translateY(-4px);
    }
    60% {
        -webkit-transform: translateY(-3px);
                transform: translateY(-3px);
    }
    80% {
        -webkit-transform: translateY(-2px);
                transform: translateY(-2px);
    }
}

@keyframes bounce {
    0%, 10%, 30%, 50%, 70%, 90%, 100% {
        -webkit-transform: translateY(0);
                transform: translateY(0);
    }
    20% {
        -webkit-transform: translateY(-3px);
                transform: translateY(-3px);
    }
    40% {
        -webkit-transform: translateY(-4px);
                transform: translateY(-4px);
    }
    60% {
        -webkit-transform: translateY(-3px);
                transform: translateY(-3px);
    }
    80% {
        -webkit-transform: translateY(-2px);
                transform: translateY(-2px);
    }
}

.scroll-to-top.visible svg {
    -webkit-animation: none;
            animation: none;
    will-change: transform;
    -webkit-transform-style: preserve-3d;
            transform-style: preserve-3d;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .scroll-to-top {
        width: 45px;
        height: 45px;
        right: 15px;
    }
    .scroll-progress-circle {
        width: 100%;
        height: 100%;
    }
    .scroll-to-top .arrow-icon {
        width: 50%;
        height: 50%;
        min-width: 13px;
        min-height: 13px;
        max-width: 22px;
        max-height: 22px;
    }
    .scroll-to-top.visible {
        bottom: 15px;
    }
}



@media (max-width: 576px) {
    .scroll-to-top {
        width: 40px;
        height: 40px;
        right: 10px;
    }
    .scroll-progress-circle {
        width: 100%;
        height: 100%;
    }
    .scroll-to-top .arrow-icon {
        width: 50%;
        height: 50%;
        min-width: 10px;
        min-height: 10px;
        max-width: 18px;
        max-height: 18px;
    }
    .scroll-to-top.visible {
        bottom: 10px;
    }
}

