/* =============================================================
   MyTherapyWizard — global responsive overrides
   Mobile-first fixes that ride on top of each page's own styles.
   Targets the shared selector vocabulary used across the site.
   Loaded LAST so its rules win on the cascade.
   Breakpoints:
     up to 480px — phone portrait (incl. 320px)
     481-768px  — phone landscape / small tablet
     769-1024px — tablet / small laptop
     1025px+    — desktop (rules above already handle this)
   ============================================================= */

/* ---------- Universal protections ---------- */
html { -webkit-text-size-adjust: 100%; }
img, video, svg { max-width: 100%; height: auto; }
table { max-width: 100%; }
pre, code { white-space: pre-wrap; word-break: break-word; }

/* Prevent horizontal overflow on all viewports */
html, body { overflow-x: hidden; }

/* ---------- Tablet & below (≤ 1024px) ---------- */
@media (max-width: 1024px) {
  /* Loosen any locked widescreen layouts */
  .step-inner,
  .flow-diagram,
  .reclaim-grid,
  .needs-grid,
  .contrast-grid,
  .overview,
  .deepdive-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .flow-diagram .flow-node::after { display: none; }
}

/* ---------- Phones & small tablets (≤ 768px) ---------- */
@media (max-width: 768px) {

  /* --- Topbar / nav --- */
  .topbar { padding: 12px 16px !important; flex-wrap: wrap; gap: 8px; }
  .topbar-nav { display: none !important; }
  .topbar-logo { width: 36px !important; height: 36px !important; }
  .topbar-brand { font-size: 15px !important; }
  .topbar-cta { font-size: 12px !important; padding: 8px 14px !important; }

  /* --- Breadcrumb --- */
  .breadcrumb { padding: 16px 16px 0 !important; font-size: 12px; flex-wrap: wrap; }

  /* --- Hero / page-hero blocks --- */
  .hero, .page-hero { padding: 32px 16px 24px !important; }
  .hero h1, .page-hero h1 {
    font-size: clamp(28px, 8vw, 40px) !important;
    line-height: 1.08 !important;
  }
  .hero-sub, .page-hero-sub {
    font-size: 16px !important;
    line-height: 1.55 !important;
  }
  .hero-tag, .page-hero-tag { font-size: 10px !important; }

  /* --- Section padding / containers --- */
  section, .section, .contrast, .step, .flow, .tie, .cta-band,
  .reclaim, .needs, .video-section,
  footer { padding-left: 16px !important; padding-right: 16px !important; }

  .step { padding-top: 32px !important; padding-bottom: 32px !important; }
  .flow, .tie, .cta-band { padding-top: 48px !important; padding-bottom: 48px !important; }

  /* --- All grids collapse to 1 column on phones --- */
  .step-inner,
  .flow-diagram,
  .reclaim-grid,
  .needs-grid,
  .contrast-grid,
  .overview,
  .deepdive-grid,
  .image-grid,
  .doc-once-stages,
  .doc-once-without-grid,
  .doc-once-with-grid,
  .footer-inner,
  [data-pj-grid] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Step number block on phones */
  .step-num .big { font-size: 56px !important; }

  /* --- Headlines that use clamp() — clamp them tighter on small screens --- */
  h1 { font-size: clamp(28px, 8vw, 40px) !important; line-height: 1.1 !important; }
  h2 { font-size: clamp(24px, 6vw, 34px) !important; line-height: 1.15 !important; }
  h3 { font-size: clamp(18px, 5vw, 22px) !important; line-height: 1.25 !important; }

  /* Paragraphs and lede */
  .step-body .lede,
  .flow-sub,
  .tie p,
  .col-head { font-size: 16px !important; line-height: 1.55 !important; }
  .step-body p { font-size: 15px !important; line-height: 1.65 !important; }
  .pullquote { font-size: 20px !important; padding: 20px 0 !important; margin: 24px 0 !important; }

  /* --- Contrast columns padding --- */
  .contrast-col { padding: 22px !important; }

  /* --- Step callout --- */
  .step-callout { padding: 16px 18px !important; }
  .step-callout p { font-size: 14px !important; }

  /* --- Flow nodes --- */
  .flow-node { padding: 18px 16px !important; }
  .flow-node::after { display: none !important; }

  /* --- CTA bands --- */
  .cta-band h2 { font-size: clamp(24px, 7vw, 34px) !important; }
  .cta-band p { font-size: 15px !important; }
  .cta-band-btns { flex-direction: column !important; align-items: stretch !important; width: 100%; }
  .cta-band-btns a, .cta-band-btns .btn-lime, .cta-band-btns .btn-ghost {
    width: 100% !important; text-align: center; box-sizing: border-box;
  }

  /* --- Footer --- */
  footer { padding: 40px 16px 24px !important; }
  .footer-inner { flex-direction: column !important; gap: 24px !important; }

  /* --- Pricing tier grid (4-up → 1-up on phone) --- */
  .pricing-grid,
  div[style*="grid-template-columns: repeat(4, 1fr)"],
  div[style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
  }

  /* --- Buttons / CTAs full-width on phones --- */
  .btn, .topbar-cta, .btn-lime, .btn-ghost { white-space: nowrap; }

  /* --- Tweak tables, deepdive blocks --- */
  .deepdive-item { padding: 18px !important; }

  /* --- Feature page nav (prev/next) --- */
  .feature-nav { padding: 16px !important; }
  .feature-nav-btn { font-size: 13px !important; padding: 10px 14px !important; }

  /* --- Video container should always fit --- */
  .video-container, iframe[src*="youtube"], iframe[src*="youtu.be"] {
    width: 100% !important; max-width: 100%; aspect-ratio: 16 / 9; height: auto !important;
  }
}

/* ---------- Phones ≤ 480px (incl. 320px) ---------- */
@media (max-width: 480px) {
  body { font-size: 15px; }

  .hero h1, .page-hero h1 { font-size: clamp(26px, 9vw, 34px) !important; }
  h1 { font-size: clamp(26px, 9vw, 34px) !important; }
  h2 { font-size: clamp(22px, 7vw, 28px) !important; }

  .topbar { padding: 10px 14px !important; }
  .topbar-brand { font-size: 14px !important; }
  .topbar-cta { font-size: 11px !important; padding: 7px 12px !important; }

  .hero, .page-hero { padding: 24px 14px 20px !important; }
  section, .section, .contrast, .step, .flow, .tie, .cta-band,
  .reclaim, .needs, .video-section,
  footer { padding-left: 14px !important; padding-right: 14px !important; }

  .step-num .big { font-size: 48px !important; }
  .pullquote { font-size: 18px !important; }

  /* Stack pricing 2-up grids to 1-up cleanly */
  div[style*="grid-template-columns: 1fr 1.5fr"],
  div[style*="grid-template-columns: 1.4fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Footer brand */
  .footer-copy { font-size: 12px !important; }
}

/* ---------- Print: hide nav/cta clutter ---------- */
@media print {
  .topbar, .breadcrumb, .cta-band, .feature-nav, footer, .ta-badge-fab { display: none !important; }
  body { background: white !important; color: black; }
}
