/* ==========================================================================
   Why Somerset County — image gallery
   A large stage image with a caption, plus a thumbnail strip that pages with
   chevrons. Selecting a thumbnail swaps the stage image, caption and alt text.
   Loaded after css/styles.css; relies on the --ws-* tokens defined there.
   Design reference: WhySomerset_Website_2026_Fun.pdf, page 2 (Outdoors)
   ========================================================================== */

.gallery { position: relative; }

/* --------------------------------------------------------------------------
   Stage
   -------------------------------------------------------------------------- */
.gallery__stage { margin: 0; }

.gallery__image {
  width: 100%;
  aspect-ratio: 1042 / 525;
  object-fit: cover;
  border-radius: 14px;
  background: rgba(0, 0, 0, .04);
}

.gallery__caption {
  margin-top: clamp(10px, 1.2vw, 17px);
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--ws-ink);
}

/* --------------------------------------------------------------------------
   Thumbnail strip
   -------------------------------------------------------------------------- */
.gallery__strip {
  position: relative;
  margin-top: clamp(20px, 2.6vw, 38px);
}

/* Exactly five across, as drawn; anything beyond that scrolls, which is what
   the chevrons drive. 5 x 190 + 4 x 21 = the 1041 content column in the comp. */
.gallery__thumbs {
  --thumb-gap: clamp(10px, 1.46vw, 21px);
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 4 * var(--thumb-gap)) / 5);
  gap: var(--thumb-gap);
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.gallery__thumbs::-webkit-scrollbar { display: none; }
.gallery__thumbs > li { scroll-snap-align: start; }

.gallery__thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: none;
  cursor: pointer;
  /* the photo's own radius, so a scaled child cannot square off the corners */
  transition: transform .3s var(--ws-ease), box-shadow .3s var(--ws-ease), opacity .3s var(--ws-ease);
}
.gallery__thumb img {
  width: 100%;
  aspect-ratio: 190 / 127;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.gallery__thumb:hover { transform: translateY(-2px); }
.gallery__thumb[aria-selected="false"] { opacity: .82; }
.gallery__thumb[aria-selected="true"] {
  box-shadow: 0 0 0 3px var(--ws-section-accent, var(--ws-amber));
  opacity: 1;
}
.gallery__thumb:focus-visible { outline: 3px solid var(--ws-green); outline-offset: 3px; }

/* Chevrons sit outside the content column, matching the testimonial carousel */
.gallery__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: clamp(38px, 4.5vw, 64px);
  padding: 0;
  border: 0;
  background: none;
  color: rgba(0, 0, 0, .28);
  cursor: pointer;
  transition: color .25s var(--ws-ease), transform .25s var(--ws-ease);
}
.gallery__arrow--prev { left: max(clamp(-116px, -8.06vw, -18px), var(--ws-rail-out)); }
.gallery__arrow--next { right: max(clamp(-116px, -8.06vw, -18px), var(--ws-rail-out)); }
.gallery__arrow svg { width: clamp(20px, 2.15vw, 31px); height: auto; display: block; }

.gallery__arrow:hover { color: rgba(0, 0, 0, .55); }
.gallery__arrow--prev:hover { transform: translateY(-50%) translateX(-3px); }
.gallery__arrow--next:hover { transform: translateY(-50%) translateX(3px); }
.gallery__arrow[disabled] { opacity: .25; cursor: default; transform: translateY(-50%); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
  .gallery__arrow--prev { left: -6px; }
  .gallery__arrow--next { right: -6px; }
  .gallery__strip { padding-inline: 30px; }
}

@media (max-width: 575.98px) {
  /* Five across is far too small on a phone, so show two and keep scrolling. */
  .gallery__thumbs { grid-auto-columns: calc((100% - var(--thumb-gap)) / 2); }
}

/* Photo credits run inline at the end of the caption, set back so the caption
   still reads as one sentence with its source attached. The client supplies
   these per picture and only some pictures have one. */
.gallery__credit { color: #6c7478; }
