/* ==========================================================================
   Jobson Garden — Gallery page

   The cover banner is the shared .page-cover component (see motion.css and
   main.css); everything below is specific to this page — the "follow us"
   cards, the photo grid, and the lightbox that opens a photo full-size.
   ========================================================================== */

.gallery-main {
  padding-block: var(--section-y);
}

.gallery-empty {
  max-width: 40rem;
  margin: 0 auto;
  padding: var(--space-16) 0;
  text-align: center;
  color: var(--muted-foreground);
  font-size: var(--text-lg, 1.1rem);
}
.gallery-empty a { color: var(--primary); font-weight: 600; }

/* --- Follow / view-album cards --------------------------------------------
   Facebook and Instagram only appear once switched on in the admin panel and
   given a profile link; Google Photos only appears as this card, never as a
   feed — see includes/gallery.php for why. */

.gallery-follow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-16);
}
.gallery-follow__card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  font-weight: 600;
  transition: border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.gallery-follow__card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}
.gallery-follow__card svg:first-child { width: 22px; height: 22px; flex: none; color: var(--primary); }
.gallery-follow__card span { flex: 1; }
.gallery-follow__arrow { width: 16px; height: 16px; flex: none; color: var(--muted-foreground); }

/* --- The grid --------------------------------------------------------------
   Square tiles: photos arrive from three different sources at three different
   aspect ratios, and a masonry layout of that mix reads as messy rather than
   candid. object-fit: cover on a fixed ratio keeps the wall even; the
   lightbox is where a photo is seen uncropped. */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: var(--space-3);
}

.gallery-tile { margin: 0; }

.gallery-tile__btn {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  background: var(--secondary);
}
.gallery-tile__btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.45s var(--ease);
}
.gallery-tile__btn:hover img,
.gallery-tile__btn:focus-visible img { transform: scale(1.06); }
.gallery-tile__btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.gallery-tile__source {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  width: 1.6rem;
  height: 1.6rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(26, 35, 27, 0.18);
}
.gallery-tile__source svg { width: 15px; height: 15px; }
.gallery-tile__source:empty { display: none; }

.gallery-tile__caption {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  line-height: 1.4;
}

/* --- Lightbox --------------------------------------------------------------
   One instance for the whole page, filled in by assets/js/gallery.js. Plain
   position: fixed rather than the <dialog> element — <dialog>'s built-in
   ::backdrop cannot be blurred consistently across the browsers this
   audience actually uses on a mid-range Android. */

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}
.gallery-lightbox[hidden] { display: none; }

.gallery-lightbox__scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 16, 0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.gallery-lightbox__frame {
  position: relative;
  z-index: 1;
  max-width: min(90vw, 60rem);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gallery-lightbox__img {
  max-width: 100%;
  max-height: 74vh;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
  background: #10140f;
}

.gallery-lightbox__caption {
  margin: var(--space-3) 0 0;
  max-width: 42rem;
  text-align: center;
  color: #f2f7ec;
  font-size: var(--text-sm);
}

.gallery-lightbox__link {
  margin-top: var(--space-2);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 600;
}

.gallery-lightbox__close,
.gallery-lightbox__nav {
  position: absolute;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition: background-color var(--duration) var(--ease);
}
.gallery-lightbox__close:hover,
.gallery-lightbox__nav:hover { background: rgba(255, 255, 255, 0.22); }
.gallery-lightbox__close svg,
.gallery-lightbox__nav svg { width: 20px; height: 20px; }

.gallery-lightbox__close { top: -3.25rem; right: 0; }
.gallery-lightbox__nav--prev { left: -3.5rem; top: 50%; transform: translateY(-50%); }
.gallery-lightbox__nav--next { right: -3.5rem; top: 50%; transform: translateY(-50%); }

@media (max-width: 720px) {
  /* No room for side arrows off the frame on a phone; a swipe or the on-image
     tap zones (added in JS) drive navigation instead. */
  .gallery-lightbox__nav { display: none; }
  .gallery-lightbox__close { top: 0.5rem; right: 0.5rem; background: rgba(0, 0, 0, 0.4); }
  .gallery-lightbox__frame { max-width: 94vw; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-tile__btn img,
  .gallery-follow__card { transition: none; }
}
