/* ==========================================================================
   Project Gallery: cards and photo viewer (gallery.html)
   Grid layout lives in custom.css (.gallery, .card, .content).
   ========================================================================== */

/* ---------- City filter (shares .filter-section styles with projects.html) ---------- */

.gallery-filter {
  margin: 30px 0;
  padding: 0 40px;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---------- Cards ---------- */

.gallery-card[hidden] {
  display: none;
}

.gallery-card__open {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.gallery-card__open img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.gallery-card__open:focus-visible {
  outline: 3px solid #f9d04b;
  outline-offset: -3px;
}

.gallery-card__count {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(11, 26, 51, 0.8);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

/* ---------- Viewer ---------- */

html.gallery-viewer-open,
html.gallery-viewer-open body {
  overflow: hidden;
}

html.gallery-viewer-open #chatbot-icon,
html.gallery-viewer-open .uls-loop,
html.gallery-viewer-open .uls-loop-bubble,
html.gallery-viewer-open .scroll-to-top,
html.gallery-viewer-open .quote-tab {
  visibility: hidden;
}

.gallery-viewer {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  grid-template-rows: auto auto auto;
  justify-items: center;
  align-content: center;
  gap: 14px;
  padding: 76px 16px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, 0.95);
  color: #fff;
}

.gallery-viewer[hidden] {
  display: none;
}

.gallery-viewer__stage {
  position: relative;
  /* One 3:4 frame for every photo, sized from the screen only (never from
     the caption), so all photos show at the same size. 290px keeps room for
     the close button, a two-line caption and the controls. */
  height: min(720px, calc(100vh - 290px), calc((100vw - 32px) * 4 / 3));
  height: min(720px, calc(100dvh - 290px), calc((100vw - 32px) * 4 / 3));
  aspect-ratio: 3 / 4;
}

.gallery-viewer__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 400ms ease;
  user-select: none;
  -webkit-user-drag: none;
}

.gallery-viewer__image.is-visible {
  opacity: 1;
}

.gallery-viewer__caption {
  text-align: center;
  max-width: 900px;
  padding-top: 18px;
}

.gallery-viewer__title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  margin: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.gallery-viewer__meta,
.gallery-viewer__counter {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 14px;
}

.gallery-viewer__controls {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.gallery-viewer__dots {
  display: flex;
  gap: 8px;
}

.gallery-viewer__dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 100, 192, 0.45);
  cursor: pointer;
  transition: background-color 200ms ease, transform 200ms ease;
}

.gallery-viewer__dot[aria-current="true"] {
  background: #0064c0;
  transform: scale(1.2);
}

.gallery-viewer__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  transition: background-color 200ms ease;
}

.gallery-viewer__btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.gallery-viewer__btn:focus-visible,
.gallery-viewer__dot:focus-visible {
  outline: 3px solid #f9d04b;
  outline-offset: 2px;
}

.gallery-viewer__btn[hidden] {
  display: none;
}

.gallery-viewer__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.gallery-viewer__nav--prev {
  left: 8px;
}

.gallery-viewer__nav--next {
  right: 8px;
}

.gallery-viewer__close {
  position: absolute;
  top: 12px;
  right: 12px;
}

/* Play / pause icon swap */
.gallery-viewer__play .icon-play,
.gallery-viewer__play[aria-pressed="true"] .icon-pause {
  display: none;
}

.gallery-viewer__play[aria-pressed="true"] .icon-play {
  display: block;
}

@media (min-width: 992px) {
  .gallery-viewer__nav--prev {
    left: -64px;
  }

  .gallery-viewer__nav--next {
    right: -64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-viewer__image,
  .gallery-viewer__dot {
    transition: none;
  }
}
