/* Mobile-Specific Enhancements for YMER */

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    /* Ensure all interactive elements are touch-friendly */
    button, .btn, a, .nav-link, .feature-card {
        min-height: 44px;
        min-width: 44px;
        padding: max(0.75rem, 11px) max(1rem, 11px);
    }
    
    /* Remove hover effects on touch devices */
    .feature-card:hover {
        transform: none !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Enhanced focus states for touch */
    button:focus, .btn:focus, a:focus {
        outline: 2px solid #2d83c5;
        outline-offset: 2px;
        box-shadow: 0 0 0 4px rgba(45, 131, 197, 0.2);
    }
}

/* Mobile viewport optimizations */
@media screen and (max-width: 768px) {
    /* Prevent horizontal scrolling */
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Optimize font sizes for mobile */
    .hero-title {
        font-size: clamp(2rem, 8vw, 3rem) !important;
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: clamp(1rem, 4vw, 1.5rem) !important;
        line-height: 1.4;
    }
    
    .feature-title {
        font-size: clamp(1.25rem, 5vw, 1.75rem) !important;
    }
    
    .feature-description {
        font-size: clamp(0.9rem, 3.5vw, 1.1rem) !important;
        line-height: 1.6;
    }
    
    /* Optimize spacing for mobile */
    .container-ymer {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .section-padding {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }
    
    /* Mobile navigation enhancements */
    .sticky-header {
        backdrop-filter: blur(10px) saturate(180%);
        -webkit-backdrop-filter: blur(10px) saturate(180%);
    }
    
    .mobile-menu-toggle {
        touch-action: manipulation;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        transition: transform 0.2s ease;
    }
    
    .mobile-menu-toggle:active {
        transform: scale(0.9);
    }
    
    /* Mobile menu overlay */
    .nav-wrapper.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: -1;
        animation: fadeIn 0.3s ease;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    /* Mobile menu items animation */
    .nav-wrapper.active .nav-item {
        animation: slideInLeft 0.3s ease forwards;
        opacity: 0;
    }
    
    .nav-wrapper.active .nav-item:nth-child(1) { animation-delay: 0.05s; }
    .nav-wrapper.active .nav-item:nth-child(2) { animation-delay: 0.1s; }
    .nav-wrapper.active .nav-item:nth-child(3) { animation-delay: 0.15s; }
    
    @keyframes slideInLeft {
        from {
            transform: translateX(-20px);
            opacity: 0;
        }
        to {
            transform: translateX(0);
            opacity: 1;
        }
    }
    
    /* Touch feedback for navigation links */
    .nav-link {
        position: relative;
        overflow: hidden;
        transition: background-color 0.2s ease;
    }
    
    .nav-link:active {
        background-color: rgba(45, 131, 197, 0.1);
    }
    
    /* Feature cards mobile optimization */
    .feature-card {
        margin-bottom: 1.5rem;
        padding: 1.5rem;
        touch-action: manipulation;
        -webkit-touch-callout: none;
    }
    
    .feature-card img {
        max-height: 150px;
        width: auto;
        object-fit: contain;
    }
    
    /* Hero carousel mobile enhancements */
    .carousel-item {
        min-height: unset;
    }
    
    .carousel-caption {
        bottom: 20%;
        padding: 1rem;
    }
    
    .carousel-control-prev,
    .carousel-control-next {
        width: 15%;
        opacity: 0.7;
    }
    
    .carousel-indicators {
        bottom: 10px;
    }
    
    .carousel-indicators button {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        margin: 0 4px;
    }
}

/* Extra small screens */
@media screen and (max-width: 480px) {
    .hero-title {
        font-size: clamp(1.75rem, 7vw, 2.5rem) !important;
    }
    
    .feature-card {
        padding: 1rem;
    }
    
    .feature-card img {
        max-height: 120px;
    }
    
    .carousel-item {
        min-height: unset;
    }
    
    .carousel-caption {
        bottom: 15%;
        padding: 0.5rem;
    }
    
    .carousel-caption h5 {
        font-size: 1.25rem;
    }
    
    .carousel-caption p {
        font-size: 0.9rem;
        display: none; /* Hide description on very small screens */
    }
}

/* Landscape mobile optimization */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .sticky-header {
        height: var(--header-mobile-height);
    }
    
    .hero-section {
        /*min-height: 65vh;*/
    }
    
    .carousel-item {
        /*min-height: 100vh;*/
    }
    
    .carousel-caption {
        bottom: 10%;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .feature-card img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .feature-card {
        background: rgba(45, 131, 197, 0.1);
        border: 1px solid rgba(45, 131, 197, 0.2);
    }
    
    .feature-card h5 {
        color: #ffffff;
    }
    
    .feature-card p {
        color: var(--text-dark);
    }
}

/* 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;
    }
    
    .carousel {
        animation: none;
    }
    
    .parallax-bg {
        transform: none !important;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS Safari viewport height issues */
    .hero-section, .carousel-item {
        min-height: -webkit-fill-available;
    }
    
    /* Fix for iOS Safari bounce scrolling */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix for iOS Safari sticky positioning */
    .sticky-header {
        position: -webkit-sticky;
        position: sticky;
    }
}

/* Android Chrome specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .feature-card {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
}

/* Performance optimizations for mobile */
.feature-card, .carousel-item {
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Smooth scrolling for mobile */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Pull-to-refresh prevention for PWA */
body {
    overscroll-behavior-y: contain;
}

/* Mobile keyboard behavior */
.mobile-input-focus {
    position: fixed;
    z-index: 9999;
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .sticky-header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .mobile-menu {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* Loading states for touch interactions */
.loading-touch {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.loading-touch::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #2d83c5;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Haptic feedback simulation */
.haptic-feedback {
    transition: transform 0.1s ease;
}

.haptic-feedback:active {
    transform: scale(0.95);
}