/**
 * ub/gallery-slider - photo gallery.
 *
 * Without JavaScript the photos are a horizontal scroll-snap strip with the
 * next photo peeking in, which is also the browser's native swipe. With it
 * (.is-ready) each photo fills the stage and the strip's scrollbar is hidden:
 * the buttons, counter and thumbnails take over, and scrolling stays native.
 */
.ub-gallery { background: var(--white, #fff); }

.ub-gal-track {
  position: relative;
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  background: var(--bg-light, #f4f7f6);
}
.ub-gal-track:focus-visible {
  outline: 3px solid var(--ub-purple, #592d82);
  outline-offset: 3px;
}

.ub-gal-slide {
  display: flex;
  flex: 0 0 88%;
  flex-direction: column;
  margin: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: var(--white, #fff);
}
.ub-gallery--single .ub-gal-slide,
.ub-gal.is-ready .ub-gal-slide { flex-basis: 100%; }

/* The frame holds the photo at one shape whatever its own, and is capped so a
   full-width stage never becomes taller than the screen. */
.ub-gal-frame {
  aspect-ratio: 16 / 9;
  max-height: min(68vh, 640px);
  overflow: hidden;
  background: var(--bg-light, #f4f7f6);
}
.ub-gal-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}
.ub-gallery--contain .ub-gal-frame img { object-fit: contain; }

.ub-gal-caption {
  padding: 16px 0 0;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text-main, #2c3e50);
}
.ub-gal:not(.is-ready) .ub-gal-caption { padding-right: 16px; }

/* Enhanced: no scrollbar, the controls replace it. */
.ub-gal.is-ready .ub-gal-track { scrollbar-width: none; }
.ub-gal.is-ready .ub-gal-track::-webkit-scrollbar { display: none; }

/* Previous, counter, Next */
.ub-gal-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}
.ub-gal-count {
  flex: 1;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--text-main, #2c3e50);
}
.ub-gal-bar .btn { min-width: 128px; min-height: 48px; justify-content: center; font-family: inherit; }
.ub-gal-bar .btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: none;
}
.ub-gal-bar .btn[aria-disabled="true"]:hover {
  background: transparent;
  color: var(--ub-purple, #592d82);
}

/* One marker per page (the testimonial carousel). Square, like every corner in
   the brand; the hit area is 28px, the marker 12px. */
.ub-gal-bar[hidden],
.ub-gal-dots[hidden],
.ub-gal-thumbs[hidden] { display: none; }
.ub-gal-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 10px;
}
.ub-gal-dot {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  cursor: pointer;
}
.ub-gal-dot::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid var(--text-light, #5b6a75);
  background: transparent;
}
.ub-gal-dot[aria-current="true"]::before {
  border-color: var(--ub-purple, #592d82);
  background: var(--ub-purple, #592d82);
}
.ub-gal-dot:focus-visible {
  outline: 3px solid var(--ub-purple, #592d82);
  outline-offset: 0;
}

/* Thumbnails: one fixed shape, current photo marked by a blue rule and full
   opacity (labelled counter, not dots). */
.ub-gal-thumbs {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding-bottom: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.ub-gal-thumb {
  flex: 0 0 132px;
  aspect-ratio: 3 / 2;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-bottom: 4px solid transparent;
  border-radius: 0;
  background: var(--bg-light, #f4f7f6);
  cursor: pointer;
  opacity: 0.62;
  transition: opacity var(--transition-dur, 300ms) var(--transition-ease, cubic-bezier(0.25, 0.8, 0.25, 1));
}
.ub-gal-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}
.ub-gal-thumb:hover { opacity: 1; }
.ub-gal-thumb[aria-current="true"] {
  opacity: 1;
  border-bottom-color: var(--ub-blue, #00a7e0);
}
.ub-gal-thumb:focus-visible {
  opacity: 1;
  outline: 3px solid var(--ub-purple, #592d82);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .ub-gal-frame { aspect-ratio: 4 / 3; max-height: 70vh; }
  .ub-gal-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .ub-gal-count { grid-column: 1 / -1; grid-row: 1; }
  .ub-gal-bar .btn { min-width: 0; width: 100%; }
  .ub-gal-thumb { flex-basis: 104px; }
}

@media (prefers-reduced-motion: reduce) {
  .ub-gal-thumb { transition: none; }
}
