/* ===== MOBILE SCROLL FIXES & COMPATIBILITY ===== */
/* Essential fixes for better mobile scroll experience */

/* iOS Safari Fixes */
body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

/* Fix for iOS bounce scroll */
html, body {
    height: 100%;
    overflow-x: hidden;
}

/* Prevent horizontal scroll */
* {
    max-width: 100%;
    box-sizing: border-box;
}

/* Fix for sticky elements during scroll */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transform: translateZ(0);
    will-change: transform;
}

/* Optimize scroll performance */
.back-to-top,
.mobile-section-nav,
.mobile-scroll-indicator,
.mobile-fab-menu,
.scroll-progress {
    transform: translateZ(0);
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* Enhanced touch targets for better usability */
.section-nav-btn,
.scroll-dot,
.fab-item,
.back-to-top {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #d4af37, #f4d03f);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #f4d03f, #d4af37);
}

/* Fix for Firefox scrollbar */
html {
    scrollbar-width: thin;
    scrollbar-color: #d4af37 rgba(0, 0, 0, 0.1);
}

/* Prevent text selection during scroll gestures */
.back-to-top,
.section-nav-btn,
.scroll-dot,
.fab-main,
.fab-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Enhanced focus states for accessibility */
.back-to-top:focus,
.section-nav-btn:focus,
.scroll-dot:focus,
.fab-main:focus,
.fab-item:focus {
    outline: 2px solid #d4af37;
    outline-offset: 2px;
}

/* High contrast mode improvements */
@media (prefers-contrast: high) {
    .back-to-top,
    .section-nav-btn,
    .fab-main {
        border: 3px solid currentColor;
        font-weight: bold;
    }
    
    .scroll-progress {
        background: currentColor;
        height: 6px;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .scroll-progress,
    .back-to-top,
    .section-nav-btn {
        transition: none;
    }
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
    .back-to-top,
    .section-nav-btn {
        background: rgba(30, 30, 30, 0.9);
        border-color: #f4d03f;
        color: #f4d03f;
    }
    
    .back-to-top:hover,
    .section-nav-btn:hover {
        background: #f4d03f;
        color: #1e1e1e;
    }
    
    .scroll-progress {
        background: linear-gradient(90deg, #f4d03f, #d4af37);
    }
}

/* Fix for landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .mobile-section-nav {
        bottom: 20px;
        right: 10px;
        flex-direction: row;
        gap: 6px;
    }
    
    .section-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .back-to-top {
        bottom: 20px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
}

/* Fix for very small screens */
@media (max-width: 320px) {
    .mobile-section-nav {
        right: 5px;
        bottom: 70px;
    }
    
    .section-nav-btn {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }
    
    .mobile-scroll-indicator {
        right: 2px;
    }
    
    .scroll-dot {
        width: 6px;
        height: 6px;
    }
    
    .back-to-top {
        width: 45px;
        height: 45px;
        bottom: 20px;
        right: 5px;
    }
}

/* Fix for notch devices */
@supports (padding: max(0px)) {
    .mobile-section-nav {
        bottom: max(90px, env(safe-area-inset-bottom) + 70px);
        right: max(15px, env(safe-area-inset-right) + 15px);
    }
    
    .back-to-top {
        bottom: max(25px, env(safe-area-inset-bottom) + 25px);
        right: max(15px, env(safe-area-inset-right) + 15px);
    }
    
    .mobile-fab-menu {
        bottom: max(25px, env(safe-area-inset-bottom) + 25px);
        left: max(15px, env(safe-area-inset-left) + 15px);
    }
}

/* Fix for Chrome mobile pull-to-refresh */
body {
    overscroll-behavior-y: contain;
}

/* Prevent zoom on double tap for specific elements */
.back-to-top,
.section-nav-btn,
.scroll-dot,
.fab-main,
.fab-item {
    touch-action: manipulation;
}

/* Fix for iOS momentum scrolling */
main,
.content,
section {
    -webkit-overflow-scrolling: touch;
}

/* Fix for Android keyboard resize */
@media (max-height: 500px) {
    .mobile-section-nav,
    .back-to-top {
        display: none;
    }
}

/* Ensure proper stacking context */
.back-to-top { z-index: 1000; }
.mobile-section-nav { z-index: 999; }
.mobile-scroll-indicator { z-index: 998; }
.mobile-fab-menu { z-index: 997; }
.scroll-progress { z-index: 1001; }

/* Optimize for battery life */
@media (prefers-reduced-motion: reduce) {
    .back-to-top,
    .section-nav-btn,
    .scroll-dot {
        animation: none;
        transition: opacity 0.1s ease;
    }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== FOOTER FIXES FOR MOBILE SCROLL ===== */
/* Ensure footer is not affected by mobile scroll elements */

footer {
    position: relative !important;
    z-index: 1 !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Ensure footer content is properly contained */
footer .container,
footer .footer-content-wrapper {
    position: relative !important;
    z-index: 2 !important;
}

/* Fix footer spacing on mobile */
@media (max-width: 768px) {
    footer {
        margin-bottom: 80px !important; /* Space for mobile scroll elements */
        padding-bottom: 20px !important;
    }
    
    /* Ensure footer bottom has proper spacing */
    .footer-bottom {
        padding-bottom: 30px !important;
    }
}

/* Fix for very small screens */
@media (max-width: 480px) {
    footer {
        margin-bottom: 100px !important; /* More space for mobile elements */
    }
}

/* Ensure footer elements don't interfere with scroll elements */
footer * {
    position: relative !important;
    z-index: auto !important;
}

/* Fix footer grid layout on mobile */
@media (max-width: 768px) {
    .footer-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 25px !important;
        margin-bottom: 30px !important;
    }
    
    .footer-brand,
    .footer-column {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* Fix footer text alignment and spacing */
@media (max-width: 768px) {
    .footer-brand {
        text-align: left !important;
        padding-right: 0 !important;
    }
    
    .footer-social {
        justify-content: flex-start !important;
        margin-top: 15px !important;
    }
    
    .footer-links,
    .footer-contact {
        text-align: left !important;
    }
    
    .footer-links a {
        display: flex !important;
        align-items: center !important;
        padding: 8px 0 !important;
    }
    
    .footer-contact li {
        display: flex !important;
        align-items: flex-start !important;
        margin-bottom: 12px !important;
    }
}

/* Fix footer bottom alignment */
.footer-bottom {
    text-align: center !important;
    clear: both !important;
}

.footer-bottom p {
    margin: 0 !important;
    padding: 0 !important;
}

/* Prevent footer content from being cut off */
@media (max-width: 768px) {
    body {
        padding-bottom: 0 !important;
    }
    
    /* Ensure main content doesn't overlap footer */
    main {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }
}

/* Fix footer container width issues */
footer .container {
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

footer .footer-content-wrapper {
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding: 0 20px !important;
}

/* Ensure footer is always at bottom */
footer {
    margin-top: auto !important;
    flex-shrink: 0 !important;
}

/* Fix for landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    footer {
        margin-bottom: 60px !important;
    }
}

/* Fix footer social icons alignment */
@media (max-width: 768px) {
    .footer-social {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
        justify-content: flex-start !important;
    }
    
    .social-icon {
        flex-shrink: 0 !important;
    }
}