/**
 * CRS MOBILE OPTIMIZATION - Feb 2026
 * 
 * Comprehensive mobile UX improvements:
 * ✅ Touch-friendly targets (48px minimum)
 * ✅ Readable typography (16px+ base)
 * ✅ Optimized spacing and rhythm
 * ✅ Rack accordion mobile improvements
 * ✅ Better image handling
 * ✅ Improved navigation
 * ✅ Performance optimizations
 * 
 * Target devices: 320px - 767px
 */

/* ==========================================================
   MOBILE FOUNDATION - Reset & Base
   ========================================================== */

@media (max-width: 767px) {
  
  /* Prevent horizontal scroll */
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  
  /* Base font size for readability */
  html {
    font-size: 16px !important; /* Never below 16px on mobile */
  }
  
  body {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  
  /* Smooth scrolling */
  html {
    scroll-behavior: smooth;
  }
  
  /* Touch-friendly tap targets */
  a, button, .clickable {
    min-height: 48px !important;
    min-width: 48px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  /* Better tap feedback */
  a, button {
    -webkit-tap-highlight-color: rgba(232, 155, 60, 0.3);
  }
  
  /* Disable text inflation */
  body, p, h1, h2, h3, h4, h5, h6 {
    text-size-adjust: none !important;
  }

  /* ==========================================================
     HEADER MOBILE OPTIMIZATION
     ========================================================== */
  
  /* Simplified header layout */
  .rack-header,
  .crs-header {
    padding: 0.75rem 1rem !important;
    min-height: 60px !important;
    gap: 0.75rem !important;
    flex-wrap: nowrap !important;
  }
  
  /* Logo scales down */
  .crs-main-logo,
  .logo-hardware-panel {
    max-height: 40px !important;
    height: 40px !important;
    width: auto !important;
  }
  
  /* Hide desktop navigation */
  .rack-nav-links,
  .header-services {
    display: none !important;
  }
  
  /* Mobile menu toggle always visible */
  .mobile-menu-toggle {
    display: flex !important;
    min-height: 48px !important;
    min-width: 48px !important;
    padding: 12px !important;
    border: 2px solid rgba(232, 155, 60, 0.5) !important;
    background: rgba(232, 155, 60, 0.05) !important;
    color: #E89B3C !important;
    font-size: 1.5rem !important;
    z-index: 1001 !important;
  }
  
  /* Adjust header button */
  .book-dropdown-trigger,
  .header-center-action button {
    font-size: 0.875rem !important;
    padding: 0.75rem 1rem !important;
    min-height: 48px !important;
  }

  /* ==========================================================
     RACK ACCORDION MOBILE OPTIMIZATION
     ========================================================== */
  
  /* Rack module containers */
  .rack-module-graphic,
  .rack-module {
    width: 100% !important;
    margin: 0 0 1rem 0 !important;
    padding: 0 !important;
  }
  
  /* Images */
  .rack-module-graphic img,
  .rack-module img {
    width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
    max-height: 60vh !important; /* Prevent excessively tall images */
  }
  
  /* Touch-friendly hotspots */
  .rack-hotspot,
  .hotspot-overlay a,
  .recording-panel,
  .rehearsal-panel,
  .control-room-button {
    min-height: 48px !important;
    min-width: 48px !important;
    touch-action: manipulation !important;
  }
  
  /* Better hotspot visibility on mobile */
  .hotspot-overlay a::after,
  .rack-hotspot::after {
    content: '' !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    background: rgba(232, 155, 60, 0.2) !important;
    pointer-events: none !important;
    opacity: 0 !important;
    transition: opacity 0.2s ease !important;
  }
  
  .hotspot-overlay a:active::after,
  .rack-hotspot:active::after {
    opacity: 1 !important;
  }

  /* ==========================================================
     TYPOGRAPHY MOBILE
     ========================================================== */
  
  /* Headings */
  h1, .h1 {
    font-size: 1.75rem !important; /* 28px */
    line-height: 1.2 !important;
    margin-bottom: 1rem !important;
  }
  
  h2, .h2 {
    font-size: 1.5rem !important; /* 24px */
    line-height: 1.25 !important;
    margin-bottom: 0.875rem !important;
  }
  
  h3, .h3 {
    font-size: 1.25rem !important; /* 20px */
    line-height: 1.3 !important;
    margin-bottom: 0.75rem !important;
  }
  
  h4, .h4 {
    font-size: 1.125rem !important; /* 18px */
    line-height: 1.35 !important;
  }
  
  /* Body text */
  p, .body-text {
    font-size: 1rem !important; /* 16px - minimum for readability */
    line-height: 1.6 !important;
    margin-bottom: 1rem !important;
    max-width: 100% !important;
  }
  
  /* Small text */
  small, .small-text {
    font-size: 0.875rem !important; /* 14px */
  }
  
  /* Rack unit titles */
  .rack-unit-title {
    font-size: 1.125rem !important;
    margin-bottom: 0.75rem !important;
  }

  /* ==========================================================
     SPACING & RHYTHM
     ========================================================== */
  
  /* Container padding */
  main,
  .container,
  .page-content {
    padding: 1rem !important;
  }
  
  /* Rack units */
  .rack-unit {
    padding: 1.25rem 1rem !important;
    margin-bottom: 1rem !important;
    border-radius: 6px !important;
  }
  
  /* Section spacing */
  section {
    padding: 2rem 1rem !important;
    margin-bottom: 1.5rem !important;
  }
  
  /* Content blocks */
  .rack-unit-content {
    padding: 0 !important;
    margin-top: 1rem !important;
  }

  /* ==========================================================
     BUTTONS & CTA MOBILE
     ========================================================== */
  
  /* All buttons */
  button,
  .btn,
  .cta-button,
  .rack-cta {
    min-height: 48px !important;
    padding: 0.875rem 1.5rem !important;
    font-size: 0.875rem !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
  }
  
  /* Primary CTA */
  .cta-button-primary,
  .cta-button-peak-red {
    min-height: 52px !important;
    padding: 1rem 2rem !important;
    font-size: 1rem !important;
  }
  
  /* Secondary CTA */
  .cta-button-secondary {
    min-height: 48px !important;
    padding: 0.875rem 1.5rem !important;
    font-size: 0.875rem !important;
  }
  
  /* Button groups */
  .button-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
    width: 100% !important;
  }
  
  .button-group button,
  .button-group .cta-button {
    width: 100% !important;
  }

  /* ==========================================================
     NAVIGATION MOBILE
     ========================================================== */
  
  /* Mobile overlay */
  .mobile-nav-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    background: rgba(10, 10, 10, 0.98) !important;
    z-index: 9999 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Mobile nav container */
  .mobile-nav-container {
    padding: 1.5rem 1rem !important;
    min-height: 100vh !important;
  }
  
  /* Mobile nav header */
  .mobile-nav-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 2rem !important;
    padding-bottom: 1rem !important;
    border-bottom: 2px solid rgba(232, 155, 60, 0.2) !important;
  }
  
  /* Mobile nav links */
  .mobile-nav-links {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
  }
  
  .mobile-nav-links a,
  .mobile-nav-links button {
    width: 100% !important;
    min-height: 52px !important;
    padding: 1rem 1.5rem !important;
    font-size: 1rem !important;
    text-align: left !important;
    border: 1px solid rgba(232, 155, 60, 0.3) !important;
    background: rgba(232, 155, 60, 0.05) !important;
    color: rgba(245, 245, 245, 0.9) !important;
    border-radius: 6px !important;
  }
  
  .mobile-nav-links a:active,
  .mobile-nav-links button:active {
    background: rgba(232, 155, 60, 0.15) !important;
    border-color: rgba(232, 155, 60, 0.5) !important;
  }
  
  /* Close button */
  .mobile-nav-close {
    min-height: 48px !important;
    min-width: 48px !important;
    font-size: 1.5rem !important;
    border: 2px solid rgba(232, 155, 60, 0.5) !important;
    background: rgba(232, 155, 60, 0.05) !important;
  }

  /* ==========================================================
     IMAGES & MEDIA
     ========================================================== */
  
  /* Responsive images */
  img {
    max-width: 100% !important;
    height: auto !important;
  }
  
  /* Prevent image overflow */
  .rack-module img,
  .service-image img,
  picture img {
    width: 100% !important;
    height: auto !important;
    object-fit: cover !important;
  }
  
  /* Constrain very tall images */
  img[src*="rack-images"] {
    max-height: 60vh !important;
    object-fit: contain !important;
  }
  
  /* Background images */
  .hero-container,
  .banner-image {
    background-size: cover !important;
    background-position: center !important;
  }

  /* ==========================================================
     FOOTER MOBILE
     ========================================================== */
  
  footer,
  .crs-footer {
    padding: 2rem 1rem !important;
  }
  
  /* Footer sections stack */
  .footer-section {
    margin-bottom: 2rem !important;
    width: 100% !important;
  }
  
  /* Footer text */
  .footer-section h3 {
    font-size: 1rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  .footer-section p,
  .footer-section a {
    font-size: 0.875rem !important;
    line-height: 1.6 !important;
  }
  
  /* Footer banner logo */
  .footer-banner-logo {
    max-width: 250px !important;
    height: auto !important;
  }
  
  /* Terminal status footer */
  .terminal-status-footer {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
    padding: 1.5rem 1rem !important;
  }
  
  .terminal-status-section {
    width: 100% !important;
  }

  /* ==========================================================
     FORMS MOBILE
     ========================================================== */
  
  /* Form inputs */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  textarea,
  select {
    min-height: 48px !important;
    padding: 0.875rem 1rem !important;
    font-size: 1rem !important; /* Prevents iOS zoom */
    border-radius: 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  textarea {
    min-height: 120px !important;
  }
  
  /* Labels */
  label {
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    margin-bottom: 0.5rem !important;
    display: block !important;
  }
  
  /* Form buttons */
  form button[type="submit"],
  form .submit-button {
    width: 100% !important;
    min-height: 52px !important;
    font-size: 1rem !important;
    margin-top: 1rem !important;
  }

  /* ==========================================================
     PERFORMANCE OPTIMIZATIONS
     ========================================================== */
  
  /* Reduce motion for animations */
  * {
    animation-duration: 0.3s !important;
    transition-duration: 0.2s !important;
  }
  
  /* Optimize scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }
  
  /* GPU acceleration for transforms */
  .rack-module,
  .mobile-nav-overlay,
  .modal,
  .overlay {
    transform: translateZ(0);
    backface-visibility: hidden;
  }

  /* ==========================================================
     UTILITY CLASSES
     ========================================================== */
  
  /* Hide on mobile */
  .hide-mobile {
    display: none !important;
  }
  
  /* Show on mobile only */
  .show-mobile {
    display: block !important;
  }
  
  /* Full width */
  .full-width-mobile {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Center content */
  .center-mobile {
    text-align: center !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
  
  /* Stack elements */
  .stack-mobile {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
  }

  /* ==========================================================
     ACCESSIBILITY ON MOBILE
     ========================================================== */
  
  /* Focus states */
  a:focus,
  button:focus,
  input:focus,
  textarea:focus,
  select:focus {
    outline: 3px solid rgba(232, 155, 60, 0.8) !important;
    outline-offset: 2px !important;
  }
  
  /* Skip to content */
  .skip-to-content {
    position: fixed !important;
    top: 1rem !important;
    left: 1rem !important;
    z-index: 10000 !important;
    padding: 1rem 1.5rem !important;
    background: #E89B3C !important;
    color: #0a0a0a !important;
    font-weight: 700 !important;
    border-radius: 6px !important;
    transform: translateY(-200%) !important;
    transition: transform 0.3s ease !important;
  }
  
  .skip-to-content:focus {
    transform: translateY(0) !important;
  }

  /* ==========================================================
     SPECIFIC COMPONENT FIXES
     ========================================================== */
  
  /* Studio intro */
  .studio-intro {
    padding: 2rem 1rem !important;
  }
  
  .studio-intro h1 {
    font-size: 1.75rem !important;
  }
  
  .studio-intro p {
    font-size: 1rem !important;
  }
  
  /* Infrastructure frame */
  .infrastructure-frame {
    padding: 1.5rem 1rem !important;
    margin: 1rem 0 !important;
  }
  
  /* Service panels */
  .service-panel {
    padding: 1.5rem 1rem !important;
    margin-bottom: 1rem !important;
  }
  
  /* Contact section */
  .contact-section {
    padding: 2rem 1rem !important;
  }
  
  /* Booking widgets */
  .booking-widget iframe {
    width: 100% !important;
    height: auto !important;
    min-height: 600px !important;
  }
  
  /* Modal dialogs */
  .modal-content {
    width: calc(100% - 2rem) !important;
    margin: 1rem !important;
    max-height: calc(100vh - 2rem) !important;
    overflow-y: auto !important;
  }

  /* ==========================================================
     ODRO REPAIR RACK MOBILE
     ========================================================== */
  
  .odro-repair-container {
    max-height: 50vh !important;
    overflow: hidden !important;
  }
  
  .odro-repair-container img {
    max-height: 50vh !important;
    object-fit: contain !important;
  }
  
  /* Repair buttons */
  .odro-repair-button {
    min-height: 48px !important;
    min-width: 48px !important;
  }
  
  /* Repair modal */
  .odro-modal {
    width: calc(100% - 2rem) !important;
    margin: 1rem !important;
    padding: 1.5rem 1rem !important;
  }
  
  .odro-modal h2 {
    font-size: 1.25rem !important;
  }
  
  .odro-modal p {
    font-size: 0.875rem !important;
  }

} /* End mobile media query */

/* ==========================================================
   TABLET OPTIMIZATION (768px - 1023px)
   ========================================================== */

@media (min-width: 768px) and (max-width: 1023px) {
  
  /* Tablet-specific adjustments */
  html {
    font-size: 15px !important;
  }
  
  .rack-header {
    padding: 1rem 1.5rem !important;
  }
  
  /* Slightly reduce logo size */
  .crs-main-logo,
  .logo-hardware-panel {
    max-height: 48px !important;
  }
  
  /* Keep some desktop nav, but simplify */
  .rack-nav-links {
    gap: 1rem !important;
    font-size: 0.9rem !important;
  }
  
  /* Containers */
  main,
  .container,
  .page-content {
    padding: 1.5rem !important;
  }
  
  /* Rack units */
  .rack-unit {
    padding: 1.5rem !important;
  }
  
  /* Buttons */
  button,
  .cta-button {
    min-height: 44px !important;
    padding: 0.75rem 1.5rem !important;
  }
  
}
