/* Big Emba photo gallery — grid + lightbox */

.post.prose .gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.85rem;
  margin: 0 0 2rem;
}

@media (min-width: 900px) {
  .post.prose .gallery {
    grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
    gap: 1rem;
  }
}

.post.prose .subtle {
  margin-bottom: 1.25rem;
}

.gallery__item {
  margin: 0;
  padding: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: zoom-in;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  font: inherit;
  color: inherit;
  border-radius: 2px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gallery__item:hover,
.gallery__item:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 3px 14px rgba(30, 74, 110, 0.12);
  outline: none;
}

.gallery__item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

/* Lightbox (<dialog>) */

.lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(12, 12, 11, 0.94);
  color: #f5f4f0;
  overflow: hidden;
}

.lightbox::backdrop {
  background: rgba(12, 12, 11, 0.94);
}

.lightbox[open] {
  display: flex;
  flex-direction: column;
}

.lightbox__toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.lightbox__counter {
  opacity: 0.85;
  letter-spacing: 0.02em;
}

.lightbox__actions {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
}

.lightbox__btn {
  font-family: inherit;
  font-size: 0.85rem;
  color: inherit;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  line-height: 1.3;
}

.lightbox__btn.lightbox__close {
  font-size: 1.75rem;
  line-height: 1;
  padding: 0 0.5rem 0 0;
  margin: 0;
  min-width: 0;
  background: none;
  border: none;
  border-radius: 0;
  opacity: 0.85;
}

.lightbox__btn.lightbox__close:hover,
.lightbox__btn.lightbox__close:focus-visible {
  background: none;
  border: none;
  opacity: 1;
  outline: none;
}

.lightbox__btn:hover,
.lightbox__btn:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}

.lightbox__stage {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: auto;
  touch-action: pan-x pan-y pinch-zoom;
}

.lightbox__img {
  max-width: min(96vw, 100%);
  max-height: calc(100vh - 9rem);
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.75rem;
  height: 3.5rem;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.lightbox__nav:hover,
.lightbox__nav:focus-visible {
  opacity: 1;
  background: rgba(30, 74, 110, 0.75);
  outline: none;
}

.lightbox__nav--prev {
  left: 0.5rem;
}

.lightbox__nav--next {
  right: 0.5rem;
}

.lightbox__filmstrip {
  flex: 0 0 auto;
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.lightbox__thumb {
  flex: 0 0 auto;
  width: 3.25rem;
  height: 2.5rem;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  opacity: 0.55;
  scroll-snap-align: center;
  overflow: hidden;
}

.lightbox__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lightbox__thumb:hover,
.lightbox__thumb:focus-visible {
  opacity: 0.9;
  outline: none;
}

.lightbox__thumb.is-active {
  opacity: 1;
  border-color: #fff;
}

@media (max-width: 640px) {
  .lightbox__nav {
    width: 2.25rem;
    height: 2.75rem;
    font-size: 1.4rem;
  }

  .lightbox__thumb {
    width: 2.75rem;
    height: 2rem;
  }
}
