/* Unified style.css for Temple Methodist Church site
   This file aims to be robust across the slightly different HTML variants
   you've been using (ministry-grid / ministries-grid / grid / carousel etc.)
*/
:root{
  --methodist-red: #C8102E;
  --max-page-width: 1200px;
  --gutter: 20px;
  --font-main: "Segoe UI", Roboto, Arial, sans-serif;
}
*{box-sizing: border-box}
html,body{
  margin:0;
  padding:0;
  font-family: var(--font-main);
  background:#ffffff;
  color:#333;
}
/* ===== Carousel (common) ===== */
.carousel, header.carousel {
  width: 100%;
  overflow: hidden;
  background: #000;
  position: relative;
  height: 350px;
}
/* Track setup */
.carousel-track, .carousel .carousel-track {
  position: relative;
  width: 100%;
  height: 100%;
  animation: none;
  will-change: auto;
}
/* Pause on hover */
.carousel:hover .carousel-track img, header.carousel:hover .carousel-track img {
  animation-play-state: paused;
}
/* Image setup */
.carousel-track img, .carousel img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  will-change: opacity;
}
/* Fade animation (assuming 4 slides; adjust nth-child and delays if different) */
@keyframes fade {
  0% { opacity: 0; }
  6.25% { opacity: 1; } /* Fade-in end (1s / 16s) */
  25% { opacity: 1; } /* Hold end (3s / 16s) */
  31.25% { opacity: 0; } /* Fade-out end (4s / 16s) */
  100% { opacity: 0; }
}
.carousel-track img:nth-child(1), .carousel img:nth-child(1) {
  animation: fade 16s linear infinite;
}
.carousel-track img:nth-child(2), .carousel img:nth-child(2) {
  animation: fade 16s linear infinite 4s;
}
.carousel-track img:nth-child(3), .carousel img:nth-child(3) {
  animation: fade 16s linear infinite 8s;
}
.carousel-track img:nth-child(4), .carousel img:nth-child(4) {
  animation: fade 16s linear infinite 12s;
}
/* Shorter variant */
header.carousel.shorter .carousel-track img,
.carousel.shorter .carousel-track img,
.carousel.shorter img {
  height: 100%;
}
/* ===== Logo (various naming conventions supported) ===== */
.logo, .logo-section, .title-logo, .church-logo, .church-logo img {
  text-align:center;
}
.logo img, .logo-section img, .title-logo img, .church-logo{
  display:block;
  margin: 24px auto 0;
  width:80%;
  max-width:900px;
  height:auto;
  animation: fadeIn 2s ease-in-out;
}
/* Small variations */
.logo.fade-in img, .fade-in img { animation: fadeIn 1.6s ease-in-out; }
@keyframes fadeIn{
  from{ opacity:0; transform: translateY(10px); }
  to{ opacity:1; transform: translateY(0); }
}
/* ===== Intro / divider ===== */
.intro, .intro-text, .church-subtitle {
  text-align:center;
  color:var(--methodist-red);
  max-width:800px;
  margin: 16px auto 24px;
  padding: 0 16px;
}
.divider, hr.divider {
  border:0;
  height:2px;
  background:var(--methodist-red);
  width:80%;
  margin:24px auto;
}
/* ===== Grid (homepage) - support multiple class names ===== */
.ministry-grid, .ministries-grid, .grid, .grid-container {
  max-width: var(--max-page-width);
  margin: 0 auto 48px;
  padding: 0 16px;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gutter);
}
@media (max-width:1000px){
  .ministry-grid, .ministries-grid, .grid, .grid-container {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width:600px){
  .ministry-grid, .ministries-grid, .grid, .grid-container {
    grid-template-columns: 1fr;
  }
}
/* grid-item styling and compatibility */
.grid-item, .ministries-grid .grid-item, .ministry-grid .grid-item {
  position:relative;
  width:100%;
  aspect-ratio: 1 / 1;
  overflow:hidden;
  border-radius:8px;
  display:block;
  background:#eee;
  cursor: pointer; /* Added for clickability */
}
/* Focus styles for accessibility */
.grid-item:focus {
  outline: 2px solid var(--methodist-red);
}
/* If inner <a> used, allow both patterns */
.grid-item a, .grid-item > a, .grid-item > img, .grid-item img {
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
}
/* Ensure the image inside inside link covers the square */
.grid-item img {
  width:100%;
  height:100%;
  object-fit:cover;
  transition: transform 0.35s ease;
}
.grid-item:hover img { transform: scale(1.05); }
/* Overlay label (supports <span> overlay or .overlay div) */
.grid-item span, .grid-item .overlay, .grid-item > .overlay {
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(200,16,46,0.72);
  color:#fff;
  opacity:0;
  transition: opacity 0.25s ease;
  padding:12px;
  text-align:center;
  font-weight:600;
  font-size:1.15rem;
  border-radius:8px;
  line-height:1.1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5); /* Added for better readability */
}
.grid-item:hover span, .grid-item:hover .overlay { opacity:1; }
/* ===== Content section for subpages (namespaced) ===== */
.page-content.wesleys .content-section,
.page-content.wesleys .content-section,
.wesleys .content-section,
.content-section {
  display:flex;
  gap:30px;
  align-items:flex-start;
  justify-content:center;
  flex-wrap:wrap;
  max-width: var(--max-page-width);
  margin: 28px auto;
  padding: 0 16px;
}
.content-section img, .wesleys .cafe-photo, .cafe-photo {
  max-width:420px;
  width:100%;
  padding:10px;
  border-radius:8px;
  object-fit:cover;
}
.content-text, .text-content, .cafe-text {
  flex:1;
  min-width: 280px;
  text-align:justify;
  line-height:1.6;
  color:#333;
}
/* Footer logos and back link general styles */
.footer-logo img, .launchpad-logo, .footer-logo img {
  display:block;
  margin:40px auto 10px;
  max-width:320px;
  width:60%;
}
.back-link a, .back-home a, a.back-link {
  color: var(--methodist-red);
  text-decoration:none;
  font-weight:600;
}
.back-link a:hover, .back-home a:hover, a.back-link:hover { text-decoration:underline; }
/* Utility: center sections */
.center { text-align:center; }
/* Make sure forms of shorter carousel handled */
.carousel.shorter, header.carousel.shorter { height:300px; }
.carousel.shorter img, header.carousel.shorter img { height:100%; object-fit:cover; }
/* Small screens adjust */
@media (max-width:768px){
  .carousel, header.carousel { height:200px; }
  .content-section { padding:0 12px; }
  .grid-item span, .grid-item .overlay { font-size:1rem; padding:8px; }
}
/* Extra adjustment for very small screens (logo size) */
@media (max-width:480px) {
  .church-logo {
    width: 90%;
  }
}
/* ===== New Modal Styles ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease-in-out; /* Smoother easing for both in and out */
}
.modal-content {
  background-color: #fff;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 90%;
  max-width: var(--max-page-width);
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  border-radius: 8px;
}
.close {
  position: absolute;
  top: 10px;
  right: 20px;
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}
.close:hover {
  color: black;
}
/* Ensure loaded content inherits your styles */
#modalBody {
  /* Add any overrides if needed, e.g., remove margins from loaded body */
  margin: 0;
  padding: 0;
}
/* For small screens */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    padding: 15px;
  }
}

/* ===== Timetable Styles ===== */
.timetable {
  width: 100%;
  max-width: 800px;
  margin: 20px auto;
  border-collapse: collapse;
  font-family: var(--font-main);
  color: #333;
}

.timetable th,
.timetable td {
  border: 1px solid #ddd;
  padding: 12px;
  text-align: left;
}

.timetable th {
  background-color: #f2f2f2;
  color: var(--methodist-red);
  font-weight: 600;
}

.timetable tr:nth-child(even) {
  background-color: #f9f9f9;
}

.timetable tr:hover {
  background-color: #f1f1f1;
}

@media (max-width: 768px) {
  .timetable {
    font-size: 0.9rem;
  }
  .timetable th,
  .timetable td {
    padding: 8px;
  }
}