/* =============================================================================
   PAGE — Gallery (live Behold grid + accessible lightbox)
   ============================================================================= */

.gallery-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--line-gold);
}

.gallery-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--step-small);
  color: var(--fg-muted);
}
.gallery-status .icon { color: var(--gold); }

.gallery-bar__actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); }

/* --- Grid ----------------------------------------------------------------- */
.gallery-grid {
  display: grid;
  gap: var(--space-sm);
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 680px) { .gallery-grid { grid-template-columns: repeat(3, 1fr); } }

.gallery-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-soft);
  background: var(--ivory-deep);
  cursor: pointer;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease);
}

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

.gallery-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(18, 18, 18, 0.35));
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.gallery-item:hover::after,
.gallery-item:focus-visible::after { opacity: 1; }

.gallery-item__badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(18, 18, 18, 0.5);
  color: #fff;
}

/* --- Empty / pending state ------------------------------------------------ */
.gallery-empty {
  display: grid;
  gap: var(--space-md);
  justify-items: center;
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  background: var(--surface-alt);
  border: 1px dashed var(--line-gold);
  border-radius: var(--radius-lg);
}
.gallery-empty__mark { font-family: var(--font-display); font-size: 3.5rem; color: var(--gold); }
.gallery-empty h2 { font-size: var(--step-h3); }
.gallery-empty p { color: var(--fg-muted); max-width: 44ch; }

/* --- Lightbox (native <dialog>, renders in the top layer) ----------------- */
dialog.lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100svh;
  max-height: 100svh;
  margin: 0;
  border: 0;
  padding: clamp(var(--space-sm), 4vw, var(--space-2xl));
  background: transparent;
  color: inherit;
  overflow: hidden;
}

/* Only lay out the grid when actually open; closed dialogs stay display:none. */
dialog.lightbox[open] {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-sm);
}

dialog.lightbox::backdrop {
  background: rgba(18, 18, 18, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.lightbox__stage {
  display: grid;
  justify-items: center;
  gap: var(--space-sm);
  max-height: 88svh;
}

.lightbox__stage img {
  max-width: min(92vw, 900px);
  max-height: 78svh;
  width: auto;
  height: auto;
  border-radius: var(--radius-md);
  background: var(--ivory-deep);
  opacity: 1;
  transition: opacity var(--dur) var(--ease);
}

.lightbox__count {
  position: absolute;
  bottom: 1rem;
  right: 1.25rem;
  color: rgba(244, 240, 231, 0.85);
  font-size: var(--step-small);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.lightbox__cap {
  max-width: 60ch;
  text-align: center;
  color: rgba(244, 240, 231, 0.9);
  font-size: var(--step-small);
}

.lightbox__ig {
  position: absolute;
  top: 1rem;
  left: 1rem;
  color: #fff;
  font-size: var(--step-small);
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.lightbox__ig:hover { text-decoration: underline; }

.lightbox__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 50%;
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.12); }

.lightbox__nav {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}
.lightbox__nav:hover { background: rgba(255, 255, 255, 0.18); }

.lightbox :focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

@media (max-width: 640px) {
  .lightbox__nav { width: 44px; height: 44px; }
}
