/* =========================================
   IMAGE BOX GRID: Heading Over Image + Overlay
   Apply .heading-on-image to the GRID container
========================================= */

/* Grid container */
.heading-on-image{
  position: relative;
}

/* Elementor container grid: let rows size to content */
.heading-on-image .e-con-inner{
  --e-con-grid-template-rows: unset !important;
  grid-template-rows: unset !important;
  grid-auto-rows: auto !important;
}

/* Each grid item: avoid stretch artifacts */
.heading-on-image .e-con-inner > *{
  align-self: start !important;
}

/* Each Image Box widget */
.heading-on-image .elementor-widget-image-box{
  position: relative;
  cursor: pointer;
}

/* Wrapper: positioning context (no background showing through) */
.heading-on-image .elementor-widget-image-box .elementor-image-box-wrapper{
  position: relative;
  background: transparent !important;
}

/* Image wrapper (figure): consistent height + no default figure gap */
.heading-on-image .elementor-widget-image-box .elementor-image-box-img{
  position: relative;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 0 !important;
  aspect-ratio: 4 / 3;           /* adjust if needed */
  overflow: hidden;
}

/* Image fills the figure */
.heading-on-image .elementor-widget-image-box .elementor-image-box-img img{
  display: block !important;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Overlay on the image area only */
.heading-on-image .elementor-widget-image-box .elementor-image-box-img::before{
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  transition: background 0.3s ease;
  z-index: 2;
  pointer-events: none;
}

.heading-on-image .elementor-widget-image-box:hover .elementor-image-box-img::before{
  background: rgba(0,0,0,0.15);
}

/* Content over the image */
.heading-on-image .elementor-widget-image-box .elementor-image-box-content{
  position: absolute;
  left: 0;
  right: 0;
  bottom: 40px;
  z-index: 3;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none; /* hover triggers on the whole card */
}

/* Title style + hover motion */
.heading-on-image .elementor-widget-image-box .elementor-image-box-title{
  position: relative;
  z-index: 4;
  color: #ffffff !important;
  font-size: 18px;
  text-transform: uppercase;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.heading-on-image .elementor-widget-image-box:hover .elementor-image-box-title{
  transform: translateY(-3px);
  opacity: 1;
}


/* Prevent stray spacing inside the wrapper by limiting the parent line height */

.heading-on-image .elementor-widget-image-box { line-height: 0; }

/* Restore normal line-height for the title (and any text you might add later) */
.heading-on-image .elementor-widget-image-box .elementor-image-box-title{
  line-height: 1.2;
}

.heading-on-image .elementor-widget-image-box .elementor-image-box-description{
  line-height: 1.4;
}



/* =========================================
   Center incomplete last row (4-column grid)
   Uses :has() (modern browsers)
========================================= */

/* 1 item on last row → center it (cols 2–3) */
.heading-on-image .e-con-inner:has(> :nth-last-child(1):nth-child(4n+1)) > :last-child{
  grid-column: 2 / span 2;
}

/* 2 items on last row → place them in cols 2 and 3 */
.heading-on-image .e-con-inner:has(> :nth-last-child(2):nth-child(4n+1)) > :nth-last-child(2){
  grid-column: 2;
}
.heading-on-image .e-con-inner:has(> :nth-last-child(2):nth-child(4n+1)) > :last-child{
  grid-column: 3;
}

/* 3 items on last row → shift right by one (cols 2,3,4) */
.heading-on-image .e-con-inner:has(> :nth-last-child(3):nth-child(4n+1)) > :nth-last-child(3){
  grid-column: 2;
}


/* =========================================
   Responsive last-row centering
   Adjust breakpoints if your layout differs
========================================= */

/* ---------- 4 columns (desktop) ---------- */
@media (min-width: 1025px){

  /* 1 item → center (cols 2–3) */
  .heading-on-image .e-con-inner:has(> :nth-last-child(1):nth-child(4n+1)) > :last-child{
    grid-column: 2 / span 2;
  }

  /* 2 items → cols 2 and 3 */
  .heading-on-image .e-con-inner:has(> :nth-last-child(2):nth-child(4n+1)) > :nth-last-child(2){
    grid-column: 2;
  }
  .heading-on-image .e-con-inner:has(> :nth-last-child(2):nth-child(4n+1)) > :last-child{
    grid-column: 3;
  }

  /* 3 items → shift right (cols 2,3,4) */
  .heading-on-image .e-con-inner:has(> :nth-last-child(3):nth-child(4n+1)) > :nth-last-child(3){
    grid-column: 2;
  }
}

/* ---------- 3 columns (tablet landscape / small desktop) ---------- */
@media (min-width: 868px) and (max-width: 1024px){

  /* 1 item → center (col 2) */
  .heading-on-image .e-con-inner:has(> :nth-last-child(1):nth-child(3n+1)) > :last-child{
    grid-column: 2;
  }

  /* 2 items → cols 2 and 3 (looks best in a 3-col grid) */
  .heading-on-image .e-con-inner:has(> :nth-last-child(2):nth-child(3n+1)) > :nth-last-child(2){
    grid-column: 2;
  }
  .heading-on-image .e-con-inner:has(> :nth-last-child(2):nth-child(3n+1)) > :last-child{
    grid-column: 3;
  }
}


/* =========================================
   Mobile hard reset
========================================= */
@media (max-width: 767px){

  .heading-on-image .e-con-inner{
    --e-con-grid-template-columns: 1fr !important;
    grid-template-columns: 1fr !important;
    --e-con-grid-template-rows: unset !important;
    grid-template-rows: none !important;
    grid-auto-rows: auto !important;
  }

  .heading-on-image .e-con-inner > *{
    grid-column: auto !important;
  }

  .heading-on-image .elementor-widget-image-box{
    line-height: 0;
  }


.heading-on-image .elementor-widget-image-box .elementor-image-box-content{
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0 !important;
  padding: 0 12px !important;
  width: max-content;
  max-width: calc(100% - 30px);
  text-align: center;
  pointer-events: none;
}

.heading-on-image .elementor-widget-image-box .elementor-image-box-title{
  display: block;
  margin: 0;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  text-align: center;
}
  
  
}



/* ---------- 1 column (mobile) ---------- */
/* Nothing needed — single column is inherently centered */



