/* Quartermaster responsive layer: tablet and phone.
   Loaded after bundle.css on every page. Desktop (above 960px) is untouched.
   Fixed sizes saved on elements in the canvas (inline width/height) win over the
   stylesheet, so below 960px they are released here with !important. */

/*
   The home hero also has editor-exported widths that make the two desktop grid
   tracks wider than a medium viewport. Make the columns shrinkable and retain
   the artwork as a cropped detail rather than letting it create horizontal
   scrolling. */
.qm-hero:not(.qm-hero--full){grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
.qm-hero:not(.qm-hero--full) .qm-hero__copy[style*="width"]{width:auto!important;max-width:min(100%,44rem)!important}
.qm-hero:not(.qm-hero--full) .qm-hero__media[style*="width"]{width:auto!important;min-width:0}
.qm-hero:not(.qm-hero--full) :is(h1,p)[style*="width"]{width:auto!important;max-width:100%!important}

/* Apply the same constraint above the tablet breakpoint. The exported page
   markup contains fixed widths on content sections as well as the hero. */
.qm :is(section,div,h1,h2,h3,p,span,b,li,ul,blockquote)[style*="width"]:not([aria-hidden]):not(.qm-header *){width:auto!important;max-width:100%!important}

/* ---------- Compact desktop / tablet (1180px and below) ----------
   This is the working-width breakpoint: a 12-column desktop composition no
   longer has enough room for four process panels or side-by-side media and
   long-form copy. Reflow those patterns before they become cramped. */
@media (max-width:1180px){
  :root{--page-margin:32px}
  .qm-section[style*="height"]{height:auto!important}

  /* Cutout heroes, including About: artwork first, then an unconstrained copy block. */
  .qm-hero:not(.qm-hero--full){grid-template-columns:1fr;min-height:0}
  .qm-hero:not(.qm-hero--full) .qm-hero__media{order:-1;min-height:360px}
  .qm-hero:not(.qm-hero--full) .qm-hero__copy{max-width:none;margin:0;padding:var(--space-8) var(--page-margin)!important}
  .qm-hero:not(.qm-hero--full) .qm-hero__media.qm-mask{min-height:360px}

  /* Founder bands are a single, readable story below desktop. Keeping the
     portrait beside long copy creates the awkward partial two-column state
     seen on tablets and narrow browser windows. */
  .qm-founder{grid-template-columns:1fr;gap:var(--space-6)}
  .qm-founder__photo{margin-left:0;width:min(100%,440px)!important;height:auto;aspect-ratio:1;justify-self:start}
  .qm .qm-founder__photo[style*="width"]:not([aria-hidden]):not(.qm-header *){width:min(100%,440px)!important}
  .qm-founder__photo .qm-mask__img{display:block;object-position:center 30%}
  .qm-section:has(> .qm-founder){padding:var(--space-9) var(--page-margin)!important}
  .qm-founder__aside{grid-column:auto;border-left:0;border-top:1px solid var(--border-subtle);padding:var(--space-5) 0 0}
  .qm-cred{grid-template-columns:1fr;gap:var(--space-6)}

  /* Image-and-copy bands are a deliberate two-part story on wide screens and
     a vertical story here. This prevents the copy from falling off the edge. */
  .qm-bleed{display:grid;grid-template-columns:1fr!important;overflow:hidden}
  .qm-bleed__media{min-height:300px}
  .qm-bleed__copy{grid-template-columns:1fr!important;gap:var(--space-5)!important;padding:var(--space-7) var(--page-margin)!important}
  .qm-bleed__copy .qm-intro__side{border-right:0;padding-right:0}

  /* Four-step processes become two readable rows rather than four compressed columns. */
  .qm-steps{grid-auto-flow:row!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;grid-auto-columns:auto!important;padding-inline:0;gap:var(--space-5)}
  .qm-steps__item{min-width:0;padding:var(--space-6)!important}
}

/* ---------- Tablet and phone (960px and below) ---------- */
@media (max-width:960px){
  /* Release fixed widths and heights set in the canvas */
  .qm :is(section,div,h1,h2,h3,p,span,b,li,ul,blockquote)[style*="width"]:not([aria-hidden]):not(.qm-header *){width:auto!important;max-width:100%!important}
  .qm .qm-founder__photo[style*="width"]{width:min(100%,440px)!important}
  .qm :is(section,div,h1,h2,h3,p,span,li)[style*="height"]:not([aria-hidden]):not(.qm-mask){height:auto!important}
  .qm [style*="grid-template-columns"]{grid-template-columns:1fr!important}

  /* Sections nested inside sections must not double the side margin */
  .qm-section .qm-section{padding-inline:0}

  /* Banners: the image comes first, the text underneath */
  .qm-hero__media{order:-1}

  /* Cutout heroes (homepage, About) */
  .qm-hero__copy{max-width:none;margin-left:0;padding:var(--space-8) var(--page-margin)!important}
  .qm-hero__frame{top:var(--space-5)!important;left:var(--page-margin);right:-80px}

  /* Full-bleed service heroes: image as a band on top, copy underneath */
  .qm-hero--full{display:flex;flex-direction:column;min-height:0}
  .qm-hero--full .qm-hero__media{position:relative;inset:auto;z-index:0;height:320px;order:-1}
  .qm-hero--full .qm-hero__media::after{background:linear-gradient(0deg,rgba(46,18,74,.20) 0%,rgba(46,18,74,0) 55%)}

  /* Founder: signature block sits under the copy */
  .qm-founder{gap:var(--space-6)}
  .qm-founder__aside{border-left:0;padding-left:0;border-top:1px solid var(--border-subtle);padding-top:var(--space-5)}

  /* Image + copy bands (Audit, Lead) */
  .qm-bleed{min-height:0}
  .qm-bleed__media{width:auto!important}

  /* Steps stack (the component flows in columns by default) */
  .qm-steps{grid-auto-flow:row;grid-template-columns:1fr!important;padding-inline:0;gap:var(--space-4)}

  /* Interim outcome checks stack with dividers on top */
  .qm-checks{gap:0}
  .qm-checks li{display:grid;grid-template-columns:minmax(0,1fr) 26px;gap:16px;align-items:start;border-left:0!important;padding:var(--space-5) 0!important;border-top:1px solid var(--border-subtle)}
  .qm-checks li svg{grid-column:2;grid-row:1;margin:0}
  .qm-checks li span{grid-column:1;grid-row:1}
  .qm-checks li:first-child{border-top:0;padding-top:0!important}

  /* Founder sections always keep the page margin, even where the canvas zeroed the padding (Audit) */
  .qm-section:has(> .qm-founder){padding:var(--space-9) var(--page-margin)!important}
}

/* ---------- Phone (640px and below) ---------- */
@media (max-width:640px){
  :root{--page-margin:20px}
  .qm-section{padding-block:var(--space-8)!important}
  .qm-section--compact,.qm-section--quote{padding-block:var(--space-7)!important}
  .qm-section:has(> .qm-bleed){padding:0!important}
  .qm-section:has(> .qm-founder){padding:var(--space-8) var(--page-margin)!important}

  /* Type scale */
  .qm .display-1{font-size:54px!important}
  .qm .display-2{font-size:42px!important}
  .qm .display-3{font-size:32px!important}
  .qm .headline-1{font-size:40px!important;line-height:1.05}
  .qm .headline-2{font-size:31px!important;line-height:1.1}
  .qm .headline-2[style*="Bebas"]{font-size:44px!important}
  .qm .headline-3{font-size:24px!important}
  .qm .title{font-size:19px}
  .qm .lead{font-size:18px!important;line-height:1.5!important}
  .qm .body{font-size:16px}
  .qm-quote p{font-size:19px}
  .qm-cta--interim .qm-cta__side p{font-size:17px}

  /* Header */
  .qm-header{--header-h:64px}
  .qm-header .qm-btn{min-height:44px;padding:10px 14px!important;font-size:13px!important;white-space:nowrap}
  .qm-header .qm-btn svg{display:none}

  /* Labels must stay inside their section rather than extending past a
     narrow column or being clipped by a neighbouring decorative layer. */
  .qm-eyebrow{max-width:100%;flex-wrap:wrap;overflow-wrap:anywhere;letter-spacing:.16em}

  /* Service tabs: three compact tabs, no subtitles */
  .qm-svcnav a{padding:14px 10px;gap:8px;font-size:13px;line-height:1.2}
  .qm-svcnav small{display:none}

  /* Heroes */
  .qm-hero__copy{padding:var(--space-7) var(--page-margin) var(--space-7)!important;gap:var(--space-5)}
  .qm-hero__media,.qm-hero--soft .qm-hero__media{min-height:280px}
  /* Service banner imagery becomes a genuine mobile image band. The desktop
     purple overlay is useful behind copy, but on phones it obscures the art
     after the copy has moved below it. */
  .qm-hero--full .qm-hero__media{height:240px;overflow:hidden}
  .qm-hero--full .qm-hero__media::after{display:none}
  .qm-hero--full .qm-hero__media>img{object-position:center center}
  .qm-hero__actions{gap:var(--space-5)}
  .qm-hero__band--accent{width:70px;right:24px}
  .qm-hero__band--signal{width:56px;right:-20px}

  /* Operating Gap band: artwork sits under the copy */
  .qm-gap-band{padding-bottom:calc(var(--space-7) + 30vw)!important;background-size:200% auto;background-position:84% bottom}

  /* Service list cards */
  .qm-svclist a{gap:var(--space-4);padding:var(--space-5) var(--space-5) var(--space-5) var(--space-4)!important}
  .qm-svclist a::before{height:44px;width:8px}

  /* Founder */
  .qm-founder__photo{height:auto;aspect-ratio:1}
  .qm-founder__aside:has(.qm-slashes){display:none}
  .qm-container[style*="padding-top"]{padding-block:0!important}
  .qm-container[style*="gap"]{gap:var(--space-7)!important}

  /* Image + copy bands */
  .qm-bleed__media{min-height:220px}
  .qm-bleed__media .qm-mask__img{clip-path:none}
  .qm-bleed__media .qm-mask__wedge{display:none}
  .qm-bleed__copy{padding:var(--space-7) var(--page-margin)!important}

  /* Steps */
  .qm-steps__item{padding:var(--space-5)!important}

  /* Quote */
  .qm-quote{grid-template-columns:1fr;gap:var(--space-2);padding:var(--space-6) var(--space-5)}
  .qm-quote__mark{font-size:72px;line-height:.6}
  .qm-quote__waves{width:70%}

  /* About: running photo */
  .qm-section--tint .qm-mask[style*="height"]{height:240px!important}
  .qm-section--tint .qm-mask[style*="height"]{margin-inline:calc(-1 * var(--page-margin))}
  .qm-section--tint .qm-mask[style*="height"] .qm-mask__img{clip-path:none}
  .qm-section.qm-section--tint:has(.qm-mask[style*="height"]){padding-top:0!important}

  /* About: journey background anchored left */
  #journey{background-position:left center!important}

  /* Call to action */
  .qm-cta{padding:var(--space-6) var(--space-5)}
  .qm-cta .qm-btn{width:100%;justify-content:center}

  /* Footer */
  .qm-footer{padding-top:var(--space-8)}
  .qm-footer__base{flex-wrap:wrap;gap:var(--space-2)}
  .qm-footer ul{gap:0}
  .qm-footer h4{margin-bottom:var(--space-2)}
  .qm-footer a:not(.qm-btn){display:inline-flex;align-items:center;min-height:44px;padding-block:7px}
}
