/* DG Security Theme — responsive layer. v1.8.9
   Loaded LAST (after main.css, products.css, checkout.css and every Customizer-generated
   inline block), because several earlier rules use !important.

   Phones  : up to 767px      -> every card / section is ONE column, smaller fonts.
   Tablets : 768px - 1024px   -> grids capped so nothing overflows, slightly smaller fonts,
                                 navigation collapses into the menu button.

   Font sizes that come from the Customizer are reduced in PHP (inc/responsive.php).
   --dgst-mfs-head / --dgst-mfs-text are the active heading / text ratios and are used
   below to scale the sizes that are written directly in the stylesheets. */


/* =====================================================================
   1. OVERFLOW SAFETY — tablets and phones (<= 1024px)
   ===================================================================== */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
img,video,canvas,iframe,embed,object{max-width:100%}
pre{max-width:100%;overflow-x:auto}
h1,h2,h3,h4,h5,h6,p,li,dd,td,th,label,figcaption{overflow-wrap:break-word}
.site-footer a,.topbar a,.contact-details p,.footer-contact a{overflow-wrap:anywhere}

@media(max-width:1024px){
  /* Safety net only: the real causes are fixed below. `clip` (unlike `hidden`) keeps sticky headers working. */
  html{overflow-x:hidden}
  body{max-width:100%;overflow-x:clip}

  /* Let grid / flex children shrink instead of forcing the page wider. */
  .split>*,.about-intro>*,.director-card>*,.team-grid>*,.contact-grid>*,.mission-grid>*,.values-grid>*,
  .footer-grid>*,.service-row>*,.trust-strip>*,.dg-service-grid>*,.dg-industry-grid>*,.dg-insight-grid>*,
  .dgp-product>*,.asl-contact-form>*,.dg-checkout-form>*,.dg-bn-form>*,.header-inner>*,.topbar-inner>*{min-width:0}

  .generic-page table:not(.dg-cart-table),.dgst-single-content table{display:block;max-width:100%;overflow-x:auto}
  .dgst-single-content iframe,.dgst-single-content video{max-width:100%}

  /* ---- Navigation collapses into the menu button (the 7 links + cart + quote button cannot fit a tablet) ---- */
  .site-header .header-inner{gap:12px}
  .site-header .nav-toggle{display:block;margin-left:auto;background:none;border:0;cursor:pointer}
  .site-header .main-nav{display:none;position:absolute;top:100%;left:0;right:0;margin:0;padding:18px 4%;box-shadow:0 8px 15px #0002;z-index:30}
  .site-header .main-nav.is-open{display:block}
  .site-header .main-nav .dg-nav-list{display:flex;flex-direction:column;gap:14px}
  .site-header .header-actions{gap:8px;flex:0 0 auto}
  .site-header .brand{min-width:0;flex:0 1 auto}

  /* ---- Hard-coded sizes scaled by the active ratio ---- */
  .about-mark>span{font-size:max(48px,calc(75px*var(--dgst-mfs-head,.8)))}
  .about-mark>strong{font-size:max(24px,calc(36px*var(--dgst-mfs-head,.8)))}
  .about-mark>b{font-size:max(17px,calc(23px*var(--dgst-mfs-head,.8)))}
  .footer-brand strong{font-size:max(18px,calc(22px*var(--dgst-mfs-head,.8)))}
  .trust-item b{font-size:max(16px,calc(20px*var(--dgst-mfs-text,.9)))}
  .dgst-single-content{font-size:max(15px,calc(17px*var(--dgst-mfs-text,.9)))}
  .dgst-single-cat{font-size:max(12px,calc(15px*var(--dgst-mfs-text,.9)))}
  .dgst-single-label{font-size:max(12px,calc(14px*var(--dgst-mfs-text,.9)))}
  .dgst-single-back a{font-size:max(13px,calc(15px*var(--dgst-mfs-text,.9)))}
  .dg-service p,.dg-industry p,.dg-insight-excerpt,.section-heading p,.cta-section p{font-size:max(13px,calc(14px*var(--dgst-mfs-text,.9)))}

  /* Single-product title / price already carried their own phone reduction; the ratio now does that job. */
  body .dgp-single h1.dgp-single-title{font-size:var(--dgp-s-title)!important}
  .dgp-single-price{font-size:var(--dgp-s-price)}
}


/* =====================================================================
   2. TABLETS (768px - 1024px) — never wider than the screen
   ===================================================================== */
@media(min-width:768px) and (max-width:1024px){
  .trust-strip{grid-template-columns:repeat(2,minmax(0,1fr))}
  .dg-insight-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .dg-service-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .dg-industry-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .dg-product-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  body .footer-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .values-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .split,.about-intro,.contact-grid{gap:34px}
  .team-grid{gap:26px}

  /* The header's own mobile rule hides the quote button at the menu breakpoint; tablets have room for it. */
  body .site-header .quote-btn{display:inline-block}

  /* Dynamic card grids: at most 2 per row (sliders / carousels / marquees keep their own behaviour). */
  body .dgst-dynamic-content:not([data-layout="carousel"]):not([data-layout="slider"]):not([data-layout="marquee"]):not([data-layout="list"]) .dgst-dynamic-track{
    grid-template-columns:repeat(min(var(--dgst-dyn-cols,2),2),minmax(0,1fr))!important}

  /* Shop */
  .dgp-product{gap:28px}
  .dgp-toolbar>.dgp-search,.dgp-filter-panel>*{min-width:0}
  .dgp-filter-panel{flex-wrap:wrap}
}


/* =====================================================================
   3. PHONES (<= 767px) — ONE COLUMN EVERYWHERE
   ===================================================================== */
@media(max-width:767px){

  /* ---- Page sections & grids -> 1 column ---- */
  .split,.about-intro,.director-card,.team-grid,.contact-grid,.mission-grid,.values-grid,
  .trust-strip,.dg-insight-grid,.dg-service-grid,.dg-industry-grid,.dg-product-grid,
  .asl-contact-form,.dg-checkout-form,.dg-shop-tools,.service-row,.service-row.image-right{
    grid-template-columns:minmax(0,1fr)!important}
  body .footer-grid{grid-template-columns:minmax(0,1fr)!important}

  .split,.about-intro,.contact-grid{gap:22px}
  .team-grid{gap:22px}
  .values-grid,.mission-grid{gap:16px}
  .dg-service-grid,.dg-industry-grid,.dg-insight-grid{gap:16px}
  .footer-grid{gap:26px}
  .footer-brand{grid-column:auto}
  .asl-contact-form .full,.dg-checkout-form .full{grid-column:auto}
  .dg-shop-tools input{grid-column:auto}

  /* Alternating image/text rows (Services page): image on top, text below. */
  .service-row.image-right .service-row-image,.service-row.image-right .service-row-copy{grid-column:1;grid-row:auto}
  .service-row{min-height:0}
  .service-row-image,.service-row-image img{height:190px;min-height:190px}

  /* Director card, team and about mark. */
  .director-art{min-height:135px}
  .director-copy{padding:22px}
  .about-mark{min-height:200px;padding:28px 20px}
  .team-photo{height:210px}

  /* "Why choose us" side image. */
  body .why-section .why-image{max-height:240px}

  /* ---- Dynamic card blocks (insights, services, industries, partners...) ---- */
  /* Overrides the Customizer "Mobile columns" choice as well as the inline value set by dynamic-content.js. */
  .dgst-dynamic-content{--dgst-dyn-cols:1!important;--dgst-dyn-mobile:1!important}
  .dgst-dynamic-content .dgst-dynamic-track{grid-template-columns:minmax(0,1fr)!important}

  /* ---- Shop ---- */
  .dgp-grid,.dgp-grid:not(.dgp-grid-related),.dgp-grid.dgp-grid-related{grid-template-columns:minmax(0,1fr)!important}
  .dgp-shop.is-list .dgp-card{flex-direction:column}
  .dgp-shop.is-list .dgp-media{flex:none}
  .dgp-product{grid-template-columns:minmax(0,1fr)!important;gap:26px}
  .dgp-toolbar{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px}
  .dgp-toolbar>.dgp-search{min-width:0}
  .dgp-filter-panel{display:none;grid-column:1/-1;flex-direction:column;gap:10px}
  .dgp-filter-panel>*{flex:none;min-width:0}
  .dgp-shop.is-filters-open .dgp-filter-panel{display:flex}
  body .dgp-filter-toggle{display:inline-flex}
  .dgp-views{display:none}
  .dgp-combo-panel{min-width:0}
  .dgp-info-top{flex-wrap:wrap}
  .dgp-pager{max-width:100%;overflow-x:auto}

  /* ---- Cart table -> stacked cards (no sideways scrolling) ---- */
  .dg-cart-table,.dg-cart-table tbody,.dg-cart-table tfoot,.dg-cart-table tr{display:block;width:100%}
  .dg-cart-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
  .dg-cart-table tr{border:1px solid #dce5ec;border-radius:10px;margin:0 0 12px;padding:4px 0}
  .dg-cart-table th,.dg-cart-table td{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:8px 14px;border:0;text-align:right}
  .dg-cart-table td[data-label]:before{content:attr(data-label);flex:0 0 auto;font-weight:700;text-align:left;color:var(--navy)}
  .dg-cart-table input{max-width:90px}

  /* ---- Checkout pop-ups ---- */
  body .dg-modal-overlay{padding:12px}
  body .dg-modal{width:100%;max-width:min(var(--dgco-width,520px),100%);max-height:calc(100vh - 24px);overflow-y:auto}
  body .dg-bn-form,body .dg-bn-form .dg-payment{grid-template-columns:minmax(0,1fr)}
  body .dg-bn-total,body .dg-bn-form .dg-btn-primary{grid-column:1/-1}

  /* ---- Header & top bar ---- */
  .topbar-inner{flex-wrap:wrap;gap:4px 14px;padding:7px 0}
  .top-location{margin-left:0}
  .site-header .quote-btn{display:none}
  .site-header .brand{flex:1 1 auto}
  body .site-header .brand img,body .site-header .brand .custom-logo{max-width:min(220px,52vw);max-height:40px}
  .cart-link{padding:6px 10px}
  .nav-toggle-label{font-size:12px}

  /* ---- Footer ---- */
  .footer-bottom .container{flex-direction:column;gap:8px;align-items:flex-start}

  /* ---- Buttons that must not push the page wider ---- */
  .btn{max-width:100%;white-space:normal;text-align:center}

  /* ---- Form fields stay >= 16px so iOS Safari does not zoom the page on focus (a common cause of "sideways scrolling") ---- */
  body input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=range]),
  body select,body textarea{font-size:16px!important}
}

@media(max-width:480px){
  .dgp-actions-lg{flex-direction:column}
  body .dgp-actions-lg .dgp-btn{flex:0 0 auto;width:100%}
  .dgp-thumbs{grid-template-columns:repeat(3,minmax(0,1fr))}
}
