/* ===== RESPONSIVE DESIGN & PERFORMANCE OPTIMIZATION ===== */

/* Performance Critical CSS */
* {
    box-sizing: border-box;
}

/* Optimize animations for better performance */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* GPU acceleration for performance-critical elements */
.da-parallax-element,
.hover-lift,
.floating-icon,
.hero-content,
.nav-link,
.attorney-card,
.practice-area-card,
.case-study-card {
    will-change: transform;
    transform: translateZ(0);
}

/* Base responsive grid system */
.responsive-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Mobile First Approach - Base styles for mobile */
/* ===== MOBILE (320px - 767px) ===== */
@media screen and (max-width: 767px) {
    /* Typography adjustments */
    .da-heading-1 { 
        font-size: clamp(2rem, 8vw, 3rem);
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    .da-heading-2 { 
        font-size: clamp(1.75rem, 6vw, 2.25rem);
        line-height: 1.25;
    }
    
    .da-heading-3 { 
        font-size: clamp(1.5rem, 5vw, 1.875rem);
    }
    
    .da-heading-4 { 
        font-size: clamp(1.25rem, 4vw, 1.5rem);
    }
    
    .da-body-large {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    /* Navigation mobile optimization */
    .desktop-nav {
        display: none;
    }
    
    .mobile-only {
        display: block !important;
    }
    
    #main-nav .da-container {
        padding: 0 12px;
    }
    
    #main-nav .da-flex {
        height: 70px;
    }
    
    .logo-icon {
        width: 32px !important;
        height: 32px !important;
    }
    
    .logo-icon i {
        font-size: 14px !important;
    }
    
    .mobile-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--da-bg-overlay);
        backdrop-filter: blur(20px);
        border-top: 1px solid var(--da-border-light);
        padding: 20px 16px;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        opacity: 0;
    }
    
    .mobile-nav.active {
        transform: translateY(0);
        opacity: 1;
    }
    
    .mobile-nav ul {
        gap: 16px !important;
    }
    
    /* Hero section mobile optimization */
    .hero-content {
        padding: 80px 0 60px;
        text-align: center;
    }
    
    .hero-subtitle {
        font-size: 0.95rem !important;
        padding: 0 12px;
        margin-bottom: 40px !important;
    }
    
    .hero-stats {
        flex-direction: column !important;
        gap: 24px !important;
        margin-bottom: 40px !important;
    }
    
    .hero-stats .stat-item {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 16px;
        padding: 16px;
        background: rgba(26, 26, 46, 0.6);
        border-radius: 12px;
        border: 1px solid var(--da-border-light);
    }
    
    .hero-stats .stat-number {
        font-size: 28px !important;
        margin: 0;
    }
    
    .hero-stats .stat-label {
        margin: 0;
        white-space: nowrap;
    }
    
    .hero-cta {
        flex-direction: column !important;
        gap: 12px !important;
        padding: 0 12px;
    }
    
    .hero-cta .da-btn {
        width: 100%;
        padding: 16px 24px !important;
        font-size: 16px !important;
    }
    
    .trust-indicators {
        margin-top: 40px !important;
        padding: 0 12px;
    }
    
    .trust-indicators .da-flex {
        flex-direction: column !important;
        gap: 16px !important;
    }
    
    .trust-badge {
        justify-content: center;
        padding: 12px;
        background: rgba(26, 26, 46, 0.4);
        border-radius: 8px;
        border: 1px solid var(--da-border-light);
    }
    
    /* Grid layouts mobile optimization */
    .da-grid-cols-2,
    .da-grid-cols-3,
    .da-grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    /* Cards mobile optimization */
    .attorney-card,
    .practice-area-card,
    .case-study-card {
        margin-bottom: 20px;
        padding: 20px;
    }
    
    .attorney-photo {
        width: 60px !important;
        height: 60px !important;
    }
    
    .practice-area-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 24px !important;
    }
    
    /* Search section mobile optimization */
    .attorney-search .da-flex {
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .attorney-search .da-input {
        width: 100%;
    }
    
    /* Button adjustments */
    .da-btn-xl {
        padding: 12px 20px !important;
        font-size: 16px !important;
    }
    
    .da-btn-lg {
        padding: 10px 16px !important;
        font-size: 15px !important;
    }
    
    /* Modal mobile optimization */
    .modal-content {
        width: 95% !important;
        max-width: none !important;
        max-height: 95vh !important;
        margin: 0 8px;
    }
    
    #chat-messages {
        height: 300px !important;
    }
    
    .chat-input {
        padding: 16px !important;
    }
    
    /* Footer mobile optimization */
    footer .da-grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 32px;
    }
    
    .footer-bottom .da-flex {
        flex-direction: column !important;
        gap: 16px;
        text-align: center;
    }
    
    /* Spacing adjustments */
    .da-py-20 {
        padding: 48px 0 !important;
    }
    
    .da-py-12 {
        padding: 32px 0 !important;
    }
    
    .da-container {
        padding: 0 12px;
    }
    
    /* Scroll to top button */
    #scroll-to-top {
        bottom: 16px !important;
        right: 16px !important;
        width: 44px !important;
        height: 44px !important;
    }
}

/* ===== TABLET (768px - 1023px) ===== */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    /* Typography */
    .da-heading-1 { 
        font-size: clamp(3rem, 6vw, 4rem);
    }
    
    .da-heading-2 { 
        font-size: clamp(2.25rem, 5vw, 3rem);
    }
    
    /* Navigation */
    .desktop-nav {
        display: flex;
        gap: 24px;
    }
    
    .mobile-only {
        display: none;
    }
    
    /* Hero section */
    .hero-stats {
        gap: 32px !important;
    }
    
    .hero-cta {
        flex-direction: row !important;
        justify-content: center;
        gap: 16px !important;
    }
    
    /* Grid adjustments */
    .da-grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .da-grid-cols-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Cards */
    .attorney-photo {
        width: 70px !important;
        height: 70px !important;
    }
    
    .practice-area-icon {
        width: 70px !important;
        height: 70px !important;
        font-size: 28px !important;
    }
    
    /* Search layout */
    .attorney-search .da-flex {
        flex-direction: row !important;
        gap: 16px !important;
    }
    
    /* Modal optimization */
    .modal-content {
        width: 85% !important;
        max-width: 700px !important;
    }
    
    #chat-messages {
        height: 400px !important;
    }
    
    /* Footer */
    footer .da-grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 40px;
    }
}

/* ===== DESKTOP (1024px - 1439px) ===== */
@media screen and (min-width: 1024px) and (max-width: 1439px) {
    /* Standard desktop layout */
    .da-container {
        max-width: 1200px;
        padding: 0 24px;
    }
    
    /* Navigation */
    .desktop-nav {
        gap: 32px;
    }
    
    /* Hero optimization */
    .hero-content {
        padding: 120px 0 80px;
    }
    
    .hero-stats {
        gap: 48px !important;
    }
    
    /* Grid layouts */
    .da-grid-cols-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .da-grid-cols-3 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ===== LARGE DESKTOP (1440px+) ===== */
@media screen and (min-width: 1440px) {
    .da-container {
        max-width: 1400px;
        padding: 0 32px;
    }
    
    /* Enhanced spacing for large screens */
    .da-py-20 {
        padding: 120px 0;
    }
    
    .hero-content {
        padding: 140px 0 100px;
    }
    
    /* Full grid layouts */
    .da-grid-cols-4 {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    .da-grid-cols-3 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    /* Larger elements for big screens */
    .attorney-photo {
        width: 90px !important;
        height: 90px !important;
    }
    
    .practice-area-icon {
        width: 90px !important;
        height: 90px !important;
        font-size: 36px !important;
    }
}

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

/* Lazy loading for images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Intersection Observer optimizations */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Critical path CSS inlining */
.above-fold {
    contain: layout style paint;
}

/* GPU layer optimization */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Reduce layout thrashing */
.no-layout-shift {
    contain: layout;
}

/* Critical animations */
@keyframes fadeInFast {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-fast {
    animation: fadeInFast 0.3s ease-out;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --da-text-primary: #ffffff;
        --da-text-secondary: #f0f0f0;
        --da-text-muted: #d0d0d0;
        --da-border-light: rgba(255, 255, 255, 0.3);
        --da-border-medium: rgba(255, 255, 255, 0.5);
        --da-border-heavy: rgba(255, 255, 255, 0.7);
    }
    
    .da-btn {
        border-width: 2px;
    }
    
    .attorney-card,
    .practice-area-card,
    .case-study-card {
        border-width: 2px;
    }
}

/* Print styles */
@media print {
    * {
        background: white !important;
        color: black !important;
        text-shadow: none !important;
        box-shadow: none !important;
    }
    
    .da-nav,
    .mobile-nav,
    .da-btn,
    #scroll-to-top,
    .modal {
        display: none !important;
    }
    
    .da-container {
        width: auto;
        margin: 0;
        padding: 0;
    }
    
    .hero-content {
        padding: 20px 0;
    }
    
    .da-grid {
        display: block;
    }
    
    .attorney-card,
    .practice-area-card,
    .case-study-card {
        break-inside: avoid;
        margin-bottom: 20px;
        border: 1px solid #ccc;
        padding: 15px;
    }
}

/* Ultra-wide displays (2560px+) */
@media screen and (min-width: 2560px) {
    .da-container {
        max-width: 1800px;
    }
    
    .hero-content {
        padding: 180px 0 140px;
    }
    
    .da-heading-1 {
        font-size: 8rem;
    }
    
    .da-heading-2 {
        font-size: 5rem;
    }
}

/* Foldable devices */
@media screen and (max-width: 1024px) and (orientation: landscape) {
    .hero-content {
        padding: 80px 0 60px;
    }
    
    .hero-stats {
        flex-direction: row !important;
        justify-content: space-around;
    }
    
    .da-grid-cols-3 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* Dark mode adjustments (if needed in future) */
@media (prefers-color-scheme: dark) {
    /* Dark Academia theme is already dark, but we might need adjustments */
    :root {
        --da-bg-primary: #0a0a18;
        --da-bg-secondary: #151526;
    }
}