/* ===================================================================
   responsive-enhancements.css — detectaleak.co.nz
   Supplements Bootstrap 3 + tpl-buddy-012 responsive styles.
   =================================================================== */

/* ------------------------------------------------------------------
   1. Images: always scale proportionally with their container.
      height:auto ensures existing img { max-width:100% } works
      correctly when HTML width/height attributes are present.
   ------------------------------------------------------------------ */
img {
  height: auto;
}

/* ------------------------------------------------------------------
   2. Thumbnail gallery blocks (.smallpic / .smallpic2 / .smallpic3)
      The existing CSS sets width:200px on these images which beats
      max-width at narrow containers. Force fluid below 600px.
   ------------------------------------------------------------------ */
@media (max-width: 600px) {
  .smallpic,
  .smallpic2,
  .smallpic3 {
    width: 50%;
    box-sizing: border-box;
    padding: 2px;
  }
  .smallpic img,
  .smallpic2 img,
  .smallpic3 img {
    width: 100%;
    height: auto;
  }
}

/* ------------------------------------------------------------------
   3. Services section — 4 cols desktop › 2×2 tablet › 1 col mobile
   ------------------------------------------------------------------ */
@media (min-width: 768px) and (max-width: 991px) {
  .services .col-sm-3 {
    width: 50%;
    float: left;
    margin-bottom: 20px;
  }
  .services .col-sm-3:nth-child(2n+1) {
    clear: left;
  }
}
@media (max-width: 767px) {
  .services .col-sm-3 {
    margin-bottom: 12px;
  }
  .services h4 {
    font-size: 16px;
  }
}

/* ------------------------------------------------------------------
   4. Contact forms
      - Inputs and select: full width on mobile
      - Textarea: max-width stops cols="80" causing horizontal scroll
        at all viewport sizes; full-width + shorter on mobile
      - Submit button: full width, tap-friendly on mobile
   ------------------------------------------------------------------ */
.formbuddy input[type="text"],
.formbuddy input[type="email"],
.formbuddy select,
.formbuddy textarea,
.cms_textarea {
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 767px) {
  .formbuddy input[type="text"],
  .formbuddy input[type="email"],
  .formbuddy select,
  .formbuddy textarea,
  .cms_textarea {
    width: 100% !important;
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }
  .formbuddy .submit input[type="submit"],
  .formbuddy .submit .cms_submit {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
  }
  .formbuddy label {
    display: block;
    margin-bottom: 4px;
  }
  .formbuddy .required,
  .formbuddy div {
    margin-bottom: 12px;
  }
}

/* ------------------------------------------------------------------
   5. Contact page sidebar — centre-align when it stacks below form
   ------------------------------------------------------------------ */
@media (max-width: 767px) {
  .mainContent .col-sm-4 h5,
  .mainContent .col-sm-4 p,
  .mainContent .col-sm-6:last-child h5,
  .mainContent .col-sm-6:last-child p {
    text-align: center !important;
  }
}

/* ------------------------------------------------------------------
   6. Responsive typography — scale headings down at mobile
   ------------------------------------------------------------------ */
@media (max-width: 767px) {
  h1 { font-size: 24px !important; line-height: 1.3; }
  h2 { font-size: 20px !important; line-height: 1.35; }
  h3 { font-size: 18px !important; }
  h4 { font-size: 15px; }
}

/* ------------------------------------------------------------------
   7. Multicol suburb lists — 2 columns at 991px (already in CSS),
      1 column at 479px where 2 columns are too narrow.
   ------------------------------------------------------------------ */
@media (max-width: 479px) {
  .multicol {
    width: 100% !important;
    float: none;
  }
}

/* ------------------------------------------------------------------
   8. Footer — centre on small screens
   ------------------------------------------------------------------ */
@media (max-width: 767px) {
  footer {
    text-align: center;
  }
  footer .address {
    font-size: 14px;
    line-height: 1.6;
  }
}

/* ------------------------------------------------------------------
   9. Rounded corners — content images and video embeds
      Excludes nav/logo/icon images via selector scope.
   ------------------------------------------------------------------ */
.mainContent img,
.mainContent iframe,
section.mainContent p > img,
section.mainContent p > iframe {
  border-radius: 8px;
}

/* Ensure iframes don't overflow their container on narrow screens */
.mainContent iframe {
  max-width: 100%;
}

/* ------------------------------------------------------------------
   10. Testimonials page
   ------------------------------------------------------------------ */

.testimonial-card {
  background: #fff;
  border: 1px solid #e4eaf2;
  border-radius: 10px;
  padding: 22px 22px 18px;
  margin-bottom: 24px;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  display: flex;
  flex-direction: column;
}
.testimonial-card .t-quote {
  font-size: 56px;
  line-height: 1;
  color: #1a3a5c;
  opacity: .12;
  font-family: Georgia, serif;
  position: absolute;
  top: 10px;
  left: 16px;
  pointer-events: none;
}
.testimonial-card .t-stars {
  color: #f0a500;
  font-size: 13px;
  margin-bottom: 10px;
  padding-top: 4px;
}
.testimonial-card .t-body {
  font-size: 14px;
  line-height: 1.65;
  color: #444;
  flex: 1;
  margin: 0;
}
.testimonial-card .t-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
}
.testimonial-card .t-author { font-weight: 700; font-size: 13px; color: #1a3a5c; }
.testimonial-card .t-date   { font-size: 12px; color: #aaa; }
.t-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
}
.t-badge-nc     { background: #fef0e6; color: #c0621a; }
.t-badge-google { background: #e8f0fe; color: #1a73e8; }
.t-badge-email  { background: #f0f4f0; color: #555; }

/* ------------------------------------------------------------------
   11. General layout breathing room on mobile
   ------------------------------------------------------------------ */
@media (max-width: 767px) {
  .container {
    padding-left: 15px;
    padding-right: 15px;
  }
  section.mainContent {
    padding: 20px 0;
  }
  p {
    font-size: 15px;
    line-height: 1.6;
  }
}

/* ------------------------------------------------------------------
   12. Fix text-align: justify on mobile — causes uneven word spacing
       at narrow widths. !important needed to beat inline style attr.
       Issue #3
   ------------------------------------------------------------------ */
@media (max-width: 767px) {
  p[style*="justify"],
  .mainContent p {
    text-align: left !important;
  }
}

/* ------------------------------------------------------------------
   13. Reduce .wrapper top margin on mobile — fixed header is ~70px
       tall on mobile, not 144px as on desktop. Issue #14
   ------------------------------------------------------------------ */
@media (max-width: 767px) {
  .wrapper {
    margin-top: 70px;
  }
}

/* ------------------------------------------------------------------
   14. Remove excess bottom margin on image-only paragraphs in
       sidebars and footer. Issue #15
   ------------------------------------------------------------------ */
footer p:has(> img:only-child),
.col-sm-4 p:has(> img:only-child),
.col-sm-3 p:has(> img:only-child) {
  margin-bottom: 8px;
}

/* ------------------------------------------------------------------
   15. Mobile nav trigger — aria-label on the <a> handles accessibility;
       the span must remain unstyled so the theme's span:before
       pseudo-element can draw the hamburger icon.
   ------------------------------------------------------------------ */

/* ------------------------------------------------------------------
   16. Centre standalone images (only child of a <p>) on mobile.
       Catches cases where text-align or nbsp was the only alignment.
   ------------------------------------------------------------------ */
@media (max-width: 767px) {
  .mainContent p > img:only-child {
    display: block;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ------------------------------------------------------------------
   17. Smallpic image grid: drop to 1 column on small phones (≤480px).
       2-column at 600px is already handled above. Issue #8
   ------------------------------------------------------------------ */
@media (max-width: 480px) {
  .smallpic,
  .smallpic2,
  .smallpic3 {
    width: 100%;
    float: none;
    margin-bottom: 8px;
  }
  .smallpic img,
  .smallpic2 img,
  .smallpic3 img {
    width: 100%;
    max-height: none;
    height: auto;
  }
  /* clearfix for the .whole wrapper used around smallpic groups */
  .whole::after {
    content: '';
    display: table;
    clear: both;
  }
}

/* ------------------------------------------------------------------
   17. Fix: .sidebar / .sidebar3 position: fixed overlays body text
       when columns stack on mobile. Issue #2
   ------------------------------------------------------------------ */
@media (max-width: 767px) {
  .sidebar,
  .sidebar3 {
    position: static;
    top: auto;
    width: 100%;
    text-align: center;
    margin: 20px 0;
  }
}

/* ------------------------------------------------------------------
   17. Region buttons — CSS-styled touch-friendly links replacing
       the old image-swap hover buttons. Issue #4
   ------------------------------------------------------------------ */
.region-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.region-btn {
  display: block;
  background: #C01C01;
  color: #fff !important;
  text-align: center;
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.2s;
}
.region-btn:hover,
.region-btn:focus {
  background: #a01601;
  color: #fff !important;
}

/* ------------------------------------------------------------------
   18. Mobile-only CTA strip — visible only below 768px, sits above
       the main content row on the homepage. Issue #6
   ------------------------------------------------------------------ */
.mobile-cta-strip {
  display: none;
}
@media (max-width: 767px) {
  .mobile-cta-strip {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 0 8px;
  }
  .mobile-cta-strip .cta-call {
    display: block;
    background: #C01C01;
    color: #fff !important;
    text-align: center;
    padding: 14px;
    border-radius: 4px;
    font-size: 17px;
    font-weight: 700;
    text-decoration: none !important;
  }
  .mobile-cta-strip .cta-quote {
    display: block;
    background: transparent;
    color: #C01C01 !important;
    text-align: center;
    padding: 13px;
    border-radius: 4px;
    border: 2px solid #C01C01;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none !important;
  }
  .mobile-cta-strip .cta-call:hover,
  .mobile-cta-strip .cta-call:focus { background: #a01601; }
  .mobile-cta-strip .cta-quote:hover,
  .mobile-cta-strip .cta-quote:focus { background: #C01C01; color: #fff !important; }
}

/* ------------------------------------------------------------------
   19. T660 moisture meter product image — float right next to its
       descriptive text paragraph, then stack centred on mobile.
   ------------------------------------------------------------------ */
.t660-float {
  float: left;
  margin: 0 20px 16px 0;
  max-width: 220px;
  width: 220px;
}
@media (max-width: 767px) {
  .t660-float {
    float: none;
    display: block;
    margin: 0 auto 16px;
    max-width: 200px;
    width: 100%;
  }
}
