/* Mobile First Responsive Design */

/* Base Mobile Styles (up to 640px) */
@media (max-width: 640px) {
    /* Typography Adjustments */
    :root {
        --font-size-xs: 0.7rem;
        --font-size-sm: 0.8rem;
        --font-size-base: 0.9rem;
        --font-size-lg: 1rem;
        --font-size-xl: 1.1rem;
        --font-size-2xl: 1.3rem;
        --font-size-3xl: 1.6rem;
        --font-size-4xl: 2rem;
        --font-size-5xl: 2.5rem;
        --font-size-6xl: 3rem;
        
        /* Adjusted Spacing for Mobile */
        --spacing-xs: 0.25rem;
        --spacing-sm: 0.75rem;
        --spacing-md: 1rem;
        --spacing-lg: 1.25rem;
        --spacing-xl: 2rem;
        --spacing-2xl: 2.5rem;
        --spacing-3xl: 3rem;
    }

    .container {
        padding: 0 var(--spacing-sm);
    }

    /* Navigation */
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: rgba(10, 10, 10, 0.95);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: var(--spacing-lg);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        animation: mobileMenuSlide 0.3s ease forwards;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links li {
        margin: var(--spacing-sm) 0;
    }

    .nav-links a {
        font-size: var(--font-size-lg);
        padding: var(--spacing-sm) 0;
        display: block;
        text-align: center;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-container {
        padding: 0 var(--spacing-lg);
    }

    /* Hero Section */
    .hero {
        min-height: 90vh;
        padding: var(--spacing-2xl) var(--spacing-sm);
    }

    .hero h1 {
        font-size: 2.2rem;
        margin-bottom: var(--spacing-lg);
    }

    .hero p {
        font-size: var(--font-size-lg);
        margin-bottom: var(--spacing-xl);
    }

    .cta-buttons {
        flex-direction: column;
        align-items: center;
        gap: var(--spacing-md);
    }

    .btn {
        width: 100%;
        max-width: 280px;
        padding: var(--spacing-md) var(--spacing-lg);
        font-size: var(--font-size-lg);
    }

    /* Phone Mockup */
    .phone-mockup {
        width: 250px;
        height: 500px;
        margin: var(--spacing-lg) auto;
    }

    .demo-content {
        padding: var(--spacing-md);
    }

    .posture-demo {
        width: 80px;
        height: 80px;
        font-size: var(--font-size-2xl);
    }

    /* Features Grid */
    .features-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .feature-card {
        padding: var(--spacing-lg);
    }

    .feature-icon {
        width: 50px;
        height: 50px;
        font-size: var(--font-size-xl);
    }

    /* Stats Section */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-lg);
    }

    .stat-item {
        padding: var(--spacing-md);
    }

    .stat-number {
        font-size: var(--font-size-3xl);
    }

    /* Demo Grid */
    .demo-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .demo-item {
        padding: var(--spacing-lg);
    }

    .demo-icon {
        font-size: var(--font-size-2xl);
    }

    /* Testimonials */
    .testimonials-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .testimonial-card {
        padding: var(--spacing-lg);
    }

    .testimonial-content p {
        font-size: var(--font-size-base);
    }

    /* Download Section */
    .download-buttons {
        flex-direction: column;
        align-items: center;
        gap: var(--spacing-md);
    }

    .download-btn {
        width: 100%;
        max-width: 280px;
        padding: var(--spacing-lg);
    }

    .download-text {
        align-items: center;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: var(--spacing-xl);
    }

    .footer-section {
        margin-bottom: var(--spacing-lg);
    }

    .social-links {
        justify-content: center;
    }

    /* AI Assistant */
    .ai-assistant {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 20px;
    }

    .assistant-icon {
        font-size: var(--font-size-xl);
    }

    /* Section Padding */
    .features-preview,
    .stats-section,
    .quick-demo,
    .testimonials,
    .download-cta {
        padding: var(--spacing-2xl) 0;
    }

    /* Hide complex animations on mobile */
    .phone-mockup {
        animation: none;
    }

    .posture-demo {
        animation: pulse 3s ease-in-out infinite;
    }
}

/* Tablet Styles (641px to 768px) */
@media (min-width: 641px) and (max-width: 768px) {
    .container {
        padding: 0 var(--spacing-lg);
    }

    /* Navigation */
    .nav-container {
        padding: 0 var(--spacing-lg);
    }

    /* Hero adjustments */
    .hero h1 {
        font-size: 3rem;
    }

    .cta-buttons {
        flex-direction: row;
        justify-content: center;
        gap: var(--spacing-lg);
    }

    /* Phone Mockup */
    .phone-mockup {
        width: 280px;
        height: 560px;
    }

    /* Grids */
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-xl);
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .demo-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .testimonials-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Download buttons */
    .download-buttons {
        flex-direction: row;
        justify-content: center;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        text-align: left;
    }
}

/* Small Desktop Styles (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 0 var(--spacing-xl);
    }

    /* Navigation shows full menu */
    .nav-toggle {
        display: none;
    }

    .nav-links {
        display: flex;
        position: static;
        background: none;
        flex-direction: row;
        padding: 0;
        border: none;
        width: auto;
    }

    /* Hero section */
    .hero h1 {
        font-size: 3.5rem;
    }

    /* Grids maintain responsive columns */
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .demo-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .testimonials-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .footer-content {
        grid-template-columns: repeat(4, 1fr);
        text-align: left;
    }
}

/* Large Desktop Styles (1025px to 1280px) */
@media (min-width: 1025px) and (max-width: 1280px) {
    .container {
        max-width: 1100px;
    }

    /* All grids at full capacity */
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .demo-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .testimonials-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Extra Large Desktop Styles (1281px and up) */
@media (min-width: 1281px) {
    .container {
        max-width: 1200px;
    }

    /* Enhanced spacing for large screens */
    .hero {
        padding: var(--spacing-3xl) var(--spacing-lg);
    }

    .features-preview,
    .stats-section,
    .quick-demo,
    .testimonials,
    .download-cta {
        padding: var(--spacing-3xl) 0;
    }
}

/* Landscape Orientation Adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .hero {
        min-height: auto;
        padding: var(--spacing-xl) var(--spacing-lg);
    }

    .phone-mockup {
        width: 200px;
        height: 400px;
    }

    .section-title {
        font-size: var(--font-size-3xl);
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Enhance visual quality for retina displays */
    .bg-animation::before {
        opacity: 0.4;
    }

    .feature-card,
    .demo-item,
    .testimonial-card {
        border-width: 0.5px;
    }
}

/* Dark Mode Preference Support */
@media (prefers-color-scheme: dark) {
    /* Already dark by default, but can be enhanced */
    :root {
        --shadow-glow: 0 0 25px rgba(255, 107, 107, 0.4);
    }
}

/* Light Mode Preference Support */
@media (prefers-color-scheme: light) {
    /* Optional light mode styles */
    body.light-mode {
        --dark-bg: #ffffff;
        --dark-surface: #f8f9fa;
        --dark-surface-2: #e9ecef;
        --dark-surface-3: #dee2e6;
        --text-primary: #212529;
        --text-secondary: rgba(33, 37, 41, 0.8);
        --text-muted: rgba(33, 37, 41, 0.6);
        
        background: var(--dark-bg);
        color: var(--text-primary);
    }
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    .phone-mockup,
    .posture-demo,
    .ai-assistant,
    .assistant-pulse,
    .bg-animation {
        animation: none !important;
    }

    .feature-card:hover,
    .demo-item:hover,
    .testimonial-card:hover {
        transform: none;
    }

    .btn:hover {
        transform: none;
    }
}

/* Print Styles */
@media print {
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }

    .bg-animation,
    .ai-assistant,
    nav,
    .phone-mockup {
        display: none;
    }

    .hero {
        min-height: auto;
        padding: 2rem 0;
    }

    .section-title {
        color: black !important;
        -webkit-text-fill-color: black !important;
    }

    .feature-card,
    .demo-item,
    .testimonial-card {
        border: 1px solid #ccc;
        break-inside: avoid;
        margin-bottom: 1rem;
    }

    .download-buttons {
        display: none;
    }
}

/* Focus and Accessibility */
@media (prefers-reduced-motion: no-preference) {
    /* Enhanced focus styles for keyboard navigation */
    .btn:focus-visible,
    .nav-links a:focus-visible,
    .feature-card:focus-visible,
    .demo-item:focus-visible {
        outline: 2px solid var(--accent-color);
        outline-offset: 2px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Touch-specific styles */
    .btn {
        min-height: 44px;
        padding: var(--spacing-md) var(--spacing-xl);
    }

    .nav-links a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .download-btn {
        min-height: 60px;
    }

    .ai-assistant {
        width: 55px;
        height: 55px;
    }

    /* Remove hover effects on touch devices */
    .feature-card:hover,
    .demo-item:hover,
    .testimonial-card:hover {
        transform: none;
    }

    /* Make touch targets larger */
    .social-link {
        width: 50px;
        height: 50px;
    }
}

/* Very Large Screens (4K+) */
@media (min-width: 1920px) {
    .container {
        max-width: 1400px;
    }

    .hero h1 {
        font-size: 5rem;
    }

    .section-title {
        font-size: 3.5rem;
    }

    .phone-mockup {
        width: 350px;
        height: 700px;
    }
}

/* Ultra-wide Screens */
@media (min-aspect-ratio: 21/9) {
    .hero-content {
        max-width: 900px;
    }

    .features-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 1000px;
        margin: 0 auto;
    }
}

/* Specific Device Optimizations */

/* iPhone SE and similar small screens */
@media (max-width: 375px) {
    .hero h1 {
        font-size: 2rem;
    }

    .phone-mockup {
        width: 220px;
        height: 440px;
    }

    .btn {
        font-size: var(--font-size-base);
        padding: var(--spacing-sm) var(--spacing-md);
    }
}

/* iPad and similar tablets */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero {
        padding: var(--spacing-3xl) var(--spacing-xl);
    }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .hero {
        min-height: 70vh;
    }

    .phone-mockup {
        width: 250px;
        height: 500px;
    }
}

/* Navigation Enhancement for Different Screen Sizes */
@media (max-width: 768px) {
    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
}

/* Ensure proper spacing on all devices */
@media (max-width: 640px) {
    section {
        padding-left: var(--spacing-md);
        padding-right: var(--spacing-md);
    }
}

/* Performance optimization for mobile */
@media (max-width: 768px) {
    .bg-animation::before {
        display: none;
    }

    .phone-mockup {
        animation: none;
        box-shadow: var(--shadow-lg);
    }

    .assistant-pulse {
        animation: none;
    }
}