/**
 * Mobile Optimizations CSS
 * Additional optimizations for mobile performance and UX
 */

/* =====================================================
   LOADING STATES
   ===================================================== */

/* Loading skeleton animation */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-gray-100) 25%,
        var(--color-gray-50) 50%,
        var(--color-gray-100) 75%
    );
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Loading spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-gray-200);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

body.loading .loading-overlay {
    opacity: 1;
    visibility: visible;
}

/* =====================================================
   SCROLL INDICATORS
   ===================================================== */

/* Scroll indicator for hero sections */
.scroll-indicator {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 50px;
    border: 2px solid var(--color-white);
    border-radius: 20px;
    opacity: 0.7;
    animation: scroll-hint 2s ease-in-out infinite;
    z-index: 1;
}

.scroll-indicator::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: var(--color-white);
    border-radius: 50%;
    animation: scroll-dot 2s ease-in-out infinite;
}

@keyframes scroll-hint {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.3; }
}

@keyframes scroll-dot {
    0% { 
        transform: translate(-50%, 0); 
        opacity: 0; 
    }
    50% { 
        opacity: 1; 
    }
    100% { 
        transform: translate(-50%, 20px); 
        opacity: 0; 
    }
}

/* Hide scroll indicator on mobile landscape */
@media (max-height: 500px) {
    .scroll-indicator {
        display: none;
    }
}

/* =====================================================
   TOUCH OPTIMIZATIONS
   ===================================================== */

/* Better touch feedback for interactive elements */
.btn,
.card,
a[class*="__link"],
button {
    -webkit-tap-highlight-color: rgba(42, 157, 143, 0.1);
    touch-action: manipulation;
}

/* Prevent accidental double-tap zoom */
a, button, input, textarea {
    touch-action: manipulation;
}

/* Smooth scroll for touch devices */
@media (hover: none) and (pointer: coarse) {
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Larger touch targets on touch devices */
    .btn {
        min-height: 48px;
        min-width: 48px;
    }
    
    .header__link {
        min-height: 48px;
        padding: 12px 16px;
    }
    
    .header__toggle {
        min-width: 48px;
        min-height: 48px;
    }
}

/* =====================================================
   ACCESSIBILITY IMPROVEMENTS
   ===================================================== */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

/* Hide focus outline for mouse users */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Skip to content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary);
    color: var(--color-white);
    padding: 12px 20px;
    border-radius: 0 0 var(--radius-md) 0;
    z-index: 10000;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 0;
}

/* =====================================================
   MOBILE-SPECIFIC UTILITIES
   ===================================================== */

/* Prevent text size adjust on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Better font rendering on mobile */
body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
}

/* Responsive videos */
video,
iframe {
    max-width: 100%;
}

/* =====================================================
   PERFORMANCE OPTIMIZATIONS
   ===================================================== */

/* GPU acceleration for animations */
.btn,
.card,
.header__nav,
.modal {
    will-change: transform;
}

/* Reduce animations on low-end devices */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .scroll-indicator {
        display: none;
    }
}

/* Content visibility for better rendering performance */
.below-fold {
    content-visibility: auto;
}

/* =====================================================
   MOBILE LANDSCAPE OPTIMIZATIONS
   ===================================================== */

@media (max-height: 500px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .section {
        padding: var(--space-lg) 0;
    }
    
    .hero {
        min-height: auto;
        padding: var(--space-xl) 0;
    }
    
    /* Smaller hero title */
    .hero__title {
        font-size: clamp(1.5rem, 4vw, 2rem);
    }
}

/* =====================================================
   SAFE AREA INSETS (iOS notch support)
   ===================================================== */

@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .header {
        padding-top: calc(var(--space-md) + env(safe-area-inset-top));
    }
    
    /* Desktop - Header fixo */
    body.has-fixed-header {
        padding-top: calc(80px + env(safe-area-inset-top));
    }
    
    /* Mobile - manter valor original menor */
    @media (max-width: 768px) {
        body.has-fixed-header {
            padding-top: calc(73px + env(safe-area-inset-top));
        }
    }
}

/* =====================================================
   PRINT STYLES
   ===================================================== */

@media print {
    /* Hide non-essential elements */
    .header,
    .footer,
    .whatsapp-float,
    .scroll-indicator,
    .btn-cta-main {
        display: none !important;
    }
    
    /* Optimize for print */
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }
    
    a {
        text-decoration: underline;
    }
    
    /* Show URLs after links */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        font-weight: normal;
    }
}
