/* ==========================================================================
   CivicAssist — Responsive overrides
   Targets inline-styled layouts via attribute selectors. !important is needed
   because most layout lives in inline styles inside the JSX components.
   ========================================================================== */

/* ---- Tablet (≤1024px) -------------------------------------------------- */
@media (max-width: 1024px) {

  /* Section vertical padding: shrink from 112px to a comfortable tablet rhythm */
  section[style*="padding: 112px"],
  section[style*="padding: 104px"] {
    padding-top: 80px !important;
    padding-bottom: 80px !important;
  }

  section[style*="padding: 80px"] {
    padding-top: 64px !important;
    padding-bottom: 64px !important;
  }

  /* Hero — reduce overshoot */
  section [style*="padding: 120px 28px 132px"] {
    padding: 88px 24px 96px !important;
  }

  /* Module grid 3-col → 2-col */
  section [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Stat strip 4-col → 2x2 */
  section [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Footer 4-col → 2-col */
  footer [style*="grid-template-columns: 1.5fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 36px !important;
  }

  /* Modules section header — title + sub side-by-side → stacked */
  section [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    align-items: start !important;
  }

  /* Demo strip — text + product preview → stacked */
  section [style*="grid-template-columns: 1fr 1.05fr"] {
    grid-template-columns: 1fr !important;
    gap: 48px !important;
  }
  section [style*="justify-self: end"] {
    justify-self: start !important;
  }

  /* Register + Contact — copy + form → stacked */
  section [style*="grid-template-columns: 0.85fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 40px !important;
  }

  /* IIMC banner — copy | photo → stacks */
  section [style*="grid-template-columns: auto 1fr auto"],
  section[id="iimc"] [style*="grid-template-columns: 1fr 1.05fr"] {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }

  /* Headlines — gentler scale */
  h1[style*="font-size: 68px"] { font-size: 48px !important; }
  h2[style*="font-size: 46px"] { font-size: 36px !important; }
  h2[style*="font-size: 42px"] { font-size: 32px !important; }
  h2[style*="font-size: 38px"] { font-size: 30px !important; }
  h2[style*="font-size: 36px"] { font-size: 28px !important; }
  p[style*="font-size: 36px"]  { font-size: 26px !important; }   /* testimonial */

  /* Hero "trust line" — wrap nicely */
  section [style*="border-radius: 999"][style*="rgba(255,255,255,.18)"] {
    flex-wrap: wrap !important;
  }
}

/* ---- Mobile (≤640px) --------------------------------------------------- */
@media (max-width: 640px) {

  /* Tighten horizontal padding on every section */
  section[style*="padding"] {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
  footer[style*="padding"] {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  /* Section vertical rhythm — compact */
  section[style*="padding: 112px"],
  section[style*="padding: 104px"] {
    padding-top: 56px !important;
    padding-bottom: 56px !important;
  }
  section[style*="padding: 80px"] {
    padding-top: 44px !important;
    padding-bottom: 44px !important;
  }

  /* Hero compact */
  section [style*="padding: 120px 28px 132px"] {
    padding: 56px 20px 64px !important;
  }

  /* All multi-col grids collapse to single column on mobile */
  section [style*="grid-template-columns: repeat(3, 1fr)"],
  section [style*="grid-template-columns: repeat(4, 1fr)"],
  section [style*="grid-template-columns: 1fr 1fr"],
  section [style*="grid-template-columns: 1fr 1.05fr"],
  section [style*="grid-template-columns: 0.85fr 1fr"],
  section [style*="grid-template-columns: auto 1fr auto"],
  footer [style*="grid-template-columns: 1.5fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  /* Headline scale — mobile */
  h1[style*="font-size: 68px"] { font-size: 36px !important; line-height: 1.05 !important; }
  h2[style*="font-size: 46px"] { font-size: 28px !important; }
  h2[style*="font-size: 42px"] { font-size: 26px !important; }
  h2[style*="font-size: 38px"] { font-size: 24px !important; }
  h2[style*="font-size: 36px"] { font-size: 24px !important; }
  p[style*="font-size: 36px"]  { font-size: 22px !important; line-height: 1.3 !important; }

  /* Body copy — slightly tighter */
  p[style*="font-size: 18px"]  { font-size: 16px !important; }
  p[style*="font-size: 16px"]  { font-size: 15px !important; }

  /* Hero trust pill — let it wrap and shrink */
  section [style*="border-radius: 999"][style*="rgba(255,255,255,.18)"] {
    flex-wrap: wrap !important;
    padding: 10px 14px !important;
    gap: 10px !important;
  }

  /* Footer bottom row — stack copyright + legal links */
  footer [style*="justify-content: space-between"][style*="padding-top: 22px"] {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  /* Demo product preview — clamp width on small screens */
  section [style*="max-width: 560"] {
    max-width: 100% !important;
  }

  /* Buttons full width on mobile when they wrap */
  section [style*="flex-wrap: wrap"] > a[style*="padding: 13px 22px"],
  section [style*="flex-wrap: wrap"] > button[style*="padding: 13px 22px"] {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Module cards — slightly tighter padding */
  section [style*="padding: 28px 26px 30px"] {
    padding: 22px 20px 24px !important;
  }
}

/* ==========================================================================
   Mobile nav (hamburger)
   ========================================================================== */
.ca-nav-toggle { display: none; }

@media (max-width: 900px) {
  /* Hide the desktop inline nav */
  header > div > nav {
    display: none !important;
  }
  /* Show the hamburger */
  .ca-nav-toggle {
    display: inline-flex !important;
    width: 42px; height: 42px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--line);
    align-items: center; justify-content: center;
    color: var(--ca-navy);
    cursor: pointer;
    padding: 0;
  }
  .ca-nav-toggle:hover { border-color: var(--ca-navy); }

  /* Mobile drawer */
  .ca-mobile-drawer {
    position: fixed;
    top: 64px; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 28px rgba(15,42,85,.10);
    padding: 18px 20px 24px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 40;
  }
  .ca-mobile-drawer.open { display: flex; }
  .ca-mobile-drawer a {
    color: var(--ca-navy);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    padding: 14px 6px;
    border-bottom: 1px solid var(--line);
  }
  .ca-mobile-drawer a:last-child {
    border-bottom: none;
    background: var(--ca-navy);
    color: #fff;
    padding: 14px 18px;
    border-radius: 8px;
    margin-top: 12px;
    font-weight: 600;
    text-align: center;
  }
}

/* Hide the mobile drawer on desktop regardless of state */
@media (min-width: 901px) {
  .ca-mobile-drawer { display: none !important; }
}
