/* ====================================================
   File: /handyman/css/gallery.css
   Fully replace with this code to support both pages
   ==================================================== */

/* === GALLERY SECTION === */
.gallery {
  padding: 80px 0;
  background-color: #fff;
}
.gallery .section-title {
  text-align: center;
  font-size: 2.5rem;
  color: #434343;
  margin-bottom: 40px;
  background-color: #f8d948;
  padding: 12px 0;
  width: 100%;
}

/* === COMMON GRID SETTINGS === */
.gallery-grid {
  display: grid;
  gap: 16px;
  justify-content: center;
  margin: 0 auto;
}

/* main gallery page: 5 items per row at 200px */
/* category page: 4 items per row at 260px (slightly bigger) */
@media (min-width: 900px) {
  body.gallery-main .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    max-width: calc(200px * 5 + 16px * 4);
  }
  body.gallery-category .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    max-width: calc(260px * 4 + 16px * 3);
  }
}

/* fallback single rule if you can't add body classes: */
.gallery-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  max-width: calc(260px * 4 + 16px * 3);
}

/* === GALLERY ITEM === */
.gallery-item {
  background-color: #292929;
  border: 1px solid var(--yellow);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.gallery-item:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 8px 16px rgba(255, 215, 0, 0.2);
}

/* === IMAGE STYLES === */
/* main page uses .thumb img, category page uses img.lightbox-trigger directly */
.gallery-item .thumb img,
.gallery-item > img.lightbox-trigger {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: transform 0.3s;
}
.gallery-item:hover .thumb img,
.gallery-item:hover > img.lightbox-trigger {
  transform: scale(1.05);
}

/* === TITLE BELOW IMAGE === */
.gallery-item h3 {
  margin: 12px 8px;
  font-size: 1.1rem;
  text-align: center;
  color: var(--light);
  padding: 8px 0;
  width: 100%;
  flex-shrink: 0;
}

/* === LIGHTBOX STYLES === */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  justify-content: center;
  align-items: center;
  z-index: 10000;
}
.lightbox-img {
  max-width: 90%;
  max-height: 90%;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 2.5rem;
  color: var(--yellow);
  cursor: pointer;
  user-select: none;
  z-index: 10001;
  transition: color 0.3s;
}
.lightbox-close:hover {
  color: #fff;
}

/* === RESPONSIVE ADJUSTMENTS === */
@media (max-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    max-width: calc(220px * 3 + 16px * 2);
  }
}

@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    max-width: calc(180px * 2 + 16px);
  }
}
