/* Mobile Responsive Enhancements for Lofinda */

/* Base Mobile Optimizations */
@media (max-width: 475px) {
    /* Ensure text readability on small screens */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Optimize touch targets */
    button, a, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Improve spacing on mobile */
    section {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }
}

/* Header Mobile Enhancements */
@media (max-width: 1024px) {
    /* Ensure header doesn't overflow */
    header {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Mobile menu button styling */
    #mobile-menu-button {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Mobile menu positioning */
    .mobile-menu {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Product Section Mobile Responsive */
@media (max-width: 768px) {
    /* Product grid optimizations */
    .product-grid {
        gap: 1rem;
    }
    
    .product-card {
        border-radius: 12px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .product-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    }
    
    /* Product image responsive */
    .product-image {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        object-fit: cover;
    }
}

/* Hero Section Mobile Optimizations */
@media (max-width: 640px) {
    .hero-section {
        min-height: 60vh;
        padding: 2rem 1rem;
    }
    
    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
        line-height: 1.5;
        margin-bottom: 1.5rem;
    }
    
    .hero-cta {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

/* Animation Performance Optimizations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .hover-effect:hover {
        transform: none;
    }
    
    /* Enhance focus states for touch */
    button:focus,
    a:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid #a99ae3;
        outline-offset: 2px;
    }
    
    /* Better button states for touch */
    button:active,
    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* High DPI Display Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure crisp images on high DPI screens */
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape Mobile Optimizations */
@media (max-width: 896px) and (orientation: landscape) {
    /* Optimize for landscape mobile viewing */
    .mobile-menu {
        width: 320px;
    }
    
    .hero-section {
        min-height: 50vh;
        padding: 1.5rem;
    }
    
    /* Compact navigation for landscape */
    header {
        height: 60px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* Dark Mode Considerations */
@media (prefers-color-scheme: dark) {
    /* Maintain brand colors but adjust contrast if needed */
    .mobile-menu {
        background-color: #1f2937;
        color: #f9fafb;
    }
    
    .mobile-menu a {
        color: #f9fafb;
    }
    
    .mobile-menu a:hover {
        background-color: #374151;
    }
}

/* Loading State Optimizations */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* Improved Focus Management */
.focus-trap {
    outline: none;
}

.focus-trap:focus-within {
    outline: 2px solid #a99ae3;
    outline-offset: 2px;
}

/* Better Typography Scaling */
@media (max-width: 375px) {
    html {
        font-size: 14px;
    }
}

@media (min-width: 376px) and (max-width: 414px) {
    html {
        font-size: 15px;
    }
}

@media (min-width: 415px) {
    html {
        font-size: 16px;
    }
}

/* Enhanced Mobile Menu Interactions */
.mobile-menu-item {
    position: relative;
    overflow: hidden;
}

.mobile-menu-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(169, 154, 227, 0.1), transparent);
    transition: left 0.5s ease;
}

.mobile-menu-item:hover::before {
    left: 100%;
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: no-preference) {
    .animate-on-scroll {
        opacity: 0;
        transform: translateY(20px);
        transition: opacity 0.6s ease, transform 0.6s ease;
    }
    
    .animate-on-scroll.visible {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Safe Area Adjustments for Newer iPhones */
@supports (padding-top: env(safe-area-inset-top)) {
    .mobile-menu {
        padding-top: env(safe-area-inset-top);
    }
    
    header {
        padding-top: calc(0.75rem + env(safe-area-inset-top));
    }
}

/* Enhanced Cart Badge */
.cart-badge {
    position: relative;
}

.cart-badge::after {
    content: attr(data-count);
    position: absolute;
    top: -8px;
    right: -8px;
    background: #a99ae3;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid white;
}

/* Performance Optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Container Query Support (Future-proofing) */
@container (max-width: 768px) {
    .responsive-container {
        padding: 1rem;
    }
}