/* =============================================================
   The Nursing Directory — Global Mobile Optimization Layer
   -------------------------------------------------------------
   ALL rules in this file are wrapped in @media (max-width: 767px).
   Desktop CSS (>= 768px) is untouched.
   This file is intentionally heavy on !important because it has
   to override per-page inline <style> blocks.
   ============================================================= */

@media (max-width: 767px) {

  /* ---------- 1. Hard stop on horizontal page overflow ----------
     The two screenshots reported on 2026-04-20 showed content
     extending past the right edge of the viewport. The root cause
     in nearly every case is some descendant being wider than 100vw
     and the body having no overflow-x clip. Fix it once, globally. */
  html, body {
    overflow-x: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  body {
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
  }

  /* Catch-all: nothing inside main/footer/header should be wider than the viewport. */
  main, header, footer, section, article, aside, nav,
  .container, .wrap, .wrapper, .content, .page, .layout,
  .max-width, .max-w, .mx-auto, .inner {
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  /* Common offenders: media + embeds. Constrain them so they never
     blow out the layout. */
  img, video, iframe, embed, object, svg, picture, canvas {
    max-width: 100% !important;
    height: auto;
  }
  /* SVGs that explicitly set width/height (icons inside buttons) keep
     their declared size — only stretch images/videos. */
  svg[width][height] { height: auto; }
  button svg, a svg, .icon svg, .nav-logo svg, .pay-donut-wrap svg,
  .donut-chart svg, .pay-mockup svg {
    width: auto !important;
    height: auto !important;
  }
  /* Restore intrinsic mockup donut sizing */
  .donut-chart svg, .pay-donut-wrap svg { width: 100% !important; height: 100% !important; }

  /* Pre / code blocks need their own scroll container */
  pre, code {
    max-width: 100% !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }
  pre {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Tables — wrap or scroll, never push the page wider */
  table {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Long unbroken strings (URLs, emails, CSV-style copy) shouldn't push the page */
  p, h1, h2, h3, h4, h5, h6, li, dt, dd, td, th, blockquote, figcaption, label, span, a {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }


  /* ---------- 2. Sticky / fixed nav: keep it tight ---------- */
  nav#main-nav > div,
  nav > div:first-child {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    height: 56px !important;
  }
  .nav-logo {
    font-size: 0.95rem !important;
    letter-spacing: -0.02em !important;
  }
  /* Already toggled by per-page <style>: hide desktop links, show hamburger.
     Reinforce here so any page that forgets the per-page rule still works. */
  #nav-links-desktop { display: none !important; }
  #nav-mobile-btn { display: inline-flex !important; align-items: center; justify-content: center; }
  #nav-mobile-menu { padding: 0.5rem 1rem 0.875rem !important; }
  #nav-mobile-menu a {
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    font-size: 0.95rem !important;
  }


  /* ---------- 3. Hero blocks — tighter top padding so the headline isn't
     hidden under the fixed nav, no side overflow ---------- */
  .hero {
    padding: 6.5rem 1rem 3rem !important;
    min-height: auto !important;
  }
  .hero h1, .hero .hero-title {
    font-size: clamp(1.85rem, 8.5vw, 2.6rem) !important;
    line-height: 1.12 !important;
    letter-spacing: -0.02em !important;
  }
  .hero p, .hero .hero-sub, .hero .hero-tagline {
    font-size: 1rem !important;
    line-height: 1.5 !important;
  }
  .hero .hero-cta, .hero .btn, .hero a.btn {
    width: auto;
    max-width: 100%;
  }
  /* Background flourishes that overflow the hero box can leak — clip them */
  .hero, .hero-bg, .hero-spline-bg, .hero-img-bg,
  .hero-glow-1, .hero-glow-2, .hero-overlay {
    overflow: hidden !important;
  }


  /* ---------- 4. Universal grid collapse —
     Force common multi-col grids to single column. Listed by class
     name patterns used across the site. Covers cards-row, stat-grid,
     guides-grid, articles-grid, tools-grid, shortage-grid, etc. */
  .cards-row,
  .shortage-grid,
  .data-grid,
  .info-grid,
  .article-grid,
  .articles-grid,
  .related-grid,
  .related-cards,
  .related-articles,
  .footer-links-grid,
  .two-col,
  .three-col,
  .four-col,
  .grid-2,
  .grid-3,
  .grid-4,
  .stat-grid,
  .stats-grid,
  .feature-grid,
  .features-grid,
  .author-flex {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  /* For genuine icon/badge grids, allow 2 columns on phones */
  .stat-grid, .stats-grid, .badge-grid, .quick-facts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  /* Guides/articles/tools — 1-up by default for big readable cards.
     If a page wants 2-up, it can override at >480px in its own block. */
  .guides-grid, .tools-grid, .all-guides-grid, .all-tools-grid {
    grid-template-columns: 1fr !important;
    gap: 0.875rem !important;
  }


  /* ---------- 5. Cards — consistent padding/radius so nothing clips ---------- */
  .card, .info-card, .guide-card, .tool-card, .article-card,
  .related-card, .stat-cell, .shortage-cell, .feature-card,
  .footer-card, .result-card, .mockup-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .info-card { padding: 22px 18px !important; }
  .guide-card, .tool-card, .article-card, .related-card { padding: 1rem 1rem 1.125rem !important; }
  .card-title, .guide-title, .tool-title, .article-title { word-wrap: break-word !important; }


  /* ---------- 6. Section / container padding —
     Most pages set 4rem+ side padding intended for desktop. Reduce it. */
  section, .section,
  main > div, main > section,
  .salary-section, .data-section, .tools-section, .guides-section,
  .hack-section, .related-section, .faq-section, .cta-section,
  .education-section, .affiliate-section, .references-section,
  .author-bio, .content-depth {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  /* Vertical breathing room — keep generous but not huge */
  .salary-section, .data-section, .tools-section, .guides-section,
  .hack-section, .related-section, .faq-section, .cta-section {
    padding-top: 2.5rem !important;
    padding-bottom: 2.5rem !important;
  }


  /* ---------- 7. Tool / calculator pages (TOOL-UI-DESIGN-SYSTEM) ---------- */
  .tool-container {
    max-width: 100% !important;
    padding: 1rem !important;
    grid-template-columns: 1fr !important;
    display: block !important;
  }
  .input-panel, .results-panel, .result-card {
    width: 100% !important;
    max-width: 100% !important;
    padding: 1.125rem 1rem !important;
  }
  .field, .field-row { width: 100% !important; }
  .field-row {
    grid-template-columns: 1fr !important;
    gap: 0.625rem !important;
  }
  .field-input, .field-select, .field input, .field select, .field textarea,
  input[type="text"], input[type="number"], input[type="email"],
  input[type="tel"], input[type="search"], input[type="url"],
  input[type="password"], select, textarea {
    width: 100% !important;
    max-width: 100% !important;
    /* iOS will zoom on focus if input font-size < 16px. */
    font-size: max(1rem, 16px) !important;
    min-height: 44px !important;
    box-sizing: border-box !important;
  }
  textarea { min-height: 96px !important; }
  .toggle-group { flex-wrap: wrap !important; }
  .btn-calculate, .btn-primary, .cta-btn, button.btn {
    width: 100% !important;
    min-height: 48px !important;
    font-size: 1rem !important;
  }
  .result-breakdown {
    grid-template-columns: 1fr !important;
    gap: 0.625rem !important;
  }
  .result-hero { font-size: clamp(2rem, 9vw, 2.75rem) !important; line-height: 1.05 !important; }


  /* ---------- 8. Carousel (homepage tools showcase) ---------- */
  .tools-carousel {
    max-width: 100% !important;
    padding: 0 38px !important;
    margin: 0 auto !important;
  }
  .carousel-viewport {
    overflow: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 18px !important;
  }
  .carousel-track {
    width: 100% !important;
    max-width: 100% !important;
  }
  .carousel-slide {
    min-width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    box-sizing: border-box !important;
    padding: 0 2px !important;
  }
  .carousel-arrow {
    width: 34px !important;
    height: 34px !important;
    font-size: 1.05rem !important;
  }
  .carousel-prev { left: 0 !important; }
  .carousel-next { right: 0 !important; }
  /* Inside-the-card mockups: prevent inner widgets from forcing the slide
     to be wider than the viewport */
  .mockup-card, .mockup-visual, .mockup-info,
  .pay-mockup, .stipend-mockup, .pay-donut-wrap, .pay-lines {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .mockup-visual { padding: 1rem 0.875rem !important; min-height: 220px !important; height: auto !important; }
  .mockup-info { padding: 1rem 1rem 1.25rem !important; }
  .mockup-title { font-size: 1.05rem !important; line-height: 1.25 !important; }
  .mockup-desc { font-size: 0.825rem !important; }


  /* ---------- 9. Compact license map widget ---------- */
  .map-grid, .state-grid, .license-grid, .compact-states-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 4px !important;
  }
  .state-cell, .state-pill, .map-cell {
    font-size: 0.7rem !important;
    padding: 0.45rem 0.25rem !important;
    min-height: 36px !important;
  }


  /* ---------- 10. Sticky bottom bars (mobile result bar) ---------- */
  .mobile-result-bar {
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    padding: 0.75rem 1rem !important;
  }


  /* ---------- 11. Footer ---------- */
  footer, .footer-card, .footer-inner-new {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    box-sizing: border-box !important;
  }
  .footer-links {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.25rem 0.75rem !important;
  }
  .footer-links a, .footer-bottom-links a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem !important;
  }
  .footer-bottom-bar {
    flex-wrap: wrap !important;
    text-align: center !important;
  }


  /* ---------- 12. Cookie banner / chatbot widgets / FABs ---------- */
  /* Don't let chatbot/FAB widgets push the page wider */
  #chatbot-widget, #spotlight-search, #report-widget,
  .chatbot-fab, .quick-find-fab, .fab {
    max-width: calc(100vw - 16px) !important;
  }
  /* Cookie banner — keep readable, don't overlap CTAs */
  .cookie-banner, #cookie-banner, .cookie-bar {
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
    padding: 0.875rem 1rem !important;
    font-size: 0.825rem !important;
    border-radius: 14px !important;
  }
  .cookie-banner button, #cookie-banner button {
    min-height: 40px !important;
    font-size: 0.85rem !important;
    padding: 0.5rem 0.875rem !important;
  }


  /* ---------- 13. Headlines / typography hierarchy ---------- */
  h1 { font-size: clamp(1.7rem, 7.5vw, 2.4rem) !important; line-height: 1.15 !important; }
  h2 { font-size: clamp(1.4rem, 5.5vw, 1.85rem) !important; line-height: 1.2 !important; }
  h3 { font-size: clamp(1.15rem, 4.5vw, 1.45rem) !important; line-height: 1.25 !important; }
  .section-title { font-size: clamp(1.55rem, 6.5vw, 2.1rem) !important; }
  .section-desc, .section-eyebrow { font-size: 0.9rem !important; }
  /* Body copy comfortable read on phones */
  p, li { font-size: 1rem !important; line-height: 1.6 !important; }
  .article-body p, .article-body li {
    font-size: 1.0625rem !important; line-height: 1.7 !important;
  }


  /* ---------- 14. Touch targets ---------- */
  a.btn, button, .cta-btn, .toggle-btn, .pill, .tab, .filter-btn {
    min-height: 44px;
  }


  /* ---------- 15. Article / news layout ---------- */
  .article-container, .news-article, article.article {
    max-width: 100% !important;
    padding: 1rem !important;
  }
  .article-hero, .news-hero {
    padding: 5rem 1rem 1.5rem !important;
  }
  .article-meta, .byline {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    font-size: 0.825rem !important;
  }
  blockquote {
    margin: 1.25rem 0 !important;
    padding: 0.875rem 1rem !important;
    font-size: 1rem !important;
  }


  /* ---------- 16. Modals / dialogs / popups ---------- */
  .modal, .dialog, [role="dialog"], .popup, .lightbox {
    max-width: calc(100vw - 24px) !important;
    width: calc(100vw - 24px) !important;
    margin: 12px auto !important;
    padding: 1.25rem 1rem !important;
    box-sizing: border-box !important;
  }


  /* ---------- 17. Misc safety nets ----------
     1. Fixed-width helper classes like w-960, w-1200 — strip them.
     2. Anything explicitly sized with min-width > 320px is dangerous on
        a 375px viewport because side padding can already eat ~32px. */
  [style*="min-width: 4"], [style*="min-width:4"],
  [style*="min-width: 5"], [style*="min-width:5"],
  [style*="min-width: 6"], [style*="min-width:6"],
  [style*="min-width: 7"], [style*="min-width:7"],
  [style*="min-width: 8"], [style*="min-width:8"],
  [style*="min-width: 9"], [style*="min-width:9"],
  [style*="width: 1200"], [style*="width:1200"],
  [style*="width: 960"],  [style*="width:960"] {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }


  /* ---------- 18. Horizontal scrollers (intentional) ----------
     Some sections WANT horizontal scroll (specialty bars, tower bars).
     Make sure they actually scroll and don't push the page sideways. */
  .scroll-x, .h-scroll, [data-scroll-x], .table-scroll {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
  }

}


/* =============================================================
   Very narrow phones (≤ 380px) — extra-tight overrides
   ============================================================= */
@media (max-width: 380px) {

  .hero { padding: 6rem 0.875rem 2.5rem !important; }
  .hero h1 { font-size: clamp(1.6rem, 8vw, 2rem) !important; }

  section, .section,
  main > div, main > section { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }

  .info-card { padding: 18px 14px !important; }
  .guide-card, .tool-card, .article-card, .related-card { padding: 0.875rem !important; }

  .stat-grid, .stats-grid, .badge-grid, .quick-facts-grid {
    grid-template-columns: 1fr !important;
  }

  .tools-carousel { padding: 0 28px !important; }
  .carousel-arrow { width: 30px !important; height: 30px !important; font-size: 0.95rem !important; }
  .mockup-title { font-size: 0.98rem !important; }

  .footer-links { grid-template-columns: 1fr !important; }

  .map-grid, .state-grid, .license-grid, .compact-states-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  }

  h1 { font-size: clamp(1.55rem, 7vw, 2rem) !important; }
  h2 { font-size: clamp(1.25rem, 5vw, 1.65rem) !important; }
}
