/* ========================
   Responsive Design
   Mobile-First Approach
======================== */

/* Extra Large Devices (1400px and up) */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
    
    .hero-content {
        gap: var(--spacing-3xl);
    }
    
    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large Devices (1200px and down) */
@media (max-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    .hero-content {
        gap: var(--spacing-2xl);
    }
    
    .image-wrapper {
        width: 350px;
        height: 350px;
    }
    
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Medium Devices (992px and down) */
@media (max-width: 992px) {
    .container {
        max-width: 960px;
    }
    
    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .hero-text {
        order: 2;
    }
    
    .hero-image {
        order: 1;
        margin-bottom: var(--spacing-2xl);
    }
    
    .hero-cta {
        justify-content: center;
    }
    
    .hero-stats {
        justify-content: center;
    }
    
    .about-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-2xl);
    }
    
    .code-window {
        max-width: 600px;
        margin: 0 auto;
    }
    
    .skills-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .featured-project {
        grid-template-columns: 1fr;
    }
    
    .project-image {
        height: 300px;
    }
    
    .contact-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-2xl);
    }
}

/* Small Devices (768px and down) */
@media (max-width: 768px) {
    /* Typography */
    h1 {
        font-size: 2.5rem;
    }
    
    h2 {
        font-size: 2rem;
    }
    
    h3 {
        font-size: 1.5rem;
    }
    
    /* Navigation */
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background: var(--surface);
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 30px var(--shadow-color);
        padding: var(--spacing-xl) 0;
        border-top: 1px solid var(--border-color);
        z-index: 999;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-link {
        display: block;
        padding: var(--spacing-md) 0;
    }
    
    .nav-actions {
        margin-right: var(--spacing-md);
    }
    
    .hamburger {
        display: flex;
        flex-direction: column;
        cursor: pointer;
        z-index: 1000;
    }
    
    .hamburger.active span:nth-child(1) {
        transform: rotate(-45deg) translate(-5px, 6px);
    }
    
    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }
    
    .hamburger.active span:nth-child(3) {
        transform: rotate(45deg) translate(-5px, -6px);
    }
    
    /* Hero Section */
    .hero {
        padding-top: 80px;
    }
    
    .hero-content {
        padding: var(--spacing-xl) var(--spacing-md);
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.5rem;
    }
    
    .hero-cta {
        flex-direction: column;
        align-items: center;
    }
    
    .hero-cta .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .image-wrapper {
        width: 300px;
        height: 300px;
    }
    
    .floating-icon {
        font-size: 1.5rem;
    }
    
    /* Skills Section */
    .skills-grid {
        grid-template-columns: 1fr;
    }
    
    .tech-icons {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Timeline */
    .timeline::before {
        left: 20px;
    }
    
    .timeline-item:nth-child(odd) .timeline-content,
    .timeline-item:nth-child(even) .timeline-content {
        margin-left: 50px;
        margin-right: 0;
        padding-left: var(--spacing-lg);
        padding-right: var(--spacing-lg);
    }
    
    .timeline-marker {
        left: 20px;
    }
    
    /* Projects */
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .project-highlights {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Publications */
    .publications-grid {
        grid-template-columns: 1fr;
    }
    
    .publication-card.featured {
        grid-column: auto;
    }
    
    /* Footer */
    .footer-content {
        flex-direction: column;
        gap: var(--spacing-lg);
        text-align: center;
    }
    
    .footer-left,
    .footer-right {
        text-align: center;
    }
}

/* Extra Small Devices (576px and down) */
@media (max-width: 576px) {
    /* Base */
    html {
        font-size: 14px;
    }
    
    .container {
        padding: 0 var(--spacing-md);
    }
    
    .section {
        padding: var(--spacing-2xl) 0;
    }
    
    .section-title {
        margin-bottom: var(--spacing-xl);
    }
    
    /* Typography */
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    /* Navigation */
    .nav-container {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .nav-logo {
        font-size: 1.25rem;
    }
    
    .nav-actions .btn-sm {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.75rem;
    }
    
    .theme-toggle {
        width: 35px;
        height: 35px;
    }
    
    /* Hero */
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1.25rem;
    }
    
    .hero-description {
        font-size: 1rem;
    }
    
    .hero-stats {
        flex-direction: column;
        gap: var(--spacing-lg);
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .image-wrapper {
        width: 250px;
        height: 250px;
    }
    
    .floating-icon {
        display: none;
    }
    
    /* About */
    .about-highlights .highlight {
        flex-direction: column;
        text-align: center;
    }
    
    .code-window {
        font-size: 0.75rem;
    }
    
    .code-content {
        padding: var(--spacing-md);
    }
    
    /* Skills */
    .skill-category {
        padding: var(--spacing-md);
    }
    
    .tech-icons {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-md);
    }
    
    .tech-icon {
        width: 50px;
        height: 50px;
    }
    
    .tech-icon i {
        font-size: 1.5rem;
    }
    
    /* Timeline */
    .timeline::before {
        display: none;
    }
    
    .timeline-marker {
        display: none;
    }
    
    .timeline-item:nth-child(odd) .timeline-content,
    .timeline-item:nth-child(even) .timeline-content {
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Projects */
    .project-card {
        margin-bottom: var(--spacing-lg);
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .github-stats {
        padding: var(--spacing-lg);
    }
    
    /* Contact */
    .contact-form-wrapper {
        padding: var(--spacing-lg);
    }
    
    .social-links {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .social-link {
        width: 40px;
        height: 40px;
    }
    
    /* Buttons */
    .btn {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 0.875rem;
    }
    
    /* Footer */
    .footer {
        padding: var(--spacing-lg) 0;
    }
}

/* Very Small Devices (400px and down) */
@media (max-width: 400px) {
    .hero-title {
        font-size: 1.75rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .image-wrapper {
        width: 200px;
        height: 200px;
    }
    
    .tech-icons {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Landscape Orientation Adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: var(--spacing-3xl) 0;
    }
    
    .hero-content {
        grid-template-columns: 1fr 1fr;
    }
    
    .hero-image {
        order: 2;
    }
    
    .hero-text {
        order: 1;
        text-align: left;
    }
    
    .image-wrapper {
        width: 200px;
        height: 200px;
    }
    
    .scroll-indicator {
        display: none;
    }
}

/* High Resolution Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .profile-img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print Styles */
@media print {
    /* Hide non-essential elements */
    .navbar,
    .theme-toggle,
    .hamburger,
    .scroll-indicator,
    .hero-cta,
    .floating-icons,
    .back-to-top,
    .social-links,
    #particles-js,
    .loader {
        display: none !important;
    }
    
    /* Reset colors for print */
    * {
        color: black !important;
        background: white !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    /* Ensure content is visible */
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    h1 {
        font-size: 24pt;
    }
    
    h2 {
        font-size: 18pt;
    }
    
    h3 {
        font-size: 14pt;
    }
    
    /* Break pages appropriately */
    .section {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    .timeline-item,
    .project-card,
    .publication-card {
        page-break-inside: avoid;
    }
    
    /* Show URLs for links */
    a[href^="http"]:after {
        content: " (" attr(href) ")";
    }
    
    /* Ensure images fit on page */
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}

/* Accessibility - 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;
    }
    
    .floating-icon {
        animation: none;
    }
    
    .scroll-indicator {
        animation: none;
    }
}

/* Dark Mode Preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary-color: #6366f1;
        --primary-dark: #4f46e5;
        --primary-light: #818cf8;
        --secondary-color: #a78bfa;
        --accent-color: #22d3ee;
        
        --background: #0a0a0f;
        --background-secondary: #111118;
        --surface: #1a1a24;
        --surface-hover: #25252f;
        
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;
        
        --border-color: #334155;
        --shadow-color: rgba(0, 0, 0, 0.5);
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .nav-link,
    .btn,
    .social-link {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .project-card:hover,
    .timeline-content:hover,
    .skill-category:hover {
        transform: none;
    }
    
    /* Improve form inputs for touch */
    input,
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }
}
