/* Additional Responsive Utilities and Fixes */

/* Fix any remaining responsive issues */

/* Ensure proper text scaling on mobile */
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Prevent horizontal scroll on mobile */
body {
  overflow-x: hidden;
}

/* Fix mobile menu z-index issues */
.mobile-menu {
  
  z-index: 9999 !important;
}

/* Ensure buttons are touch-friendly */
.btn, button, .mobile-menu-toggle {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}

/* Fix image loading on slow connections */
img {
  image-rendering: optimizeQuality;
  background-color: var(--gray-100);
}

/* Loading states */
.lazy {
  opacity: 0;
  transition: opacity 0.3s;
}

.lazy.loaded {
  opacity: 1;
}

/* Enhanced focus styles for accessibility */
*:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Fix viewport issues on iOS */
@supports (-webkit-touch-callout: none) {
  .hero-section {
    min-height: -webkit-fill-available;
  }
}

/* Fix font rendering issues */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Ensure proper spacing on all screen sizes */
@media (max-width: 374px) {
  .container {
    padding: 0 0.75rem;
  }
  
  .hero-title {
    font-size: 1.5rem !important;
  }
  
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
  }
}

/* Fix carousel responsiveness */
.carousel-container {
  overflow: hidden;
  border-radius: 0.5rem;
}

.cert-item {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-item img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

/* Fix timeline responsiveness */
@media (max-width: 767px) {
  .timeline::before {
    left: 1rem;
  }
  
  .timeline-icon {
    left: -2.75rem;
  }
}

/* Fix contact form on very small screens */
@media (max-width: 374px) {
  .contact-form {
    margin: 0 -0.5rem;
  }
  
  .form-input {
    padding: 0.5rem;
    font-size: 0.875rem;
  }
}

/* Fix footer responsiveness */
@media (max-width: 480px) {
  .footer-content {
    text-align: center;
  }
  
  .social-icons {
    justify-content: center;
  }
}

/* Ensure smooth animations */
@media (prefers-reduced-motion: no-preference) {
  .reveal, .animate-on-scroll {
    animation: fadeInUp 0.6s ease-out forwards;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fix hover states on touch devices */
@media (hover: none) {
  .project-overlay {
    opacity: 1;
    background: rgba(0, 0, 0, 0.3);
  }
  
  .btn:hover {
    transform: none;
  }
  
  .social-link:hover {
    transform: none;
  }
}

/* Fix layout shifts */
.loading-placeholder {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Optimize performance */
.project-image,
.hero-image,
.about-image {
  contain: layout style paint;
}

/* Fix sticky elements */
.modern-nav.scrolled {
  transform: translateY(0);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Fix modal issues on landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .modal-content {
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .modal-header {
    padding: 0.75rem 1rem;
  }
  
  .modal-body {
    padding: 0.5rem 1rem;
  }
  
  .modal-footer {
    padding: 0.75rem 1rem;
  }
}

/* Fix text selection */
::selection {
  background: var(--primary-500);
  color: white;
}

::-moz-selection {
  background: var(--primary-500);
  color: white;
}

/* Fix scroll behavior */
html {
  scroll-padding-top: 80px;
}

/* Fix input zoom on iOS */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  select,
  textarea,
  input[type="text"],
  input[type="email"],
  input[type="tel"] {
    font-size: 16px;
  }
}

/* Fix safe area insets for newer devices */
@supports (padding: max(0px)) {
  .container {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  
  .modern-nav {
    padding-top: env(safe-area-inset-top);
  }
  
  .scroll-to-top {
    bottom: max(2rem, env(safe-area-inset-bottom));
    right: max(2rem, env(safe-area-inset-right));
  }
}

/* Dark mode improvements */
@media (prefers-color-scheme: dark) {
  :root {
    --white: #1a1a1a;
    --gray-50: #2a2a2a;
    --gray-100: #3a3a3a;
    --gray-200: #4a4a4a;
    --gray-800: #e5e5e5;
    --gray-900: #ffffff;
  }
  
  .modern-nav {
    background: rgba(26, 26, 26, 0.95);
  }
  
  .card, .modal-content {
    background: var(--gray-50);
  }
}

/* Fix Chrome autofill styles */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--white) inset;
  -webkit-text-fill-color: var(--gray-800);
  transition: background-color 5000s ease-in-out 0s;
}

/* Print optimizations */
@media print {
  * {
    color: black !important;
    background: white !important;
  }
  
  .hero-section {
    min-height: initial;
    page-break-after: always;
  }
  
  .section {
    page-break-inside: avoid;
    margin-bottom: 2rem;
  }
  
  .project-card {
    break-inside: avoid;
    margin-bottom: 1rem;
  }
}

/* Fix edge cases */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Performance optimizations */
.will-change-auto {
  will-change: auto;
}

.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

/* Fix layout on ultra-wide screens */
@media (min-width: 2560px) {
  .container {
    max-width: 2000px;
  }
}

/* Fix very tall screens */
@media (min-height: 1200px) {
  .hero-section {
    min-height: 100vh;
  }
}
