/* ============================================================
   CONVERGE RADIANCE — GALLERY SECTION + LIGHTBOX
   ============================================================ */

/* The section stays out of the page until the feed returns items.
   These need explicit [hidden] rules: the UA's bare `[hidden]` selector loses to
   any class that sets `display` (.gallery-filters is display:flex). */
.gallery-section[hidden]  { display: none; }
.gallery-filters[hidden]  { display: none; }
.gallery-skeleton[hidden] { display: none; }
.gallery-more[hidden]     { display: none; }

/* ── FILTERS ──────────────────────────────────────────────── */
.gallery-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-lg);
}
.gallery-filter {
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(123, 50, 40, 0.20);
  background: transparent;
  color: var(--color-text-mid);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  transition: background var(--duration-mid) var(--ease-out),
              color var(--duration-mid) var(--ease-out),
              border-color var(--duration-mid) var(--ease-out);
}
.gallery-filter:hover { border-color: var(--color-primary); color: var(--color-primary); }
.gallery-filter.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-white);
}

/* ── GRID ─────────────────────────────────────────────────────
   Multi-column masonry rather than a fixed-ratio grid: uploads range
   from wide banners to portrait shots, and a forced 4/3 crop turned
   anything panoramic into an unreadable zoom.
   ───────────────────────────────────────────────────────────── */
.gallery-grid {
  columns: 4 260px;
  column-gap: var(--space-md);
}

/* One or two items would otherwise sit stranded in a four-column track. */
.gallery-grid--count-1 { columns: 1; max-width: 680px; margin-inline: auto; }
.gallery-grid--count-2 { columns: 2 260px; max-width: 900px; margin-inline: auto; }

/* Wrapper carries the column break so the <button> never straddles a column. */
.gallery-item {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: var(--space-md);
}

.gallery-tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-bg-cream);
  border: 1px solid rgba(123, 50, 40, 0.08);
  cursor: pointer;
  transition: transform var(--duration-mid) var(--ease-out),
              box-shadow var(--duration-mid) var(--ease-out);
}
.gallery-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }

/* Natural aspect ratio — no cropping. Extreme portraits are capped so a
   single tall upload cannot run away with the column. */
.gallery-tile__img {
  width: 100%;
  height: auto;
  max-height: 620px;
  object-fit: cover;
  object-position: center;
  transition: transform var(--duration-slow) var(--ease-out);
}
.gallery-tile:hover .gallery-tile__img { transform: scale(1.04); }

/* Embeds are always 16:9. Forcing the box also crops the black letterbox bars
   off YouTube's 4:3 hqdefault still when no maxres frame exists. */
.gallery-tile--embed .gallery-tile__img {
  aspect-ratio: 16 / 9;
  height: 100%;
  max-height: none;
}

.gallery-tile__fallback {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--color-primary-pale), var(--color-gold-pale));
}
.gallery-tile__fallback::after {
  content: '';
  width: 56px; height: 64px;
  background: var(--color-primary);
  opacity: 0.16;
  clip-path: var(--clip-hex);
}

/* Caption veil */
.gallery-tile__veil {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  padding: var(--space-sm);
  text-align: left;
  background: linear-gradient(to top, rgba(26, 16, 8, 0.82) 0%, rgba(26, 16, 8, 0.35) 42%, rgba(26, 16, 8, 0) 72%);
  opacity: 0;
  transition: opacity var(--duration-mid) var(--ease-out);
}
.gallery-tile:hover .gallery-tile__veil,
.gallery-tile:focus-visible .gallery-tile__veil { opacity: 1; }

.gallery-tile__cat {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-gold-light);
}
.gallery-tile__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  color: var(--color-text-white);
}

/* Play badge for videos */
.gallery-tile__play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 56px; height: 56px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.92);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 20px rgba(26, 16, 8, 0.30);
  transition: transform var(--duration-mid) var(--ease-out), background var(--duration-mid);
}
.gallery-tile__play::after {
  content: '';
  margin-left: 4px;
  border-style: solid;
  border-width: 10px 0 10px 17px;
  border-color: transparent transparent transparent var(--color-primary);
}
.gallery-tile:hover .gallery-tile__play { transform: translate(-50%, -50%) scale(1.1); background: #fff; }

/* "Show more" */
.gallery-more {
  text-align: center;
  margin-top: var(--space-lg);
}

/* Loading skeleton */
.gallery-skeleton {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-md);
}
.gallery-skeleton span {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg, rgba(123,50,40,0.05) 30%, rgba(123,50,40,0.11) 50%, rgba(123,50,40,0.05) 70%);
  background-size: 250% 100%;
  animation: gallery-shimmer 1.4s var(--ease-inout) infinite;
}
@keyframes gallery-shimmer {
  0%   { background-position: 150% 0; }
  100% { background-position: -50% 0; }
}

/* ── LIGHTBOX ─────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: clamp(1rem, 4vw, 3rem);
  background: rgba(18, 11, 6, 0.94);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-mid) var(--ease-out), visibility var(--duration-mid);
}
.lightbox.open { opacity: 1; visibility: visible; }

.lightbox__stage {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 1100px;
  max-height: 78vh;
}
.lightbox__stage img,
.lightbox__stage video {
  max-width: 100%;
  max-height: 78vh;
  width: auto;
  border-radius: var(--radius-md);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.lightbox__frame {
  width: min(100%, 1100px);
  aspect-ratio: 16 / 9;
  max-height: 78vh;
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.lightbox__caption {
  width: 100%;
  max-width: 1100px;
  padding-top: var(--space-sm);
  text-align: center;
}
.lightbox__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--color-text-white);
}
.lightbox__text {
  font-size: var(--text-sm);
  color: var(--color-text-white-dim);
  margin-top: 4px;
}
.lightbox__count {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wider);
  color: var(--color-gold-light);
  margin-top: var(--space-2);
}

.lightbox__btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-text-white);
  transition: background var(--duration-fast), transform var(--duration-fast);
}
.lightbox__btn:hover { background: rgba(255, 255, 255, 0.26); }
.lightbox__btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lightbox__btn--close { top: clamp(1rem, 3vw, 2rem); right: clamp(1rem, 3vw, 2rem); }
.lightbox__btn--prev  { left:  clamp(0.5rem, 2vw, 1.5rem); top: 50%; transform: translateY(-50%); }
.lightbox__btn--next  { right: clamp(0.5rem, 2vw, 1.5rem); top: 50%; transform: translateY(-50%); }
.lightbox__btn--prev:hover, .lightbox__btn--next:hover { transform: translateY(-50%) scale(1.06); }
.lightbox__btn[hidden] { display: none; }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .gallery-grid           { columns: 2 220px; }
  .gallery-grid--count-2  { columns: 2 220px; }
}
@media (max-width: 560px) {
  .gallery-grid,
  .gallery-grid--count-1,
  .gallery-grid--count-2  { columns: 1; max-width: none; }
  .gallery-skeleton       { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .gallery-tile__img      { max-height: 420px; }
  .gallery-tile__veil { opacity: 1; padding: var(--space-3); }
  .gallery-tile__title { font-size: var(--text-sm); }
  .gallery-tile__play { width: 44px; height: 44px; }
  .lightbox__btn { width: 40px; height: 40px; }
  .lightbox__btn--prev { left: 0.25rem; }
  .lightbox__btn--next { right: 0.25rem; }
}
