/* ============================================================
   GALLERY.CSS — gallery widget and lightbox
   Requires: global.css
   Covers: paginated grid, cells, nav dots, lightbox overlay
   Safe to include on any page that needs gallery/lightbox
   ============================================================ */

/* GALLERY WRAPPER */
.gallery-wrapper {
  position: relative; overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; border-radius: 7px;
}
.gallery-wrapper::-webkit-scrollbar { display: none; }

.gallery-track { display: flex; width: 100%; }

.gallery-page {
  min-width: 100%; width: 100%; flex-shrink: 0;
  scroll-snap-align: start;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
}

/* GRID CELLS */
.g-cell {
  aspect-ratio: 1; background: var(--bg2); border-radius: 7px;
  overflow: hidden; position: relative; cursor: pointer;
  border: 0.5px solid var(--border); border-top: 1.5px solid var(--sage);
}
.g-cell img {
  width: 100%; height: 100%; object-fit: cover;
  object-position: center 75%; display: block;
  transition: transform 0.5s ease;
}
.g-cell:hover img { transform: scale(1.05); }
.g-cell-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2);
}
.g-placeholder-inner {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--sage-light); opacity: 0.4;
}

/* GALLERY NAV */
.gallery-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }
.g-arrow {
  width: 34px; height: 34px; border-radius: 50%;
  border: 0.5px solid var(--border2); background: var(--surface);
  color: var(--text2); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px; transition: all 0.2s; user-select: none;
}
.g-arrow:hover { border-color: var(--sage); color: var(--sage-dark); }
.g-arrow:disabled { opacity: 0.3; cursor: default; border-color: var(--border); }
.g-dots { display: flex; gap: 6px; }
.g-dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--sand);
  transition: background 0.2s, transform 0.2s; cursor: pointer;
}
.g-dot.active { background: var(--sage-dark); transform: scale(1.3); }

/* LIGHTBOX */
.lb {
  position: fixed; inset: 0;
  background: rgba(244,237,224,0.93);
  backdrop-filter: blur(22px);
  z-index: 999;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.lb.open { opacity: 1; pointer-events: all; }

/* Scrollable track */
.lb-scroller {
  width: 100%; height: 80vh;
  overflow-x: scroll; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  display: flex; align-items: center;
}
.lb-scroller::-webkit-scrollbar { display: none; }

.lb-track {
  display: flex; align-items: center;
  padding: 0 13%;
  flex-shrink: 0;
}

.lb-slide {
  flex-shrink: 0;
  width: 68vw; max-width: 680px;
  height: 78vh;
  scroll-snap-align: center;
  display: flex; align-items: center; justify-content: center;
  padding: 0 10px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.lb-slide img {
  max-width: 100%; max-height: 76vh;
  object-fit: contain; border-radius: 8px; display: block;
  user-select: none; pointer-events: none; -webkit-user-drag: none;
}
.lb-slide:not(.active) { opacity: 0.32; transform: scale(0.87); }
.lb-slide.active { opacity: 1; transform: scale(1); }

.lb-close {
  position: absolute; top: 20px; right: 24px;
  font-size: 22px; color: var(--text2); cursor: pointer;
  background: none; border: none; padding: 8px; z-index: 2; transition: color 0.2s;
}
.lb-close:hover { color: var(--text); }

.lb-counter { margin-top: 14px; font-size: 12px; color: var(--text3); letter-spacing: 0.1em; }

.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%;
  border: 0.5px solid var(--border2); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; color: var(--text2);
  transition: all 0.2s; z-index: 2;
}
.lb-nav:hover { border-color: var(--sage); color: var(--sage-dark); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }

/* DARK MODE — lightbox background override */
body.dark .lb { background: rgba(20,21,18,0.96); }
