/* ==========================================================================
   Responsive — desktop-first overrides. Load LAST.
   Breakpoints: 1200 / 992 / 768 / 576
   ========================================================================== */

@media (max-width: 1200px) {
  :root { --gutter: 1.25rem; }

  .showcase__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 230px; }
}

@media (max-width: 1024px) {
  /* Two cards side by side leaves no room for the square tile — drop it to
     its own full-width row. */
  .showcase__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .products__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .testimonial-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Coverage: map above, list below */
  .coverage__layout { grid-template-columns: 1fr; gap: var(--sp-6); }
  .blog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .client-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .finish-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Quote split: stack, and release the panel's internal scroll. A nested
     scroll area inside a scrolling page is hostile on touch — let the
     content flow at its natural height instead. */
  .quote-split__grid { grid-template-columns: 1fr; gap: var(--sp-6); }
  .scroll-panel {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  .scroll-panel-wrap::after { display: none; }

  /* Bento: top row stacks; the wide card drops its 3-up to title+list / media */
  .bento__grid { grid-template-columns: 1fr; }
  .bento-card { padding: var(--sp-6); }
  .bento-card--wide { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bento-card--wide .bento-card__title { grid-column: 1 / -1; }
  .promo-tile {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    /* drop the square-ish floor, or the banner becomes a dead slab */
    min-height: 0;
    padding: var(--sp-5) var(--sp-6);
  }
  .promo-tile__arrow { order: 2; width: 56px; height: 56px; margin-left: 0; }
}

@media (max-width: 992px) {
  :root {
    --fs-3xl: 1.875rem;
    --fs-4xl: 2.25rem;
    --sp-8: 3rem;
    --sp-9: 4rem;
    --header-h: 68px;
  }

  /* Scoped to the top bar — a bare .search here would also shrink the
     full-width copy in the mobile drawer. */
  .topbar__search { width: 220px; }

  /* ---- Hero: pin OFF below this width ---------------------------------
     Stacked, the hero copy plus the box is taller than a phone viewport.
     A sticky pane taller than the viewport can never fully scroll into
     view, so its lower half would be unreachable. Release the pin and let
     hero.js fall back to plain scroll-progress (it detects this itself by
     measuring the pin distance). */
  .hero { height: auto; }
  .hero__sticky {
    position: static;
    height: auto;
    padding-block: var(--sp-7);
  }

  /* Hero stacks: copy first, box below it */
  .hero__inner {
    grid-template-columns: 1fr;
    gap: var(--sp-6);
    min-height: 0;
    text-align: center;
  }
  .hero__lead { margin-inline: auto; }
  .hero__actions,
  .hero__stats { justify-content: center; }
  /* padding-top gives the risen contents headroom, since place-items:center
     would otherwise let them ride up into the copy above */
  .scene { min-height: 400px; padding-top: var(--sp-6); }
  .scene { --box-w: 240px; --box-d: 192px; --box-h: 164px; }

  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(2, 1fr); }
  /* Footer: 4 columns -> 2, claim spans the row */
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-claim { grid-column: 1 / -1; padding-left: 0; flex-direction: row; align-items: flex-end; justify-content: space-between; }

  /* ---- Off-canvas navigation ------------------------------------------
     Full-height drawer sliding in from the right. It covers the top bar
     too, so it carries its own logo + close button rather than trying to
     align under a sticky header. */
  .nav-toggle { display: grid; }
  .site-header__cta { display: none; }   /* the CTA moves into the drawer */

  .nav {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: var(--z-drawer);
    display: flex;
    flex-direction: column;
    /* Must reset align-items: the desktop rule centres the row, and once
       the axis flips to column that centre-aligns every child across the
       drawer instead of letting it fill the width. */
    align-items: stretch;
    width: min(400px, 88vw);
    margin-inline: 0;
    background: var(--c-surface);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(100%);
    /* visibility is transitioned too: without it the panel would blink out
       instead of sliding, and while closed it keeps the drawer's links out
       of the tab order. */
    transition: transform var(--dur) var(--ease), visibility var(--dur) var(--ease);
    visibility: hidden;
  }
  .nav.is-open { transform: none; visibility: visible; }

  .nav__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--c-line);
  }

  .nav__list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--sp-3) var(--sp-4);
  }
  .nav__item { width: 100%; }

  .nav__link {
    justify-content: space-between;
    width: 100%;
    padding: var(--sp-4);
    font-size: var(--fs-base);
    font-weight: 500;
  }

  /* ---- Mega menu becomes an inline accordion panel -------------------- */
  .mega {
    position: static;
    width: auto;
    padding: 0 var(--sp-4) var(--sp-4);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
    /* Collapsed by default; .is-open on the parent reveals it. Height is
       not animated — the panel's height is unknown, and a max-height guess
       either clips long menus or makes short ones sluggish. */
    display: none;
    opacity: 1;
    visibility: visible;
    transition: none;
  }
  /* Hover must NOT open the panel on touch — only the explicit toggle does */
  .nav__item--mega:hover > .mega,
  .nav__item--mega:focus-within > .mega { display: none; }
  .nav__item--mega.is-open > .mega { display: block; transform: none; }

  .mega__inner { grid-template-columns: 1fr; gap: var(--sp-4); }
  .mega__grid { grid-template-columns: 1fr; }
  .mega__heading { margin-bottom: var(--sp-2); }
  .mega__item { padding: var(--sp-2) var(--sp-3); }
  .mega__promo { padding: var(--sp-4); }

  /* ---- Drawer footer -------------------------------------------------- */
  .nav__foot {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    margin-top: auto;
    padding: var(--sp-5);
    border-top: 1px solid var(--c-line);
    background: var(--c-brand-tint);
  }
  .nav__contact { display: grid; gap: var(--sp-3); font-size: var(--fs-sm); }
  .nav__contact a {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    color: var(--c-body);
  }
  .nav__contact a:hover { color: var(--c-brand-deep); }
  .nav__contact .icon { color: var(--c-brand-deep); }
}

@media (max-width: 768px) {
  /* ---- App-style bottom nav -------------------------------------------
     Turned on here. Three things have to move out of its way:
       1. the footer grows a bottom pad so the bar never covers its last row
          (padding goes on the FOOTER, not <body> — on body it would leave a
          white strip under the dark footer)
       2. back-to-top lifts above the bar
       3. the floating message pill is hidden: the bar already carries Call
          and Menu, and two stacked floating controls on a phone is clutter */
  .bottom-nav { display: block; }

  .site-footer {
    padding-bottom: calc(var(--sp-6) + 58px + env(safe-area-inset-bottom, 0px));
  }
  .back-to-top {
    bottom: calc(var(--sp-4) + 58px + env(safe-area-inset-bottom, 0px));
  }
  .float-msg { display: none; }

  :root { --fs-3xl: 1.625rem; --fs-2xl: 1.375rem; }

  .grid--2 { grid-template-columns: 1fr; }
  .section-head__text { font-size: var(--fs-base); }

  /* ---- Process: flow turns vertical -----------------------------------
     Five columns can't hold readable copy on a phone, so each step becomes
     an icon-left row and the connector runs down the icon column. */
  .process__track { grid-template-columns: 1fr; }
  .process__step {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    column-gap: var(--sp-4);
    padding: 0 0 var(--sp-6);
    text-align: left;
  }
  .process__icon { grid-row: 1 / span 3; margin: 0; }
  .process__num,
  .process__title,
  .process__text { grid-column: 2; }

  .process__step:not(:last-child)::before,
  .process__step:not(:last-child)::after {
    top: 76px;
    left: 33px;
    width: 3px;
    /* -42px, not -76px: carries the line past the step's padding and down
       to the centre of the next icon. */
    height: calc(100% - 42px);
  }
  .process__step:not(:last-child)::after {
    height: calc((100% - 42px) * var(--on2));
  }

  .help-bar { flex-wrap: wrap; }
  .help-bar__text { flex: 1 1 100%; order: 2; }
  .help-bar__actions { flex: 1 1 100%; order: 3; }

  .hero__stats { gap: var(--sp-4) var(--sp-5); }
  .scene { min-height: 340px; }
  .scene { --box-w: 200px; --box-d: 160px; --box-h: 138px; }

  /* Showcase: one card per row; the tile stops being square and becomes a
     short wide banner so it doesn't eat a whole screen height. */
  .showcase__grid { grid-template-columns: 1fr; }
  .products__grid { grid-template-columns: 1fr; }
  .testimonial-grid { grid-template-columns: 1fr; }
  .coverage__list { grid-template-columns: 1fr; }
  .blog-grid { grid-template-columns: 1fr; }
  /* head + CTA stack rather than squeezing the button */
  .section-head-row { flex-direction: column; align-items: flex-start; gap: var(--sp-4); }
  .client-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .client-grid__item { padding: var(--sp-5) var(--sp-3); }
  /* FAQ: two columns of accordions become one continuous list */
  .faq__grid { grid-template-columns: 1fr; }
  .faq__col .accordion__item:first-child { border-top: 0; }
  .faq__col:first-child .accordion__item:first-child { border-top: 1px solid var(--c-line); }
  .finish-grid { grid-template-columns: 1fr; }
  /* Let the tab row scroll sideways rather than wrap into a tall stack */
  .tabs__list { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding-bottom: var(--sp-2); }
  .promo-tile { min-height: 0; }
  .promo-tile__arrow { width: 52px; height: 52px; }

  /* Top bar: keep tap-to-call/email, drop the search — it belongs in the
     mobile nav drawer, not squeezed into a 44px bar. */
  .topbar__inner { justify-content: center; padding-block: var(--sp-2); }
  .topbar__contact { justify-content: center; gap: var(--sp-2) var(--sp-4); }
  .topbar__search { display: none; }
}

@media (max-width: 576px) {
  .grid--3,
  .grid--4 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .footer-claim { flex-direction: column; align-items: flex-start; }
  /* Icon-only pill, or it eats half the viewport */
  .float-msg__label { display: none; }
  .float-msg { left: var(--sp-4); bottom: var(--sp-4); }

  .btn { width: 100%; }
  .btn--ghost { width: auto; }

  .topbar { font-size: var(--fs-xs); }

  /* Shallower angle + smaller type so more of the message fits per screen */
  .marquee-band { padding-block: var(--sp-6); }
  .marquee { transform: rotate(-2deg); padding-block: var(--sp-3); }
  .marquee__item { font-size: var(--fs-sm); }
  .marquee__icon { width: 18px; height: 18px; }

  /* Side-by-side leaves ~200px of text and a 120px thumbnail — stack it,
     illustration first as the visual hook. */
  /* Bento: everything to a single column, illustration last */
  .bento-card--split,
  .bento-card--wide { grid-template-columns: 1fr; }
  .bento-card--wide .bento-card__title { grid-column: auto; }
  .bento-card__media { max-width: 300px; margin-inline: auto; }
  .bento-badge { width: 88px; height: 88px; left: 0; }

  .form__row--2 { grid-template-columns: 1fr; }
  .quote-card { padding: var(--sp-5); }

  /* Undo the desktop compaction: 36px controls are too small to hit with a
     thumb, so touch gets the full-size fields back. */
  .quote-card .form__control { padding: var(--sp-3) var(--sp-4); }
  .quote-card .form__label { font-size: var(--fs-sm); }
  .quote-card textarea.form__control { min-height: 96px; }

  .promo-card { grid-template-columns: 1fr; padding: var(--sp-5); }
  .promo-card__media { order: -1; width: 100%; max-width: 240px; margin-inline: auto; }
  .promo-card__text { max-width: none; }

  .hero__sticky { padding-block: var(--sp-6); }
  .hero__stat { flex: 1 1 40%; }
  .scene { min-height: 290px; }
  .scene { --box-w: 168px; --box-d: 134px; --box-h: 116px; }
}
