/* Variant Energo — adaptive layouts v12.
   Narrow viewport means less room, not necessarily a telephone. Keep the
   explicitly selected Phone mode, its menu and its 80% zoom untouched.
   Loaded after site.css, mobile-layout and the previous refinements. */

/* All public pages, cabinets and admin panels must fit the available width;
   do not change desktop text alignment or scale the entire site. */
html,body { min-width:0; }
body,body > .site-page,main.wrap { max-width:100%; }
.wrap { width:100%; min-width:0; }
main.wrap,main.wrap > *, .site-page, .grid > *, .two > *,
.layout > *, .catalog-detail-layout > *, .showcase-detail-layout > *,
.product-detail-layout > *, .request-contact-layout > * { min-width:0; }
main :is(img,video,canvas) { max-width:100%; }
main :is(.card,.panel,.equipment-tile,.catalog-product-tile,.catalog-card,
         .admin-product-picker-tile,.detail-description) { overflow-wrap:anywhere; }
main :is(input,select,textarea) { max-width:100%; }
.tablewrap { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
/* Leave intentionally wide tables scrollable, rather than squeeze columns. */
@media (max-width:760px) {
  main.wrap > table { display:block; max-width:100%; overflow-x:auto; }
}

/* The existing site.css forces the navigation to a second line below 1540px.
   A standard 1366px laptop still has room if the nav uses natural item widths.
   Do NOT apply this to user-selected phone mode or its pop-up menus. */
@media (min-width:1240px) {
  html:not([data-site-version="phone"]) .site-header .head {
    display:grid;
    grid-template-columns:minmax(124px,150px) minmax(195px,232px) minmax(0,1fr);
    grid-template-rows:auto;
    column-gap:clamp(10px,1.2vw,18px);
    row-gap:10px;
    align-items:center;
  }
  html:not([data-site-version="phone"]) .site-header .header-contacts {
    grid-column:1;
    grid-row:1;
    min-width:0;
    justify-self:start;
  }
  html:not([data-site-version="phone"]) .site-header .brand.brand-lockup {
    grid-column:2;
    grid-row:1;
    width:auto;
    max-width:100%;
    min-width:0;
    justify-self:start;
  }
  html:not([data-site-version="phone"]) .site-header nav {
    grid-column:3;
    grid-row:1;
    display:flex;
    justify-content:flex-end;
    align-items:center;
    flex-wrap:nowrap;
    column-gap:clamp(5px,.7vw,11px);
    row-gap:8px;
    min-width:0;
  }
  html:not([data-site-version="phone"]) .site-header nav a.nav-link,
  html:not([data-site-version="phone"]) .site-header nav a.nav-link[href] {
    width:auto!important;
    flex:0 1 auto!important;
    min-width:0;
    white-space:nowrap;
  }
}

/* On smaller laptops and with 125–150% browser zoom, use a deliberately
   balanced two-row header, rather than a left-clustered broken first row. */
@media (min-width:641px) and (max-width:1239px) {
  html:not([data-site-version="phone"]) .site-header .head {
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    grid-template-rows:auto auto;
    align-items:center;
    row-gap:13px;
  }
  html:not([data-site-version="phone"]) .site-header .header-contacts {
    grid-column:1;
    grid-row:1;
    justify-self:start;
    min-width:0;
  }
  html:not([data-site-version="phone"]) .site-header .brand.brand-lockup {
    grid-column:2;
    grid-row:1;
    justify-self:end;
    justify-content:flex-end;
    width:auto;
    min-width:0;
    max-width:100%;
  }
  html:not([data-site-version="phone"]) .site-header nav {
    grid-column:1 / -1;
    grid-row:2;
    display:flex;
    justify-content:center;
    align-items:center;
    flex-wrap:wrap;
    min-width:0;
    width:100%;
    column-gap:clamp(8px,1.2vw,15px);
    row-gap:7px;
  }
}

/* A desktop-mode browser at unusually small logical widths (including
   strong browser zoom) must not require horizontal page scrolling. */
@media (max-width:640px) {
  html:not([data-site-version="phone"]) .site-header .head {
    width:100%;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    row-gap:12px;
  }
  html:not([data-site-version="phone"]) .site-header .header-contacts {
    grid-column:1;
    grid-row:1;
    min-width:0;
  }
  html:not([data-site-version="phone"]) .site-header .header-contacts a {
    white-space:normal;
    overflow-wrap:anywhere;
  }
  html:not([data-site-version="phone"]) .site-header .brand.brand-lockup {
    grid-column:2;
    grid-row:1;
    justify-self:end;
    width:auto;
    max-width:100%;
    min-width:0;
  }
  html:not([data-site-version="phone"]) .site-header nav {
    grid-column:1 / -1;
    grid-row:2;
    justify-content:center;
    width:100%;
    flex-wrap:wrap;
    gap:5px 10px;
  }
  html:not([data-site-version="phone"]) .site-header nav a.nav-link,
  html:not([data-site-version="phone"]) .site-header nav a.nav-link[href] {
    width:auto!important;
    flex:0 1 auto!important;
  }
}

/* Responsive content: do not shrink typography or distort photographs. */
@media (min-width:761px) and (max-width:1100px) {
  .home-page .home-equipment-section .equipment-grid,
  .home-page .home-goods-section .goods-showcase-grid,
  .catalog-product-grid,
  .admin-product-picker-grid {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .request-contact-layout { column-gap:clamp(18px,2.5vw,30px); }
}
@media (max-width:760px) {
  .site-page .wrap { min-width:0; }
  .product-detail-layout,.catalog-detail-layout,.showcase-detail-layout {
    grid-template-columns:minmax(0,1fr);
  }
  .catalog-filter-groups { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .admin-product-picker-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:580px) {
  .catalog-filter-groups,
  .admin-product-picker-grid,
  .request-contact-layout,
  .request-identity-fields { grid-template-columns:minmax(0,1fr); }
  .actions,.cart-summary,.pagination { max-width:100%; }
  .footer-grid > * { min-width:0; }
}
/* The chosen mobile mode always keeps one product/category per row, including
   when someone forces Phone on a wide desktop monitor. */
html[data-site-version="phone"] :is(
  .catalog-product-grid,.catalog-directions,.catalog-filter-groups,
  .equipment-grid,.admin-product-picker-grid
) { grid-template-columns:minmax(0,1fr)!important; }
