/* Page Header for Ministry Page */
.page-header {
  position: relative;
  padding: 6rem 0;
  text-align: center;
  color: var(--white);
  background: url('../images/ministries/ministries.jpg') no-repeat center center/cover;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-header .container {
  position: relative; /* z-index requires a position property */
  z-index: 2;
}

.page-header-overlay {
  content: '';
  position: absolute; top:0; left:0; right:0; bottom:0;
  background: rgba(44, 62, 80, 0.7); /* --primary-color with opacity */
  z-index: 1;
}

.page-header h1 {
  color: var(--white);
  font-size: 2.8rem;
}
.page-header p {
  font-size: 1.1rem;
  color: #eee;
  max-width: 600px;
  margin: 0.5rem auto 0 auto;
}

/* Main container for all ministry items */
.ministries-container {
  padding: 3rem 0;
}

/* Individual Ministry Item Section */
.ministry-item {
  padding: 4rem 1rem;  
  border-bottom: 1px solid #e0e0e0;
}

/* Alternating background color for readability */
.ministry-item:nth-child(even) {
  background-color: var(--light-gray);
}

.ministry-item:last-child {
  border-bottom: none;
}

/* Grid layout for details and gallery */
.ministry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 3rem;
  align-items: start; /* Align content columns to the top */
}

.ministry-details h2 {
  font-size: 2.2rem;
  margin-bottom: 1.5rem;
  color: var(--accent-color);
}

.ministry-details p {
  line-height: 1.7;
  margin-bottom: 2rem; /* Creates space between the text and the director card */
}

/* A simple wrapper for the gallery and its button */
.gallery-wrapper {
    width: 100%;
}

/* Director Info Card */
.director-info {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background-color: #fff;
  padding: 1.25rem;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.07);
  margin: 0;
}

.ministry-item:nth-child(even) .director-info {
   /* Ensure contrast on gray background */
   background-color: #fff;
}
.director-info img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}
.director-text h4 {
  margin: 0 0 0.25rem 0;
  color: var(--primary-color);
}
.director-text a {
  font-weight: 500;
  text-decoration: none;
}

/* Photo Gallery for Ministry */
.ministry-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.ministry-gallery img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
}

.profile-placeholder {
    font-size: 50px;
    color: #ccc;
    display: inline-block;
    width: 50px;
    height: 50px;
    text-align: center;
    line-height: 50px;
}

/* --- Carousel Styles --- */
.ministry-gallery.carousel {
  position: relative;
  overflow: hidden;
  grid-template-columns: 1fr;
}

.carousel-track {
  display: flex;
  transition: transform 0.8s ease-in-out;
}

.carousel-slide {
  width: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 0 0.5rem;
}

.ministry-gallery.carousel img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.carousel-slide:first-child { padding-left: 0; }
.carousel-slide:last-child { padding-right: 0; }

.carousel-track .carousel-slide:last-child:nth-child(odd) {
  width: 100%;
  padding-right: 0;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  background-color: rgba(0, 0, 0, 0.5);
  color: var(--white);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease, background-color 0.2s ease;
}
.ministry-gallery.carousel:hover .carousel-arrow {
  opacity: 1;
}
.carousel-arrow:hover {
  background-color: rgba(0, 0, 0, 0.7);
}
.carousel-arrow.prev { left: 1rem; }
.carousel-arrow.next { right: 1rem; }

/* --- Static Gallery Fallback --- */
.ministry-gallery:not(.carousel) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}
.ministry-gallery:not(.carousel) img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
}
.ministry-gallery:not(.carousel) img:hover {
  transform: scale(1.05);
}

/* Call-to-action link below the gallery */
.ministry-cta {
  text-align: center;
  margin-top: 1.5rem;
}

.ministry-cta a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  transition: background-color 0.2s ease;
}

.ministry-cta a:hover {
  background-color: var(--accent-color-light);
  text-decoration: none;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .ministry-item {
    padding: 3rem 0;
  }
  .ministry-details h2 {
    font-size: 1.8rem;
    text-align: center;
  }
  .ministry-grid {
    gap: 2rem;
  }
  .director-info {
    flex-direction: column;
    text-align: center;
    margin: 2rem 0;
  }
  .ministry-gallery {
    grid-template-columns: 1fr;
  }
  .ministry-gallery img {
    height: 250px;
  }
  .ministry-gallery.carousel img {
    width: 100%;
  }
  .gallery-wrapper {
    margin-top: 2rem;
  }
}