/* ============================================
   Responsive / Mobile-First Styles
   ============================================ */

/* Mobile-first: sidebar hidden by default on small screens */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
  }

  .top-bar {
    display: flex;
  }

  .main-content {
    padding-top: calc(var(--nav-height) + var(--spacing-md));
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
  }

  .accessibility-bar {
    top: var(--nav-height);
    border-top: none;
    border-bottom-right-radius: 0;
  }

  .welcome-hero h1 {
    font-size: 1.8rem;
  }

  .three-second-rule .steps {
    flex-direction: column;
    align-items: center;
  }

  .module-nav {
    flex-direction: column;
  }

  .module-nav .btn {
    max-width: 100%;
  }
}

/* Desktop: sidebar always visible */
@media (min-width: 1025px) {
  .page-wrapper {
    padding-left: var(--sidebar-width);
  }

  .sidebar {
    transform: translateX(0);
  }

  .top-bar {
    display: none;
  }

  .sidebar-overlay {
    display: none !important;
  }
}

/* Tablet landscape adjustments */
@media (min-width: 768px) and (max-width: 1024px) {
  .main-content {
    max-width: 700px;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }
}

/* ── General mobile fixes (all phones and small tablets) ── */
@media (max-width: 768px) {
  /* Prevent horizontal overflow everywhere */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* Base typography */
  body {
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
  }

  /* All content must fit viewport */
  .main-content, .page-wrapper, .module-header,
  .lesson-section, .what-you-learn, .module-intro,
  .quiz-container, .results-section {
    max-width: 100%;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Universal padding */
  .main-content {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* All images fit viewport */
  img, iframe, video, svg, canvas {
    max-width: 100%;
    height: auto;
  }

  /* All tables scroll horizontally */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* Buttons full-width and tappable */
  .btn, button:not(.a11y-btn):not(.menu-btn):not(.sidebar-close):not(.theme-toggle-btn),
  .quiz-option, .module-nav .btn {
    min-height: 44px;
    font-size: 1rem;
    padding: 12px 20px;
  }

  .module-nav .btn {
    width: 100%;
    text-align: centre;
  }

  /* Code blocks scroll */
  pre, code {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
  }

  /* Homepage module grid */
  .module-grid {
    grid-template-columns: 1fr;
  }

  /* Module cards stack */
  .module-card {
    flex-direction: column;
  }

  .module-card .card-icon {
    margin-bottom: 0.5rem;
  }

  /* Stats bar wraps */
  .stats-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Welcome hero contained */
  .welcome-hero {
    padding: 16px;
  }

  .welcome-hero h1 {
    font-size: 1.5rem;
    word-wrap: break-word;
  }

  /* Tip boxes and check boxes fit */
  .tip-box, .confidence-check, .confidence-check-box {
    padding: 12px 16px;
    font-size: 1rem;
    line-height: 1.6;
  }

  /* Section progress indicator */
  .section-progress {
    flex-wrap: wrap;
  }

  /* Sidebar links tappable */
  .sidebar nav a {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 1rem;
  }

  /* Print centre cards */
  .cheat-sheet-card {
    width: 100%;
  }

  /* B2B pricing cards stack */
  .pricing, .price-card, .tools-grid {
    display: block;
  }

  .price-card, .tool-card {
    margin-bottom: 1rem;
  }

  /* FAQ details */
  details summary {
    min-height: 44px;
    padding: 12px 0;
  }
}

/* 375px phone — minimum viable mobile (iPhone SE, older Android) */
@media (max-width: 375px) {
  body {
    font-size: 16px;
    overflow-x: hidden;
  }

  .main-content {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Ensure all text is readable */
  .tip-box, .confidence-check, .lesson-section p,
  .what-you-learn li, .module-intro p {
    font-size: 1rem;
    line-height: 1.6;
  }

  /* Ensure all buttons are tappable */
  .btn, button, a.btn, .quiz-option, .nav-link {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 16px;
    font-size: 1rem;
  }

  /* Images contained */
  img, iframe, video, svg {
    max-width: 100%;
    height: auto;
  }

  /* Tables scroll horizontally if needed */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Module cards stack fully */
  .module-card {
    flex-direction: column;
    text-align: center;
  }

  /* Sidebar nav items large enough to tap */
  .sidebar nav a {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 1rem;
  }

  /* Accessibility bar wraps nicely */
  .accessibility-bar {
    gap: 4px;
    padding: 4px;
  }

  /* Quiz options full-width */
  .quiz-option {
    width: 100%;
    text-align: left;
  }

  /* Module header */
  .module-header h1 {
    font-size: 1.3rem;
    word-wrap: break-word;
  }

  /* Stats and grids single column */
  .stats-bar, .module-grid, .features {
    grid-template-columns: 1fr;
  }
}

/* Small phone adjustments */
@media (max-width: 480px) {
  :root {
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
  }

  .main-content {
    padding-left: var(--spacing-sm);
    padding-right: var(--spacing-sm);
  }

  .welcome-hero {
    padding: var(--spacing-md);
  }

  .welcome-hero h1 {
    font-size: 1.5rem;
  }

  .module-card {
    flex-direction: column;
    text-align: center;
  }

  .module-card .card-icon {
    margin: 0 auto;
  }

  .accessibility-bar {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .a11y-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 0.9rem;
  }

  .podcast-card {
    flex-direction: column;
    text-align: center;
  }

  .scam-example {
    font-size: 0.85rem;
    word-break: break-word;
  }
}

/* iPad specific (most important target) */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .main-content {
    padding: calc(var(--nav-height) + var(--spacing-lg)) var(--spacing-lg) 120px;
    max-width: 680px;
  }

  .module-card {
    padding: var(--spacing-lg);
  }

  .quiz-option {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1.05rem;
  }

  .btn-large {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 1.2rem;
  }
}

@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
  .main-content {
    max-width: 780px;
    padding: var(--spacing-lg) var(--spacing-xl);
  }
}
