/* ==========================================================================
   GLOBAL RESPONSIVENESS OVERRIDE
   ========================================================================== */

/* 1. Global Box-Sizing & Reset to Prevent Overflows */
*, *::before, *::after {
  box-sizing: border-box !important;
}

html, body {
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100vw !important;
  margin: 0 !important;
}

/* 2. Responsive Media (Images, Videos, Iframes) */
img, video, iframe, canvas, svg, picture {
  max-width: 100% !important;
  height: auto;
  display: block;
}

.iframe-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
  overflow: hidden;
  margin-bottom: 24px;
}

.iframe-container iframe, .iframe-container object, .iframe-container embed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  border: none;
}

/* 3. Responsive Tables */
.responsive-table {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  width: 100% !important;
  max-width: 100% !important;
  display: block;
}

table {
  width: 100% !important;
  max-width: 100% !important;
}

/* 4. Fluid Typography (Scales from 320px to 1440px) */
/* This ensures desktop stays mostly the same but shrinks perfectly on mobile */
h1 { font-size: clamp(2rem, 5vw, 4rem) !important; line-height: 1.1 !important; }
h2 { font-size: clamp(1.75rem, 4vw, 3rem) !important; line-height: 1.2 !important; }
h3 { font-size: clamp(1.5rem, 3vw, 2.25rem) !important; line-height: 1.3 !important; }
h4 { font-size: clamp(1.25rem, 2.5vw, 1.75rem) !important; line-height: 1.4 !important; }
p, li, span, label, div {
  white-space: normal !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

/* 5. Base Touch Targets for Forms and Buttons (iOS zoom prevention) */
input, select, textarea {
  font-size: 16px !important;
  max-width: 100% !important;
}

.btn-primary, .btn-secondary, .btn-gold, .btn-buy, button, .btn-access, .btn-dl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px !important;
  box-sizing: border-box !important;
  word-break: break-word;
  white-space: normal !important;
}

/* ==========================================================================
   BREAKPOINTS
   ========================================================================== */

/* Up to Tablet (1024px and below) */
@media (max-width: 1024px) {
  /* Prevent horizontal scrolling on standard containers */
  .container, .wrapper, section, main, header, footer {
    max-width: 100% !important;
    padding-left: clamp(16px, 4vw, 40px) !important;
    padding-right: clamp(16px, 4vw, 40px) !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
}

/* Mobile Devices (768px and below) */
@media (max-width: 768px) {
  /* Convert grid and multi-column layouts to single column */
  .inner, .pattern-grid, .diff-grid, .grid, .columns-2, .grid-cols-2, .grid-cols-3,
  .about-us-container #authority .inner, .about-us-container #method .inner,
  .content-grid, .vault-grid, .portal-layout,
  [style*="display: grid"], [style*="grid-template-columns"], .checkbox-group, .routine-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 24px !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Convert flex rows to column */
  .authority-stat-row, .method-step, .row, .flex-row, .vault-header {
    flex-direction: column !important;
    gap: 16px !important;
    align-items: flex-start !important;
  }
  
  /* Fix Month Nav Tabs so they don't force page stretch (enable internal scroll) */
  .month-nav {
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch;
    width: 100vw !important;
    margin-left: -20px !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  /* Workbook Specific Fixes: Prevent text cutting inside .page elements */
  body { padding: 0 !important; overflow-x: hidden !important; }
  .page {
    padding: 16px !important;
    margin: 0 !important;
    min-height: auto;
    box-shadow: none !important;
    width: 100vw !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-wrap: break-word !important;
  }
  
  /* Fix workbook inner flexboxes pushing widths out */
  .page .video-box, 
  .page [style*="display:flex"], 
  .page [style*="display: flex"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Preserve checkbox layout */
  .page .checkbox-list li, 
  .page .checkbox-item {
    flex-direction: row !important;
    align-items: flex-start !important;
  }

  /* Buttons full width on mobile with safe edge margins */
    .btn-primary, .btn-secondary, .btn-gold, .btn-buy, a.px-8.py-4, .btn-access, .btn-dl {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: calc(100vw - 32px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 18px 16px !important;
    box-sizing: border-box !important;
    text-align: center !important;
    white-space: normal !important;
    flex-wrap: wrap !important;
    font-size: 11px !important;
    letter-spacing: 0.1em !important;
    text-indent: 0 !important;
  }

    .routine-field-input { width: 10% !important; flex: 1 !important; min-width: 0 !important; }

  .routine-field-row { max-width: 100% !important; width: 100% !important; box-sizing: border-box !important; overflow: hidden !important; }

  /* Form inputs full width */
  input, textarea, select {
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
    /* Make tables responsive */
  table { display: block !important; width: 100% !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch !important;  }

  table th, table td { white-space: normal !important; padding: 6px 4px !important; font-size: 11px !important; word-break: break-word !important; }

  /* Overrides for specific sections */
  main { padding-top: 60px !important; }
  .scene-box { padding: 24px 16px !important; }
  .card, .card-featured, .sidebar-card { width: 100% !important; box-sizing: border-box !important; }
  
  /* Navigation adjustment */
  nav, .nav-links {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    padding: 16px !important;
    gap: 10px !important;
  }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
  h1 { font-size: 2.2rem !important; }
  h2 { font-size: 1.8rem !important; }
  
  /* Tighter padding */
  .container, .wrapper, section, main, header, footer {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  
  .card-top {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }
}

/* Extra Small Mobile (375px & 320px) */
@media (max-width: 375px) {
  h1 { font-size: 1.8rem !important; }
  h2 { font-size: 1.5rem !important; }
  p, li, div { font-size: 0.95rem !important; }
}




