/*===============================================
  MODERN RESPONSIVE MEDIA QUERIES - MOBILE FIRST
  Progressive enhancement from mobile to desktop
===============================================*/

/*===============================================
  MOBILE FIRST BASE - ALREADY HANDLED IN MAIN CSS
  Base styles are mobile-friendly by default
===============================================*/

/*===============================================
  MODERN MOBILE-FIRST RESPONSIVE DESIGN
  Enhanced mobile experience with contemporary patterns
===============================================*/

/*===============================================
  EXTRA SMALL MOBILE (max-width: 380px)
  Ultra-compact phones
===============================================*/
@media screen and (max-width: 380px) {
  :root {
    --space-section: 3rem;
  }

  /* Ultra-compact navigation */
  .navbar {
    padding: var(--space-3) 0;
  }

  .nav-brand .logo {
    font-size: 1.25rem;
  }

  .theme-toggle,
  .mobile-menu-toggle {
    width: 2.25rem;
    height: 2.25rem;
  }

  /* Hero adjustments */
  .image-wrapper {
    width: 240px;
    height: 240px;
  }

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

  .hero-subtitle {
    font-size: 1.125rem;
  }

  .hero-actions .btn {
    font-size: 0.875rem;
    padding: 0.625rem 1rem;
  }

  .social-link {
    width: 2.5rem;
    height: 2.5rem;
  }

  /* Compact cards */
  .stat-item,
  .credential-card {
    padding: var(--space-4);
  }

  .card-icon {
    width: 3rem;
    height: 3rem;
    font-size: 1.5rem;
  }

  .project-image {
    height: 200px;
  }

  .contact-icon {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/*===============================================
  SMALL MOBILE (max-width: 480px)
  Primary mobile optimization
===============================================*/
@media screen and (max-width: 480px) {
  /* Smooth section spacing */
  section {
    padding-top: 4rem;
    padding-bottom: 4rem;
  }

  section:first-of-type {
    padding-top: 6rem;
  }

  /* Modern mobile navigation */
  .nav-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: var(--space-8);
    z-index: var(--z-modal);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  
  .nav-menu.active {
    display: flex;
    opacity: 1;
    pointer-events: all;
    animation: slideIn 0.3s ease-out;
  }

  @keyframes slideIn {
    from {
      transform: translateY(-20px);
    }
    to {
      transform: translateY(0);
    }
  }
  
  .nav-menu li {
    width: 100%;
    text-align: center;
    transform: translateY(20px);
    opacity: 0;
    animation: fadeInItem 0.3s ease-out forwards;
  }

  .nav-menu.active li:nth-child(1) { animation-delay: 0.1s; }
  .nav-menu.active li:nth-child(2) { animation-delay: 0.15s; }
  .nav-menu.active li:nth-child(3) { animation-delay: 0.2s; }
  .nav-menu.active li:nth-child(4) { animation-delay: 0.25s; }

  @keyframes fadeInItem {
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .nav-menu a {
    font-size: 1.5rem;
    font-weight: 600;
    padding: var(--space-4);
    display: block;
    width: 100%;
  }
  
  .mobile-menu-toggle {
    display: flex;
    z-index: calc(var(--z-modal) + 1);
  }

  /* Hero Section - Mobile First */
  .hero-section {
    min-height: auto;
    padding: 5rem 0 3rem;
  }

  .hero-content {
    grid-template-columns: 1fr;
    gap: 3rem;
    text-align: center;
  }
  
  .hero-image {
    order: 1;
    margin-bottom: 1rem;
  }
  
  .hero-text {
    order: 2;
    gap: 1.5rem;
  }
  
  .image-wrapper {
    width: 260px;
    height: 260px;
    margin: 0 auto;
  }

  .profile-image {
    border-width: 3px;
  }

  .image-backdrop {
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
  }

  .hero-title {
    font-size: 2.5rem;
    flex-direction: column;
    gap: 0;
  }

  .hero-subtitle {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }

  .hero-description {
    font-size: 1rem;
    max-width: 100%;
    padding: 0 0.5rem;
  }

  .hero-actions {
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
  }
  
  .hero-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
  }

  .social-links {
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
  }

  .social-link {
    width: 3rem;
    height: 3rem;
    font-size: 1.125rem;
  }

  .scroll-indicator {
    bottom: 1.5rem;
  }

  /* About Section - Stacked Layout */
  .about-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
  
  .about-visual {
    gap: 1.5rem;
  }

  .about-image-container {
    border-radius: 1.5rem;
  }

  .about-image {
    border-radius: 1.5rem;
  }

  .experience-badge {
    font-size: 2rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    grid-row: auto;
    grid-column: auto;
  }

  .stat-item {
    padding: 1.25rem;
    border-radius: 1rem;
  }

  .stat-number {
    font-size: 1.75rem;
  }

  .stat-label {
    font-size: 0.875rem;
  }

  .about-content {
    grid-row: auto;
    grid-column: auto;
    gap: 1.5rem;
  }

  .about-subtitle {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .about-description {
    font-size: 1rem;
    margin-bottom: 1.5rem;
  }

  .expanded-text p {
    font-size: 0.9375rem;
    margin-bottom: 1rem;
  }

  .read-more-btn {
    font-size: 0.9375rem;
    margin-top: 1rem;
  }

  .credentials-section {
    grid-template-columns: 1fr;
    gap: 1rem;
    grid-column: auto;
  }

  .credential-card {
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.5rem;
    text-align: center;
    align-items: center;
  }

  .card-icon {
    width: 4rem;
    height: 4rem;
    font-size: 2rem;
    border-radius: 1rem;
  }

  .card-title {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
  }

  .credential-list {
    gap: 0.5rem;
  }

  .credential-list li {
    font-size: 0.875rem;
    padding-left: 1rem;
  }

  /* Skills Section - Single Column */
  .skills-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .skill-category {
    padding: 1.5rem;
    border-radius: 1.5rem;
  }

  .category-header {
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-direction: column;
    text-align: center;
  }

  .category-icon {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.5rem;
    margin: 0 auto;
  }

  .category-title {
    font-size: 1.25rem;
  }

  .skills-list {
    gap: 0.875rem;
  }

  .skill-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
  }

  .skill-info {
    width: 100%;
    gap: 0.75rem;
  }

  .skill-icon {
    font-size: 1.25rem;
  }

  .skill-name {
    font-size: 0.9375rem;
  }

  .skill-level {
    width: 100%;
    justify-content: space-between;
    min-width: auto;
  }

  .level-text {
    font-size: 0.75rem;
    min-width: auto;
  }

  .level-bar {
    flex: 1;
    max-width: 100px;
  }

  /* Projects Section - Card Focus */
  .project-filters {
    gap: 0.5rem;
    padding: 0 0.5rem;
  }
  
  .filter-btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    border-radius: 2rem;
  }

  .projects-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .project-card {
    border-radius: 1.5rem;
  }

  .project-image {
    height: 220px;
  }

  .project-tech {
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .tech-tag {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
  }

  .project-content {
    padding: 1.5rem;
  }

  .project-title {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
  }

  .project-description {
    font-size: 0.9375rem;
    margin-bottom: 1.25rem;
  }

  .project-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  .project-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Contact Section - Full Width Form */
  .contact-content {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .contact-form-wrapper {
    padding: 1.5rem;
    border-radius: 1.5rem;
  }

  .contact-form {
    gap: 1.25rem;
  }

  .form-group {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .input-icon {
    left: 1rem;
    font-size: 1rem;
  }

  .form-input,
  .form-textarea {
    padding: 1rem 1rem 1rem 2.75rem;
    font-size: 1rem;
    border-radius: 0.75rem;
  }

  .form-textarea {
    min-height: 140px;
  }

  .submit-btn {
    padding: 1rem;
    font-size: 1rem;
    border-radius: 0.75rem;
  }

  .contact-info {
    gap: 1.5rem;
  }

  .contact-item {
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 1rem;
  }

  .contact-icon {
    width: 3rem;
    height: 3rem;
    font-size: 1.25rem;
    border-radius: 0.75rem;
  }

  .contact-details h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }

  .contact-details p {
    font-size: 0.9375rem;
  }

  .contact-socials h4 {
    font-size: 1rem;
    margin-bottom: 1rem;
  }

  .contact-socials .social-links {
    justify-content: flex-start;
  }

  /* Section Headers - Mobile Optimized */
  .section-header {
    margin-bottom: 2.5rem;
    padding: 0 0.5rem;
  }

  .section-label {
    font-size: 0.75rem;
  }

  .section-title {
    font-size: 2rem;
    margin-bottom: 1rem;
  }

  .section-divider {
    width: 50px;
    height: 3px;
    margin-bottom: 1rem;
  }

  .section-description {
    font-size: 1rem;
    padding: 0 0.5rem;
  }

  /* Footer */
  .footer {
    padding: 2rem 0;
  }

  .footer-content p {
    font-size: 0.875rem;
    line-height: 1.6;
  }

  /* Container spacing */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Touch-friendly interactions */
  .btn,
  .social-link,
  .filter-btn,
  .mobile-menu-toggle,
  .theme-toggle {
    min-height: 44px;
    min-width: 44px;
  }
}

/*===============================================
  MEDIUM MOBILE (481px - 640px)
  Larger phones, better spacing
===============================================*/
@media screen and (min-width: 481px) and (max-width: 640px) {
  .hero-content {
    grid-template-columns: 1fr;
    gap: 3.5rem;
    text-align: center;
  }
  
  .image-wrapper {
    width: 300px;
    height: 300px;
  }

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

  .hero-actions {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
  }

  .hero-actions .btn {
    flex: 1;
    min-width: 160px;
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }

  .credentials-section {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .credential-card {
    flex-direction: row;
    text-align: left;
  }

  .skills-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .category-header {
    flex-direction: row;
    text-align: left;
  }

  .category-icon {
    margin: 0;
  }

  .projects-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .project-image {
    height: 240px;
  }

  .contact-content {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .form-group {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .project-actions {
    flex-direction: row;
    gap: 1rem;
  }

  .project-actions .btn {
    flex: 1;
  }
}

/*===============================================
  LANDSCAPE MOBILE OPTIMIZATION
===============================================*/
@media screen and (max-height: 600px) and (orientation: landscape) {
  .hero-section {
    min-height: auto;
    padding: 3rem 0 2rem;
  }
  
  .hero-content {
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
    text-align: left;
  }

  .hero-image {
    order: 1;
  }

  .hero-text {
    order: 2;
    gap: 1rem;
  }

  .image-wrapper {
    width: 200px;
    height: 200px;
  }

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

  .hero-subtitle {
    font-size: 1.125rem;
  }

  .hero-description {
    font-size: 0.875rem;
  }

  .hero-actions {
    flex-direction: row;
    gap: 0.75rem;
  }

  .hero-actions .btn {
    font-size: 0.875rem;
    padding: 0.625rem 1.25rem;
  }

  .social-links {
    gap: 0.75rem;
    justify-content: flex-start;
  }

  .social-link {
    width: 2.5rem;
    height: 2.5rem;
  }

  .scroll-indicator {
    display: none;
  }

  section {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
  }
}

/*===============================================
  TOUCH DEVICE OPTIMIZATIONS
===============================================*/
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .nav-menu a {
    padding: 1rem 1.5rem;
  }

  .btn {
    padding: 1rem 1.75rem;
  }

  /* Remove complex hover effects */
  .skill-item:hover,
  .project-card:hover,
  .credential-card:hover,
  .stat-item:hover {
    transform: none;
  }

  /* Always show overlays on mobile */
  .project-overlay {
    opacity: 0.95;
    background: linear-gradient(
      to top,
      rgba(15, 23, 42, 0.95) 0%,
      rgba(99, 102, 241, 0.8) 100%
    );
    padding: 1rem;
    align-items: flex-end;
  }

  .project-tech {
    width: 100%;
    justify-content: flex-start;
  }

  /* Better form inputs on mobile */
  .form-input,
  .form-textarea {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Smooth scrolling areas */
  .project-filters {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .project-filters::-webkit-scrollbar {
    display: none;
  }
}

/*===============================================
  REDUCED MOTION SUPPORT
===============================================*/
@media (prefers-reduced-motion: reduce) {
  .nav-menu.active,
  .nav-menu li,
  .project-card {
    animation: none !important;
  }

  .hero-content,
  .about-grid,
  .skills-grid,
  .projects-grid,
  .contact-content {
    animation: none !important;
  }
}

/*===============================================
  TABLET PORTRAIT (min-width: 641px)
===============================================*/
@media screen and (min-width: 641px) and (max-width: 768px) {
  /* Navigation remains desktop-like */
  .mobile-menu-toggle {
    display: none;
  }
  
  .nav-menu {
    display: flex;
    gap: var(--space-6);
  }
  
  /* Hero Section */
  .hero-content {
    grid-template-columns: 1fr;
    gap: var(--space-16);
    text-align: center;
  }
  
  .image-wrapper {
    width: 350px;
    height: 350px;
  }
  
  /* About Section */
  .about-grid {
    grid-template-columns: 1fr;
    gap: var(--space-16);
  }
  
  .credentials-section {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
  }
  
  /* Skills Section */
  .skills-grid {
    grid-template-columns: 1fr;
    gap: var(--space-12);
  }
  
  /* Projects Section */
  .projects-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
  }
  
  /* Contact Section */
  .contact-content {
    grid-template-columns: 1fr;
    gap: var(--space-12);
  }
}

/*===============================================
  TABLET LANDSCAPE (min-width: 769px)
===============================================*/
@media screen and (min-width: 769px) and (max-width: 1024px) {
  /* Hero Section */
  .hero-content {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-12);
  }
  
  .image-wrapper {
    width: 350px;
    height: 350px;
  }
  
  /* About Section */
  .about-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-12);
  }
  
  .about-image {
    height: 400px;
  }
  
  /* Skills Section */
  .skills-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-12);
  }
  
  /* Projects Section */
  .projects-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-8);
  }
  
  /* Contact Section */
  .contact-content {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-12);
  }
}

/*===============================================
  SMALL DESKTOP (min-width: 1025px)
===============================================*/
@media screen and (min-width: 1025px) and (max-width: 1280px) {
  /* All desktop layouts are handled in main CSS */
  /* This breakpoint is for fine-tuning */
  
  .projects-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}

/*===============================================
  LARGE DESKTOP (min-width: 1281px)
===============================================*/
@media screen and (min-width: 1281px) {
  /* Enhance for larger screens */
  .container {
    max-width: var(--container-2xl);
  }
  
  .hero-section {
    padding: var(--space-32) 0;
  }
  
  .image-wrapper {
    width: 450px;
    height: 450px;
  }
  
  .about-grid {
    gap: var(--space-24);
  }
  
  .skills-grid {
    gap: var(--space-20);
  }
  
  .projects-grid {
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: var(--space-10);
  }
  
  .contact-content {
    gap: var(--space-20);
  }
}

/*===============================================
  EXTRA LARGE DESKTOP (min-width: 1536px)
===============================================*/
@media screen and (min-width: 1536px) {
  .hero-content {
    gap: var(--space-24);
  }
  
  .image-wrapper {
    width: 500px;
    height: 500px;
  }
  
  .about-grid {
    gap: var(--space-32);
  }
  
  .about-image {
    height: 600px;
  }
}

/*===============================================
  PRINT STYLES
===============================================*/
@media print {
  * {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
  
  header,
  .mobile-menu-toggle,
  .theme-toggle,
  .scroll-indicator,
  .project-filters,
  .contact-form-wrapper,
  .footer {
    display: none !important;
  }
  
  .hero-actions,
  .project-actions {
    display: none !important;
  }
  
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
  
  .project-card,
  .credential-card,
  .skill-category {
    page-break-inside: avoid;
  }
  
  .section-title {
    font-size: 18pt;
    margin-bottom: 12pt;
  }
  
  .hero-title {
    font-size: 24pt;
  }
  
  a {
    text-decoration: underline;
  }
  
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 80%;
  }
}

/*===============================================
  ACCESSIBILITY & PREFERENCES
===============================================*/

/* Respect user's motion preferences */
@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;
  }
  
  .image-backdrop,
  .title-decoration,
  .scroll-down {
    animation: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --accent-primary: #0000ff;
    --accent-secondary: #800080;
    --text-primary: #000000;
    --text-secondary: #333333;
    --border-color: #666666;
  }
  
  .darkmode {
    --accent-primary: #66b3ff;
    --accent-secondary: #cc99ff;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --border-color: #999999;
  }
}

/* Focus visible for better keyboard navigation */
@media (prefers-reduced-motion: no-preference) {
  .nav-menu a:focus-visible,
  .btn:focus-visible,
  .social-link:focus-visible,
  .theme-toggle:focus-visible,
  .mobile-menu-toggle:focus-visible,
  .filter-btn:focus-visible,
  .form-input:focus-visible,
  .form-textarea:focus-visible,
  .submit-btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
  }
}

/*===============================================
  LANDSCAPE ORIENTATION ADJUSTMENTS
===============================================*/
@media screen and (max-height: 600px) and (orientation: landscape) {
  .hero-section {
    min-height: auto;
    padding: var(--space-16) 0;
  }
  
  .scroll-indicator {
    display: none;
  }
  
  .image-wrapper {
    width: 250px;
    height: 250px;
  }
  
  section {
    padding-top: var(--space-12);
    padding-bottom: var(--space-12);
  }
}

/*===============================================
  HOVER CAPABILITY DETECTION
===============================================*/
@media (hover: none) and (pointer: coarse) {
  /* Touch device adjustments */
  .btn,
  .social-link,
  .filter-btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  .nav-menu a {
    padding: var(--space-3) var(--space-4);
  }
  
  /* Remove hover effects on touch devices */
  .skill-item:hover,
  .project-card:hover,
  .credential-card:hover {
    transform: none;
  }
  
  .project-overlay,
  .image-overlay {
    opacity: 0.8;
  }
}

/*===============================================
  ULTRA-WIDE SCREENS (min-width: 2560px)
===============================================*/
@media screen and (min-width: 2560px) {
  .container {
    max-width: 1800px;
  }
  
  .hero-content {
    max-width: 1400px;
    margin: 0 auto;
  }
  
  .section-header {
    max-width: 800px;
    margin: 0 auto var(--space-20);
  }
}

/*===============================================
  DARK MODE MEDIA QUERY SUPPORT
===============================================*/
@media (prefers-color-scheme: dark) {
  /* This will be handled by JavaScript, but providing fallback */
  body:not(.lightmode) {
    --text-primary: var(--dark-text-primary);
    --text-secondary: var(--dark-text-secondary);
    --text-muted: var(--dark-text-muted);
    --bg-primary: var(--dark-bg-primary);
    --bg-secondary: var(--dark-bg-secondary);
    --bg-tertiary: var(--dark-bg-tertiary);
    --border-color: var(--gray-700);
    --shadow-color: rgba(0, 0, 0, 0.3);
  }
}