/* =============================================================================
   Mobile Optimization - Comprehensive Mobile Responsiveness
   Optimizes all pages for mobile devices (phones & tablets)
   ============================================================================= */

/* =============================================================================
   1. Global Mobile Improvements
   ============================================================================= */

/* Ensure proper viewport scaling */
@viewport {
    width: device-width;
    zoom: 1;
}

/* Prevent text size adjustment on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Smooth scrolling for mobile */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Improve tap highlighting */
* {
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
}

/* Remove 300ms delay on mobile */
a, button, input, select, textarea {
    touch-action: manipulation;
}

/* =============================================================================
   2. Typography Adjustments
   ============================================================================= */

@media (max-width: 768px) {
    /* Prevent font boosting on mobile */
    body {
        -webkit-text-size-adjust: none;
        text-size-adjust: none;
    }

    /* Improve readability */
    p, li {
        font-size: 16px;
        line-height: 1.6;
    }

    /* Headings scale better */
    h1 {
        font-size: clamp(1.75rem, 5vw, 2.5rem);
        line-height: 1.2;
    }

    h2 {
        font-size: clamp(1.5rem, 4vw, 2rem);
        line-height: 1.3;
    }

    h3 {
        font-size: clamp(1.25rem, 3vw, 1.5rem);
        line-height: 1.4;
    }
}

/* =============================================================================
   3. Navigation Improvements
   ============================================================================= */

@media (max-width: 768px) {
    /* Ensure mobile menu is accessible */
    .nav-toggle {
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
        background-color: transparent;
        border: 2px solid rgba(255, 255, 255, 0.8);
        border-radius: 6px;
    }

    /* Make hamburger lines visible */
    .nav-toggle-line {
        background-color: #fff !important;
        height: 3px;
        width: 24px;
    }

    /* Mobile menu improvements */
    .nav-menu {
        max-height: calc(100vh - 100px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background-color: #003d73 !important; /* Darker shade of #00549A */
    }

    /* Ensure header stays blue on mobile */
    .site-header {
        background-color: #00549A !important;
    }

    /* Touch-friendly nav links */
    .nav-link {
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        color: #fff !important; /* White text on blue background */
        background-color: transparent;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-link:hover,
    .nav-link:focus {
        background-color: rgba(255, 255, 255, 0.1) !important;
        color: #fff !important;
    }

    /* CTA button styling in mobile menu */
    .nav-cta {
        background-color: #f59e0b !important;
        color: #fff !important;
        border-radius: 6px;
        margin-top: 10px;
    }

    .nav-cta:hover {
        background-color: #d97706 !important;
    }

    /* Sticky header optimization */
    .site-header {
        position: sticky;
        top: 0;
        z-index: 1000;
    }
}

/* =============================================================================
   4. Layout & Grid Improvements
   ============================================================================= */

@media (max-width: 768px) {
    /* Container adjustments */
    .container, .container-clean {
        padding-left: 20px;
        padding-right: 20px;
    }

    /* Force single column on mobile */
    .projects-grid,
    .services-grid,
    .skills-categories,
    .contact-methods-grid {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }

    /* Hero layouts stack */
    .hero-content,
    .contact-grid {
        grid-template-columns: 1fr !important;
    }

    /* Better spacing for mobile */
    .section, .section-clean {
        padding: 40px 0;
    }

    .section-header {
        margin-bottom: 30px;
    }
}

@media (max-width: 480px) {
    /* Tighter spacing on small screens */
    .container, .container-clean {
        padding-left: 16px;
        padding-right: 16px;
    }

    .section, .section-clean {
        padding: 30px 0;
    }
}

/* =============================================================================
   5. Form Improvements
   ============================================================================= */

@media (max-width: 768px) {
    /* iOS-friendly input sizes (prevents zoom) */
    .form-input,
    .form-select,
    .form-textarea,
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important;
        min-height: 44px;
        padding: 12px 16px;
    }

    /* Better textarea */
    .form-textarea,
    textarea {
        min-height: 120px;
    }

    /* Touch-friendly buttons */
    .btn, .btn-clean, button[type="submit"] {
        min-height: 48px;
        padding: 12px 24px;
        font-size: 16px;
    }

    /* Form rows stack */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }

    /* Full width CTAs on mobile */
    .hero-actions,
    .cta-actions {
        flex-direction: column;
        width: 100%;
    }

    .hero-actions .btn,
    .cta-actions .btn {
        width: 100%;
        text-align: center;
    }
}

/* =============================================================================
   6. Card & Component Improvements
   ============================================================================= */

@media (max-width: 768px) {
    /* Better card spacing */
    .project-card,
    .service-card,
    .skill-category {
        margin-bottom: 20px;
    }

    /* Card content padding */
    .project-content,
    .service-card {
        padding: 20px;
    }

    /* Timeline improvements */
    .timeline::before {
        left: 20px;
    }

    .timeline-item {
        padding-left: 50px;
    }

    /* Accordion improvements */
    .faq-question,
    .accordion-header {
        padding: 16px;
        font-size: 16px;
    }

    .faq-answer.expanded,
    .accordion-content.active {
        padding: 0 16px 16px;
    }
}

/* =============================================================================
   7. Image & Media Optimization
   ============================================================================= */

@media (max-width: 768px) {
    /* Responsive images */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Project images */
    .project-image {
        aspect-ratio: 16 / 9;
        max-height: 250px;
    }

    /* Hero visuals */
    .hero-visual,
    .hero-code-block {
        max-width: 100%;
        padding: 20px;
    }

    /* Code blocks */
    .code-content {
        font-size: 14px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* =============================================================================
   8. Footer Optimization
   ============================================================================= */

@media (max-width: 768px) {
    .site-footer {
        padding: 40px 0 20px;
    }

    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 32px;
        text-align: center;
    }

    .footer-section {
        padding: 0 16px;
    }

    .footer-title {
        font-size: 1.125rem;
        margin-bottom: 16px;
    }

    .footer-description {
        font-size: 0.875rem;
        line-height: 1.6;
        margin-bottom: 16px;
    }

    .footer-subtitle {
        font-size: 1rem;
        margin-bottom: 12px;
    }

    .footer-nav {
        align-items: center;
        gap: 8px;
    }

    .footer-link,
    .footer-service {
        font-size: 0.875rem;
        padding: 8px 0;
    }

    .footer-social {
        justify-content: center;
        flex-wrap: wrap;
        gap: 12px;
        margin-top: 16px;
    }

    .social-link-enhanced {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px;
        min-height: 44px;
        border-radius: 50% !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        background-color: rgba(255, 255, 255, 0.1) !important;
        flex-shrink: 0;
    }

    .social-link-enhanced svg {
        width: 20px !important;
        height: 20px !important;
        flex-shrink: 0;
    }

    .footer-contact-info {
        gap: 12px;
        margin-bottom: 16px;
    }

    .footer-contact-item {
        font-size: 0.875rem;
        justify-content: center;
    }

    .footer-cta-button {
        display: inline-flex;
        padding: 12px 24px;
        font-size: 0.875rem;
        width: auto;
        max-width: 100%;
    }

    .footer-cta-button .material-icons {
        font-size: 20px;
    }

    .footer-bottom {
        margin-top: 24px;
        padding-top: 16px;
    }

    .footer-bottom-content {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .footer-copyright {
        font-size: 0.75rem;
        order: 2;
    }

    .back-to-top-btn {
        order: 1;
        padding: 8px 16px;
        font-size: 0.8125rem;
    }

    .back-to-top-btn .material-icons {
        font-size: 16px;
    }

    .back-to-top-text {
        font-size: 0.75rem;
    }

    .footer-legal {
        flex-direction: column;
        gap: 8px;
        order: 3;
    }

    .footer-legal-item {
        font-size: 0.75rem;
        padding: 4px;
    }
}

/* Extra small mobile footer */
@media (max-width: 480px) {
    .footer-content {
        gap: 24px;
    }

    .footer-section {
        padding: 0 12px;
    }

    .social-link-enhanced {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px;
        min-height: 42px;
        border-radius: 50% !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        background-color: rgba(255, 255, 255, 0.1) !important;
    }

    .social-link-enhanced svg {
        width: 18px !important;
        height: 18px !important;
    }

    .footer-cta-button {
        padding: 10px 20px;
        font-size: 0.8125rem;
        width: 100%;
    }
}

/* =============================================================================
   9. Table Responsiveness
   ============================================================================= */

@media (max-width: 768px) {
    /* Make tables scrollable */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* Stack table on very small screens if needed */
    @supports (display: grid) {
        table.responsive {
            display: grid;
        }
    }
}

/* =============================================================================
   10. Performance & Touch Improvements
   ============================================================================= */

@media (max-width: 768px) {
    /* Reduce animation complexity on mobile */
    @media (prefers-reduced-motion: no-preference) {
        * {
            animation-duration: 0.3s !important;
            transition-duration: 0.2s !important;
        }
    }

    /* Better scrolling performance */
    .nav-menu,
    .form-select,
    .code-content {
        -webkit-overflow-scrolling: touch;
    }

    /* Remove hover effects on touch devices */
    @media (hover: none) {
        .project-card:hover,
        .service-card:hover,
        .btn:hover {
            transform: none;
        }
    }
}

/* =============================================================================
   11. About Page Specific
   ============================================================================= */

@media (max-width: 768px) {
    /* Hero clean sections */
    .hero-clean {
        padding: 40px 20px;
    }

    .hero-content-clean {
        flex-direction: column;
        text-align: center;
    }

    .hero-text-clean {
        max-width: 100%;
    }

    .hero-title-clean {
        font-size: clamp(1.75rem, 6vw, 2.5rem);
    }

    .hero-visual-clean {
        margin-top: 30px;
    }

    /* Skills grid */
    .skills-grid-clean {
        grid-template-columns: 1fr !important;
    }

    /* Backend expertise grid */
    .backend-expertise-grid {
        grid-template-columns: 1fr !important;
    }

    .expertise-category {
        padding: 20px;
    }
}

/* =============================================================================
   12. Home Page Specific
   ============================================================================= */

@media (max-width: 768px) {
    /* Hero adjustments */
    .hero {
        padding: 40px 0;
    }

    .hero-actions {
        gap: 15px;
    }

    /* Service/feature cards */
    .services-grid {
        gap: 25px;
    }
}

/* =============================================================================
   13. Projects Page Specific
   ============================================================================= */

@media (max-width: 768px) {
    /* Project grid */
    .projects-grid {
        grid-template-columns: 1fr !important;
        gap: 30px;
    }

    /* Project filters */
    .filter-tabs {
        gap: 10px;
    }

    .filter-tab {
        padding: 10px 20px;
        font-size: 14px;
    }

    /* Project cards */
    .project-technologies {
        gap: 8px;
    }

    .tech-tag {
        font-size: 11px;
        padding: 4px 10px;
    }
}

/* =============================================================================
   14. Contact Page Specific
   ============================================================================= */

@media (max-width: 768px) {
    /* Contact form container */
    .contact-form-container {
        padding: 24px;
    }

    /* Contact methods */
    .contact-methods-grid {
        gap: 20px;
    }

    .contact-method-card {
        padding: 24px;
    }

    /* Social links */
    .social-links {
        flex-direction: column;
        gap: 12px;
    }

    .social-link {
        width: 100%;
        justify-content: center;
    }

    /* FAQ section */
    .faq-container {
        gap: 16px;
    }
}

/* =============================================================================
   15. Utility Classes
   ============================================================================= */

@media (max-width: 768px) {
    /* Hide on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Show only on mobile */
    .show-mobile {
        display: block !important;
    }

    /* Center on mobile */
    .center-mobile {
        text-align: center !important;
        justify-content: center !important;
    }

    /* Full width on mobile */
    .full-width-mobile {
        width: 100% !important;
    }

    /* No padding on mobile */
    .no-padding-mobile {
        padding: 0 !important;
    }
}

/* =============================================================================
   16. Small Mobile (< 480px) Specific Adjustments
   ============================================================================= */

@media (max-width: 480px) {
    /* Further reduce spacing */
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    /* Smaller buttons on tiny screens */
    .btn, .btn-clean {
        padding: 10px 20px;
        font-size: 14px;
    }

    /* Tighter cards */
    .project-card,
    .service-card {
        padding: 16px;
    }

    /* Smaller tech tags */
    .tech-tag {
        font-size: 10px;
        padding: 3px 8px;
    }
}

/* =============================================================================
   17. Extra Small Mobile (< 360px)
   ============================================================================= */

@media (max-width: 360px) {
    /* Minimal spacing for tiny devices */
    .container, .container-clean {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Even smaller text */
    body {
        font-size: 14px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    /* Compact buttons */
    .btn, .btn-clean {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* =============================================================================
   18. Tablet (481px - 768px) Specific
   ============================================================================= */

@media (min-width: 481px) and (max-width: 768px) {
    /* 2-column grid for tablets */
    .services-grid,
    .skills-categories {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Better use of tablet space */
    .hero-content {
        gap: 40px;
    }
}

/* =============================================================================
   19. Landscape Mobile Specific
   ============================================================================= */

@media (max-width: 896px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .hero,
    .section {
        padding: 30px 0;
    }

    /* Shorter hero */
    .hero-title {
        font-size: 2rem;
    }

    /* Compact navigation */
    .site-header {
        padding: 10px 0;
    }
}

/* =============================================================================
   20. High DPI / Retina Displays
   ============================================================================= */

@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
    /* Crisper borders */
    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* =============================================================================
   21. Dark Mode Support (Optional - for future)
   ============================================================================= */

@media (prefers-color-scheme: dark) {
    /* Mobile users often prefer dark mode */
    /* Add dark mode styles here if needed */
}

/* =============================================================================
   22. Print Optimization
   ============================================================================= */

@media print {
    /* Hide unnecessary elements on print */
    .nav-toggle,
    .nav-menu,
    .footer-social,
    .hero-actions,
    .cta-section {
        display: none !important;
    }

    /* Better print layout */
    * {
        background: white !important;
        color: black !important;
    }
}
