/* ==========================================================================
   KANAM — Client Gallery
   ========================================================================== */

/* ---- Hero ---- */

.gallery-hero {
  padding: 176px 64px 48px;
  text-align: center;
  background: var(--a-bg);
}

.gallery-hero__eyebrow {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--a-gold);
  margin-bottom: 16px;
}

.gallery-hero__title {
  font-weight: 600;
  font-size: 44px;
  max-width: 780px;
  margin: 0 auto 18px;
}

.gallery-hero__subhead {
  font-size: 16px;
  line-height: 1.6;
  color: var(--a-text-secondary);
  max-width: 620px;
  margin: 0 auto;
}

/* ---- Filter bar ---- */

.gallery-filter {
  position: sticky;
  top: 88px;
  z-index: 10;
  background: rgba(10, 9, 8, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--a-divider);
  padding: 18px 64px;
}

.gallery-filter__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.gallery-filter__chip {
  padding: 8px 20px;
  border: 1px solid var(--a-divider);
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: var(--a-text-secondary);
  transition: color 200ms ease, border-color 200ms ease, background 200ms ease;
}

.gallery-filter__chip:hover {
  color: var(--a-text-primary);
  border-color: var(--a-text-secondary);
}

.gallery-filter__chip.is-active {
  color: #141311;
  border-color: var(--a-gold);
  background: linear-gradient(90deg, var(--a-gold-light), var(--a-gold));
}

/* ---- Masonry grid ---- */

.gallery-grid {
  padding: 48px 64px 100px;
  columns: 4;
  column-gap: 20px;
  /* Tile clamps: keep masonry balanced no matter what size photo gets dropped
     into images/gallery/. min = floor for ultra-wide landscapes, max = cap for
     ultra-tall portraits (~1:2), skeleton = placeholder height while a
     dimension-less (w/h omitted) photo is still loading. */
  --gallery-tile-min-h: 140px;
  --gallery-tile-max-h: 640px;
  --gallery-tile-skeleton-h: 220px;
}

html.js .gallery-item {
  opacity: 0;
}

.gallery-item {
  break-inside: avoid;
  margin: 0 0 20px;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
}

.gallery-item.is-hidden {
  display: none;
}

.gallery-item__btn {
  display: block;
  width: 100%;
  padding: 0;
  cursor: pointer;
  background: var(--a-surface);
}

.gallery-item__img {
  display: block;
  width: 100%;
  height: auto;
  min-height: var(--gallery-tile-min-h);
  max-height: var(--gallery-tile-max-h);
  object-fit: cover;
  object-position: center;
  transition: transform 500ms ease, opacity 400ms ease;
}

/* Photo shipped with w/h in portfolio-data.js — aspect-ratio reserves the
   exact space up front (zero CLS). */
.gallery-item__img--sized {
  aspect-ratio: var(--ar);
}

/* Photo shipped WITHOUT w/h — flows at its natural size (clamped above) and
   fades in once it finishes loading. The button's --a-surface background
   underneath acts as the skeleton while the image is transparent. */
.gallery-item__img--natural {
  min-height: var(--gallery-tile-skeleton-h);
  opacity: 0;
}

.gallery-item__img--natural.is-loaded {
  min-height: var(--gallery-tile-min-h);
  opacity: 1;
}

.gallery-item__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 9, 8, 0) 55%, rgba(10, 9, 8, 0.75) 100%);
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

.gallery-item__btn:hover .gallery-item__img,
.gallery-item__btn:focus-visible .gallery-item__img {
  transform: scale(1.05);
}

.gallery-item__btn:hover .gallery-item__overlay,
.gallery-item__btn:focus-visible .gallery-item__overlay {
  opacity: 1;
}

.gallery-item__btn:focus-visible {
  outline: 2px solid var(--a-gold);
  outline-offset: 2px;
}

/* ---- Lightbox ---- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 9, 8, 0.96);
  opacity: 0;
  visibility: hidden;
  transition: opacity 250ms ease;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.lightbox__stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(88vw, 1100px);
  max-height: 86vh;
}

.lightbox__img {
  max-width: 100%;
  max-height: 74vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox__caption {
  color: var(--a-text-secondary);
  font-size: 14px;
  margin-top: 16px;
  text-align: center;
  max-width: 60ch;
}

.lightbox__counter {
  color: var(--a-gold);
  font-size: 12px;
  letter-spacing: 1px;
  margin-top: 6px;
}

.lightbox__close,
.lightbox__nav {
  position: absolute;
  color: var(--a-text-primary);
  background: rgba(21, 19, 16, 0.6);
  border: 1px solid var(--a-divider);
  border-radius: 999px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}

.lightbox__close:hover,
.lightbox__nav:hover {
  background: var(--a-gold);
  color: #141311;
  border-color: var(--a-gold);
}

.lightbox__close {
  top: 24px;
  right: 24px;
}

.lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__nav--prev { left: 24px; }
.lightbox__nav--next { right: 24px; }

@media (prefers-reduced-motion: reduce) {
  .gallery-item__img,
  .gallery-item__overlay,
  .lightbox,
  .lightbox__close,
  .lightbox__nav,
  .gallery-filter__chip {
    transition: none;
  }

  /* No fade — image appears instantly once loaded, skeleton bg still shows
     until the browser paints it. */
  .gallery-item__img--natural {
    opacity: 1;
  }
}

/* ---- Responsive ---- */

@media (max-width: 1024px) {
  .gallery-hero {
    padding: 152px 40px 40px;
  }

  .gallery-filter {
    padding: 16px 40px;
  }

  .gallery-grid {
    padding: 40px 40px 80px;
    columns: 3;
    --gallery-tile-min-h: 130px;
    --gallery-tile-max-h: 560px;
    --gallery-tile-skeleton-h: 200px;
  }

  .lightbox__nav {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
}

@media (max-width: 767.98px) {
  .gallery-hero {
    padding: 132px 20px 32px;
  }

  .gallery-hero__title {
    font-size: 30px;
  }

  .gallery-filter {
    padding: 14px 20px;
  }

  .gallery-filter__inner {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .gallery-filter__chip {
    flex: 0 0 auto;
  }

  .gallery-grid {
    padding: 32px 20px 64px;
    columns: 2;
    column-gap: 12px;
    --gallery-tile-min-h: 120px;
    --gallery-tile-max-h: 480px;
    --gallery-tile-skeleton-h: 180px;
  }

  .gallery-item {
    margin-bottom: 12px;
  }

  .lightbox__close {
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .lightbox__nav {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .lightbox__nav--prev { left: 12px; }
  .lightbox__nav--next { right: 12px; }
}
