/* ==========================================================================
   HABIT FIX WELLNESS - Advanced Mobile-First & Responsive Stylesheet
   Zero Horizontal Scrolling • Pixel-Perfect Clean Layout • Mobile Optimization
   ========================================================================== */

/* 1. Global Viewport & Overflow Guards */
html, body {
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100vw !important;
  margin: 0 !important;
  padding: 0 !important;
  position: relative !important;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
  box-sizing: border-box !important;
}

/* Guard against overflowing media or raw embeds */
img, svg, video, canvas, audio, iframe, embed, object {
  max-width: 100% !important;
  height: auto;
}

/* Mobile iOS Safari Font Size Zoom Prevention */
input, select, textarea, button {
  font-size: 16px !important;
  max-width: 100% !important;
}

/* Ensure containers never exceed viewport width */
.container,
.container-fluid,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
  width: 100% !important;
  max-width: 100% !important;
  padding-left: 14px !important;
  padding-right: 14px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

@media (min-width: 576px) {
  .container { max-width: 540px !important; }
}
@media (min-width: 768px) {
  .container { max-width: 720px !important; }
}
@media (min-width: 992px) {
  .container { max-width: 960px !important; }
}
@media (min-width: 1200px) {
  .container { max-width: 1140px !important; }
}
@media (min-width: 1400px) {
  .container { max-width: 1280px !important; }
}

/* Row gutters guard to prevent -15px negative margins from causing horizontal scroll */
.row {
  margin-left: -8px !important;
  margin-right: -8px !important;
  max-width: calc(100% + 16px) !important;
}

.row > [class*="col"] {
  padding-left: 8px !important;
  padding-right: 8px !important;
  max-width: 100% !important;
}

/* Table Responsive Scrolling Guard */
.table-responsive {
  width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  margin-bottom: 1rem;
}

/* ==========================================================================
   2. Small Mobile Screens (< 576px) - Strict Layout Formatting
   ========================================================================== */
@media (max-width: 575.98px) {
  
  /* Top Notice Bar Mobile */
  .top-notice-bar {
    padding: 6px 0 !important;
    font-size: 0.72rem !important;
  }

  .top-notice-bar .container {
    flex-direction: column !important;
    gap: 4px !important;
    text-align: center !important;
  }

  .top-notice-bar .d-flex {
    justify-content: center !important;
    flex-wrap: wrap !important;
  }

  .lang-selector-group {
    padding: 1px 3px !important;
    gap: 2px !important;
  }

  .lang-selector-group .lang-btn {
    font-size: 0.7rem !important;
    padding: 2px 6px !important;
  }

  /* Header Brand & Navigation */
  .site-header {
    padding: 0 !important;
  }

  .site-header .navbar {
    padding: 6px 0 !important;
  }

  .site-header-logo {
    height: 32px !important;
    max-width: 135px !important;
    object-fit: contain !important;
  }

  .header-mobile-bmi-btn {
    font-size: 0.72rem !important;
    padding: 5px 9px !important;
    gap: 4px !important;
  }

  .header-hamburger-btn {
    width: 36px !important;
    height: 36px !important;
    border-radius: 8px !important;
    gap: 4px !important;
  }

  .header-hamburger-btn .ham-bar {
    width: 18px !important;
  }

  /* Mobile Drawer Container */
  .header-nav-collapse {
    padding: 12px 10px 18px 10px !important;
    margin-top: 8px !important;
    max-height: 82vh !important;
  }

  .mobile-lang-drawer-box {
    padding: 8px 10px !important;
    margin-bottom: 10px !important;
  }

  .mobile-lang-drawer-box .mobile-lang-btn {
    font-size: 0.75rem !important;
    padding: 5px 6px !important;
  }

  .header-nav-list .nav-link {
    font-size: 0.9rem !important;
    padding: 9px 12px !important;
  }

  .mobile-drawer-cta-group {
    padding-top: 12px !important;
    gap: 8px !important;
  }

  /* Typography Scales */
  h1, .display-4, .display-5, .hero-title {
    font-size: 1.65rem !important;
    line-height: 1.25 !important;
    word-break: break-word !important;
  }

  h2, .section-title {
    font-size: 1.4rem !important;
    line-height: 1.28 !important;
    word-break: break-word !important;
  }

  h3 {
    font-size: 1.2rem !important;
  }

  h4 {
    font-size: 1.05rem !important;
  }

  h5 {
    font-size: 0.95rem !important;
  }

  p, .section-lead, .lead, .hero-lead {
    font-size: 0.9rem !important;
    line-height: 1.55 !important;
  }

  .badge-subtle, .section-subtitle {
    font-size: 0.725rem !important;
    padding: 4px 10px !important;
  }

  /* Cards & Containers */
  .p-4, .p-5, .p-md-5 {
    padding: 16px !important;
  }

  .py-5 {
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
  }

  .hero-portrait-card, .hero-portrait-img, .coach-image-wrapper img {
    height: auto !important;
    max-height: 300px !important;
    width: 100% !important;
    border-radius: 14px !important;
  }

  .page-hero-banner-img {
    height: auto !important;
    max-height: 240px !important;
  }

  .page-hero-floating-pill {
    position: static !important;
    margin-top: 10px !important;
    width: 100% !important;
    border-radius: 12px !important;
    padding: 8px 12px !important;
  }

  /* Button Layout in CTAs */
  .hero-cta-group,
  .ready-cta-section .d-flex,
  .page-hero .d-flex {
    flex-direction: column !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .hero-cta-group .btn,
  .ready-cta-section .btn,
  .page-hero .btn {
    width: 100% !important;
    margin: 0 !important;
  }

  /* Floating Contact Dock */
  .floating-contact-dock {
    bottom: 14px !important;
    right: 12px !important;
    gap: 8px !important;
  }

  .floating-btn {
    width: 46px !important;
    height: 46px !important;
  }

  .floating-btn i {
    font-size: 1.25rem !important;
  }

  .floating-btn-tooltip {
    display: none !important;
  }

  /* Interactive Elements */
  .bmi-spectrum-container {
    width: 100% !important;
    overflow: hidden !important;
    padding: 0 !important;
  }

  .matrix-tab-btn {
    padding: 8px 12px !important;
    font-size: 0.785rem !important;
  }

  .gallery-filter-btn {
    font-size: 0.785rem !important;
    padding: 5px 10px !important;
  }

  /* Modal Dialog Fix */
  .modal-dialog {
    margin: 8px auto !important;
    max-width: calc(100vw - 16px) !important;
  }

  .modal-content {
    border-radius: 14px !important;
  }

  .modal-body {
    padding: 14px !important;
  }
}

/* ==========================================================================
   3. Tablet & Mid-Sized Mobile (576px - 767.98px)
   ========================================================================== */
@media (min-width: 576px) and (max-width: 767.98px) {
  .site-header-logo {
    height: 36px !important;
    max-width: 160px !important;
  }

  .hero-title {
    font-size: 2.1rem !important;
  }

  .section-title {
    font-size: 1.7rem !important;
  }

  .hero-portrait-card img,
  .hero-portrait-img {
    height: 350px !important;
    object-fit: cover !important;
  }

  .floating-contact-dock {
    bottom: 16px !important;
    right: 16px !important;
  }

  .floating-btn {
    width: 50px !important;
    height: 50px !important;
  }
}

/* ==========================================================================
   4. Tablets (768px - 991.98px)
   ========================================================================== */
@media (min-width: 768px) and (max-width: 991.98px) {
  .hero-title {
    font-size: 2.5rem !important;
  }

  .section-title {
    font-size: 2rem !important;
  }

  .hero-portrait-img {
    height: 380px !important;
  }

  .site-header-logo {
    height: 40px !important;
    max-width: 180px !important;
  }

  .floating-contact-dock {
    bottom: 20px !important;
    right: 20px !important;
  }
}

/* ==========================================================================
   5. Desktop Layout Polish (>= 992px)
   ========================================================================== */
@media (min-width: 992px) {
  .site-header .navbar {
    padding: 10px 0 !important;
  }

  .site-header-logo {
    height: 46px !important;
    max-width: 210px !important;
  }

  .hero-section {
    padding: 70px 0 90px !important;
  }

  .header-nav-list {
    gap: 4px !important;
  }

  .header-nav-list .nav-link {
    padding: 8px 14px !important;
    font-size: 0.925rem !important;
    border-radius: var(--radius-pill) !important;
  }

  .floating-btn:hover .floating-btn-tooltip {
    opacity: 1 !important;
    transform: translateY(-50%) translateX(-8px) !important;
  }
}

/* ==========================================================================
   6. Touch & Accessibility Polishes
   ========================================================================== */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets for mobile fingers */
  a, button, .nav-link, .lang-btn, .mobile-lang-btn, .time-slot-btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
  }

  /* Prevent sticky hover states on touch screens */
  .transformation-card:hover,
  .tracker-card:hover {
    transform: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .pulse-ring {
    display: none !important;
  }
}
