/* Base styles with fixed image height but flexible box height */
.page_category-projects .featured-image-button .elements-button {
  border: solid 1px var(--wp--preset--color--ar-color-primary-04);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* Changed to flex-start for better title alignment */
  align-items: stretch;
  width: 100%; /* Responsive width */
  min-height: 480px; /* Minimum height, but will expand with longer titles */
  text-align: center;
  box-sizing: border-box;
  position: relative;
  transition: all 0.3s ease;
}

.page_category-projects .featured-image-button .elements-button img {
  width: 100%;
  height: 400px; /* Fixed image height */
  -webkit-filter: grayscale(100%);
  filter: grayscale(100%);
  -o-object-fit: cover;
     object-fit: cover;
  transition: all 0.3s ease;
}

.page_category-projects .featured-image-button .elements-button img:hover {
  -webkit-filter: grayscale(0);
  filter: grayscale(0);
  transition: all 0.3s ease;
}

.page_category-projects .featured-image-button .elements-button::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 16px;
  width: calc(100% - 32px);
  height: 400px; /* Match exact image height */
  background-color: #6F8BFF;
  opacity: 0.2;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.page_category-projects .featured-image-button .elements-button:hover::after {
  opacity: 0;
  -webkit-filter: grayscale(0);
  filter: grayscale(0);
}

.page_category-projects .featured-image-button h2 {
  margin: 16px 0 0 0; /* Added top margin to separate from image */
  padding: 0 8px;
  font-size: 24px;
  line-height: 32px;
  font-family: 'Trench Slab Variable', serif;
  font-weight: 300;
  color: var(--wp--preset--color--ar-color-secondary-05);
  min-height: 40px; /* Minimum height, but will expand */
  display: flex;
  justify-content: center;
  align-items: center;
  word-wrap: break-word;
  text-decoration: none;
  transition: all 0.3s ease;
}

/* Grid layout for the featured posts container */
.page_category-projects .featured-posts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  width: 100%;
  max-width: 1700px;
  margin: 0 auto;
}

/* Media query for larger screens */
@media (min-width: 1300px) {
  .page_category-projects .featured-posts {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1700px;
    margin: 0 auto;
  }
  
  .page_category-projects .featured-image-button .elements-button {
    max-width: 520px;
    margin: 0 auto;
  }
}

/* Media query for medium screens */
@media (max-width: 1200px) {
  .page_category-projects .featured-posts {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Media query for mobile screens */
@media (max-width: 768px) {
  .page_category-projects .featured-posts {
    grid-template-columns: 1fr;
  }
  
  .page_category-projects .featured-image-button .elements-button img {
    height: 370px; /* Slightly smaller on mobile */
  }
  
  .page_category-projects .featured-image-button .elements-button::after {
    height: 370px; /* Match mobile image height */
  }
  
  .page_category-projects .featured-image-button h2 {
    font-size: 20px;
    line-height: 28px;
  }
}

/***************************/
/* Also for the Front Page */
/***************************/
.page_category-home .featured-image-button .elements-button {
  border: solid 1px var(--wp--preset--color--ar-color-primary-04);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* Changed to flex-start for better title alignment */
  align-items: stretch;
  width: 100%; /* Responsive width */
  min-height: 480px; /* Minimum height, but will expand with longer titles */
  text-align: center;
  box-sizing: border-box;
  position: relative;
  transition: all 0.3s ease;
}

.page_category-home .featured-image-button .elements-button img {
  width: 100%;
  height: 400px; /* Fixed image height */
  -webkit-filter: grayscale(100%);
  filter: grayscale(100%);
  -o-object-fit: cover;
     object-fit: cover;
  transition: all 0.3s ease;
}

.page_category-home .featured-image-button .elements-button img:hover {
  -webkit-filter: grayscale(0);
  filter: grayscale(0);
  transition: all 0.3s ease;
}

.page_category-home .featured-image-button .elements-button::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 16px;
  width: calc(100% - 32px);
  height: 400px; /* Match exact image height */
  background-color: #6F8BFF;
  opacity: 0.2;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.page_category-home.featured-image-button .elements-button:hover::after {
  opacity: 0;
  -webkit-filter: grayscale(0);
  filter: grayscale(0);
}

.page_category-home .featured-image-button h2 {
  margin: 16px 0 0 0; /* Added top margin to separate from image */
  padding: 0 8px;
  font-size: 24px;
  line-height: 32px;
  font-family: 'Trench Slab Variable', serif;
  font-weight: 300;
  color: var(--wp--preset--color--ar-color-secondary-05);
  min-height: 40px; /* Minimum height, but will expand */
  display: flex;
  justify-content: center;
  align-items: center;
  word-wrap: break-word;
  text-decoration: none;
  transition: all 0.3s ease;
}

/* Grid layout for the featured posts container */
.page_category-home .featured-posts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  width: 100%;
  max-width: 1700px;
  margin: 0 auto;
}

/* Media query for larger screens */
@media (min-width: 1300px) {
  .page_category-home .featured-posts {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1700px;
    margin: 0 auto;
  }
  
  .page_category-home .featured-image-button .elements-button {
    max-width: 520px;
    margin: 0 auto;
  }
}

/* Media query for medium screens */
@media (max-width: 1200px) {
  .page_category-home .featured-posts {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Media query for mobile screens */
@media (max-width: 768px) {
  .page_category-home .featured-posts {
    grid-template-columns: 1fr;
  }
  
  .page_category-home .featured-image-button .elements-button img {
    height: 370px; /* Slightly smaller on mobile */
  }
  
  .page_category-home .featured-image-button .elements-button::after {
    height: 370px; /* Match mobile image height */
  }
  
  .page_category-home .featured-image-button h2 {
    font-size: 20px;
    line-height: 28px;
  }
}