/* ── Lightgallery overrides ─────────────────────────── */
.lg-backdrop {
  background: #070707;
}

.lg-toolbar {
  background: transparent;
}

.lg-actions .lg-next,
.lg-actions .lg-prev {
  background: rgba(44, 46, 28, 0.6);
  border: 0.5px solid rgba(211, 125, 112, 0.3);
  border-radius: 2px;
}

.lg-counter {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: rgba(211, 125, 112, 0.6);
}

.lg-sub-html {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 0.88rem;
  letter-spacing: 0.06em;
  color: rgba(209, 164, 83, 0.85);
  background: linear-gradient(
    to top,
    rgba(7, 7, 7, 0.78) 0%,
    transparent 100%
  );
  padding: 2rem 2rem 1.2rem;
}

/* ── Hide lightbox-only captions on the page ────────── */
.gallery__caption-hidden {
  display: none;
}

/* ── Shared gallery wrapper ─────────────────────────── */
/* Breaks out of the 68ch post__body column to 60vw     */
.gallery {
  width: 60vw;
  margin-left: calc(50% - 30vw);
  margin-right: calc(50% - 30vw);
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
}

/* On narrow screens fall back to full post body width */
@media (max-width: 700px) {
  .gallery {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

.gallery__item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.25s ease;
}

.gallery__item:hover img {
  opacity: 0.82;
}

/* ════════════════════════════════════════════════════
   ROW — horizontal slider with arrow buttons
   Wrapped in .gallery-row-outer for positioning arrows.
   ════════════════════════════════════════════════════ */

/* Outer wrapper holds the strip + arrow buttons */
/* Inherits the 60vw breakout from .gallery        */
.gallery-row-outer {
  position: relative;
  width: 60vw;
  margin-left: calc(50% - 30vw);
  margin-right: calc(50% - 30vw);
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 700px) {
  .gallery-row-outer {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

/* Arrow buttons */
.gallery-row-outer .row-arrow {
  display: none;
  position: absolute;
  top: 38%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(14, 11, 8, 0.55);
  border: 0.5px solid rgba(196, 158, 88, 0.35);
  color: rgba(228, 210, 172, 0.85);
  font-size: 1rem;
  width: 36px;
  height: 36px;
  border-radius: 2px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    border-color 0.2s;
  user-select: none;
}

.gallery-row-outer .row-arrow:hover {
  background: rgba(120, 85, 30, 0.35);
  border-color: rgba(196, 158, 88, 0.7);
}

.gallery-row-outer .row-arrow--prev {
  left: 0;
}
.gallery-row-outer .row-arrow--next {
  right: 0;
}

/* Show arrows only on non-touch devices */
@media (hover: hover) {
  .gallery-row-outer .row-arrow {
    display: flex;
  }
  /* Indent the strip to make room for arrows */
  .gallery-row-outer .gallery--row {
    padding-left: 44px;
    padding-right: 44px;
  }
}

.gallery--row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
  align-items: flex-start;
  /* Smooth programmatic scrolling from arrow buttons */
  scroll-behavior: smooth;
}

.gallery--row::-webkit-scrollbar {
  display: none;
}

/* Default item width */
.gallery--row .gallery__item {
  flex: 0 0 auto;
  scroll-snap-align: start;
  cursor: pointer;
  width: 72%;
  max-width: 520px;
}

/* 16:9 — wide, cinematic */
.gallery--row .gallery__item.is-16-9 {
  width: 88%;
  max-width: 640px;
}

/* 1:1 — square, compact */
.gallery--row .gallery__item.is-1-1 {
  width: 52%;
  max-width: 380px;
}

/* Images: natural ratio, no cropping */
.gallery--row .gallery__item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
}

.gallery--row .gallery__caption {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 0.82rem;
  font-style: italic;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  margin-top: 0.55rem;
  line-height: 1.5;
}

.gallery--row::after {
  content: "";
  flex: 0 0 1px;
}

/* ════════════════════════════════════════════════════
   MASONRY GRID — click to enlarge, caption in lightbox
   ════════════════════════════════════════════════════ */
.gallery--masonry {
  display: grid;
  /* Each column is at least 280px wide — so:
     1 photo  → 1 column (fills full width)
     2 photos → 2 columns
     3+ photos → up to 3 columns               */
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  grid-auto-rows: auto;
  gap: 8px;
  align-items: start;
}

.gallery--masonry .gallery__item {
  cursor: pointer;
  overflow: hidden;
  border-radius: 2px;
  position: relative;
}

.gallery--masonry .gallery__item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
  transition:
    opacity 0.25s ease,
    transform 0.3s ease;
}

.gallery--masonry .gallery__item:hover img {
  opacity: 0.78;
  transform: scale(1.02);
}

/* 16:9 spans 2 columns when there's room */
.gallery--masonry .gallery__item.is-16-9 {
  grid-column: span 2;
}

/* ════════════════════════════════════════════════════
   SINGLE IMAGE — inline photo at post body width (68ch)
   Caption shown on page below photo and in lightbox.
   ════════════════════════════════════════════════════ */
.single-image {
  width: 100%;
  max-width: 68ch;
  margin: 2.5rem auto;
}

.single-image .gallery__item {
  cursor: pointer;
  overflow: hidden;
  border-radius: 2px;
  position: relative;
}

.single-image .gallery__item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
  transition: opacity 0.25s ease;
}

.single-image .gallery__item:hover img {
  opacity: 0.82;
}

.single-image .gallery__caption {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 0.82rem;
  font-style: italic;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  margin-top: 0.55rem;
  line-height: 1.5;
}

/* ── External embeds (Flourish, Datawrapper, etc.) ── */
.post__embed {
  width: 60vw;
  margin-left: calc(50% - 30vw);
  margin-right: calc(50% - 30vw);
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 700px) {
  .post__embed {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}
