/* ============================================================
   Atlantic Property Care — Mobile responsive overrides
   Inline-style React, so rules use attribute selectors + !important.
   ============================================================ */

/* ---------- Tablet ---------- */
@media (max-width: 980px) {
  /* All multi-col grids collapse */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 1.05fr 1fr"],
  [style*="grid-template-columns: 1.1fr 1fr"],
  [style*="grid-template-columns: 1.4fr 1fr"],
  [style*="grid-template-columns: 1.6fr"],
  [style*="grid-template-columns: 1.2fr 2fr"],
  [style*="grid-template-columns: 1fr 1.4fr"],
  [style*="grid-template-columns: 1fr 1.2fr"] {
    grid-template-columns: 1fr !important;
  }
  [style*="repeat(3, 1fr)"] { grid-template-columns: 1fr 1fr !important; }
  [style*="repeat(4, 1fr)"] { grid-template-columns: 1fr 1fr !important; }
  [style*="repeat(6, 1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
    position: static !important;
    top: auto !important;
  }

  /* Hide promo elements on the navy top bar */
  body > div > div:first-child > div:first-child > span:nth-child(n+3) {
    display: none !important;
  }
}

/* ---------- Phones ---------- */
@media (max-width: 720px) {
  /* Global section + nav padding */
  section, footer {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  /* Reduce vertical padding on big sections */
  section[style*="padding: '96px 32px"],
  section[style*="padding: '160px 32px"],
  section[style*="padding: '80px 32px"],
  section[style*="padding: '72px 32px"],
  section[style*="padding: '56px 32px"] {
    padding-top: 48px !important;
    padding-bottom: 48px !important;
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  /* Hero band's special inner padding */
  section > div[style*="padding: '72px 32px 0"] {
    padding: 32px 18px 0 !important;
  }

  /* TOP BAR — keep only essentials */
  body > div > div:first-child {
    padding: 8px 18px !important;
    font-size: 11px !important;
  }
  body > div > div:first-child > div:first-child {
    flex-wrap: wrap !important;
    gap: 6px !important;
    flex: 1 1 100% !important;
  }
  body > div > div:first-child > div:first-child > span:nth-child(n+2) {
    display: none !important;
  }
  body > div > div:first-child > div:nth-child(2) {
    display: none !important;
  }

  /* All 1fr-1fr grids → single column */
  [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
  [style*="repeat(3, 1fr)"] { grid-template-columns: 1fr !important; }
  [style*="repeat(4, 1fr)"] { grid-template-columns: 1fr 1fr !important; }
  [style*="repeat(6, 1fr)"] {
    grid-template-columns: 1fr 1fr !important;
    position: static !important;
    top: auto !important;
    gap: 6px !important;
  }

  /* NAV — stack, scrollable links, hide phone label block */
  nav {
    flex-wrap: wrap !important;
    gap: 10px !important;
    padding: 10px 16px !important;
  }
  nav > a { gap: 10px !important; }
  nav > a img { width: 34px !important; height: 34px !important; }
  nav > a > div > div:first-child { font-size: 14px !important; }
  nav > a > div > div:nth-child(2) { font-size: 9px !important; }

  nav > div:nth-child(2) {
    order: 3 !important;
    width: 100% !important;
    gap: 18px !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    padding-bottom: 4px !important;
    -webkit-overflow-scrolling: touch !important;
  }
  nav > div:nth-child(2) > a {
    font-size: 13px !important;
    flex-shrink: 0 !important;
  }
  nav > div:nth-child(3) { gap: 8px !important; }
  nav > div:nth-child(3) > div:nth-child(1),
  nav > div:nth-child(3) > div:nth-child(2) { display: none !important; }
  nav > div:nth-child(3) > a {
    padding: 10px 14px !important;
    font-size: 12px !important;
  }

  /* HEADINGS */
  h1 { font-size: 36px !important; line-height: 1.08 !important; letter-spacing: -1px !important; }
  h2 { font-size: 26px !important; line-height: 1.15 !important; letter-spacing: -0.6px !important; }
  h3 { font-size: 19px !important; }
  p  { font-size: 15px !important; }

  /* Big stat / display numbers */
  [style*="font: 600 76px"], [style*="font: 600 72px"],
  [style*="font: 600 64px"], [style*="font: 600 56px"],
  [style*="font: 600 48px"], [style*="font: 600 44px"] {
    font-size: 30px !important;
    line-height: 1.08 !important;
    letter-spacing: -0.6px !important;
  }
  [style*="font: 600 36px"] {
    font-size: 22px !important;
  }
  [style*="font: 600 28px"] {
    font-size: 20px !important;
  }

  /* HERO: stack 2-col intro */
  section[style*="linear-gradient(180deg, #d8e3ee"] > div > div[style*="grid-template-columns"],
  div[style*="gap: 80"][style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
    padding-bottom: 32px !important;
  }

  /* HERO trust badges row — stack neatly */
  div[style*="gap: 18"][style*="align-items: center"]:has(> div[style*="border-radius: '50%'"]) {
    flex-wrap: wrap !important;
  }
  /* Seal badges shrink */
  div[style*="width: 78"][style*="height: 78"][style*="border-radius: '50%'"] {
    width: 56px !important;
    height: 56px !important;
  }
  div[style*="width: 78"][style*="height: 78"] > div:first-child {
    font-size: 9px !important;
  }
  div[style*="width: 78"][style*="height: 78"] > div:nth-child(2) {
    font-size: 11px !important;
  }

  /* HERO Stats row — tighter */
  div[style*="gap: 24"][style*="padding-top: 20"] {
    gap: 16px !important;
  }

  /* HERO BOTTOM: hero photo + floating form card → bring form into flow */
  /* The photo */
  div[style*="height: 560"] {
    height: 260px !important;
  }
  /* The absolutely-positioned form wrapper */
  div[style*="position: 'absolute'"][style*="top: -120"],
  div[style*="position:'absolute'"][style*="top:-120"] {
    position: static !important;
    width: 100% !important;
    max-width: 540px !important;
    margin: -48px auto 24px !important;
    right: auto !important;
    top: auto !important;
  }
  /* The dark form card */
  div[style*="padding: '52px 36px 32px"] {
    padding: 36px 22px 24px !important;
    border-radius: 14px !important;
  }
  /* Two-col form fields inside the card */
  div[style*="padding: '52px 36px 32px"] [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* SERVICE area pill row — wrap tight */
  div[style*="flex-wrap: wrap"][style*="gap: 8"] > span {
    font-size: 12px !important;
    padding: 6px 10px !important;
  }

  /* CTA band — reduce padding + stack */
  div[style*="padding: '72px 64px"] {
    padding: 40px 22px !important;
    border-radius: 18px !important;
    gap: 24px !important;
  }
  /* CTA inside two-col → stack */
  div[style*="padding: '72px 64px"][style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  div[style*="padding: '72px 64px"] a {
    padding: 14px 18px !important;
    font-size: 14px !important;
  }

  /* PROCESS 4-up grid: stack to 1 col on phones (overrides tablet 2x2) */
  /* (we want 2x2 grid, kept above) — but tighten */
  div[style*="repeat(4, 1fr)"][style*="background: '#e5e5e5'"] > div {
    padding: 20px 18px !important;
    min-height: 180px !important;
  }

  /* TESTIMONIAL cards stack — tighter padding */
  div[style*="padding: '32px 28px"] {
    padding: 24px 20px !important;
  }

  /* FOOTER columns stack */
  footer [style*="grid-template-columns: 1.6fr"] {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }
  footer { padding: 48px 18px 24px !important; }
  footer img[alt="Atlantic Property Care"] { height: 44px !important; }
  footer [style*="height: 1"][style*="rgba(255,255,255,0.08)"] {
    margin: 32px 0 16px !important;
  }
  footer > div > div:last-child {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: flex-start !important;
  }

  /* PAGE HERO on subpages */
  section[style*="linear-gradient(180deg, #d8e3ee 0%, #f5e9d8"] {
    padding: 48px 18px 56px !important;
  }

  /* SERVICES PAGE: sticky TOC unstuck + shrink */
  div[style*="repeat(6, 1fr)"][style*="position:"] {
    position: static !important;
    top: auto !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }
  div[style*="repeat(6, 1fr)"] > a {
    padding: 10px 10px !important;
  }
  div[style*="repeat(6, 1fr)"] > a > span:nth-child(2) {
    font-size: 12px !important;
  }

  /* SERVICE ROW — alternate flip needs to put image on top always */
  section[style*="padding: '56px 32px 96px"] > div > div[style*="padding: '72px 0"] {
    padding: 36px 0 !important;
    gap: 24px !important;
  }
  section[style*="padding: '56px 32px 96px"] > div > div[style*="padding: '72px 0"] > div:first-child,
  section[style*="padding: '56px 32px 96px"] > div > div[style*="padding: '72px 0"] > div:nth-child(2) {
    order: unset !important;
  }
  section[style*="padding: '56px 32px 96px"] > div > div[style*="padding: '72px 0"] > div[style*="order: 2"] {
    order: 1 !important;
  }
  section[style*="padding: '56px 32px 96px"] > div > div[style*="padding: '72px 0"] > div[style*="order: 1"] {
    order: 2 !important;
  }

  /* ABOUT page collage tighten */
  div[style*="aspectRatio: '4/3'"] { aspect-ratio: 4/3 !important; }

  /* CONTACT page form card padding */
  div[style*="padding: '40px 40px"] {
    padding: 28px 20px !important;
    border-radius: 14px !important;
  }
  div[style*="padding: '40px 40px"] h3 { font-size: 22px !important; }
  /* Contact "what do you need" tile grid → 2-col on phone */
  div[style*="padding: '40px 40px"] [style*="repeat(3, 1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }
  /* Timeline pill row — wrap */
  div[style*="padding: '40px 40px"] > div > div > div[style*="gap: 8"][style*="display: 'flex'"] {
    flex-wrap: wrap !important;
  }
  /* Submit button row stack */
  div[style*="padding: '40px 40px"] [style*="justify-content: 'space-between'"][style*="padding-top: 8"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 14px !important;
  }
  div[style*="padding: '40px 40px"] [style*="justify-content: 'space-between'"][style*="padding-top: 8"] button {
    width: 100% !important;
    justify-content: center !important;
  }

  /* FAQ items */
  button[style*="padding: '22px 26px"], button[style*="padding:'22px 26px"] {
    padding: 18px 18px !important;
  }

  /* Tweaks panel responsive */
  [style*="width: 340"], [style*="width:340"] {
    width: calc(100vw - 24px) !important;
    max-width: 360px !important;
    right: 12px !important;
    bottom: 12px !important;
  }

  /* Sticky stuff — unstick on mobile */
  [style*="position: 'sticky'"], [style*="position:'sticky'"] {
    position: static !important;
    top: auto !important;
  }

  /* Map SVG on home — shrink */
  svg[viewBox="0 0 500 400"] {
    aspect-ratio: 5 / 4 !important;
    width: 100% !important;
    height: auto !important;
  }
}

/* ---------- Tight phones ---------- */
@media (max-width: 380px) {
  h1 { font-size: 30px !important; }
  h2 { font-size: 22px !important; }
  section, nav, footer { padding-left: 14px !important; padding-right: 14px !important; }
  div[style*="padding: '52px 36px 32px"] { padding: 28px 18px 20px !important; }
  nav > a > div > div:first-child { font-size: 13px !important; }
  body > div > div:first-child { font-size: 10px !important; }
}
