/* Mobile Touch Optimierungen für bessere UX */

/* Basis Mobile Fixes */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Touch-friendly Buttons */
@media (pointer: coarse) {
    .btn,
    .nav-link,
    .filter-btn,
    .quick-service,
    .hamburger {
        min-height: 48px !important;
        min-width: 48px !important;
        padding: 12px 16px !important;
        touch-action: manipulation;
        user-select: none;
    }
    
    /* Touch feedback */
    .btn:active,
    .nav-link:active,
    .filter-btn:active,
    .quick-service:active {
        transform: scale(0.96) !important;
        transition: transform 0.1s ease !important;
    }
}

/* Mobile Input Optimizations */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px !important; /* Verhindert Zoom auf iOS */
        border-radius: 8px !important;
        padding: 12px 16px !important;
        line-height: 1.5 !important;
        appearance: none !important;
        -webkit-appearance: none !important;
    }
    
    /* Custom Select Arrow */
    select {
        background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23ffffff' d='m2 5l-2-3h4z'/%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: right 16px center !important;
        background-size: 12px !important;
        padding-right: 40px !important;
    }
    
    /* Remove default focus outline, add custom */
    input:focus,
    textarea:focus,
    select:focus {
        outline: none !important;
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
    }
}

/* Mobile Navigation Enhancements */
@media (max-width: 768px) {
    .nav-menu {
        overscroll-behavior: contain !important;
    }
    
    .nav-menu.active {
        animation: slideInFromLeft 0.3s ease-out !important;
    }
    
    @keyframes slideInFromLeft {
        from {
            transform: translateX(-100%) !important;
            opacity: 0 !important;
        }
        to {
            transform: translateX(0) !important;
            opacity: 1 !important;
        }
    }
    
    /* Staggered menu item animation */
    .nav-item {
        transition: transform 0.3s ease, opacity 0.3s ease !important;
    }
    
    .nav-menu.active .nav-item:nth-child(1) { transition-delay: 0.05s !important; }
    .nav-menu.active .nav-item:nth-child(2) { transition-delay: 0.1s !important; }
    .nav-menu.active .nav-item:nth-child(3) { transition-delay: 0.15s !important; }
    .nav-menu.active .nav-item:nth-child(4) { transition-delay: 0.2s !important; }
    .nav-menu.active .nav-item:nth-child(5) { transition-delay: 0.25s !important; }
    .nav-menu.active .nav-item:nth-child(6) { transition-delay: 0.3s !important; }
    .nav-menu.active .nav-item:nth-child(7) { transition-delay: 0.35s !important; }
}

/* Mobile Scroll Improvements */
@media (max-width: 768px) {
    html {
        scroll-behavior: smooth !important;
        scroll-padding-top: 80px !important;
    }
    
    body {
        overscroll-behavior: none !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Prevent bounce scrolling */
    .nav-menu.active ~ * {
        overflow: hidden !important;
        height: 100vh !important;
    }
}

/* Mobile Card Improvements */
@media (max-width: 768px) {
    .service-card,
    .gallery-item,
    .contact-item {
        transform: translateZ(0) !important; /* Hardware acceleration */
        backface-visibility: hidden !important;
    }
    
    .service-card:active,
    .gallery-item:active {
        transform: scale(0.98) translateZ(0) !important;
        transition: transform 0.1s ease !important;
    }
}

/* Mobile Typography Improvements */
@media (max-width: 768px) {
    h1, h2, h3, h4, h5, h6 {
        word-wrap: break-word !important;
        hyphens: auto !important;
        -webkit-hyphens: auto !important;
        -ms-hyphens: auto !important;
    }
    
    p, span, div {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
}

/* Loading States for Mobile */
@media (max-width: 768px) {
    .btn.loading {
        pointer-events: none !important;
        opacity: 0.8 !important;
    }
    
    .submit-btn.loading .btn-content {
        opacity: 0 !important;
    }
    
    .submit-btn.loading .btn-loading {
        opacity: 1 !important;
    }
}

/* Mobile Gallery Improvements */
@media (max-width: 768px) {
    .gallery-img {
        transition: transform 0.3s ease !important;
    }
    
    .gallery-item:active .gallery-img {
        transform: scale(1.02) !important;
    }
    
    .gallery-overlay {
        transition: opacity 0.3s ease !important;
    }
}

/* Mobile Contact Form Improvements */
@media (max-width: 768px) {
    .form-section {
        margin-bottom: 2rem !important;
    }
    
    .section-title {
        position: sticky !important;
        top: 80px !important;
        background: rgba(15, 23, 42, 0.95) !important;
        padding: 0.5rem 0 !important;
        z-index: 10 !important;
        margin-bottom: 1rem !important;
        border-radius: 8px !important;
    }
    
    .quick-services {
        gap: 0.75rem !important;
    }
    
    .quick-service {
        min-height: 60px !important;
        padding: 1rem 0.75rem !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        gap: 0.5rem !important;
    }
    
    .quick-service i {
        font-size: 1.25rem !important;
    }
    
    .quick-service span {
        font-size: 0.8rem !important;
        line-height: 1.2 !important;
    }
}

/* Accessibility Improvements for Mobile */
@media (max-width: 768px) {
    /* Focus indicators */
    button:focus,
    a:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid #3b82f6 !important;
        outline-offset: 2px !important;
    }
    
    /* High contrast mode support */
    @media (prefers-contrast: high) {
        .btn,
        .nav-link,
        .service-card {
            border: 2px solid currentColor !important;
        }
    }
    
    /* Reduced motion support */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
        
        .nav-menu.active .nav-item {
            transition-delay: 0s !important;
        }
    }
}

/* Landscape Mobile Optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .nav-menu {
        padding-top: 1rem !important;
        justify-content: flex-start !important;
        overflow-y: auto !important;
    }
    
    .nav-item {
        margin: 0.25rem 0 !important;
    }
    
    .nav-link {
        padding: 0.75rem 1.5rem !important;
        font-size: 1rem !important;
    }
    
    .hero {
        min-height: 100vh !important;
        padding: 3rem 0 1rem !important;
    }
}

/* Fix for mobile safari bottom bar */
@supports (-webkit-touch-callout: none) {
    .hero {
        min-height: -webkit-fill-available !important;
    }
    
    .nav-menu {
        height: -webkit-fill-available !important;
    }
}
