/* ==========================================================================
   247NJPLUMBER - GLOBAL RESPONSIVE DESIGN SYSTEM
   Ensures seamless presentation on Mobile (320px-480px), Tablet (481px-991px),
   Laptops (992px-1366px), and Desktops (1400px+)
   ========================================================================== */

/* ─── GLOBAL OVERFLOW & CONTAINER GUARDS ─── */
html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: border-box;
}

img, video, iframe {
  max-width: 100%;
}

/* ─── DESKTOP & LARGE TABLETS (1100px - 1366px) ─── */
@media (max-width: 1366px) {
  .nav-menu .nav-links {
    gap: 10px;
  }
  .nav-menu .nav-links a {
    padding: 7px 10px !important;
    font-size: 14.5px;
  }
  .header-actions {
    gap: 12px;
  }
  .header-phone {
    font-size: 14px;
  }
  .btn-nav-quote {
    padding: 8px 16px;
    font-size: 13.5px;
  }
}

/* ─── TABLETS & SMALL LAPTOPS (992px - 1199px) ─── */
@media (max-width: 1199px) {
  .services-grid,
  .areas-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 20px;
  }
  .hero-layout {
    gap: 32px;
  }
  .hero-title {
    font-size: clamp(34px, 4vw, 46px) !important;
  }
  .counties {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* ─── MOBILE & TABLET NAVIGATION DRAWER (< 992px) ─── */
@media (max-width: 991.98px) {
  /* Header Container */
  .main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #ffffff;
  }
  .header-container {
    position: relative;
    padding: 10px 16px !important;
  }
  .brand-logo .logo-title {
    font-size: 22px !important;
  }
  .brand-logo .logo-subtitle {
    font-size: 10px !important;
  }

  /* Hamburger Toggle */
  .mobile-toggle {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
  }
  .mobile-toggle span {
    display: block;
    width: 24px;
    height: 2.5px;
    background: var(--nj-navy, #0A2246);
    border-radius: 2px;
    transition: all 0.25s ease-in-out;
  }
  .mobile-toggle.active span:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
  }
  .mobile-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-8px);
  }
  .mobile-toggle.active span:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
  }

  /* Nav Menu Dropdown */
  .nav-menu {
    display: none !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    background: #ffffff !important;
    border-top: 1px solid var(--nj-border, #e2e8f0);
    box-shadow: 0 16px 32px rgba(11, 27, 43, 0.12);
    padding: 18px 24px 24px !important;
    z-index: 999;
  }
  .nav-menu.active {
    display: block !important;
    animation: navSlideDown 0.25s ease-out forwards;
  }
  @keyframes navSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .nav-menu .nav-links {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .nav-menu .nav-links li {
    width: 100% !important;
  }
  .nav-menu .nav-links a {
    display: block !important;
    width: 100% !important;
    padding: 12px 14px !important;
    font-size: 16px !important;
    border-radius: 8px !important;
    border-bottom: 1px solid #f1f5f9;
  }
  .nav-menu .nav-links li:last-child a {
    border-bottom: none;
  }

  /* Layout Grids: 1-col on tablet/mobile */
  .hero-layout,
  .why-us-grid,
  .split,
  .clayout,
  .sink-leaks-grid,
  .intro-section .container {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }
  .sink-leaks-image-col {
    order: -1;
  }
  .sink-leaks-image-col .photo-card img,
  .photo-wrap img {
    max-height: 380px;
    object-fit: cover;
  }

  /* Mid Grids */
  .services-grid,
  .areas-grid,
  .trust-strip-grid,
  .situations-grid,
  .signs-grid,
  .leaks-repair-grid,
  .emergency-handles-grid,
  .facts,
  .counties,
  .slist,
  .footer-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 18px !important;
  }
  .do-this-grid,
  .egrid,
  .vals,
  .steps-grid,
  .faq-two-sections {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
}

/* ─── MOBILE PHONES (< 640px) ─── */
@media (max-width: 640px) {
  /* Topbar */
  .topbar {
    padding: 6px 0 !important;
  }
  .topbar .container {
    flex-direction: column !important;
    gap: 4px !important;
    text-align: center !important;
  }
  .topbar-left,
  .topbar-right {
    justify-content: center !important;
    font-size: 12px !important;
  }
  .topbar-loc {
    display: none !important;
  }

  /* Header Brand and Actions */
  .brand-logo .logo-mark svg {
    width: 28px !important;
    height: 28px !important;
  }
  .brand-logo .logo-title {
    font-size: 20px !important;
  }
  .brand-logo .logo-subtitle {
    font-size: 9px !important;
  }
  .header-actions .header-phone {
    display: none !important;
  }
  .btn-nav-quote {
    padding: 7px 12px !important;
    font-size: 12.5px !important;
    border-radius: 5px !important;
  }

  /* Hero Section */
  .hero-section,
  .phero,
  .pagehead,
  .page-hero {
    padding: 38px 0 46px !important;
  }
  .hero-title,
  .phero h1,
  .pagehead h1,
  .page-hero h1 {
    font-size: clamp(26px, 8vw, 36px) !important;
    line-height: 1.15 !important;
    margin-bottom: 12px !important;
  }
  .hero-subtitle {
    font-size: 16px !important;
    line-height: 1.45 !important;
    margin-bottom: 12px !important;
  }
  .hero-desc,
  .phero p,
  .pagehead p {
    font-size: 14.5px !important;
    line-height: 1.55 !important;
  }

  /* Trust Pills */
  .hero-trust-pills {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .trust-pill {
    font-size: 12px !important;
    padding: 5px 10px !important;
  }

  /* Hero CTAs */
  .hero-call-wrap,
  .phero .cta-row,
  .hero-ctas,
  .costs-cta-wrap {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 10px !important;
  }
  .hero-call-wrap a,
  .phero .cta-row .btn,
  .hero-ctas a,
  .costs-cta-wrap a {
    width: 100% !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* Lead Forms */
  .lead-form-card,
  .form-card {
    padding: 22px 16px !important;
    border-radius: 10px !important;
  }
  .form-title,
  .form-card h2 {
    font-size: 22px !important;
  }
  .form-sub,
  .form-card .sub {
    font-size: 14px !important;
    margin-bottom: 16px !important;
  }
  .frow {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .field input,
  .field select,
  .field textarea,
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px !important; /* Prevents auto-zoom in iOS Safari */
    padding: 12px !important;
  }

  /* All Multi-Column Grids Become 1-Column */
  .services-grid,
  .areas-grid,
  .trust-strip-grid,
  .situations-grid,
  .signs-grid,
  .leaks-repair-grid,
  .emergency-handles-grid,
  .facts,
  .counties,
  .slist,
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Sections Padding */
  section,
  .contact-page-wrap section,
  .about-page-wrap section,
  .signs-leak-section,
  .do-this-section,
  .costs-section {
    padding: 44px 0 !important;
  }

  /* Badges & Costs */
  .costs-card {
    padding: 30px 18px !important;
    border-radius: 12px !important;
  }
  .costs-card h2 {
    font-size: 26px !important;
  }
  .cost-price-badge {
    font-size: 32px !important;
    padding: 6px 20px !important;
  }
  .cost-explanation,
  .cost-guarantee {
    font-size: 14px !important;
  }

  /* Map Container */
  .map-container,
  .contact-map {
    height: 280px !important;
  }
  .map-iframe,
  .contact-map iframe {
    height: 280px !important;
  }

  /* Footer Bottom */
  .footer-bottom {
    flex-direction: column !important;
    text-align: center !important;
    gap: 12px !important;
  }
  .footer-bottom-links {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 8px !important;
  }

  /* Sticky Call Bar (Full-Width Touch Targets) */
  .sticky-call-bar,
  .sticky {
    padding: 8px 12px !important;
  }
  .sticky-call-bar .sticky-bar-text,
  .sticky .txt {
    display: none !important;
  }
  .sticky-call-bar .sticky-bar-actions,
  .sticky .acts {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .btn-sticky-quote,
  .btn-sticky-call,
  .sticky .btn {
    width: 100% !important;
    text-align: center !important;
    padding: 12px 6px !important;
    font-size: 14px !important;
    border-radius: 8px !important;
  }
}

/* ─── EXTRA SMALL PHONES (< 380px) ─── */
@media (max-width: 379.98px) {
  .wrap,
  .container {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
  .brand-logo .logo-title {
    font-size: 18px !important;
  }
  .btn-nav-quote {
    display: none !important; /* Retain hamburger only on ultra-narrow phones */
  }
  .btn-sticky-quote,
  .btn-sticky-call,
  .sticky .btn {
    font-size: 13px !important;
    padding: 10px 4px !important;
  }
}