/* ---------- Lightbox (unchanged) ---------- */
.ba-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0,0,0,.85);
  z-index: 9999;
}
.ba-lightbox.open { display: grid; }
.ba-lightbox img { max-width: 94vw; max-height: 94vh; }

/* ---------- Global figure sizing & captions ---------- */
.docs-wrap figure {
  max-width: 880px;               /* cap inline image width on large screens */
  margin: 1.1rem auto;            /* center in the text column */
}
.docs-wrap img {
  display: block;
  width: 100%;
  height: auto;
}
.docs-wrap figure img {
  max-height: 72vh;               /* never taller than the viewport on big screens */
  object-fit: contain;
}
.docs-wrap figcaption {
  font-size: .9rem;
  line-height: 1.35;
  color: var(--text-weak, #a8acb3);
  margin-top: .5rem;
}

/* ---------- Two-up pairs (e.g., city-days pair, MacGyver pair) ---------- */
.fig-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
  max-width: 1040px;              /* a touch wider to fit both at comfy size */
  margin: 1.2rem auto;
}
.fig-row figure { margin: 0; max-width: none; }
@media (max-width: 900px) { .fig-row { grid-template-columns: 1fr; } }

/* ---------- 2×2 grid (new OBSY v2 photos) ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 1040px;
  margin: 1rem auto 1.4rem;
}
@media (max-width: 900px) { .gallery-grid { grid-template-columns: 1fr; } }
.gallery-grid figure { margin: 0; }

/* ---------- Float an illustrative figure with text wrap ---------- */
/* Use for the FreeCAD render so “Two buildings, air gap” text wraps nicely */
.figure-float-right {
  float: right;
  width: clamp(320px, 36vw, 560px);   /* scales up but stays sensible on 4K */
  margin: .3rem 0 1rem 1rem;
}
.figure-float-right img { max-height: 60vh; }
@media (max-width: 1100px) {
  .figure-float-right { float: none; width: 100%; margin: .8rem auto; }
}

/* ---------- Headings spacing polish near figures ---------- */
.docs-wrap h2 + figure,
.docs-wrap h3 + figure { margin-top: .6rem; }
figure + h2, figure + h3 { margin-top: 1.3rem; }
