/* ============================================
   Advanced Responsive Utilities
   ============================================ */

/* Extra Small Devices (Portrait Phones) */
@media (max-width: 375px) {
    :root {
        font-size: 14px;
    }
    
    .hero-title {
        font-size: 36px;
    }
    
    .section-title {
        font-size: 28px;
    }
    
    .btn {
        padding: 12px 24px;
        font-size: 14px;
    }
    
    .feature-card,
    .showcase-item {
        padding: var(--spacing-md);
    }
}

/* Small Devices (Landscape Phones) */
@media (min-width: 576px) and (max-width: 767px) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }
    
    .hero-buttons {
        flex-direction: row;
    }
    
    .btn {
        padding: 14px 32px;
    }
}

/* Medium Devices (Tablets) */
@media (min-width: 768px) and (max-width: 991px) {
    .container {
        padding: 0 40px;
    }
    
    .hero-title {
        font-size: 60px;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .showcase-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cta-content {
        grid-template-columns: 1fr;
    }
}

/* Large Devices (Desktops) */
@media (min-width: 992px) and (max-width: 1199px) {
    .container {
        padding: 0 60px;
    }
    
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .showcase-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Extra Large Devices */
@media (min-width: 1400px) {
    .container {
        max-width: 1400px;
    }
    
    .hero-title {
        font-size: 90px;
    }
    
    .section-title {
        font-size: 56px;
    }
}

/* Tablet Landscape Specific */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .hero {
        min-height: 80vh;
    }
    
    .hero-content {
        padding: var(--spacing-2xl) 0;
    }
}

/* High Resolution Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize for retina displays */
    .hero-bg img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 48px;
        padding: 16px 32px;
    }
    
    .nav-link {
        padding: 12px 0;
    }
    
    .social-link {
        width: 48px;
        height: 48px;
    }
    
    /* Remove hover effects on touch devices */
    .feature-card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
}

/* Print Optimization */
@media print {
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    .navbar,
    .mobile-menu-toggle,
    .hero-buttons,
    .cta-buttons,
    .social-links,
    .scroll-to-top {
        display: none !important;
    }
    
    .hero {
        min-height: auto;
        page-break-after: always;
    }
    
    .section-header {
        page-break-after: avoid;
    }
    
    .feature-card,
    .showcase-item {
        page-break-inside: avoid;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .hero-bg img {
        transform: none !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    /* Uncomment to enable dark mode */
    /*
    :root {
        --background: #1a1a1a;
        --white: #0f0f0f;
        --grey-900: #f5f5f5;
        --grey-700: #d1d1d1;
    }
    
    body {
        background-color: var(--background);
        color: var(--grey-700);
    }
    
    .navbar {
        background-color: #262626;
    }
    
    .feature-card,
    .phone-mockup {
        background-color: #262626;
    }
    */
}

/* Container Queries (Future-proof) */
@supports (container-type: inline-size) {
    .features {
        container-type: inline-size;
        container-name: features;
    }
    
    @container features (max-width: 768px) {
        .features-grid {
            grid-template-columns: 1fr;
        }
    }
}

/* Focus Visible for Keyboard Navigation */
@supports selector(:focus-visible) {
    *:focus {
        outline: none;
    }
    
    *:focus-visible {
        outline: 2px solid var(--brand-primary);
        outline-offset: 2px;
    }
}

/* Landscape Orientation - Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 100px 0 50px;
    }
    
    .hero-title {
        font-size: 40px;
        margin-bottom: 16px;
    }
    
    .hero-subtitle {
        font-size: 16px;
        margin-bottom: 24px;
    }
    
    .navbar {
        padding: 8px 0;
    }
}

/* Specific Device Targeting (iPhone X and similar) */
@media only screen 
    and (device-width: 375px) 
    and (device-height: 812px) 
    and (-webkit-device-pixel-ratio: 3) {
    
    .navbar {
        padding-top: env(safe-area-inset-top);
    }
    
    .hero {
        padding-top: env(safe-area-inset-top);
    }
}

/* iPad Pro Specific */
@media only screen 
    and (min-device-width: 1024px) 
    and (max-device-width: 1366px)
    and (-webkit-min-device-pixel-ratio: 2) {
    
    .showcase-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Skip to Content Link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--brand-primary);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 9999;
}

.skip-to-content:focus {
    top: 0;
}
