/* OPTIMIZED MEDIA QUERIES */

/* Large Desktop (1400px and down) */
@media screen and (max-width: 1400px) {
    .container {
        padding: 0 3rem;
    }
    
    #home {
        gap: 3rem;
        min-height: 90vh;
    }
    
    .section_pic_container img {
        width: 280px;
        height: 280px;
    }
}

/* Medium Desktop/Tablet (1200px and down) */
@media screen and (max-width: 1200px) {
    .container {
        padding: 0 2rem;
    }
    
    .nav-container {
        padding: 1rem 1.5rem;
    }
    
    /* Home section */
    #home {
        flex-direction: column;
        gap: 2rem;
        min-height: auto;
        padding: 2rem 0;
    }
    
    .section_pic_container img {
        width: 260px;
        height: 260px;
    }
    
    .section_text {
        text-align: center;
    }
    
    .title_1 {
        font-size: 2.8rem;
    }
    
    /* Projects */
    .flagship-projects {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }
    
    /* Contact */
    .contact-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

/* Small Tablet (768px and down) */
@media screen and (max-width: 768px) {
    /* Navigation */
    .nav-menu {
        display: none;
    }
    
    .hamburger {
        display: flex;
    }
    
    .nav-container {
        padding: 1rem;
    }
    
    /* Theme toggle - show text on mobile but smaller */
    .theme-toggle .theme-text {
        display: inline;
        font-size: 0.75rem;
    }
    
    .theme-toggle {
        padding: 0.4rem 0.8rem;
        border-radius: 20px;
        font-size: 0.8rem;
    }
    
    .theme-toggle i {
        font-size: 0.9rem;
    }
    
    /* Mobile nav hint */
    .mobile-nav-hint {
        display: none;
    }
    
    /* Hide Contact Info button on mobile (only in home section) */
    #home .btn_container {
        display: none;
    }
    
    /* Container adjustments */
    .container {
        padding: 0 1rem;
    }
    
    /* Home section */
    #home {
        padding: 1rem 0;
        min-height: 70vh;
    }
    
    .section_pic_container img {
        width: 220px;
        height: 220px;
    }
    
    .section_text_p1 {
        font-size: 1.1rem;
    }
    
    .title_1 {
        font-size: 2.2rem;
    }
    
    .section_text_p2 {
        font-size: 1.1rem;
    }
    
    .btn_color {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }
    
    /* Section titles */
    .title_2 {
        font-size: 2rem;
    }
    
    .title_2::after {
        width: 50px;
        height: 2px;
    }
    
    /* About section */
    .text_container p {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .tressiq-button {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }
    
    /* Social cards */
    .social-cards {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.8rem;
        padding: 0 1rem;
    }
    
    .social-card {
        padding: 0.7rem 1rem;
        font-size: 0.85rem;
    }
    
    .social-card i {
        font-size: 1.1rem;
    }
    
    /* Projects carousel */
    .projects-carousel,
    .blog-carousel {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    
    .project-card,
    .blog-post {
        flex: 0 0 auto;
        width: 100%;
        max-width: 320px;
    }
    
    .carousel-nav,
    .blog-carousel-nav,
    .other-projects-carousel-nav {
        display: flex;
        justify-content: center;
        gap: 1rem;
        margin-top: 1rem;
    }
    
    /* Other projects carousel mobile */
    .other-projects-carousel {
        display: flex;
        flex-direction: row;
    }
    
    .other-projects-carousel .project-card {
        min-width: 90vw;
        max-width: 90vw;
        flex: 0 0 90vw;
    }
    
    /* Projects grid */
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .project-card {
        margin: 0;
    }
    
    /* Research grid */
    .research-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .research-area {
        padding: 1.5rem;
    }
    
    .research-area i {
        font-size: 2.5rem;
    }
    
    /* Blog grid */
    .blog-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .blog-card {
        padding: 1.5rem;
    }
    
    /* Platform cards */
    .platform-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .platform-card {
        padding: 1rem;
    }
    
    /* Contact form */
    .contact-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .contact-form {
        gap: 1rem;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 0.7rem;
        font-size: 0.9rem;
    }
    
    .submit-button {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }
    
    /* Info items */
    .info-item {
        margin-bottom: 1rem;
    }
    
    .info-item i {
        font-size: 1rem;
        width: 18px;
    }
    
    /* Footer */
    footer {
        padding: 1.5rem 0;
    }
    
    footer p {
        font-size: 0.9rem;
    }
    
    /* Page headers */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 2rem;
    }
    
    .back-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    section {
        padding: 2rem 0 1.5rem 0;
    }
    .page-content {
        padding-top: 60px;
    }
    .featured-projects, .blog-preview, .contact, .home-contact-section {
        padding: 2rem 0 1.2rem 0;
    }
    .project-card, .blog-card {
        margin: 0 auto 1.2rem auto;
        max-width: 98vw;
    }
    .social-cards {
        gap: 0.5rem;
    }
    .contact-container {
        gap: 1.2rem;
    }
    .btn_color, .submit-button, .tressiq-button {
        padding: 0.7rem 1.2rem;
        font-size: 0.95rem;
    }
    .back-btn {
        margin-bottom: 0.5rem;
        padding: 0.6rem 1.1rem;
        font-size: 0.95rem;
    }
    .title_2, .title_1, h1, h2 {
        margin-bottom: 1.2rem;
    }
    .mobile-menu li {
        margin: 1.5rem 0 !important;
    }
    .mobile-menu a {
        padding: 0.7rem 0 !important;
        font-size: 1.2rem !important;
    }
    .container, .text_container, .about-content {
        padding-left: 1.2rem !important;
        padding-right: 1.2rem !important;
    }
}

/* Mobile (600px and down) */
@media screen and (max-width: 600px) {
    .nav-container {
        padding: 0.8rem;
    }
    
    .container {
        padding: 0 0.8rem;
    }
    
    /* Home section */
    #home {
        padding: 0.8rem 0;
        min-height: 60vh;
    }
    
    .section_pic_container img {
        width: 200px;
        height: 200px;
    }
    
    .section_text_p1 {
        font-size: 1rem;
    }
    
    .title_1 {
        font-size: 2rem;
    }
    
    .section_text_p2 {
        font-size: 1rem;
    }
    
    .btn_color {
        padding: 0.7rem 1.3rem;
        font-size: 0.85rem;
    }
    
    /* Section titles */
    .title_2 {
        font-size: 1.8rem;
    }
    
    .title_2::after {
        width: 40px;
        height: 2px;
    }
    
    /* About section */
    .text_container p {
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    .tressiq-button {
        padding: 0.7rem 1.3rem;
        font-size: 0.85rem;
    }
    
    /* Social cards */
    .social-cards {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.6rem;
        padding: 0 0.8rem;
    }
    
    .social-card {
        padding: 0.6rem 0.9rem;
        font-size: 0.8rem;
    }
    
    .social-card i {
        font-size: 1rem;
    }
    
    /* Project cards */
    .project-card,
    .blog-post {
        max-width: 280px;
    }
    
    .carousel-btn {
        width: 40px;
        height: 40px;
    }
    
    .view-all-btn {
        padding: 0.7rem 1.3rem;
        font-size: 0.85rem;
    }
    
    /* Form elements */
    .form-group {
        margin-bottom: 0.8rem;
    }
    
    .form-group label {
        font-size: 0.85rem;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 0.6rem;
        font-size: 0.85rem;
    }
    
    .submit-button {
        padding: 0.7rem 1.3rem;
        font-size: 0.85rem;
    }
    
    /* Info items */
    .info-item {
        margin-bottom: 0.8rem;
    }
    
    .info-item i {
        font-size: 0.9rem;
        width: 16px;
    }
    
    /* Footer */
    footer {
        padding: 1.2rem 0;
    }
    
    footer p {
        font-size: 0.85rem;
    }
}

/* Small Mobile (480px and down) */
@media screen and (max-width: 480px) {
    .nav-container {
        padding: 0.6rem;
    }
    
    .container {
        padding: 0 0.6rem;
    }
    
    /* Home section */
    #home {
        padding: 0.6rem 0;
        min-height: 50vh;
    }
    
    .section_pic_container img {
        width: 180px;
        height: 180px;
    }
    
    .section_text_p1 {
        font-size: 0.9rem;
    }
    
    .title_1 {
        font-size: 1.8rem;
    }
    
    .section_text_p2 {
        font-size: 0.9rem;
    }
    
    .btn_color {
        padding: 0.6rem 1.2rem;
        font-size: 0.8rem;
    }
    
    /* Section titles */
    .title_2 {
        font-size: 1.6rem;
    }
    
    .title_2::after {
        width: 35px;
        height: 2px;
    }
    
    /* About section */
    .text_container p {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    .tressiq-button {
        padding: 0.6rem 1.2rem;
        font-size: 0.8rem;
    }
    
    /* Social cards */
    .social-cards {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        padding: 0 0.6rem;
    }
    
    .social-card {
        padding: 0.5rem 0.8rem;
        font-size: 0.75rem;
    }
    
    .social-card i {
        font-size: 0.95rem;
    }
    
    /* Project cards */
    .project-card,
    .blog-post {
        max-width: 260px;
        margin: 0 0.3rem;
    }
    
    .carousel-btn {
        width: 35px;
        height: 35px;
    }
    
    .view-all-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.8rem;
    }
    
    /* Form elements */
    .form-group {
        margin-bottom: 0.6rem;
    }
    
    .form-group label {
        font-size: 0.8rem;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .submit-button {
        padding: 0.6rem 1.2rem;
        font-size: 0.8rem;
    }
    
    /* Info items */
    .info-item {
        margin-bottom: 0.6rem;
    }
    
    .info-item i {
        font-size: 0.8rem;
        width: 14px;
    }
    
    /* Footer */
    footer {
        padding: 1rem 0;
    }
    
    footer p {
        font-size: 0.8rem;
    }
    
    section {
        padding: 1.2rem 0 0.7rem 0;
    }
    .project-card, .blog-card {
        margin: 0 auto 0.7rem auto;
        max-width: 99vw;
    }
    .btn_color, .submit-button, .tressiq-button {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    .back-btn {
        margin-bottom: 0.3rem;
        padding: 0.5rem 0.8rem;
        font-size: 0.9rem;
    }
    .title_2, .title_1, h1, h2 {
        margin-bottom: 0.7rem;
    }
    .home-contact-section {
        margin-top: 1rem;
    }
}

/* Extra Small Mobile (360px and down) */
@media screen and (max-width: 360px) {
    .nav-container {
        padding: 0.5rem;
    }
    
    .container {
        padding: 0 0.5rem;
    }
    
    /* Home section */
    #home {
        padding: 0.5rem 0;
        min-height: 45vh;
    }
    
    .section_pic_container img {
        width: 160px;
        height: 160px;
    }
    
    .section_text_p1 {
        font-size: 0.85rem;
    }
    
    .title_1 {
        font-size: 1.6rem;
    }
    
    .section_text_p2 {
        font-size: 0.85rem;
    }
    
    .btn_color {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
    
    /* Section titles */
    .title_2 {
        font-size: 1.4rem;
    }
    
    .title_2::after {
        width: 30px;
        height: 2px;
    }
    
    /* About section */
    .text_container p {
        font-size: 0.85rem;
        line-height: 1.3;
    }
    
    .tressiq-button {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
    
    /* Social cards */
    .social-cards {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.4rem;
        padding: 0 0.5rem;
    }
    
    .social-card {
        padding: 0.4rem 0.7rem;
        font-size: 0.7rem;
    }
    
    .social-card i {
        font-size: 0.9rem;
    }
    
    /* Project cards */
    .project-card,
    .blog-post {
        max-width: 240px;
        margin: 0 0.2rem;
    }
    
    .carousel-btn {
        width: 30px;
        height: 30px;
    }
    
    .view-all-btn {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
    
    /* Form elements */
    .form-group {
        margin-bottom: 0.5rem;
    }
    
    .form-group label {
        font-size: 0.75rem;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 0.4rem;
        font-size: 0.75rem;
    }
    
    .submit-button {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
    
    /* Info items */
    .info-item {
        margin-bottom: 0.5rem;
    }
    
    .info-item i {
        font-size: 0.75rem;
        width: 12px;
    }
    
    /* Footer */
    footer {
        padding: 0.8rem 0;
    }
    
    footer p {
        font-size: 0.75rem;
    }
    
    /* Mobile menu */
    .mobile-menu a {
        font-size: 1rem;
        padding: 0.8rem 1.5rem;
    }
}

/* Landscape orientation for small screens */
@media screen and (max-height: 500px) and (orientation: landscape) {
    #home {
        min-height: auto;
        padding: 1rem 0;
    }
    
    .section_pic_container img {
        width: 120px;
        height: 120px;
    }
    
    .title_1 {
        font-size: 1.8rem;
    }
    
    .mobile-menu {
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .mobile-menu a {
        padding: 0.4rem 2rem;
    }
}

/* High DPI displays */
@media screen and (-webkit-min-device-pixel-ratio: 2), screen and (min-resolution: 192dpi) {
    .section_pic_container img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .mobile-nav-hint {
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .mobile-menu {
        background: #0a0a0a !important;
    }
    .mobile-menu a {
        color: #e0e0e0 !important;
    }
}

.home-contact-section {
    margin-top: 2rem;
}

/* Force dark mobile menu background when in dark theme */
[data-theme="dark"] .mobile-menu,
:root:not([data-theme="light"]) .mobile-menu {
    background: #0a0a0a !important;
}
[data-theme="dark"] .mobile-menu a,
:root:not([data-theme="light"]) .mobile-menu a {
    color: #e0e0e0 !important;
}

/* Light theme mobile menu */
[data-theme="light"] .mobile-menu {
    background: #fff !important;
}
[data-theme="light"] .mobile-menu a {
    color: #333 !important;
}

/* Remove prefers-color-scheme overrides since we handle it with data-theme */

/* Ensure menu item spacing and section padding on mobile */
@media screen and (max-width: 768px) {
    .mobile-menu li {
        margin: 1.5rem 0 !important;
    }
    .mobile-menu a {
        padding: 0.7rem 0 !important;
        font-size: 1.2rem !important;
    }
    .container, .text_container, .about-content {
        padding-left: 1.2rem !important;
        padding-right: 1.2rem !important;
    }
}