/* ===== IMAGE GALLERY ===== */
.gallery {
  max-width: 820px;
  margin: 40px auto 0;
  padding: 0 16px;
  box-sizing: border-box;
}
.gallery-heading {
  font-family: 'Special Elite', 'Times New Roman', Times, serif;
  font-weight: 400;
  letter-spacing: .02em;
  font-size: 24px;
  text-align: center;
  margin: 0 0 20px;
  color: var(--color-text);
}

/* Thumbnail grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.gallery-thumb {
  position: relative;
  display: block;
  padding: 0;
  border: 1px solid var(--color-border);
  background: var(--color-card-bg);
  cursor: pointer;
  overflow: hidden;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease;
}
/* Organic border-radius */
.gallery-thumb:nth-child(1) { border-radius: 20px 16px 18px 14px; }
.gallery-thumb:nth-child(2) { border-radius: 14px 20px 16px 18px; }
.gallery-thumb:nth-child(3) { border-radius: 18px 14px 20px 16px; }
.gallery-thumb:nth-child(4) { border-radius: 16px 18px 14px 20px; }
.gallery-thumb:nth-child(5) { border-radius: 20px 14px 16px 18px; }
.gallery-thumb:nth-child(6) { border-radius: 14px 16px 20px 18px; }
.gallery-thumb:nth-child(7) { border-radius: 18px 20px 14px 16px; }
.gallery-thumb:nth-child(8) { border-radius: 16px 14px 18px 20px; }
.gallery-thumb:nth-child(9) { border-radius: 20px 18px 16px 14px; }

.gallery-thumb img {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.gallery-thumb:hover,
.gallery-thumb:focus-visible {
  transform: scale(1.03);
  box-shadow: 0 8px 24px var(--color-card-shadow);
}
.gallery-thumb:hover img,
.gallery-thumb:focus-visible img {
  transform: scale(1.08);
}

/* Entry animation */
@keyframes galleryIn { from { opacity: 0; transform: scale(0.95) translateY(12px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@media (prefers-reduced-motion: no-preference) {
  html.js .gallery-thumb { opacity: 0; transform: scale(0.95) translateY(12px); }
  html.js .gallery-thumb.revealed { animation: galleryIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
  html.js .gallery-thumb.revealed:nth-child(1) { animation-delay: 0.05s; }
  html.js .gallery-thumb.revealed:nth-child(2) { animation-delay: 0.10s; }
  html.js .gallery-thumb.revealed:nth-child(3) { animation-delay: 0.15s; }
  html.js .gallery-thumb.revealed:nth-child(4) { animation-delay: 0.20s; }
  html.js .gallery-thumb.revealed:nth-child(5) { animation-delay: 0.25s; }
  html.js .gallery-thumb.revealed:nth-child(6) { animation-delay: 0.30s; }
}

/* ===== LIGHTBOX ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0,0,0,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.lightbox.open {
  opacity: 1;
  visibility: visible;
}
body.lightbox-open {
  overflow: hidden;
}

.lightbox-img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 60px 20px;
  box-sizing: border-box;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 12px;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.lightbox.open .lightbox-img {
  opacity: 1;
  transform: scale(1);
}

/* Controls */
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255,255,255,.1);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255,255,255,.2);
  transform: scale(1.1);
}

.lightbox-close {
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  font-size: 28px;
  line-height: 1;
  z-index: 2;
}
.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  font-size: 24px;
  line-height: 1;
  z-index: 2;
}
.lightbox-prev:hover,
.lightbox-next:hover {
  transform: translateY(-50%) scale(1.1);
}
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,.6);
  font-family: 'Lexend', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 300;
}

/* Responsive */
@media (max-width: 700px) {
  .gallery { margin-top: 28px; padding: 0 12px; }
  .gallery-heading { font-size: 20px; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .gallery-thumb img { height: 140px; }
  .lightbox-prev, .lightbox-next { width: 40px; height: 40px; font-size: 20px; }
  .lightbox-close { width: 40px; height: 40px; font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-thumb { opacity: 1 !important; transform: none !important; animation: none !important; }
  .lightbox, .lightbox-img { transition: none !important; }
}
