/* Mobile-Specific Styles and Touch Interactions */

/* Mobile-First Responsive Breakpoints */
@media (max-width: 480px) {
  :root {
    --grid-gap: 1rem;
    --grid-margin: 0.75rem;
  }

  /* Typography scaling for small screens */
  .hero-title,
  .cta-section h1 {
    font-size: 2rem !important;
    line-height: 1.2;
  }

  .cta-section h2 {
    font-size: 1.5rem !important;
  }

  .cta-section p {
    font-size: 0.95rem;
  }

  /* Button sizing */
  .cta-button {
    padding: 0.875rem 1.25rem;
    font-size: 0.95rem;
  }

  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.8rem;
  }
}

/* Touch-Friendly Interactions */
.is-touch .nav-link,
.is-touch .mobile-nav-link,
.is-touch .cta-button,
.is-touch .btn {
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.is-touch .product-card,
.is-touch .section-card,
.is-touch .paper-layer {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.is-touch .product-card:active,
.is-touch .section-card:active,
.is-touch .paper-layer:active {
  transform: scale(0.98);
}

/* Disable hover effects on touch devices */
.is-touch .interactive-image:hover {
  transform: none;
}

.is-touch .paper-layer:hover {
  transform: none;
  box-shadow: var(--shadow-md);
}

/* Mobile Navigation Improvements */
@media (max-width: 768px) {
  html {
    box-sizing: border-box;
  }

  *,
  *::before,
  *::after {
    box-sizing: inherit;
  }

  body {
    overflow-x: hidden;
    /* Prevent horizontal scrolling */
    padding-left: 1rem;
    /* Add default horizontal padding */
    padding-right: 1rem;
    /* Add default horizontal padding */
  }

  .banner-grid,
  .form-container,
  .content-block,
  .products-grid {
    width: 100%;
    /* Ensure these containers take full width */
  }

  .mobile-nav-overlay {
    backdrop-filter: blur(20px);
  }

  .mobile-nav-list {
    padding: 2rem;
  }

  .mobile-nav-item {
    margin: 1.5rem 0;
    padding: 0.5rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    transition: background-color 0.2s ease;
  }

  .mobile-nav-item:active {
    background: rgba(255, 255, 255, 0.1);
  }

  .mobile-nav-link {
    display: block;
    padding: 0.75rem;
    text-align: center;
  }

  /* Global Benefits Grid (used in REFLEX and others) */
  .benefits-grid {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
    width: 100%;
  }

  .feature-highlight-grid,
  .why-reflex-grid,
  .s4-prep-grid {
    grid-template-columns: 1fr !important;
    margin-bottom: 2rem !important;
  }
}

/* Banner Grid Mobile Optimization */
@media (max-width: 768px) {
  .banner-grid {
    grid-template-columns: 1fr;
    padding: 1.5rem;
    min-height: auto;
    text-align: center;
  }

  .full-page-header .banner-grid {
    min-height: 70vh;
    padding: 2rem 1rem;
  }

  .banner-image {
    margin-top: 1.5rem;
    order: 2;
  }

  .cta-section {
    order: 1;
  }

  .cta-buttons {
    flex-direction: column;
    gap: 1rem;
    align-items: center;
  }

  .cta-buttons .btn {
    margin: 0 !important;
    width: 100%;
    max-width: 280px;
  }

  /* Force order for special banner types (banner4, banner5, banner6) on mobile */
  .banner4 .banner-grid .cta-section,
  .banner5 .banner-grid .cta-section,
  .banner6 .banner-grid .cta-section {
    order: 1 !important;
  }

  .banner4 .banner-grid .banner-image,
  .banner5 .banner-grid .banner-image,
  .banner6 .banner-grid .banner-image {
    order: 2 !important;
  }

  /* Fix fixed-width placeholders causing overflow */
  .image-placeholder,
  .hero-image-placeholder {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
  }
}

/* Product Grid Mobile Layout */
@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .product-card {
    padding: 1.5rem;
    margin-bottom: 1rem;
  }

  .product-card h3 {
    font-size: 1.25rem;
  }

  .product-card .btn {
    width: 100%;
  }

  /* Products Detailed Layout Fix */
  .product-details-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
    padding: 1rem !important;
  }

  .product-menu {
    flex-direction: row !important;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem !important;
  }

  .product-menu-item {
    flex: 1 1 calc(33.333% - 0.5rem);
    padding: 0.75rem 0.5rem !important;
    font-size: 0.8rem;
    text-align: center;
  }
}

/* Form Mobile Optimization */
@media (max-width: 768px) {
  .form-container {
    margin: 0 1rem;
    padding: 1.5rem;
  }

  .form-input,
  .form-textarea {
    font-size: 16px;
    /* Prevents zoom on iOS */
    padding: 0.875rem;
  }

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

/* Content Block Mobile Layout */
@media (max-width: 768px) {
  .content-block {
    margin: 2rem 0;
    padding: 1.5rem;
    border-radius: 0.75rem;
  }

  .section-card {
    padding: 1.5rem;
    margin: 1rem 0;
  }
}

/* Page Divider Mobile */
@media (max-width: 768px) {
  .page-divider {
    margin: 2.5rem 0;
  }

  .divider-text {
    font-size: 1.125rem;
  }

  .divider-center {
    margin: 0 1rem;
  }
}

/* Performance Optimizations for Mobile */
.is-mobile .custom-cursor {
  display: none !important;
}

.is-mobile .paper-layer::before,
.is-mobile .paper-layer::after {
  display: none;
}

.is-mobile .interactive-image {
  transition: none;
}

.is-mobile .glass-paper {
  backdrop-filter: none;
  background: rgba(255, 255, 255, 0.1);
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {

  .banner,
  .content-block,
  .section-card,
  .product-card,
  .paper-layer {
    transition: none;
    animation: none;
  }

  .interactive-image {
    transition: none;
  }

  .nav-link::after {
    transition: none;
  }

  .custom-cursor {
    display: none;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --bg-primary: #000000;
  }

  .paper-layer {
    border: 2px solid var(--hsi-orange);
  }

  .nav-link {
    border-bottom: 1px solid transparent;
  }

  .nav-link:hover,
  .nav-link:focus {
    border-bottom-color: var(--hsi-orange);
  }
}

/* Print Styles */
@media print {

  .site-header,
  .mobile-nav-overlay,
  .custom-cursor,
  .page-divider {
    display: none;
  }

  .banner,
  .content-block,
  .section-card {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  body {
    background: white;
    color: black;
  }

  .paper-layer {
    border: 1px solid #ccc;
    background: white;
  }
}

/* Landscape Orientation on Mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .full-page-header .banner-grid {
    min-height: 50vh;
  }

  .hero-title,
  .cta-section h1 {
    font-size: 1.75rem !important;
  }

  .mobile-nav-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }

  .mobile-nav-item {
    margin: 0.5rem;
    flex: 0 0 auto;
  }
}

/* Dark Mode Enhancements for Mobile */
@media (prefers-color-scheme: dark) {

  .is-mobile .form-input,
  .is-mobile .form-textarea {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
  }

  .is-mobile .product-card,
  .is-mobile .section-card {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
  }
}

/* Safe Area Support for newer mobile devices */
@supports (padding: env(safe-area-inset-top)) {
  .site-header {
    padding-top: env(safe-area-inset-top);
  }

  .mobile-nav-overlay {
    padding-top: env(safe-area-inset-top);
  }

  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Loading States for Mobile */
.loading .banner,
.loading .content-block {
  opacity: 0;
  transform: translateY(20px);
}

.loaded .banner,
.loaded .content-block {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

/* Focus Management for Accessibility */
.nav-link:focus,
.mobile-nav-link:focus,
.cta-button:focus,
.btn:focus {
  outline: 2px solid var(--hsi-orange);
  outline-offset: 2px;
}

.form-input:focus,
.form-textarea:focus {
  outline: 2px solid var(--hsi-orange);
  outline-offset: -2px;
}
/* Announcements Slider Mobile Fix */
@media (max-width: 768px) {
  .announcements-container {
    width: calc(100vw - 2rem) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: none !important;
    box-sizing: border-box;
  }

  .announcement-item {
    padding: 1.5rem 1rem !important;
  }

  .announcement-comment {
    max-width: 100% !important;
    font-size: 0.85rem !important;
  }
}
