/* PostShare Mobile & Performance Optimizations */
/* Google Core Web Vitals & Mobile-First Responsive Design */

/* Critical Performance Optimizations */
* {
    will-change: auto;
}

body {
    /* Prevent layout shifts */
    contain: layout style paint;
    /* Optimize scrolling performance */
    -webkit-overflow-scrolling: touch;
    /* Prevent text scaling in landscape */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Mobile-First Responsive Grid */
.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .grid.sm\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .grid.sm\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
    .grid.md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .grid.md\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .grid.md\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
    .grid.lg\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .grid.lg\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Mobile Header Optimizations */
@media (max-width: 768px) {
    .header {
        height: 35px !important;
        padding: 0 0.5rem !important;
    }
    
    .logo {
        width: 24px !important;
        height: 24px !important;
        font-size: 12px !important;
    }
    
    .brand-text h1 {
        font-size: 14px !important;
    }
    
    .brand-text p {
        font-size: 10px !important;
    }
    
    .nav-actions .btn {
        padding: 0.3rem 0.6rem !important;
        font-size: 12px !important;
    }
    
    .navigation {
        padding: 0.3rem 0 !important;
    }
    
    .nav-links li a {
        font-size: 12px !important;
        padding: 0.2rem 0.5rem !important;
    }
}

/* Mobile Typography */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem !important;
        line-height: 1.2 !important;
        margin-bottom: 1rem !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
        line-height: 1.5 !important;
        margin-bottom: 1.5rem !important;
    }
    
    .text-3xl { font-size: 1.5rem !important; }
    .text-2xl { font-size: 1.25rem !important; }
    .text-xl { font-size: 1.125rem !important; }
    .text-lg { font-size: 1rem !important; }
}

/* Mobile Button Optimizations */
@media (max-width: 768px) {
    .btn-hero {
        padding: 0.8rem 1.5rem !important;
        font-size: 14px !important;
        margin: 0.25rem !important;
        min-height: 44px; /* Touch target size */
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn-hero.w-full {
        width: 100% !important;
    }
}

/* Mobile Card Optimizations */
@media (max-width: 768px) {
    .feature-card {
        padding: 1.5rem !important;
        margin-bottom: 1rem !important;
        border-radius: 15px !important;
    }
    
    .feature-card .w-16,
    .feature-card .w-14,
    .feature-card .w-12 {
        width: 40px !important;
        height: 40px !important;
        margin-bottom: 1rem !important;
    }
    
    .feature-card .text-2xl {
        font-size: 1.25rem !important;
    }
}

/* Mobile Spacing Optimizations */
@media (max-width: 768px) {
    .py-12 { padding: 0.5rem 0 !important; }
    .px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }
    .mb-16 { margin-bottom: 1rem !important; }
    .mb-12 { margin-bottom: 0.75rem !important; }
    .mb-8 { margin-bottom: 0.5rem !important; }
    .gap-8 { gap: 1rem !important; }
    .gap-6 { gap: 0.75rem !important; }
}

/* Mobile Form Optimizations */
@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px !important; /* Prevent zoom on iOS */
        padding: 0.75rem !important;
        border-radius: 8px !important;
    }
    
    .form-group {
        margin-bottom: 1rem !important;
    }
}

/* Touch Optimizations */
@media (hover: none) and (pointer: coarse) {
    .hover\:scale-105:hover {
        transform: none !important;
    }
    
    .hover\:shadow-xl:hover {
        box-shadow: none !important;
    }
    
    /* Add tap highlight */
    .btn-hero,
    .feature-card,
    .nav-links a {
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    }
}

/* Landscape Mobile Optimizations */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .hero-title {
        font-size: 2rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .hero-subtitle {
        font-size: 0.9rem !important;
        margin-bottom: 1rem !important;
    }
    
    .feature-card {
        padding: 1rem !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        color-scheme: dark;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .animated-bg,
    .particles {
        animation: none !important;
    }
}

/* High Contrast Support */
@media (prefers-contrast: high) {
    .feature-card {
        border-width: 2px !important;
        border-color: white !important;
    }
    
    .gradient-text {
        color: white !important;
        background: none !important;
        -webkit-background-clip: unset !important;
        -webkit-text-fill-color: unset !important;
    }
}

/* Performance Optimizations */
.feature-card {
    contain: layout style;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.btn-hero {
    contain: layout style;
    transform: translateZ(0);
}

/* Loading State Optimizations */
.loading {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Critical Content Prioritization */
.above-fold {
    contain: strict;
}

.below-fold {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}