/* Ensure the ultra-thin cut is used (no synthetic bold) */
#unit-lightbox, #unit-lightbox * {
  font-optical-sizing: auto;
  font-kerning: normal;
  font-synthesis-weight: none; /* prevents fake bold if 100 isn't loaded */
}

/* Match your theme’s H2 look */
.unit-lightbox__text h2 {
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  text-transform: capitalize;
  letter-spacing: 0;
  font-size: 46px;
  line-height: 56px;
  font-weight: 200;
  margin: 0 0 8px;
  color: #fff; /* if needed to match the dark modal */
}

/* If other global rules try to force Open Sans on h2, out-specific them: */
#unit-lightbox .unit-lightbox__text h2 { font-family: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif; }

.unit-lightbox__text p {
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  color: #fff; /* if needed to match the dark modal */
  margin: 0 0 16px; 
  line-height: 1.4; 
  white-space: pre-line; 
}

/* Clickable SVG spaces: only show pointer on elements we flag as clickable */
#svg-container [data-clickable="true"] { cursor: pointer; outline: none; }

/* Lightbox container: add internal padding so dialog never hugs the iframe edges */
#unit-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  padding: clamp(8px, 2vw, 16px);
}

/* Dim overlay */
.unit-lightbox__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}

/* Modal dialog:
   - Width gutters inside iframe
   - Height capped to iframe viewport
   - Inner content scrolls, not the page */
.unit-lightbox__dialog {
  position: relative;
  margin: 0 auto;
  width: min(860px, 100% - clamp(16px, 4vw, 32px));
  max-height: calc(100dvh - clamp(16px, 4vw, 32px));
  max-height: calc(100svh - clamp(16px, 4vw, 32px)); /* Safari fallback */
  max-height: calc(100vh  - clamp(16px, 4vw, 32px)); /* generic fallback */

  background: #111; color: #eee; border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;      /* clip inner scroll */
  box-sizing: border-box;
  /* Reserve space for the corner buttons (height + inset). Use dvh/safe area where supported. */
  padding-bottom: max(56px, env(safe-area-inset-bottom, 0px) + 16px);
}

/* Close button stays pinned in the corner */
.unit-lightbox__close {
  position: absolute; top: 8px; right: 8px;
  border: 0; background: transparent; color: #bbb;
  font-size: 26px; line-height: 1; cursor: pointer;
}
.unit-lightbox__close:hover { color: #fff; }

/* Content uses a grid and becomes the scrolling area if needed */
.unit-lightbox__content {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "media text";
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;  /* allow child to shrink */
  flex: 1;        /* fill dialog height */
}

/* Media sizing: keep image from dominating tiny iframes */
.unit-lightbox__media { grid-area: media; max-height: 45dvh; overflow: hidden; }
.unit-lightbox__media img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; background:#222; }

.unit-lightbox__text { grid-area: text; min-height: 0; }

/* Narrow iframes: stack vertically */
@media (max-width: 700px) {
  .unit-lightbox__content {
    grid-template-columns: 1fr;
    grid-template-areas:
      "media"
      "text";
  }
  .unit-lightbox__media { max-height: 38dvh; }
}

/* Short/square iframes (e.g., ~387×387): put text (with CTA) above image */
@media (max-height: 500px) {
  .unit-lightbox__content {
    grid-template-columns: 1fr;
    grid-template-areas:
      "text"
      "media";
  }
  .unit-lightbox__media { max-height: 30dvh; }
}

/* Account for notches/safe areas on mobile browsers */
@supports (padding: max(0px)) {
  #unit-lightbox {
    padding-bottom: max(clamp(8px, 2vw, 16px), env(safe-area-inset-bottom));
    padding-top:    max(clamp(8px, 2vw, 16px), env(safe-area-inset-top));
  }
}

/* Shared pill look (CTA + toggle) */
.unit-lightbox__cta,
.unit-lightbox__switch {
  position: absolute;
  bottom: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #CC7A00;      /* darker orange edge */
  background: #FF9800;            /* orange fill */
  color: #111;
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  z-index: 2;
}
/* Corners: CTA left, toggle right */
.unit-lightbox__cta { left: 12px; }
.unit-lightbox__switch { right: 12px; }

/* Hover/focus accessibility */
.unit-lightbox__cta:hover,
.unit-lightbox__switch:hover { filter: brightness(0.95); }
.unit-lightbox__cta:focus-visible,
.unit-lightbox__switch:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
/* Compact mode turns the lightbox into a single-pane view with a toggle */
#unit-lightbox.is-mobile-compact .unit-lightbox__content {
  grid-template-columns: 1fr;
  grid-template-areas: "media" "text"; /* order is controlled by show-* classes below */
}

/* Show media-only */
#unit-lightbox.is-mobile-compact.show-media .unit-lightbox__media { display: block; position:relative; }
#unit-lightbox.is-mobile-compact.show-media .unit-lightbox__text { display: none; }
/* Show text-only */
#unit-lightbox.is-mobile-compact.show-text  .unit-lightbox__media { display: none; }
#unit-lightbox.is-mobile-compact.show-text  .unit-lightbox__text { display: block; }

/* When compact, keep the image contained and readable */
#unit-lightbox.is-mobile-compact .unit-lightbox__media { 
  max-height: none; 
}
#unit-lightbox.is-mobile-compact .unit-lightbox__media img { 
  height: auto; 
  max-height: calc(100dvh - 80px);  /* leave room for pills/close */
  object-fit: contain;
  background: #111;
}

/* Show the appropriate pill per view */
#unit-lightbox.is-mobile-compact.show-media .unit-lightbox__switch--toText  { display: inline-block; }
#unit-lightbox.is-mobile-compact.show-media .unit-lightbox__switch--toMedia { display: none; }
#unit-lightbox.is-mobile-compact.show-text  .unit-lightbox__switch--toText  { display: none; }
#unit-lightbox.is-mobile-compact.show-text  .unit-lightbox__switch--toMedia { display: inline-block; }

/* Show the new caption only in compact + media view (photo-only) */
.unit-lightbox__caption-outside {
  position: absolute;
  left: 12px;
  right: 120px;            /* leave room for the Details → pill on the right */
  bottom: 10px;
  padding: 6px 0;          /* no background: it's *below* the image, not overlay */
  margin: 0;
  z-index: 2;
  color: #fff;
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  text-transform: capitalize;
  letter-spacing: 0;
  font-weight: 200;        /* bump a touch for readability; adjust if you want thinner */
  font-size: 46px;
  line-height: 56px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* long titles won’t run under the Details pill */
}

#unit-lightbox.is-mobile-compact.show-text  .unit-lightbox__caption-outside  { display: none; }
#unit-lightbox.is-mobile-compact.show-media .unit-lightbox__caption-outside  { display: inline-block; }