/*
  BGOP - Promo Grid
  =================
  The grid itself, plus the .promo-box rules that are module-scoped rather
  than theme-level.

  Base .promo-box styling (flex layout, .inner, .onhover-content, the hover
  transitions) comes from the theme's main.css and theme-overrides.css, which
  load on every page. Only the block below is module-scoped, so it has to be
  carried here as well as in BGOP - Promo Box. The two copies are identical;
  if both modules appear on one page the duplicate rules are harmless.
*/

.pgrid {
  display: grid;
  grid-template-columns: repeat(var(--pgrid-cols, 2), minmax(0, 1fr));
  gap: var(--pgrid-gap, 32px);
}

/* Four and three across are too tight for a card with a heading in it long
   before the mobile breakpoint, so step down rather than jumping straight
   to one column. */
@media (max-width: 1100px) {
  .pgrid {
    grid-template-columns: repeat(min(var(--pgrid-cols, 2), 2), minmax(0, 1fr));
  }
}

@media (max-width: 675px) {
  .pgrid {
    grid-template-columns: 1fr;
  }
}

/* The grid owns its own spacing, so the dnd section around it should not add
   more. Cards are grid items, never floated columns. */
.pgrid > .promo-box {
  margin: 0;
  width: auto;
  min-width: 0;
}

/* ---------- shared with BGOP - Promo Box (keep the two in step) ---------- */

.promo-box { padding: 3rem; }
.promo-box .promo-box-bg:before { background: linear-gradient(to bottom, rgba(15,15,15,0), rgba(15,15,15,.25) 100%); }
.promo-box h4 { font-family: var(--card-font); font-size: var(--font-size-card); line-height: 1.14285; margin: 0; font-weight: 800; }

.promo-box {
  box-sizing: border-box;
  border: var(--pb-border-width, 1px) solid var(--pb-border-color, rgba(0, 0, 0, .08));
  border-radius: var(--pb-radius, 16px);
}

/* The radius has to reach the background clipper and the theme's hover wash
   too, or both paint square corners over the rounded card -- on chevron
   cards especially, where the card itself is overflow:visible. */
.promo-box-clip,
.promo-box:before {
  border-radius: inherit;
}

.promo-box:before {
  width: 100%;
}

.promo-box-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
}

/* Both dark layers: the resting bottom fade and the hover wash. */
.promo-box.promo-box_noscrim .promo-box-bg:before,
.promo-box.promo-box_noscrim:before {
  display: none;
}

.promo-box .inner h4 {
  color: var(--pb-title-color, #fff);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--pb-title-color);
}

.promo-box .inner .onhover-content,
.promo-box .inner .onhover-content * {
  color: var(--pb-text-color, #fff);
}

.promo-box.promo-box_chevron {
  overflow: visible;
}

/* The icon keeps its place; the chevron is drawn behind it, so the offsets
   move the plate only. align-self stops the flex container stretching
   .cc-icon into a tall box the chevron would then centre on. */
.promo-box.promo-box_chevron .cc-icon {
  align-self: flex-start;
  flex: 0 0 auto;
  position: relative;
  display: inline-block;
  z-index: 10;
  line-height: 0;
}

.promo-box.promo-box_chevron .cc-icon::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: var(--pb-badge-w, 92px);
  height: var(--pb-badge-h, 64px);
  background: var(--pb-badge-bg, #008778);
  transform:
    translate(-50%, -50%)
    translate(var(--pb-badge-x, -10px), var(--pb-badge-y, 0px))
    rotate(var(--pb-badge-rotate, 0deg))
    skewX(var(--pb-badge-skew, -12deg));
}

.promo-box.promo-box_chevron .cc-icon img {
  display: block;
  height: auto;
  position: relative;
  width: var(--pb-badge-icon, 71px);
  z-index: 1;
}

/* Clip horizontally out at the page, not the card, so a chevron reaching
   past the card edge is never cropped. clip, not hidden: hidden would force
   the other axis to auto and create a scroll container. */
.body-container-wrapper:has(.promo-box.promo-box_chevron) {
  overflow-x: clip;
}

@supports not selector(:has(*)) {
  @media (max-width: 675px) {
    .promo-box.promo-box_chevron {
      overflow: hidden;
    }
  }
}

/* ---------- Promo Grid only: toggles ---------- */

/* Chevron off: keep the icon and its sizing, drop only the plate behind it. */
.promo-box.promo-box_nochevron .cc-icon::before {
  display: none;
}

/*
  Hover effect off. These cards don't get .promo-box_noscale, so the hover
  handlers never expand them -- but the shared mouseleave handler (bound on
  every .promo-box, possibly by Promo Box's copy of the script) still writes
  opacity:0 inline. Hence !important. The description goes into normal flow
  under the title, and the card uses min-height so it grows to fit.
*/
.promo-box.promo-box_static {
  align-content: flex-start;
  border-color: var(--pb-title-color);
}

.promo-box.promo-box_static .inner {
  margin-top: 1rem;
}

.promo-box.promo-box_static .heading-wrapper {
  transform: none !important;
}

.promo-box.promo-box_static .onhover-content {
  position: static;
  visibility: visible;
  opacity: 1 !important;
  transform: none !important;
  margin-top: 12px;
}

/*
  Mobile / small-tablet expanded state
  ------------------------------------
  Desktop is deliberately untouched: everything here sits inside the media
  query.

  On a wide card the hover mechanism is fine -- .onhover-content is absolutely
  positioned so it adds no height, and module.js slides .heading-wrapper up by
  exactly that height to make room. On a narrow card the same description
  wraps to many more lines, so the heading travels far enough up to collide
  with the icon at the top of the card.

  Below, the expanded card puts the description back in normal flow and drops
  the fixed height, so the card grows to fit instead of the heading moving.
  The !important flags are not decoration: module.js writes those transforms
  as inline styles, which a stylesheet cannot otherwise beat.

  The collapsed state is unchanged, so cards still sit at their set height
  until tapped.
*/
@media (max-width: 991px) {
  .promo-box.is-expanded {
    height: auto !important;
  }

  .promo-box.is-expanded .heading-wrapper {
    transform: none !important;
  }

  .promo-box.is-expanded .onhover-content {
    position: static;
    opacity: 1 !important;
    transform: none !important;
    margin-top: 12px;
  }
}
