/**
 * Global mobile-first responsive design system
 * ============================================
 * Loaded LAST from shared heads (templateHead + page heads) so every existing
 * and newly generated page inherits fluid layout, touch targets, media handling,
 * and overflow guards automatically — without changing brand colors or desktop
 * composition intent.
 *
 * Breakpoints (fluid; not device locks):
 *   xs  ~360   sm  ~480   md  ~640   tab ~768
 *   lg  ~960   xl ~1100   2xl ~1280  3xl ~1440+
 */

:root {
  --rp-container: min(1200px, calc(100% - clamp(1.25rem, 4vw, 2.5rem)));
  --rp-space-1: clamp(0.5rem, 1.5vw, 0.75rem);
  --rp-space-2: clamp(0.75rem, 2vw, 1.25rem);
  --rp-space-3: clamp(1rem, 3vw, 2rem);
  --rp-space-4: clamp(1.5rem, 4vw, 3rem);
  --rp-space-5: clamp(2rem, 5vw, 4rem);
  --rp-touch: 44px;
  --rp-header-offset: 0px;
  --rp-safe-bottom: env(safe-area-inset-bottom, 0px);
  --rp-safe-top: env(safe-area-inset-top, 0px);
  --rp-safe-left: env(safe-area-inset-left, 0px);
  --rp-safe-right: env(safe-area-inset-right, 0px);
  --rp-fab-clearance: calc(5.5rem + var(--rp-safe-bottom));
  --rp-radius: clamp(12px, 2vw, 20px);
}

/* ---------- Base / box model ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: clip;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  padding-left: var(--rp-safe-left);
  padding-right: var(--rp-safe-right);
}

/* Clearance so fixed FAB / scroll nav do not cover CTAs */
main,
#main-content,
.site-main {
  padding-bottom: 0;
}

@media (max-width: 1024px) {
  main,
  #main-content,
  .site-main {
    padding-bottom: max(1rem, calc(var(--rp-fab-clearance) - 2rem));
  }
}

img,
video,
svg,
canvas,
iframe,
embed,
object {
  max-width: 100%;
  height: auto;
}

iframe {
  width: 100%;
  max-width: 100%;
  border: 0;
}

picture,
figure {
  max-width: 100%;
}

/* Decorative blobs must not expand layout */
[class*="__glow"],
[class*="glow"],
.svcTile__glow,
.badge-float {
  max-width: none;
  pointer-events: none;
}

.svcTile,
.svcCard2,
.service-card,
.strip__item,
.hero,
.page-banner,
.templatePageBanner {
  overflow: hidden;
}

/* ---------- Containers & layout primitives ---------- */
.container,
.header-inner,
.footer-inner,
.topbar__inner {
  width: var(--rp-container);
  max-width: 100%;
  margin-inline: auto;
}

.row,
.grid,
.grid-2,
.grid-3,
.services-grid,
.serveGrid,
.areaGrid,
.citiesGrid,
.metric-grid,
.metrics-grid,
.trust-grid,
.trust,
.faq-grid,
.contact-grid,
.hero__grid,
.hero__layout,
.locationIntro__inner,
.svcCards,
.svcGrid,
.provincesGrid,
.footer-grid,
.footer__grid,
.footerStates__grid,
.statesFooter__grid,
.aboutGrid,
.why-grid-premium,
.landmarkHub__grid,
.strip__inner,
.stats-grid {
  min-width: 0;
  max-width: 100%;
}

.svcCard2,
.svcTile,
.service-card,
.landmarkHub__card,
.trust__item,
.strip__item,
.metricCard,
.contact-item-premium {
  min-width: 0;
  max-width: 100%;
}

/* Long strings must not force horizontal scroll */
a,
p,
h1, h2, h3, h4, h5, h6,
li,
span,
label,
td,
th,
.nav__areaLabel,
.breadcrumb,
.breadcrumbs,
.header-call-btn__number,
.fabCall__ctaBottom,
.topbar__tagline,
.hero__sub,
.locationIntro__text {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Prefer soft wrap for body copy; keep anywhere for URLs/phones via .break-anywhere */
p,
li,
.locationIntro__text p {
  overflow-wrap: break-word;
  word-break: normal;
}

a[href^="tel"],
a[href^="mailto"],
a[href^="http"] {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ---------- Typography (fluid) ---------- */
h1,
.hero h1,
.hero__title,
.page-banner h1,
.templatePageBanner h1 {
  font-size: clamp(1.65rem, 1.1rem + 2.4vw, 3rem) !important;
  line-height: 1.15;
  max-width: 100%;
}

h2,
.section-title,
.landmarkHub__title,
.svcSection__title,
.locationIntro__title {
  font-size: clamp(1.35rem, 1rem + 1.5vw, 2.25rem);
  line-height: 1.2;
}

h3 {
  font-size: clamp(1.1rem, 0.95rem + 0.8vw, 1.5rem);
  line-height: 1.25;
}

p,
li,
.hero__sub,
.hero p,
.landmarkHub__sub {
  font-size: clamp(0.95rem, 0.9rem + 0.25vw, 1.05rem);
  line-height: 1.6;
}

/* ---------- Touch targets & controls ---------- */
a.btn,
.btn,
button.btn,
.header-call-btn,
.mobile-toggle,
.nav-link,
.nav__link,
input[type="submit"],
button[type="submit"],
.fab-call,
.scrollNav,
.postalCodesGrid__chip {
  min-height: var(--rp-touch);
}

.mobile-toggle {
  min-width: var(--rp-touch);
  min-height: var(--rp-touch);
}

input,
select,
textarea,
button {
  max-width: 100%;
  font-size: 16px; /* prevents iOS focus zoom */
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

form {
  max-width: 100%;
}

.heroLeadForm,
.hero-contact-form,
.contact-form,
.contactDockForm,
.contactFormEmbed {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.heroLeadForm input,
.heroLeadForm textarea,
.heroLeadForm select,
.contact-form input,
.contact-form textarea,
.contact-form select {
  width: 100%;
  max-width: 100%;
}

/* Focus visibility for a11y across responsive states */
:focus-visible {
  outline: 2px solid var(--accent, #0b3fbf);
  outline-offset: 2px;
}

.btn:focus-visible,
.nav-link:focus-visible,
.mobile-toggle:focus-visible {
  outline-offset: 3px;
}

/* ---------- Media / maps ---------- */
.map iframe,
.contact-map iframe,
.contactEmbeddedMap iframe,
.contactEmbeddedMap,
[class*="map"] iframe {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  min-height: 220px;
}

.contactEmbeddedMap {
  max-width: 100%;
  overflow: hidden;
}

/* ---------- Tables ---------- */
table {
  max-width: 100%;
}

.table-wrap,
.table-responsive,
.responsive-table {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.container > table,
.locationIntro table,
.prose table,
article table,
.privacy-content table,
.legal-content table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Fixed / sticky / overlays ---------- */
.site-header-sticky,
.main-header,
.sticky-header {
  max-width: 100%;
}

.fabCall {
  right: max(0.75rem, var(--rp-safe-right)) !important;
  bottom: max(0.75rem, var(--rp-safe-bottom)) !important;
  max-width: calc(100vw - 1.5rem);
  z-index: 200;
}

.fab-call,
.fabCall,
[class*="fab"],
.cookie-consent,
.cookieConsent,
.scroll-navigator,
.scrollNav,
.back-to-top,
.phone-float {
  max-width: calc(100vw - 1.5rem);
}

.scrollNav {
  left: max(0.75rem, var(--rp-safe-left)) !important;
  bottom: max(0.75rem, var(--rp-safe-bottom)) !important;
}

.modal,
.dialog,
[role="dialog"] {
  max-width: min(100%, 100vw);
  max-height: min(100vh, 100dvh);
}

.dropdown,
.nav-dropdown-content,
.areasServeZipFlyout,
.nav__menu {
  max-width: min(100vw - 1rem, 100%);
}

/* FAB popup: stack above button on narrow screens so it never clips */
@media (max-width: 480px) {
  .fabCall__popup {
    right: 0 !important;
    left: auto !important;
    bottom: calc(100% + 10px) !important;
    min-width: 0 !important;
    width: min(260px, calc(100vw - 1.5rem)) !important;
    max-width: calc(100vw - 1.5rem) !important;
  }

  .fabCall__popup::after {
    right: 18px !important;
    bottom: -7px !important;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    border-top: none;
  }
}

/* ---------- Areas We Serve hierarchy (mobile drawer) ---------- */
@media (max-width: 1100px) {
  .main-header .nav-item.has-dropdown.active .dropdown.nav-dropdown-content {
    max-height: min(70vh, 520px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  .areasServeHierarchy,
  .areasServeZipFlyout {
    min-width: 0 !important;
    width: 100%;
    max-width: 100%;
  }

  .areasServeHierarchy .areasServeZipFlyout__list {
    max-height: min(48vh, 360px);
  }

  .areasServeDrill__row > .nav__areaLink {
    min-height: var(--rp-touch);
  }

  .areasServeDrill__toggle {
    min-width: var(--rp-touch);
    min-height: var(--rp-touch);
  }

  .main-nav {
    max-width: min(320px, 100vw) !important;
  }
}

/* ---------- Topbar: allow wrap on small screens ---------- */
@media (max-width: 768px) {
  .topbar__tagline {
    white-space: normal !important;
  }

  .topbar__inner {
    grid-template-columns: 1fr !important;
    gap: 0.5rem;
    text-align: center;
  }

  .topbar__left,
  .topbar__center,
  .topbar__right {
    justify-self: center;
  }
}

/* ---------- Hero / banners ---------- */
.hero,
.page-banner,
.templatePageBanner {
  max-width: 100%;
  overflow: hidden;
}

.hero__content,
.hero__copy,
.hero__form,
.hero-contact-form,
.hero__col--copy,
.hero__col--form {
  min-width: 0;
  max-width: 100%;
}

/* Hero layout: fluid columns — never force a 280px track on narrow viewports */
.hero__layout {
  grid-template-columns: minmax(0, 1fr) minmax(0, min(400px, 100%));
}

@media (min-width: 961px) {
  .hero__layout {
    grid-template-columns: minmax(0, 1fr) minmax(min(280px, 100%), 400px);
  }
}

.hero__actions {
  flex-wrap: wrap;
  max-width: 100%;
}

.hero-buttons {
  max-width: 100%;
}

@media (max-width: 960px) {
  .hero__layout,
  .hero__grid,
  .hero-grid,
  .hero .grid-2,
  .contact-grid,
  .about-grid,
  .aboutGrid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: var(--rp-space-3);
  }

  .hero__form,
  .hero-contact-form,
  .hero__col--form,
  .contact-form,
  .contactDockForm {
    width: 100%;
    max-width: 100%;
  }

  .hero {
    padding-block: clamp(3rem, 8vw, 5rem) !important;
  }

  .hero__actions .btn,
  .hero-buttons .btn {
    width: 100%;
    max-width: 100%;
    white-space: normal;
  }

  .hero-buttons {
    width: 100%;
    max-width: 100% !important;
  }
}

/* ---------- Grids / cards — fluid column collapse ---------- */
/* Prefer a floor that never exceeds the viewport (mobile-safe minmax) */
.landmarkHub__grid {
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)) !important;
}

@media (max-width: 1024px) {
  .svcSection .svcCards,
  .svcCards {
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)) !important;
    max-width: 100% !important;
  }

  .services-grid,
  .serveGrid,
  .metric-grid,
  .metrics-grid,
  .trust-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .serveGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .citiesGrid,
  .citiesSection .citiesGrid:not(.citiesGrid--zips),
  .statesFooter__grid,
  .footerStates__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 820px) {
  .serveGrid,
  .citiesGrid,
  .citiesSection .citiesGrid:not(.citiesGrid--zips),
  .statesFooter__grid,
  .provincesGrid,
  .footerStates__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Service listing grid: never let span-2 invent a second crushed column */
@media (max-width: 768px) {
  .grid-3 {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-auto-columns: minmax(0, 1fr);
  }

  .grid-3 > .service-card,
  .grid-3 > .service-card-cta-pair,
  .service-card-cta-pair--span-2,
  .service-card-cta-pair--span-full {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
  }

  .grid-3 > .service-card h3,
  .service-card--listing h3 {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
  }
}

@media (max-width: 640px) {
  .services-grid,
  .serveGrid,
  .metric-grid,
  .metrics-grid,
  .trust-grid,
  .trust,
  .areaGrid,
  .citiesGrid,
  .citiesSection .citiesGrid:not(.citiesGrid--zips),
  .faq-grid,
  .provincesGrid,
  .serveGrid__grid,
  .svcCards,
  .svcSection .svcCards,
  .svcGrid,
  .statesFooter__grid,
  .footerStates__grid,
  .why-grid-premium,
  .grid-2,
  .grid-3,
  .stats-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .svcSection .svcCards {
    grid-template-columns: minmax(0, 1fr) !important;
    justify-content: stretch !important;
  }

  .container,
  .header-inner {
    width: min(100% - 1.5rem, 1200px);
  }

  .btn,
  a.btn,
  .header-call-btn {
    width: auto;
    max-width: 100%;
  }

  .btn-full,
  .btn--full,
  .heroLeadForm__submit {
    width: 100%;
  }

  .hero__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero .hero__content h1 {
    max-width: 100%;
  }
}

/* ---------- Landmark hub ---------- */
@media (max-width: 640px) {
  .landmarkHub--zip {
    padding: var(--rp-space-3) 0;
  }

  .landmarkHub__zipTabs {
    gap: 0.5rem;
  }

  .landmarkHub--zip .landmarkHub__zipTab {
    min-height: var(--rp-touch);
  }

  .landmarkHub__zipPanelBody {
    padding: 1.25rem 1rem 1.5rem;
  }

  .landmarkHub:not(.landmarkHub--zip):not(.landmarkHub--nearby) .landmarkHub__card--link {
    flex: 1 1 100%;
    max-width: 100%;
  }
}

/* ---------- Footer ---------- */
@media (max-width: 768px) {
  .footer-grid,
  .site-footer .grid,
  .footer__grid {
    grid-template-columns: 1fr !important;
    gap: var(--rp-space-3);
  }

  .footer-bottom {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--rp-space-2);
  }

  .footer-logo,
  .site-footer img {
    max-width: min(220px, 70vw);
    height: auto;
  }
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs,
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  max-width: 100%;
}

/* ---------- Section spacing (mobile-first fluid) ---------- */
@media (max-width: 768px) {
  .svcSection,
  .locationIntro,
  .citiesSection,
  .about-section,
  .cta-section,
  section.section {
    padding-left: 0;
    padding-right: 0;
  }

  .svcSection {
    padding-block: clamp(1.75rem, 5vw, 2.75rem);
  }
}

/* ---------- Very small phones ---------- */
@media (max-width: 360px) {
  .main-header .logo img {
    width: min(160px, 48vw);
    max-height: 44px;
  }

  .header-call-btn__number {
    font-size: 0.8rem;
  }

  .container {
    width: min(100% - 1rem, 1200px);
  }

  .fab-call {
    width: 52px;
    height: 52px;
  }
}

/* ---------- Large monitors: keep readable measure ---------- */
@media (min-width: 1440px) {
  .container {
    width: min(1200px, calc(100% - 4rem));
  }
}

@media (min-width: 1920px) {
  .container {
    width: min(1240px, calc(100% - 5rem));
  }
}

/* ---------- Landscape phones ---------- */
@media (max-height: 480px) and (orientation: landscape) {
  .main-header .main-nav.active {
    padding-top: 4.5rem !important;
  }

  .areasServeHierarchy .areasServeZipFlyout__list {
    max-height: min(40vh, 220px);
  }

  .hero {
    padding-block: 2.5rem !important;
  }

  .fabCall__popup {
    max-height: min(40vh, 180px);
    overflow: auto;
  }
}

/* ---------- Portrait/landscape shared safety ---------- */
@media (max-width: 1100px) {
  .topbar__link,
  .header__queriesPhone {
    white-space: normal;
  }
}

/* Postal chips: wrap freely, never overflow */
.postalCodesGrid {
  max-width: 100%;
}

.postalCodesGrid__chip {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 480px) {
  .postalCodesGrid__chip {
    min-width: calc(50% - 10px);
    flex: 1 1 calc(50% - 10px);
  }
}

/* Embedded contact iframes */
.contactFormEmbed,
.contactFormEmbed__frame,
.heroContactForm {
  width: 100% !important;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.contactFormEmbed__frame iframe {
  width: 100% !important;
  max-width: 100%;
  border: 0;
  border-radius: inherit;
}

@media (max-width: 640px) {
  .contactFormEmbed__frame {
    min-height: 420px !important;
  }
}

/* ---------- Cookie banner / strip / trust (site-specific safety) ---------- */
.cookie-banner {
  max-width: 100vw;
  box-sizing: border-box;
}

.strip__inner,
.strip__inner--services,
.trust {
  max-width: 100%;
  min-width: 0;
}

/* Scoreboard (stats-floating): never sit on top of the mobile hero form */
.stats-floating {
  max-width: 100%;
}

.stats-grid,
.stat-item,
.stat-number,
.stat-label {
  min-width: 0;
  max-width: 100%;
}

.stat-number::after {
  content: none !important; /* suffixes come from markup */
}

@media (max-width: 960px) {
  .stats-floating {
    /* Cancel the desktop -80px pull-up that covers the stacked hero form */
    margin-top: 1rem !important;
    margin-bottom: var(--rp-space-2);
    padding-inline: 0;
    z-index: 2;
  }

  .hero + .stats-floating,
  section.hero + section.stats-floating {
    margin-top: 1rem !important;
  }
}

@media (max-width: 640px) {
  .strip__inner,
  .strip__inner--services,
  .trust {
    grid-template-columns: 1fr !important;
  }

  .stats-floating {
    margin-top: 0 !important;
    padding-top: 0.25rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 1rem 0.75rem !important;
    padding: 1.5rem 1rem !important;
  }

  .stat-number {
    font-size: clamp(1.45rem, 7vw, 2rem) !important;
    line-height: 1.15;
  }

  .stat-label {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
  }
}

@media (max-width: 360px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
}

@media (max-width: 768px) and (min-width: 641px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .strip__inner,
  .strip__inner--services {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Prevent decorative transforms from expanding scroll width */
.svcTile::after,
.social__icon::after,
.check-list--premium li:hover {
  max-width: 100%;
}

@media (max-width: 768px) {
  .check-list--premium li:hover {
    transform: none;
  }
}
