/*
* MyPortfolio - Responsive Stylesheet
* Author: Matteo Pasotti
* Version: 2.0 (Performance Optimized)
* 
* This file has been optimized for better performance and smoother responsive behavior
*/

/* ===== Global Variables & Base Settings ===== */
:root {
    --header-height: 60px;
    --footer-height: 120px;
    --transition-speed: 0.3s;
    --anim-duration: 0.5s;
  }
  
  /* ===== Utility Classes ===== */
  .hide-on-mobile {
    display: initial;
  }
  
  .show-on-mobile {
    display: none;
  }
  
  /* ===== Media Query Breakpoints ===== */
  
  /* Extra Large Screens (1400px and up) */
  @media (min-width: 1400px) {
    .container {
      width: 1320px;
      max-width: 90%;
    }
    
    h1 { font-size: 5.5rem; }
    .tagline { font-size: 3.2rem; }
    
    /* Larger project cards on big screens */
    .project-grid {
      grid-template-columns: repeat(3, 1fr);
      gap: 2.5rem;
    }
  }
  
  /* Large Screens (1200px to 1399px) */
  @media (min-width: 1200px) and (max-width: 1399px) {
    .container {
      width: 1140px;
      max-width: 90%;
    }
    
    /* Typography refinements */
    h1 { font-size: 4.5rem; }
    .tagline { font-size: 2.8rem; }
    
    /* Project grid with better spacing */
    .project-grid {
      grid-template-columns: repeat(3, 1fr);
      gap: 2rem;
    }
  }
  
  /* Medium Screens (992px to 1199px) */
  @media (min-width: 992px) and (max-width: 1199px) {
    .container {
      width: 960px;
      max-width: 90%;
    }
    
    /* Typography adjustments */
    h1 { font-size: 4rem; }
    .tagline { font-size: 2.5rem; }
    
    /* Hero section spacing */
    .hero {
      padding: var(--space-xl) 0 var(--space-lg);
    }
    
    /* Project grid with better spacing */
    .project-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 2rem;
    }
  }
  
  /* Small Screens (768px to 991px) */
  @media (min-width: 768px) and (max-width: 991px) {
    .container {
      width: 720px;
      max-width: 90%;
    }
    
    /* Typography adjustments */
    h1 { font-size: 3.5rem; }
    h2 { font-size: 2rem; }
    .tagline { font-size: 2rem; }
    
    /* Grid adjustments */
    .about-grid {
      grid-template-columns: 1fr;
      gap: var(--space-md);
    }
    
    .about-image {
      max-width: 400px;
      margin: 0 auto;
      order: -1;
    }
    
    .hero-grid {
      grid-template-columns: 1fr;
      gap: var(--space-md);
    }
    
    .hero-image {
      order: -1;
      max-width: 400px;
      margin: 0 auto var(--space-lg) auto;
    }
    
    /* Skill grid compact layout */
    .skills-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 1rem;
    }
    
    /* Contact layout optimization */
    .contact-grid {
      grid-template-columns: 1fr;
      gap: var(--space-md);
    }
    
    .contact-info, .contact-form {
      max-width: 600px;
      margin-left: auto;
      margin-right: auto;
    }
    
    /* Project grid adjustment */
    .project-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 1.5rem;
    }
    
    /* Certifications & challenges grid */
    .certifications-grid,
    .challenges-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 1.5rem;
    }
  }
  
  /* Mobile Landscape (576px to 767px) */
  @media (min-width: 576px) and (max-width: 767px) {
    .container {
      width: 540px;
      max-width: 95%;
    }
    
    /* Typography adjustments */
    h1 { font-size: 2.75rem; }
    h2 { font-size: 1.75rem; }
    .tagline { font-size: 1.5rem; }
    
    /* Show mobile navigation */
    .menu-toggle {
      display: block;
      z-index: 100;
    }
    
    .hide-on-mobile {
      display: none;
    }
    
    .show-on-mobile {
      display: initial;
    }
    
    /* Mobile navigation styles */
    .nav-links {
      position: fixed;
      top: 0;
      right: -100%;
      width: 80%;
      max-width: 300px;
      height: 100vh;
      flex-direction: column;
      background-color: var(--color-bg-secondary);
      padding: var(--space-xl) var(--space-md);
      transition: var(--transition);
      z-index: 90;
      justify-content: center;
      align-items: center;
    }
    
    .nav-links.active {
      right: 0;
    }
    
    .nav-links li {
      margin: var(--space-sm) 0;
    }
    
    .nav-links a {
      display: block;
      font-size: 1.1rem;
    }
    
    /* Mobile menu animations */
    .menu-toggle.active .hamburger {
      background-color: transparent;
    }
    
    .menu-toggle.active .hamburger::before {
      transform: rotate(45deg);
      top: 0;
    }
    
    .menu-toggle.active .hamburger::after {
      transform: rotate(-45deg);
      bottom: 0;
    }
    
    /* Grid adjustments */
    .project-grid,
    .skill-grid,
    .certifications-grid,
    .challenges-grid {
      grid-template-columns: 1fr;
      gap: 1rem;
    }
    
    .social-grid {
      grid-template-columns: repeat(2, 1fr);
    }
    
    /* Side navigation tweaks */
    .nav-indicator {
      right: 10px;
    }
    
    .nav-dot {
      width: 10px;
      height: 10px;
    }
    
    /* Timeline adjustment */
    .timeline::before {
      left: 30px;
    }
    
    .timeline-item {
      padding-left: 70px;
    }
    
    .timeline-dot {
      left: 26px;
    }
    
    .timeline-date {
      position: relative;
      left: -65px;
      top: -10px;
      width: auto;
      text-align: left;
      margin-bottom: 10px;
    }
    
    /* Tab navigation adjustments */
    .skills-tabs-nav,
    .achievement-tabs-nav {
      overflow-x: auto;
      justify-content: flex-start;
      padding-bottom: 10px;
      -webkit-overflow-scrolling: touch;
      scroll-snap-type: x mandatory;
      scrollbar-width: none; /* Firefox */
    }
    
    .skills-tabs-nav::-webkit-scrollbar,
    .achievement-tabs-nav::-webkit-scrollbar {
      display: none; /* Chrome, Safari, Edge */
    }
    
    .skill-tab-btn,
    .achievement-tab-btn {
      white-space: nowrap;
      padding: 8px 15px;
      font-size: 0.9rem;
      scroll-snap-align: start;
    }
    
    /* Disable snap scrolling on mobile */
    html {
      scroll-snap-type: none;
    }
    
    section.snap-section {
      min-height: auto;
      scroll-snap-align: none;
      padding: 60px 0;
    }
    
    #contact.snap-section {
      padding-bottom: 80px;
    }
    
    /* Footer adjustments */
    .footer-content {
      flex-direction: column;
      gap: var(--space-md);
    }
  }
  
  /* Mobile Portrait (up to 575px) */
  @media (max-width: 575px) {
    .container {
      width: 100%;
      max-width: 95%;
      padding: 0 15px;
    }
    
    /* More compact typography */
    h1 { font-size: 2.25rem; }
    .tagline { font-size: 1.25rem; }
    .description { font-size: 1rem; }
    .section-title { font-size: 1.8rem; }
    .section-subtitle { font-size: 0.9rem; }
    
    /* Layout adjustments */
    .project-card {
      margin-bottom: 1.5rem;
    }
    
    .project-title {
      font-size: 1.25rem;
    }
    
    /* Responsive buttons */
    .cta-buttons {
      flex-direction: column;
      gap: var(--space-sm);
    }
    
    .btn {
      width: 100%;
      display: block;
      text-align: center;
    }
    
    /* Spacing adjustment */
    .hero {
      padding-top: calc(var(--space-lg) + 60px);
    }
    
    /* Project filter buttons */
    .projects-filter {
      overflow-x: auto;
      justify-content: flex-start;
      padding-bottom: 10px;
      -webkit-overflow-scrolling: touch;
      scroll-snap-type: x mandatory;
    }
    
    .filter-btn {
      white-space: nowrap;
      scroll-snap-align: start;
      font-size: 0.8rem;
      padding: 6px 12px;
    }
    
    /* Hero image adjustment */
    .hero-image {
      max-width: 80%;
      margin: 0 auto var(--space-md) auto;
    }
    
    /* Contact grid adjustments */
    .contact-grid {
      gap: var(--space-md);
    }
    
    /* Footer spacing */
    .footer {
      padding: var(--space-md) 0 var(--space-sm);
    }
    
    /* Tighten spacing on mobile */
    section {
      padding: var(--space-md) 0;
    }
  }
  
  /* ===== Dark Mode Support ===== */
  @media (prefers-color-scheme: dark) {
    :root {
      --color-bg: #0a0a0a;
      --color-bg-secondary: #111111;
      --color-text: #f5f5f5;
      --color-text-secondary: #999999;
    }
  }
  
  /* ===== Reduced Motion ===== */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
    
    .fade-in {
      opacity: 1;
      transform: none;
      transition: none;
    }
    
    html {
      scroll-behavior: auto;
      scroll-snap-type: none;
    }
  }
  
  /* ===== Print Styles ===== */
  @media print {
    * {
      background: transparent !important;
      color: #000 !important;
      box-shadow: none !important;
      text-shadow: none !important;
    }
    
    body {
      background-color: white !important;
      color: black !important;
      font-size: 12pt;
      line-height: 1.4;
    }
    
    .header, .footer, .nav-indicator, 
    .scroll-progress, .menu-toggle, 
    .contact-form, .cta-buttons, 
    .social-links, .nav-links {
      display: none !important;
    }
    
    .container {
      width: 100% !important;
      max-width: 100% !important;
      padding: 0;
      margin: 0;
    }
    
    /* Avoid page breaks inside important sections */
    .about-grid, .timeline-item, 
    .project-card, .certification-card,
    .challenge-card {
      page-break-inside: avoid;
    }
    
    /* Show URLs after links */
    a::after {
      content: " (" attr(href) ")";
      font-size: 90%;
    }
    
    /* Simple borders instead of shadows */
    .project-card, .skill-item, 
    .certification-card, .challenge-card,
    .timeline-content {
      border: 1px solid #ddd !important;
      border-radius: 0 !important;
    }
    
    /* Optimize font colors for print */
    p, .project-description, .timeline-content p,
    .certification-date, .challenge-description {
      color: #333 !important;
    }
    
    /* Add page numbers */
    @page {
      margin: 2cm;
    }
  }