/**
 * Responsive Images and Touch Target CSS
 * Mobile-first approach with performance optimizations
 */

/* Responsive Image Base Classes */
.responsive-img {
    max-width: 100%;
    height: auto;
    display: block;
}

.responsive-img-inline {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

/* Lazy Loading Optimization */
.lazy-img {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-img.loaded {
    opacity: 1;
}

/* Image Container with Aspect Ratios */
.img-container {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
}

.img-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Common aspect ratios */
.aspect-16-9 {
    aspect-ratio: 16/9;
}

.aspect-4-3 {
    aspect-ratio: 4/3;
}

.aspect-1-1 {
    aspect-ratio: 1/1;
}

.aspect-3-2 {
    aspect-ratio: 3/2;
}

/* Property Image Specific Styles */
.property-img-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #f8f9fa;
    aspect-ratio: 16/9;
}

.property-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

.property-img:hover {
    transform: scale(1.05);
}

/* Hero Image Styles */
.hero-img-container {
    position: relative;
    width: 100%;
    min-height: 60vh;
    overflow: hidden;
    background: linear-gradient(135deg, #091435, #3E5CAA);
}

.hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0.8;
}

/* Agent Photo Styles */
.agent-photo-container {
    position: relative;
    overflow: hidden;
    border-radius: 50%;
    background: #f8f9fa;
    aspect-ratio: 1/1;
}

.agent-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

/* Touch Target Requirements (44px minimum) */
.tap-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Button Touch Targets */
.btn, 
.button, 
button,
input[type="submit"],
input[type="button"] {
    min-height: 44px;
    padding: 0.75rem 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.2;
}

/* Link Touch Targets */
.nav-link,
.menu-link,
.card-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* Form Input Touch Targets */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="search"],
select,
textarea {
    min-height: 44px;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    line-height: 1.2;
    transition: border-color 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #3E5CAA;
    box-shadow: 0 0 0 3px rgba(62, 92, 170, 0.1);
}

/* Image Loading States */
.img-loading {
    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;
    }
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
    /* Mobile-specific touch targets */
    .tap-target {
        min-height: 48px;
        min-width: 48px;
    }
    
    .btn,
    .button,
    button {
        min-height: 48px;
        padding: 1rem 1.5rem;
        width: 100%;
        justify-content: center;
    }
    
    .nav-link {
        min-height: 48px;
        padding: 1rem;
    }
    
    /* Stack images vertically on mobile */
    .img-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Adjust hero image height for mobile */
    .hero-img-container {
        min-height: 50vh;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    /* Tablet optimizations */
    .img-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 1025px) {
    /* Desktop optimizations */
    .img-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }
    
    /* Hover effects for non-touch devices */
    .btn:hover,
    .button:hover,
    button:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }
    
    .nav-link:hover {
        background: rgba(62, 92, 170, 0.1);
    }
}

/* Print Styles */
@media print {
    .responsive-img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
    
    .hero-img-container {
        height: 300px !important;
    }
}

/* High DPI Display Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .property-img,
    .hero-img,
    .agent-photo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .property-img,
    .lazy-img,
    .btn,
    .button,
    .nav-link {
        transition: none;
    }
    
    .property-img:hover {
        transform: none;
    }
    
    .img-loading {
        animation: none;
        background: #f0f0f0;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .img-container,
    .property-img-container,
    .agent-photo-container {
        background: #2c2c2c;
    }
    
    .img-loading {
        background: linear-gradient(90deg, #3c3c3c 25%, #4c4c4c 50%, #3c3c3c 75%);
        background-size: 200% 100%;
        animation: loading 1.5s infinite;
    }
    
    input,
    select,
    textarea {
        background: #2c2c2c;
        color: #fff;
        border-color: #4c4c4c;
    }
    
    input:focus,
    select:focus,
    textarea:focus {
        border-color: #3E5CAA;
    }
}