/**
 * Scroll To Top Button Styles
 * 
 * Floating button positioned in bottom right corner
 * with smooth transitions and hover effects.
 */

.ad-scroll-to-top {
    /* Positioning */
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    
    /* Button styling */
    width: 3rem;
    height: 3rem;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    
    /* Colors - using Arcane Druid theme colors */
    background: #2f6b44; /* Primary green */
    color: white;
    box-shadow: 0 4px 12px rgba(47, 107, 68, 0.3);
    
    /* Transitions */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.8);
    transition: all 0.3s ease-in-out;
    
    /* Flex layout for centering icon */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Show state */
.ad-scroll-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Hover effects */
.ad-scroll-to-top:hover {
    background: #245336; /* Darker green */
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(47, 107, 68, 0.4);
}

/* Active/pressed state */
.ad-scroll-to-top:active {
    transform: translateY(0) scale(0.95);
    box-shadow: 0 2px 8px rgba(47, 107, 68, 0.3);
}

/* Icon styling */
.ad-scroll-to-top svg {
    width: 1.5rem;
    height: 1.5rem;
    transition: transform 0.2s ease;
}

.ad-scroll-to-top:hover svg {
    transform: translateY(-1px);
}

/* Focus styles for accessibility */
.ad-scroll-to-top:focus {
    outline: none;
    box-shadow: 0 4px 12px rgba(47, 107, 68, 0.3), 0 0 0 3px rgba(47, 107, 68, 0.2);
}

/* Responsive adjustments - Fixed mobile visibility issues */
@media (max-width: 768px) {
    .ad-scroll-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 2.75rem; /* Increased from 2.5rem */
        height: 2.75rem; /* Increased from 2.5rem */
        /* Ensure it stays above mobile browser UI */
        z-index: 99999;
    }
    
    .ad-scroll-to-top svg {
        width: 1.4rem; /* Increased from 1.25rem */
        height: 1.4rem;
    }
}

@media (max-width: 480px) {
    .ad-scroll-to-top {
        bottom: 1.5rem; /* Increased from 1rem - safer distance from edge */
        right: 1.5rem; /* Increased from 1rem */
        width: 2.75rem; /* Increased from 2.25rem - was too small */
        height: 2.75rem;
        /* Add minimum size to prevent disappearing */
        min-width: 2.75rem;
        min-height: 2.75rem;
        /* Ensure visibility on mobile browsers */
        position: fixed !important;
    }
    
    .ad-scroll-to-top svg {
        width: 1.25rem; /* Increased from 1rem */
        height: 1.25rem;
        /* Ensure icon stays centered */
        flex-shrink: 0;
    }
}

/* Add a specific media query for very small screens */
@media (max-width: 360px) {
    .ad-scroll-to-top {
        bottom: 1.25rem;
        right: 1.25rem;
        /* Keep button large enough to be usable */
        width: 2.5rem;
        height: 2.5rem;
        min-width: 2.5rem;
        min-height: 2.5rem;
    }
}

/* Fix for mobile browsers with dynamic viewport */
@media (max-height: 600px) and (max-width: 768px) {
    .ad-scroll-to-top {
        /* Use viewport units that account for mobile browser UI */
        bottom: 5vh;
        right: 1.5rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ad-scroll-to-top {
        border: 2px solid currentColor;
        background: white;
        color: #2f6b44;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ad-scroll-to-top {
        transition: opacity 0.1s ease;
    }
    
    .ad-scroll-to-top:hover {
        transform: none;
    }
    
    .ad-scroll-to-top svg {
        transition: none;
    }
    
    .ad-scroll-to-top:hover svg {
        transform: none;
    }
}

/* Dark mode support (if theme supports it) */
@media (prefers-color-scheme: dark) {
    .ad-scroll-to-top {
        background: #4a8f65;
        box-shadow: 0 4px 12px rgba(74, 143, 101, 0.3);
    }
    
    .ad-scroll-to-top:hover {
        background: #3e7555;
        box-shadow: 0 6px 20px rgba(74, 143, 101, 0.4);
    }
    
    .ad-scroll-to-top:focus {
        box-shadow: 0 4px 12px rgba(74, 143, 101, 0.3), 0 0 0 3px rgba(74, 143, 101, 0.2);
    }
}