/* ============================================
   COMPREHENSIVE RESPONSIVE FIXES
   Professional Enhancement for Albert's Portfolio
   ============================================ */

/* ===== GLOBAL RESPONSIVE IMPROVEMENTS ===== */
:root {
  --mobile-section-padding: 50px 0;
  --tablet-section-padding: 70px 0;
  --desktop-section-padding: 100px 0;
}

/* Base responsive improvements */
html {
  font-size: 100%; /* Base font size for better rem scaling */
}

body {
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  box-sizing: border-box;
  max-width: 100%;
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Fluid typography for better scaling */
h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

h3 {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
}

p {
  font-size: clamp(0.9rem, 2vw, 1rem);
}

/* ===== RESPONSIVE LAYOUT FIXES ===== */

/* Extra small devices (phones, 576px and down) */
@media (max-width: 576px) {
  .container {
    max-width: 100%;
    padding: 0 15px;
  }

  .section-padding {
    padding: var(--mobile-section-padding);
  }

  /* Header & Navigation */
  #header .container {
    height: 70px;
  }

  .logo a {
    font-size: 20px;
  }

  .nav-toggle {
    width: 25px;
    height: 20px;
  }

  /* Improved mobile menu */
  .nav-menu {
    max-width: 85%;
    border-radius: 10px;
    padding: 20px 0;
  }

  .mobile-menu-profile {
    padding: 20px;
    text-align: center;
  }

  .mobile-menu-profile img {
    box-sizing: border-box;
    max-width: 80px;
    max-height: 80px;
    border-radius: 50%;
    margin: 0 auto 15px;
    border: 3px solid var(--primary-color);
  }

  /* Hero Section */
  .hero {
    padding-top: 100px;
  }

  .hero-content {
    flex-direction: column-reverse;
    gap: 30px;
  }

  .hero-text {
    padding-right: 0;
    text-align: center;
  }

  .hero-text h1 {
    font-size: 28px;
    margin-bottom: 10px;
  }

  .hero-text h2 {
    font-size: 18px;
    margin-bottom: 15px;
  }

  .hero-text p {
    font-size: 14px;
    margin-bottom: 20px;
  }

  .hero-btns {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .hero-btns .btn {
    width: 100%;
  }

  .hero-image {
    max-width: 200px;
    margin: 0 auto;
  }

  .image-container {
    width: 180px;
    height: 180px;
  }

  .social-icons {
    justify-content: center;
    margin-top: 20px;
  }

  /* About Section */
  .about-content {
    flex-direction: column;
    gap: 30px;
  }

  .about-image {
    max-width: 250px;
    margin: 0 auto;
  }

  .skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  .skill-tags span {
    font-size: 12px;
    padding: 4px 8px;
  }

  /* Services Section */
  .services-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .service-card {
    padding: 25px;
  }

  /* Portfolio Section */
  .portfolio-filters {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .portfolio-filters button {
    font-size: 12px;
    padding: 6px 12px;
  }

  .portfolio-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  /* Testimonials Section */
  .testimonials-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .testimonial-content {
    padding: 20px;
  }

  /* Contact Section */
  .contact-content {
    flex-direction: column;
    gap: 30px;
  }

  .contact-info, .contact-form {
    width: 100%;
  }

  .contact-form-row {
    flex-direction: column;
    gap: 15px;
  }

  .contact-form-row .form-group {
    width: 100%;
  }
}

/* Small devices (landscape phones, 576px to 767px) */
@media (min-width: 577px) and (max-width: 767px) {
  .container {
    max-width: 540px;
  }

  .section-padding {
    padding: var(--mobile-section-padding);
  }

  /* Hero Section */
  .hero-content {
    flex-direction: column-reverse;
    gap: 40px;
  }

  .hero-text {
    text-align: center;
    padding-right: 0;
  }

  .hero-image {
    max-width: 220px;
    margin: 0 auto;
  }

  /* Services & Portfolio */
  .services-grid,
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}

/* Medium devices (tablets, 768px to 991px) */
@media (min-width: 768px) and (max-width: 991px) {
  .container {
    max-width: 720px;
  }

  .section-padding {
    padding: var(--tablet-section-padding);
  }

  /* Hero Section */
  .hero-content {
    gap: 30px;
  }

  .hero-text {
    flex: 3;
  }

  .hero-image {
    flex: 2;
  }

  /* About Section */
  .about-content {
    gap: 30px;
  }

  .about-image {
    flex: 1;
  }

  .about-text {
    flex: 2;
  }

  /* Services & Portfolio */
  .services-grid,
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
  }

  /* Contact Section */
  .contact-content {
    gap: 30px;
  }
}

/* Large devices (desktops, 992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
  .container {
    max-width: 960px;
  }

  .section-padding {
    padding: var(--desktop-section-padding);
  }

  /* Services & Portfolio */
  .services-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
  }

  .portfolio-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
  }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
  .container {
    max-width: 1140px;
  }

  /* Services & Portfolio */
  .services-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
  }

  .portfolio-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
  }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
/* Focus states for better keyboard navigation */
a:focus,
button:focus,
input:focus,
textarea:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Improved touch targets for mobile */
@media (max-width: 767px) {
  button, 
  .btn,
  .nav-menu li a,
  .portfolio-filters button {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ===== PERFORMANCE ENHANCEMENTS ===== */
/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
    transition-duration: 0.01ms;
    scroll-behavior: auto;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .nav-toggle,
  .nav-menu,
  .social-icons,
  .btn,
  .scroll-down,
  footer {
    display: none;
  }

  body {
    color: #000;
    background: #fff;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  img {
    max-width: 100%;
    page-break-inside: avoid;
  }

  .hero-content,
  .about-content,
  .contact-content {
    display: block;
  }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --light-color: #121212;
    --dark-color: #f8f9fa;
    --light-gray: #2d2d2d;
    --gray-color: #a0a0a0;
  }

  body {
    background-color: var(--light-color);
    color: var(--dark-color);
  }

  #header {
    background-color: rgba(18, 18, 18, 0.95);
  }

  #header.scrolled {
    background-color: #121212;
  }

  .logo a,
  .nav-menu li a {
    color: var(--dark-color);
  }

  .nav-toggle span {
    background-color: var(--dark-color);
  }

  .service-card,
  .portfolio-item,
  .testimonial-content,
  .contact-info,
  .contact-form {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
  }

  input, textarea {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--dark-color);
    border-color: rgba(255, 255, 255, 0.2);
  }
}

/* ===== ANIMATION OPTIMIZATIONS ===== */
/* Optimize animations for better performance */
.fade-up,
.fade-right,
.fade-left,
[data-aos] {
  backface-visibility: hidden;
  will-change: transform, opacity;
}

/* ===== ADDITIONAL FIXES ===== */
/* Fix for iOS form elements */
input,
textarea,
button {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 5px;
}

/* Fix for sticky hover on mobile */
@media (hover: hover) {
  .btn:hover,
  .nav-menu li a:hover,
  .portfolio-filters button:hover,
  .social-icons a:hover {
    opacity: 0.85;
  }
}

/* ===== ADDITIONAL RESPONSIVE ENHANCEMENTS ===== */

/* Improved navigation for all screen sizes */
@media (max-width: 768px) {
  /* Enhanced mobile navigation - ONLY show on mobile */
  .nav-toggle,
  #navToggle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    width: 30px;
    height: 21px;
    z-index: 9999;
    position: relative;
  }
  
  .nav-toggle span,
  #navToggle span {
    background-color: #000000;
    height: 3px;
    border-radius: 3px;
    display: block;
    transition: all 0.3s ease;
  }
  
  /* Better mobile menu animation */
  .nav-menu {
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  
  .nav-menu.active {
    transform: translateX(0);
    opacity: 1;
  }
  
  /* Improved spacing for mobile sections */
  .section-header {
    margin-bottom: 40px;
  }
  
  /* Better mobile form experience */
  input, textarea, select {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 991px) {
  /* Improved tablet layout for portfolio */
  .portfolio-item {
    transition: transform 0.3s ease;
  }
  
  .portfolio-item:hover {
    transform: translateY(-5px);
  }
}

/* Hide hamburger menu on tablets and larger screens */
@media (min-width: 769px) {
  .nav-toggle,
  #navToggle {
    display: none;
  }
  
  /* Ensure nav menu is always visible on desktop */
  .nav-menu {
    display: flex;
    opacity: 1;
    visibility: visible;
    position: static;
    background: transparent;
    box-shadow: none;
    transform: none;
    width: auto;
    height: auto;
    padding: 0;
  }
}

/* Desktop enhancements */
@media (min-width: 992px) {
  /* Smooth hover effects for desktop */
  .service-card,
  .portfolio-item,
  .social-icons a {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .service-card:hover,
  .portfolio-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  }
  
  /* Enhanced desktop navigation */
  .nav-menu li a::after {
    transition: width 0.3s ease;
  }
}

/* High-resolution screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Optimize images for high-DPI displays */
  .hero-image img,
  .about-image img,
  .portfolio-img img {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Fix for flexbox gap support */
@supports not (gap: 20px) {
  .hero-content > * {
    margin: 0 10px;
  }
  
  .services-grid > *,
  .portfolio-grid > *,
  .testimonials-grid > * {
    margin: 10px;
  }
}

/* Fix for object-fit support */
.profile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@supports not (object-fit: cover) {
  .profile-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
  }
}