/* ==========================================================================
   Gallery page: sticky filters, masonry grid, cards, lightbox
   Loaded only on the gallery template.
   ========================================================================== */

/* Sticky filter toolbar */
.gallery-toolbar {
  position: sticky;
  top: var(--header-height);
  z-index: 40;
  background: rgba(5, 5, 5, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  padding-block: 0.85rem;
}
.gallery-toolbar__inner {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--page-gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.gallery-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  /* Hide the horizontal scrollbar; row still scrolls via touch/trackpad. */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.gallery-filters::-webkit-scrollbar { display: none; }
/* On desktop the tabs fit, so let them wrap/center rather than scroll. */
@media (min-width: 1024px) {
  .gallery-filters { flex-wrap: wrap; overflow-x: visible; }
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  min-height: 40px;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-silver);
  white-space: nowrap;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.filter-btn:hover { color: var(--color-white); }
.filter-btn[aria-pressed="true"] {
  background: var(--color-navy);
  color: var(--color-white);
}
.filter-btn__count {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-silver);
  padding: 0.1rem 0.4rem;
  background: var(--color-charcoal);
}
.filter-btn[aria-pressed="true"] .filter-btn__count { color: var(--color-silver-light); }

.gallery-count {
  display: none;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-silver);
  flex-shrink: 0;
}
@media (min-width: 1024px) { .gallery-count { display: inline-flex; } }

/* Masonry grid (CSS columns) */
.gallery-grid {
  max-width: var(--container-max);
  margin-inline: auto;
  column-gap: var(--space-lg);
  column-count: 1;
}
@media (min-width: 640px) { .gallery-grid { column-count: 2; } }
@media (min-width: 1024px) { .gallery-grid { column-count: 3; } }

.gallery-card {
  break-inside: avoid;
  margin-bottom: var(--space-lg);
  background: var(--color-charcoal);
  overflow: hidden;
  box-shadow: 0 12px 24px rgba(0,0,0,0.35);
}
.gallery-card.is-hidden { display: none; }

.gallery-card__button {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.gallery-card__img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.7s var(--ease);
}
.gallery-card__button:hover .gallery-card__img { transform: scale(1.025); }

/* Hover info overlay (desktop enhancement only) */
.gallery-card__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 1.25rem;
  text-align: left;
  background: linear-gradient(to top, var(--color-bg), rgba(5,5,5,0.5) 50%, transparent);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  pointer-events: none;
}
@media (hover: hover) and (min-width: 1024px) {
  .gallery-card__button:hover .gallery-card__overlay,
  .gallery-card__button:focus-visible .gallery-card__overlay { opacity: 1; }
}
.gallery-card__overlay .card-cat {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-primary);
  margin-bottom: 0.15rem;
}
.gallery-card__overlay h3 { font-size: 1.125rem; font-weight: 500; }

/* Under-card meta (always visible, touch-friendly) */
.gallery-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem;
}
.gallery-card__meta-title {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  color: var(--color-white);
}
.gallery-card__meta-collection {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-silver);
  margin-top: 0.1rem;
}
.gallery-card__expand {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--color-silver);
  cursor: pointer;
}
.gallery-card__expand:hover { color: var(--color-white); }

.gallery-empty {
  max-width: var(--container-max);
  margin-inline: auto;
  padding: var(--space-2xl) var(--page-gutter);
  text-align: center;
  color: var(--color-silver);
  display: none;
}
.gallery-empty.is-visible { display: block; }

/* --------------------------------------------------------------------------
   Lightbox
   -------------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  flex-direction: column;
  background: rgba(5, 5, 5, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 1rem;
  overflow-y: auto;
}
.lightbox.is-open { display: flex; }
@media (min-width: 768px) { .lightbox { padding: 2rem; } }

.lightbox__bar {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-shrink: 0;
  /* Stay pinned at the top while a tall image scrolls, so the close and
     prev/next controls are always reachable on mobile. */
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(5, 5, 5, 0.96);
  padding-block: 0.75rem;
  margin-bottom: 0.5rem;
}
.lightbox__tags { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.lightbox__collection {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-primary);
  background: var(--color-navy);
  padding: 0.3rem 0.75rem;
  white-space: nowrap;
}
.lightbox__location {
  font-size: 0.8125rem;
  color: var(--color-silver);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 640px) { .lightbox__location { display: none; } }

.lightbox__controls { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.lightbox__ctrl {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-charcoal);
  border: none;
  color: var(--color-silver);
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.lightbox__ctrl:hover { background: var(--color-surface); color: var(--color-white); }
.lightbox__ctrl--close:hover { background: #93000a; color: var(--color-white); }

.lightbox__stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  min-height: 0;
}
.lightbox__img {
  max-height: 72vh;
  max-width: 100%;
  width: auto;
  object-fit: contain;
  box-shadow: 0 30px 60px rgba(0,0,0,0.6);
}
/* On small screens leave room for the pinned bar + info so a portrait image
   never pushes the controls or actions out of reach. */
@media (max-width: 640px) {
  .lightbox__img { max-height: 62vh; }
  .lightbox__info { margin-top: 1rem; padding: 1.1rem; }
}

.lightbox__info {
  width: 100%;
  max-width: var(--container-max);
  margin: 1.5rem auto 0;
  background: var(--color-charcoal);
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  flex-shrink: 0;
}
@media (min-width: 1024px) {
  .lightbox__info { grid-template-columns: 7fr 5fr; align-items: center; gap: var(--space-xl); padding: 2rem; }
}
.lightbox__title { margin-bottom: 0.4rem; }
.lightbox__desc { font-size: 0.9375rem; color: var(--color-silver); line-height: 1.6; }
.lightbox__desc:empty { display: none; }

.lightbox__actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.lightbox__buy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--color-navy);
  color: var(--color-white);
  transition: background-color 0.25s var(--ease);
}
.lightbox__buy:hover { background: var(--color-navy-active); }
.lightbox__buy-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.lightbox__buy-sub { display: block; font-size: 0.8125rem; color: var(--color-silver); margin-top: 0.15rem; }
.lightbox__buy .icon { flex-shrink: 0; }
.lightbox__buy--merch { background: var(--color-surface); }
.lightbox__buy--merch:hover { background: var(--color-surface-high); }
.lightbox__buy--merch[hidden] { display: none; }
