/* ========================================
   COMPREHENSIVE MOBILE RESPONSIVE FIXES
   ======================================== */

/* Force proper viewport behavior */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* Container fix for all devices */
.container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;
}

@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* ========================================
   NAVIGATION - MOBILE FIXES
   ======================================== */

@media (max-width: 768px) {
    /* Navigation */
    .main-nav {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(248, 251, 249, 0.98);
        backdrop-filter: blur(10px);
    }
}

/* ========================================
   HERO SECTION - MOBILE FIXES
   ======================================== */

@media (max-width: 768px) {
    .hero-section {
        padding-top: 90px !important;
        min-height: auto !important;
    }

    .hero-content {
        display: flex !important;
        flex-direction: column !important;
        gap: 2rem;
        text-align: center;
    }

    .hero-title {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }

    .hero-subtitle {
        font-size: 1.1rem !important;
    }

    .hero-description {
        font-size: 0.95rem !important;
        max-width: 100% !important;
    }

    .hero-profile {
        order: -1;
        margin-bottom: 1rem;
    }

    .profile-image-container {
        max-width: 250px !important;
        margin: 0 auto;
    }

    .hero-cta {
        flex-direction: column !important;
        gap: 1rem;
    }

    .hero-cta .btn {
        width: 100%;
        justify-content: center;
    }

    /* Video background - show on all devices per owner preference */
    .hero-video-container {
        display: block !important;
    }

    .hero-video {
        display: block !important;
    }

    /* Hide gradient - video shows instead */
    .hero-section::before {
        display: none !important;
    }
}

/* ========================================
   CARDS & GRIDS - MOBILE FIXES
   ======================================== */

@media (max-width: 768px) {
    .card-grid,
    .project-cards,
    .media-grid,
    .publications-grid,
    .expertise-grid,
    .affiliations-grid,
    .stats-container {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }

    .expertise-card,
    .project-card,
    .media-card,
    .publication-item {
        margin-bottom: 1rem;
    }

    .card-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.5rem !important;
    }
}

/* ========================================
   IMAGES - RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto !important;
    }

    .project-image,
    .media-image,
    .featured-image {
        height: auto !important;
        min-height: 200px;
    }

    .profile-image {
        width: 100% !important;
        height: auto !important;
    }
}

/* ========================================
   TYPOGRAPHY - MOBILE
   ======================================== */

@media (max-width: 768px) {
    .section-title {
        font-size: 1.8rem !important;
    }

    .section-subtitle {
        font-size: 1rem !important;
    }

    h1 { font-size: 2rem !important; }
    h2 { font-size: 1.75rem !important; }
    h3 { font-size: 1.4rem !important; }
    h4 { font-size: 1.2rem !important; }
    h5 { font-size: 1.1rem !important; }
    h6 { font-size: 1rem !important; }

    p, li {
        font-size: 0.95rem !important;
        line-height: 1.6 !important;
    }
}

/* ========================================
   BUTTONS - MOBILE
   ======================================== */

@media (max-width: 768px) {
    .btn {
        padding: 0.75rem 1.5rem !important;
        font-size: 0.95rem !important;
        width: auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-large {
        padding: 1rem 2rem !important;
        font-size: 1rem !important;
    }

    .btn i {
        margin-left: 0.5rem !important;
    }
}

/* ========================================
   SECTIONS - SPACING
   ======================================== */

@media (max-width: 768px) {
    section {
        padding: 3rem 0 !important;
    }

    .section-header {
        margin-bottom: 2rem !important;
    }

    .expertise-section,
    .impact-section,
    .projects-section,
    .publications-section,
    .media-section,
    .contact-section {
        padding: 3rem 0 !important;
    }
}

/* ========================================
   WORLD MAP - MOBILE
   ======================================== */

@media (max-width: 768px) {
    #world-map {
        height: 300px !important;
    }

    .map-container {
        margin: 2rem 0;
    }
}

/* ========================================
   FORMS - MOBILE
   ======================================== */

@media (max-width: 768px) {
    .form-row {
        flex-direction: column !important;
        gap: 1rem;
    }

    .form-group {
        width: 100% !important;
    }

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    select,
    textarea {
        width: 100% !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 0.875rem !important;
    }

    .contact-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem;
    }
}

/* ========================================
   FOOTER - MOBILE
   ======================================== */

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr !important;
        text-align: center !important;
        gap: 2rem;
    }

    .footer-about {
        grid-column: 1 !important;
    }

    .footer-social {
        justify-content: center !important;
        gap: 1rem;
    }

    .footer-social a {
        width: 50px !important;
        height: 50px !important;
    }

    .footer-links,
    .footer-contact {
        text-align: center !important;
    }

    .footer-links ul {
        list-style: none;
        padding: 0;
    }

    .footer-links a::before {
        display: none !important;
    }

    .footer-contact p {
        justify-content: center !important;
    }
}

/* ========================================
   MEDIA PAGE - MOBILE
   ======================================== */

@media (max-width: 768px) {
    .filter-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .filter-btn {
        padding: 0.5rem 1rem !important;
        font-size: 0.85rem !important;
    }

    .media-card {
        margin-bottom: 2rem;
    }

    .media-content {
        padding: 1.5rem !important;
    }

    .media-image {
        height: auto !important;
        min-height: 200px;
    }

    .media-image img {
        width: 100%;
        height: auto !important;
        object-fit: cover;
    }

    .featured-media {
        flex-direction: column !important;
    }

    .featured-video {
        width: 100% !important;
        margin-bottom: 1.5rem;
    }
}

/* ========================================
   PUBLICATIONS PAGE - MOBILE
   ======================================== */

@media (max-width: 768px) {
    .publication-item {
        padding: 1.5rem !important;
    }

    .pub-header {
        flex-direction: column !important;
        gap: 1rem;
    }

    .pub-icon {
        width: 50px !important;
        height: 50px !important;
    }

    .pub-content h3 {
        font-size: 1.1rem !important;
    }

    .pub-metrics {
        flex-wrap: wrap !important;
        gap: 0.75rem;
    }

    .pub-metric {
        font-size: 0.85rem !important;
        padding: 0.4rem 0.8rem !important;
    }

    .pub-actions {
        flex-wrap: wrap !important;
        gap: 0.75rem;
    }

    .pub-actions .btn {
        width: 100%;
    }
}

/* ========================================
   ABOUT PAGE - MOBILE
   ======================================== */

@media (max-width: 768px) {
    .bio-content {
        flex-direction: column !important;
    }

    .bio-image {
        margin-bottom: 2rem;
    }

    .bio-image img {
        width: 100% !important;
        height: auto !important;
    }

    .bio-stats {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .education-container-wrapper {
        grid-template-columns: 1fr !important;
        gap: 2rem;
    }

    .degree-item,
    .cert-item {
        padding: 1.5rem !important;
    }

    .timeline-item {
        padding-left: 1.5rem !important;
    }

    .timeline-marker {
        width: 25px !important;
        height: 25px !important;
        font-size: 0.75rem !important;
    }
}

/* ========================================
   PROJECTS PAGE - MOBILE
   ======================================== */

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

    .project-card {
        margin-bottom: 1.5rem;
    }

    .project-image {
        height: 200px !important;
    }

    .project-content {
        padding: 1.5rem !important;
    }

    .project-tags {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .project-tag {
        font-size: 0.75rem !important;
        padding: 0.3rem 0.6rem !important;
    }
}

/* ========================================
   CONTACT PAGE - MOBILE
   ======================================== */

@media (max-width: 768px) {
    .quick-contact {
        flex-direction: column !important;
        gap: 1.5rem;
    }

    .contact-method {
        width: 100% !important;
        padding: 1.5rem !important;
    }

    .contact-method i {
        font-size: 2rem !important;
    }
}

/* ========================================
   LOADER - MOBILE
   ======================================== */

@media (max-width: 768px) {
    .loader-forest-scene {
        width: 240px !important;
        height: 240px !important;
    }

    .loader-ring {
        width: 200px !important;
        height: 200px !important;
    }

    .loader-main-icon {
        width: 80px !important;
        height: 80px !important;
    }

    .loader-brand {
        font-size: 1.6rem !important;
        letter-spacing: 2px;
    }

    .loader-tagline {
        font-size: 0.9rem !important;
    }
}

/* ========================================
   ANIMATIONS - REDUCED ON MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Reduce animations for better performance */
    .forest-elements,
    .animated-leaf,
    .animated-bird {
        display: none !important;
    }

    .loader-particles .particle {
        display: none;
    }

    .loader-particles .particle:nth-child(1),
    .loader-particles .particle:nth-child(3),
    .loader-particles .particle:nth-child(5) {
        display: block;
    }
}

/* ========================================
   TABLET - SPECIFIC FIXES
   ======================================== */

@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 90%;
    }

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

    .hero-title {
        font-size: 3rem !important;
    }

    .section-title {
        font-size: 2.25rem !important;
    }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */

@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets for touch devices */
    .btn,
    .nav-link,
    .filter-btn,
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Remove hover effects on touch devices */
    .btn:hover,
    .card:hover,
    .project-card:hover {
        transform: none !important;
    }

    /* Better touch feedback */
    .btn:active,
    .nav-link:active {
        opacity: 0.7;
    }
}

/* ========================================
   LANDSCAPE MODE - MOBILE
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        padding: 6rem 0 3rem !important;
        min-height: auto !important;
    }

    .hero-profile {
        display: none;
    }

    .loader-forest-scene {
        width: 200px !important;
        height: 200px !important;
    }
}

/* ========================================
   VERY SMALL DEVICES
   ======================================== */

@media (max-width: 375px) {
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .hero-title {
        font-size: 1.75rem !important;
    }

    .section-title {
        font-size: 1.5rem !important;
    }

    .btn {
        padding: 0.625rem 1.25rem !important;
        font-size: 0.875rem !important;
    }

    .stat-number {
        font-size: 2rem !important;
    }

    .footer-social a {
        width: 44px !important;
        height: 44px !important;
    }
}

/* ========================================
   ACCESSIBILITY - MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Ensure text is readable */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* Prevent text from being too small */
    * {
        min-font-size: 14px;
    }

    /* Better focus indicators for keyboard navigation */
    a:focus,
    button:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid var(--primary-dark);
        outline-offset: 2px;
    }
}
