/* ==========================================================================
   TankAndBarrel.com - "Optional Accessories" + "Customers Also Purchased" (tb_related)
   2026-11-27  -  CSS only. Same links, same names, same alt text, same images.
   Scoped to the two containers only:
     #cm_pi_xsell      (Optional Accessories, cm_sc_xsell_in_cart module)
     .also-purchased   (Customers Also Purchased)
   Neither section has a checkbox, quantity box or button - each card is just
   an image link, a name link, the part number and a price - so nothing about
   add to cart or checkout is touched.

   What it does
   - Real card grid (CSS grid): 4 across on desktop, 3 across on tablets,
     2 across on phones. Short rows keep the same card width instead of
     stretching one or two cards across the page.
   - Every card is the same height: fixed-height photo well with
     object-fit: contain, name clamped to 4 lines (5 on phones) so size/dimension text is not cut, part number under the name,
     price pinned to the bottom, then a "View details" button.
   - Whole card is clickable (the name link is stretched over the card).
   - Heading gets the brand-blue accent in place of the default pure-blue text.
   ========================================================================== */

/* ---- section wrapper + heading ---- */
#cm_pi_xsell,
.also-purchased {
  margin-top: 26px;
  margin-bottom: 18px;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#cm_pi_xsell > font,
.also-purchased > font,
form[name="cart_quantity"] .col-sm-12.reviews > h3 > font,
.col-sm-12.reviews > h3 > font {
  display: block;
  color: #13253a !important;
}

#cm_pi_xsell > font > h3,
.also-purchased > font > h3,
#cm_pi_xsell > h3,
.also-purchased > h3,
form[name="cart_quantity"] .col-sm-12.reviews > h3,
.col-sm-12.reviews > h3 {
  margin: 0 0 14px !important;
  padding: 2px 0 2px 12px;
  border-left: 4px solid #1f3a93;
  font-size: 22px !important;
  font-weight: 700;
  line-height: 1.2;
  color: #13253a !important;
}

/* ---- the grid ---- */
#cm_pi_xsell > .row,
.also-purchased > .row {
  display: -ms-grid;
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0 !important;
  padding: 0;
}

/* Bootstrap's clearfix pseudo-elements would otherwise become grid items */
#cm_pi_xsell > .row::before,
#cm_pi_xsell > .row::after,
.also-purchased > .row::before,
.also-purchased > .row::after {
  content: none !important;
  display: none !important;
}

#cm_pi_xsell > .row > [class*="col-"],
.also-purchased > .row > [class*="col-"] {
  display: -webkit-flex;
  display: flex;
  float: none;
  width: auto !important;
  min-width: 0;
  margin: 0;
  padding: 0;
}

/* ---- the card ---- */
#cm_pi_xsell .thumbnail,
.also-purchased .thumbnail {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
          flex-direction: column;
  -webkit-flex: 1 1 auto;
          flex: 1 1 auto;
  position: relative;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  margin: 0;
  padding: 0;
  background: #fff;
  border: 1px solid #e3e8ee;
  border-radius: 8px;
  -webkit-box-shadow: 0 1px 3px rgba(19, 37, 58, .06);
          box-shadow: 0 1px 3px rgba(19, 37, 58, .06);
  overflow: hidden;
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
  -webkit-transition: border-color .15s ease, box-shadow .15s ease;
          transition: border-color .15s ease, box-shadow .15s ease;
}

#cm_pi_xsell .thumbnail:hover,
#cm_pi_xsell .thumbnail:focus-within,
.also-purchased .thumbnail:hover,
.also-purchased .thumbnail:focus-within {
  border-color: #1f3a93;
  -webkit-box-shadow: 0 6px 16px rgba(19, 37, 58, .13);
          box-shadow: 0 6px 16px rgba(19, 37, 58, .13);
}

/* ---- photo well: same size for every card, never cropped ---- */
#cm_pi_xsell .thumbnail > a:first-child,
.also-purchased .thumbnail > a:first-child {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
          align-items: center;
  -webkit-justify-content: center;
          justify-content: center;
  -webkit-flex: 0 0 170px;
          flex: 0 0 170px;
  width: 100%;
  height: 170px;
  padding: 14px 14px 6px;
  background: #fff;
  overflow: hidden;
  line-height: 0;
  font-size: 12px;
  color: #5b6b7d;
  text-decoration: none;
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
}

#cm_pi_xsell .thumbnail > a:first-child img,
.also-purchased .thumbnail > a:first-child img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  object-fit: contain;
  object-position: center;
}

/* ---- caption: name, part number, price, button ---- */
#cm_pi_xsell .thumbnail .caption,
.also-purchased .thumbnail .caption {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
          flex-direction: column;
  -webkit-flex: 1 1 auto;
          flex: 1 1 auto;
  padding: 6px 14px 14px;
  text-align: left;
}

#cm_pi_xsell .thumbnail .caption > hr,
.also-purchased .thumbnail .caption > hr {
  display: none;
}

#cm_pi_xsell .thumbnail .caption > p,
.also-purchased .thumbnail .caption > p {
  margin: 0;
  text-align: left !important;
}

/* name */
#cm_pi_xsell .thumbnail .caption > p:first-of-type,
.also-purchased .thumbnail .caption > p:first-of-type {
  margin-bottom: 4px;
}

#cm_pi_xsell .thumbnail .caption > p:first-of-type a,
.also-purchased .thumbnail .caption > p:first-of-type a {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: #13253a;
  text-decoration: none;
}

/* stretch the name link over the whole card: one big click target */
#cm_pi_xsell .thumbnail .caption > p:first-of-type a::after,
.also-purchased .thumbnail .caption > p:first-of-type a::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
}

#cm_pi_xsell .thumbnail:hover .caption > p:first-of-type a,
#cm_pi_xsell .thumbnail:focus-within .caption > p:first-of-type a,
.also-purchased .thumbnail:hover .caption > p:first-of-type a,
.also-purchased .thumbnail:focus-within .caption > p:first-of-type a {
  color: #1f3a93;
}

#cm_pi_xsell .thumbnail .caption > p:first-of-type a:focus,
.also-purchased .thumbnail .caption > p:first-of-type a:focus {
  outline: none;
}

#cm_pi_xsell .thumbnail:focus-within,
.also-purchased .thumbnail:focus-within {
  outline: 2px solid #1f3a93;
  outline-offset: 2px;
}

/* part number */
#cm_pi_xsell .thumbnail .caption > p:nth-of-type(2),
.also-purchased .thumbnail .caption > p:nth-of-type(2) {
  margin-bottom: 10px;
}

#cm_pi_xsell .thumbnail .caption > p:nth-of-type(2) strong,
.also-purchased .thumbnail .caption > p:nth-of-type(2) strong {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .02em;
  color: #5b6b7d;
}

/* price: last paragraph, pinned to the bottom so every card lines up */
#cm_pi_xsell .thumbnail .caption > p:last-of-type,
.also-purchased .thumbnail .caption > p:last-of-type {
  margin-top: auto;
  padding-bottom: 12px;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
  color: #1f3a93;
}

/* if a card ever has only a name and a price, the name still sits on top */
#cm_pi_xsell .thumbnail .caption > p:first-of-type:last-of-type,
.also-purchased .thumbnail .caption > p:first-of-type:last-of-type {
  margin-top: 0;
  padding-bottom: 0;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

/* button (visual only: the whole card is the link) */
#cm_pi_xsell .thumbnail .caption::after,
.also-purchased .thumbnail .caption::after {
  content: "View details";
  display: block;
  padding: 9px 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  color: #fff;
  background: #1f3a93;
  border-radius: 6px;
  -webkit-transition: background-color .15s ease;
          transition: background-color .15s ease;
}

#cm_pi_xsell .thumbnail:hover .caption::after,
#cm_pi_xsell .thumbnail:focus-within .caption::after,
.also-purchased .thumbnail:hover .caption::after,
.also-purchased .thumbnail:focus-within .caption::after {
  background: #162b70;
}

/* a card with no photo link at all: keep the same height with a quiet placeholder */
#cm_pi_xsell .thumbnail > .caption:first-child::before,
.also-purchased .thumbnail > .caption:first-child::before {
  content: "";
  display: block;
  -webkit-flex: 0 0 150px;
          flex: 0 0 150px;
  margin: 8px 0 12px;
  background: #f3f5f8;
  border-radius: 6px;
}

/* --------------------------------------------------------------------------
   Tablet (768-991): 3 across
   -------------------------------------------------------------------------- */
@media (min-width: 768px) and (max-width: 991px) {
  #cm_pi_xsell > .row,
  .also-purchased > .row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* --------------------------------------------------------------------------
   Phone (up to 767): 2 across, tighter cards
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  #cm_pi_xsell,
  .also-purchased {
    margin-top: 20px;
  }

  #cm_pi_xsell > font > h3,
  .also-purchased > font > h3,
  #cm_pi_xsell > h3,
  .also-purchased > h3,
  form[name="cart_quantity"] .col-sm-12.reviews > h3,
  .col-sm-12.reviews > h3 {
    font-size: 19px !important;
    margin-bottom: 12px !important;
  }

  #cm_pi_xsell > .row,
  .also-purchased > .row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #cm_pi_xsell .thumbnail > a:first-child,
  .also-purchased .thumbnail > a:first-child {
    -webkit-flex-basis: 128px;
            flex-basis: 128px;
    height: 128px;
    padding: 10px 10px 4px;
  }

  #cm_pi_xsell .thumbnail .caption,
  .also-purchased .thumbnail .caption {
    padding: 4px 10px 10px;
  }

  #cm_pi_xsell .thumbnail .caption > p:first-of-type a,
  .also-purchased .thumbnail .caption > p:first-of-type a {
    -webkit-line-clamp: 5; /* part-size names like (23" H x 12" D) must not be cut off */
    font-size: 13.5px;
    line-height: 1.3;
  }

  #cm_pi_xsell .thumbnail > .caption:first-child::before,
  .also-purchased .thumbnail > .caption:first-child::before {
    -webkit-flex-basis: 110px;
            flex-basis: 110px;
  }

  #cm_pi_xsell .thumbnail .caption > p:nth-of-type(2),
  .also-purchased .thumbnail .caption > p:nth-of-type(2) {
    margin-bottom: 8px;
  }

  #cm_pi_xsell .thumbnail .caption > p:nth-of-type(2) strong,
  .also-purchased .thumbnail .caption > p:nth-of-type(2) strong {
    font-size: 11.5px;
  }

  #cm_pi_xsell .thumbnail .caption > p:last-of-type,
  .also-purchased .thumbnail .caption > p:last-of-type {
    padding-bottom: 10px;
    font-size: 18px;
  }

  #cm_pi_xsell .thumbnail .caption::after,
  .also-purchased .thumbnail .caption::after {
    padding: 9px 8px;
    font-size: 13px;
  }
}
