/* Enhanced Mobile Responsiveness */

/* Mobile-First Approach */
@media (max-width: 768px) {
  /* Navigation Improvements */
  .header-container {
    position: relative;
    padding: 1rem 0;
  }
  
  .mobile-menu-toggle {
    display: block !important;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary);
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
  }
  
  nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
  }
  
  nav.active {
    display: block;
  }
  
  nav ul {
    flex-direction: column;
    gap: 0;
    padding: 1rem 0;
  }
  
  nav a {
    display: block;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--cream);
    transition: background 0.3s ease;
  }
  
  nav a:hover {
    background: var(--cream);
  }
  
  nav a.active {
    background: var(--cream);
    color: var(--primary);
  }
  
  /* Hero Section Mobile */
  .hero h1 {
    font-size: 2rem !important;
    line-height: 1.3;
  }
  
  .hero p {
    font-size: 1rem !important;
  }
  
  .hero-buttons {
    flex-direction: column;
    width: 100%;
    padding: 0 1rem;
  }
  
  .btn {
    width: 100%;
    text-align: center;
  }
  
  /* Product Cards Mobile */
  .products-showcase {
    grid-template-columns: 1fr;
    padding: 0 1rem;
  }
  
  .product-feature {
    margin-bottom: 2rem;
  }
  
  .product-info {
    padding: 1.5rem 1rem;
  }
  
  /* Story Section Mobile */
  .about-content {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .about-image {
    order: -1;
    margin-bottom: 2rem;
  }
  
  /* Process Steps Mobile */
  .process-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .process-step {
    padding: 1.5rem;
  }
  
  /* Configurator Mobile */
  .product-configurator {
    padding: 1.5rem 1rem;
  }
  
  .product-header {
    flex-direction: column;
    text-align: center;
  }
  
  .product-header img {
    width: 150px;
    height: 150px;
  }
  
  .configurator-options {
    grid-template-columns: 1fr;
  }
  
  .generate-sku-btn {
    font-size: 1rem;
    padding: 1rem 1.5rem;
  }
  
  /* Touch-Friendly Improvements */
  .config-select,
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px; /* Apple's recommended touch target */
  }
  
  /* Footer Mobile */
  .footer .wrapper {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 2rem;
  }
  
  .social {
    justify-content: center;
  }
  
  /* Testimonials Mobile */
  .testimonials-grid {
    grid-template-columns: 1fr;
  }
  
  .testimonial-card {
    margin-bottom: 1.5rem;
  }
  
  /* Benefits Grid Mobile */
  .benefits-grid {
    grid-template-columns: 1fr;
  }
  
  .benefit {
    margin-bottom: 1.5rem;
  }
}

/* Tablet Optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    padding: 0 2rem;
  }
  
  .products-showcase {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .process-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .benefits-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Touch Device Enhancements */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .product-card:hover {
    transform: none;
  }
  
  .btn:hover {
    transform: none;
  }
  
  /* Larger touch targets */
  .btn {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Better spacing for touch */
  .nav a {
    padding: 1rem;
  }
  
  /* Disable parallax on mobile for performance */
  .hero {
    background-attachment: scroll;
  }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .hero {
    min-height: 100vh;
  }
  
  .hero h1 {
    font-size: 1.8rem !important;
  }
}

/* High DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Serve higher resolution images for retina displays */
  .logo {
    background-image: url('../BakeryWebsiteImages/Logo/logo@2x.jpg');
    background-size: contain;
  }
}

/* Accessibility Improvements for Mobile */
@media (max-width: 768px) {
  /* Larger fonts for readability */
  body {
    font-size: 18px;
  }
  
  /* Better contrast for outdoor viewing */
  .btn.primary {
    background: var(--primary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  }
  
  /* Skip to content link */
  .skip-to-content {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 999;
  }
  
  .skip-to-content:focus {
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 1rem 2rem;
    text-decoration: none;
    border-radius: 0 0 8px 8px;
  }
}

/* Performance Optimizations */
@media (max-width: 768px) {
  /* Disable animations on mobile for better performance */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation: none !important;
      transition: none !important;
    }
  }
  
  /* Optimize font loading */
  .font-display-swap {
    font-display: swap;
  }
}

/* Improved Form Layouts on Mobile */
@media (max-width: 768px) {
  .contact-grid,
  .location-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .form-group {
    margin-bottom: 1.2rem;
  }
  
  .form-group label {
    font-size: 0.95rem;
  }
  
  /* Stack buttons on mobile */
  .hero-buttons {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 0 2rem;
  }
  
  .hero-buttons .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Improved Gallery on Mobile */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
  }
  
  .gallery-item {
    border-radius: 8px;
  }
  
  .gallery-item img {
    height: 150px;
  }
  
  .gallery-item-overlay {
    padding: 1rem 0.5rem 0.5rem;
  }
  
  .gallery-item-title {
    font-size: 1rem;
  }
  
  .gallery-item-category {
    font-size: 0.8rem;
  }
}

/* Better Product Cards on Mobile */
@media (max-width: 768px) {
  .products-showcase {
    padding: 0 1rem;
  }
  
  .product-feature {
    margin-bottom: 1.5rem;
  }
  
  .product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .product-link {
    font-size: 0.9rem;
  }
}

/* Improved Footer on Mobile */
@media (max-width: 768px) {
  .footer .wrapper {
    padding: 2rem 1rem;
    gap: 2rem;
  }
  
  .footer h4 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }
  
  .newsletter form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .newsletter input[type="email"] {
    width: 100%;
    margin-right: 0;
  }
  
  .newsletter button {
    width: 100%;
  }
}

/* Better Testimonials on Mobile */
@media (max-width: 768px) {
  .testimonials-grid {
    padding: 0 1rem;
  }
  
  .testimonial-card {
    padding: 1.5rem;
  }
  
  .testimonial-card p {
    font-size: 1rem;
  }
}

/* Improved Configurator on Mobile */
@media (max-width: 768px) {
  .product-configurator {
    padding: 1rem;
    margin: 1rem;
  }
  
  .product-header {
    gap: 1rem;
  }
  
  .product-header img {
    width: 100px;
    height: 100px;
  }
  
  .product-info h3 {
    font-size: 1.5rem;
  }
  
  .product-info p {
    font-size: 0.95rem;
  }
  
  .configurator-options {
    gap: 1rem;
  }
  
  .config-select {
    padding: 0.7rem;
    font-size: 16px;
  }
  
  .generate-sku-btn {
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
  }
}

/* Better Hero Section on Mobile */
@media (max-width: 768px) {
  .hero {
    min-height: 60vh;
  }
  
  .hero-content {
    padding: 1.5rem;
  }
  
  .hero-title {
    font-size: 2rem !important;
    line-height: 1.2;
    margin-bottom: 1rem;
  }
  
  .hero-subtitle {
    font-size: 1rem !important;
    line-height: 1.5;
  }
  
  .hero-freshness {
    margin-top: 1.5rem;
  }
  
  .fresh-badge {
    font-size: 0.9rem;
    padding: 0.6rem 1.2rem;
  }
}

/* Improved Process Steps on Mobile */
@media (max-width: 768px) {
  .process-grid {
    padding: 0 1rem;
  }
  
  .process-step {
    padding: 1.5rem;
  }
  
  .step-icon {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
  }
  
  .process-step h3 {
    font-size: 1.2rem;
  }
  
  .process-step p {
    font-size: 0.95rem;
  }
}

/* Better Section Spacing on Mobile */
@media (max-width: 768px) {
  section {
    padding: 3rem 0;
  }
  
  .section-title {
    font-size: 2rem;
    margin-bottom: 1rem;
  }
  
  .section-subtitle {
    font-size: 1rem;
    margin-bottom: 2rem;
  }
}

/* Improved Scroll to Top Button */
@media (max-width: 768px) {
  #scrollTop {
    bottom: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
  }
}

/* Swipe Gestures Support */
.swipe-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.swipe-container::-webkit-scrollbar {
  display: none;
}

.swipe-item {
  scroll-snap-align: start;
  flex: 0 0 auto;
}

/* Touch-friendly Cards */
@media (hover: none) and (pointer: coarse) {
  .product-card,
  .testimonial-card,
  .gallery-item,
  .faq-item {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  
  .product-card:active,
  .testimonial-card:active,
  .gallery-item:active {
    transform: scale(0.98);
  }
}

/* Improved Accessibility on Mobile */
@media (max-width: 768px) {
  .skip-to-content:focus {
    top: 10px;
    left: 10px;
    right: auto;
    transform: none;
  }
  
  /* Larger touch targets for links */
  a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  
  /* Better focus indicators */
  *:focus {
    outline-offset: 4px;
  }
}

/* Landscape Mobile Optimizations */
@media (max-width: 812px) and (orientation: landscape) {
  .hero {
    min-height: 90vh;
  }
  
  .hero-content {
    padding: 1rem;
  }
  
  .hero-title {
    font-size: 1.8rem !important;
  }
  
  .hero-subtitle {
    font-size: 0.95rem !important;
  }
  
  nav {
    max-height: 60vh;
  }
}

/* Small Mobile Devices */
@media (max-width: 375px) {
  .container {
    padding: 0 1rem;
  }
  
  .hero-title {
    font-size: 1.75rem !important;
  }
  
  .section-title {
    font-size: 1.75rem;
  }
  
  .btn {
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
  }
  
  .product-card h3,
  .testimonial-card .author strong {
    font-size: 1.1rem;
  }
}

/* iPad and Tablet Specific */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    padding: 0 2rem;
  }
  
  .products-showcase {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .process-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .benefits-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .testimonials-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
  /* iOS specific fixes */
  .hero {
    min-height: -webkit-fill-available;
  }
  
  input,
  textarea,
  select {
    -webkit-appearance: none;
    border-radius: 0;
  }
  
  /* Prevent iOS zoom on form focus */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="date"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* Loading States for Mobile */
.mobile-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.mobile-loading::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid var(--cream);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
