/* =========================================================================
   FF44 ENGLISH RESPONSIVE DESIGN ENGINE (PHASE 31)
   5 Device Tiers:
   1. Small Mobile (<= 375px)
   2. Large Mobile (376px - 640px)
   3. Tablet (641px - 1024px)
   4. Laptop (1025px - 1280px)
   5. Desktop (>= 1281px)

   Guarantees:
   - Zero horizontal overflow (overflow-x: hidden on root)
   - >= 44px touch targets on mobile
   - iOS Safe-area insets (notch & home bar)
   - Legible responsive typography with clamp()
   ========================================================================= */

/* Root Overflow & Box-Sizing Shield */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: clip;
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  max-width: 100%;
  overflow-x: clip;
  margin: 0;
  padding: 0;
}

/* Touch Targets: minimum 44px x 44px */
button,
a,
input,
select,
textarea,
.ds-btn,
.ds-quiz-option,
.ds-mobile-nav-item {
  min-height: 44px;
  touch-action: manipulation;
}

/* Responsive Table Wrapper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* =========================================================================
   TIER 1 & 2: MOBILE (<= 768px)
   ========================================================================= */
@media (max-width: 768px) {
  /* Show Mobile Navigation */
  .ds-mobile-nav {
    display: block;
  }

  /* Add bottom padding to body so content isn't covered by bottom nav */
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 16px)) !important;
  }

  /* Hide Desktop top-nav links */
  .ds-nav-links {
    display: none !important;
  }

  /* Navbar height and padding */
  .ds-navbar {
    padding: 0 16px;
    height: 56px;
  }

  /* Container padding */
  .container,
  .main-content,
  .page-container {
    padding-left: 14px !important;
    padding-right: 14px !important;
    width: 100% !important;
  }

  /* Convert grids to single column */
  .grid,
  .cards-grid,
  .lesson-grid,
  .course-grid,
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Card padding reduction */
  .ds-card {
    padding: 16px !important;
  }

  /* Responsive Headings */
  h1 { font-size: clamp(1.5rem, 5vw, 2rem) !important; }
  h2 { font-size: clamp(1.25rem, 4vw, 1.5rem) !important; }
  h3 { font-size: clamp(1.1rem, 3.5vw, 1.25rem) !important; }

  /* Full width buttons */
  .ds-btn-mobile-full {
    width: 100% !important;
  }
}

/* =========================================================================
   TIER 1 SPECIFIC: SMALL MOBILE (<= 375px) - iPhone SE, Galaxy A-series
   ========================================================================= */
@media (max-width: 375px) {
  .ds-navbar {
    padding: 0 10px;
  }

  .ds-card {
    padding: 12px !important;
  }

  .ds-btn {
    padding: 8px 14px;
    font-size: 0.875rem;
  }

  .ds-badge {
    font-size: 0.6875rem;
    padding: 2px 6px;
  }
}

/* =========================================================================
   TIER 3: TABLET (769px - 1024px) - iPad, Galaxy Tab
   ========================================================================= */
@media (min-width: 769px) and (max-width: 1024px) {
  .ds-mobile-nav {
    display: none;
  }

  .grid,
  .cards-grid,
  .lesson-grid,
  .course-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }

  .ds-navbar {
    padding: 0 24px;
  }
}

/* =========================================================================
   TIER 4: LAPTOP (1025px - 1280px)
   ========================================================================= */
@media (min-width: 1025px) and (max-width: 1280px) {
  .ds-mobile-nav {
    display: none;
  }

  .grid,
  .cards-grid,
  .lesson-grid,
  .course-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 20px !important;
  }
}

/* =========================================================================
   TIER 5: DESKTOP (>= 1281px) - Ultra-wide & 4K Displays
   ========================================================================= */
@media (min-width: 1281px) {
  .ds-mobile-nav {
    display: none;
  }

  .container,
  .main-content {
    max-width: 1280px;
    margin: 0 auto;
  }

  .grid,
  .cards-grid,
  .lesson-grid,
  .course-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
  }
}
