/*
 * COMMAND 3100_064W — Structural layout contract
 * Load LAST on storefront. Cache: ?v=067
 * Geometry only. Does not restyle theme, contact dock, or type.
 */
body.cw-r2 {
  --cw-rail: 1520px;
  --cw-gutter: 1rem;
  --content-max-wide: 1520px;
  --max-width: 1520px;
  --content-max: 1520px;
}

@media (min-width: 768px) {
  body.cw-r2 { --cw-gutter: 1.5rem; }
}
@media (min-width: 1200px) {
  body.cw-r2 { --cw-gutter: 2rem; }
}

body.cw-r2 .cw-rail,
body.cw-r2 .container {
  width: min(calc(100% - (2 * var(--cw-gutter))), var(--cw-rail));
  max-width: var(--cw-rail);
  margin-inline: auto;
  padding-inline: 0;
  box-sizing: border-box;
}

/* Outer flow is full-bleed; do not trap sections in content-max */
body.cw-r2 .main-container {
  width: 100%;
  max-width: none !important;
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  padding-left: 0;
  padding-right: 0;
}

body.cw-r2 .site-header,
body.cw-r2 .main-footer,
body.cw-r2 .cw-im-hero,
body.cw-r2 .cw-hero,
body.cw-r2 .cw-r2-section,
body.cw-r2 .cw-listing-main,
body.cw-r2 .cw-listing-intro,
body.cw-r2 .cw-listing-discovery,
body.cw-r2 .cw-listing-grid-section {
  width: 100%;
  max-width: none;
}

/* Legacy theme layers add their own inline padding to the hero/sections.
   The final rail owns horizontal gutters, so outer bands must not add a second one. */
body.cw-r2 .cw-im-hero,
body.cw-r2 .cw-hero,
body.cw-r2 .cw-r2-section {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Homepage sections without .container: children sit on the rail */
body.cw-r2 .main-container > .cw-r2-section > *,
body.cw-r2 .main-container > .cw-utility-section > *,
body.cw-r2 .main-container > .cw-final-cta > * {
  width: min(calc(100% - (2 * var(--cw-gutter))), var(--cw-rail));
  max-width: var(--cw-rail);
  margin-inline: auto;
  box-sizing: border-box;
}

body.cw-r2 .cw-im-hero-grid {
  width: min(calc(100% - (2 * var(--cw-gutter))), var(--cw-rail)) !important;
  max-width: var(--cw-rail);
  margin-inline: auto;
}

body.cw-r2 .site-header .container,
body.cw-r2 .cw-g-header-inner,
body.cw-r2 .cw-header-inner {
  width: min(calc(100% - (2 * var(--cw-gutter))), var(--cw-rail)) !important;
  max-width: var(--cw-rail) !important;
  margin-inline: auto;
  padding-inline: 0 !important;
}

body.cw-r2.cw-listing-page .cw-header-inner,
body.cw-r2.cw-product-detail .cw-header-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem 1.25rem;
}
@media (max-width: 1023px) {
  body.cw-r2 .header-row-nav { display: none; }
  body.cw-r2.cw-listing-page .cw-header-inner,
  body.cw-r2.cw-product-detail .cw-header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}
body.cw-r2 .cw-g-header-inner,
body.cw-r2 .cw-header-inner {
  min-height: 122px !important;
  padding-top: 16px !important;
  padding-bottom: 16px !important;
}

body.cw-r2 #main-header {
  min-height: 127px;
}

@media (max-width: 1023px) {
  body.cw-r2 .cw-g-header-inner,
  body.cw-r2 .cw-header-inner {
    min-height: 102px !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }
  body.cw-r2 #main-header { min-height: 107px; }
  body.cw-r2.cw-product-detail .cw-header-actions > a { display: none !important; }
}

body.cw-r2.cw-product-detail .pd-wrap {
  width: min(calc(100% - (2 * var(--cw-gutter))), var(--cw-rail));
  max-width: var(--cw-rail) !important;
  margin-inline: auto;
  padding-left: 0;
  padding-right: 0;
  box-sizing: border-box;
}

/* Canonical product grid — homepage + listing */
body.cw-r2 #product-grid-list.cw-product-grid,
body.cw-r2.cw-listing-page #product-grid-main.cw-product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem;
  width: 100%;
  margin-bottom: 0;
}

/* Homepage grid is a direct section child, so it needs the rail explicitly.
   Listing already inherits the same rail from its parent .container. */
body.cw-r2 .main-container > .cw-r2-section > #product-grid-list.cw-product-grid {
  width: min(calc(100% - (2 * var(--cw-gutter))), var(--cw-rail));
  max-width: var(--cw-rail);
  margin-inline: auto;
}
@media (max-width: 1439px) {
  body.cw-r2 #product-grid-list.cw-product-grid,
  body.cw-r2.cw-listing-page #product-grid-main.cw-product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 1023px) {
  body.cw-r2 #product-grid-list.cw-product-grid,
  body.cw-r2.cw-listing-page #product-grid-main.cw-product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }
}
@media (max-width: 380px) {
  body.cw-r2 #product-grid-list.cw-product-grid,
  body.cw-r2.cw-listing-page #product-grid-main.cw-product-grid {
    grid-template-columns: 1fr;
  }
}

/* Footer: 3 markup columns, full-bleed outer, same inner rail */
body.cw-r2 .footer-grid {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1.2fr);
}
@media (max-width: 1023px) {
  body.cw-r2 .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 767px) {
  body.cw-r2 .footer-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1600px) {
  body.cw-r2 {
    --max-width: 1520px;
    --content-max: 1520px;
  }
  body.cw-r2 .container,
  body.cw-r2 .cw-g-header-inner,
  body.cw-r2 .cw-header-inner,
  body.cw-r2 .cw-im-hero-grid {
    max-width: 1520px !important;
    width: min(calc(100% - (2 * var(--cw-gutter))), 1520px) !important;
  }
}
