/* Back to Top Button with Scroll Progress */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 1000;
    background: none;
    border: none;
    padding: 0;
    border-radius: 50%;
}

.back-to-top.visible {
    opacity: 0.6;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-2px);
    opacity: 1; /* Full opacity on hover for color intensity */
}

.back-to-top-circle {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--background-color1, #ffffff);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
    overflow: hidden;
    /* Add backdrop filter for better visibility */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.back-to-top:hover .back-to-top-circle {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
    background: var(--background-color2, #f8f8f8);
}

/* Progress ring around the circle */
.progress-ring {
    position: absolute;
    top: -2px;
    left: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    transform: rotate(-90deg);
    pointer-events: none;
}

.progress-ring-background {
    fill: none;
    stroke: var(--text-color1-20-opacity, rgba(34, 34, 34, 0.1));
    stroke-width: 2;
    opacity: 0.5; /* Subtle background for both desktop and mobile */
}

.progress-ring-progress {
    fill: none;
    stroke: var(--text-color1, #222222);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 176; /* 2 * PI * 28 (radius) */
    stroke-dashoffset: 176;
    transition: stroke-dashoffset 0.1s ease;
    opacity: 0.6;
}

/* Arrow icon */
.back-to-top-arrow {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.arrow-svg {
    width: 100%;
    height: 100%;
    fill: var(--text-color1, #222222);
    transition: fill 0.3s ease;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
    }
    
    .back-to-top:active {
        transform: scale(0.95);
    }
    
    /* Hide on very small screens when keyboard might be visible */
    @media (max-height: 500px) {
        .back-to-top {
            display: none;
        }
    }
}

/* Ensure button doesn't interfere with content */
@media (max-width: 480px) {
    .back-to-top {
        bottom: 16px;
        right: 16px;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .back-to-top {
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }
    
    .progress-ring-progress {
        transition: none;
    }
    
    .back-to-top:hover {
        transform: none;
    }
}
