/* =====================================================================
   UGTM FAE child - article photo gallery, image viewer and Facebook link
   (2026-11-15).

   Loaded by single.php ONLY on posts whose content carries one of the
   opt-in hooks (.ugtm-gallery, .ugtm-fb-link, data-ugtm-lightbox), so no
   other page, card, logo or image is affected. Every selector is scoped
   to those hooks or to the viewer the script creates.

   Without JavaScript the gallery is still a native horizontal scroll-snap
   strip (swipe / trackpad) and every image links to its full-size file.
   ===================================================================== */

/* --- gallery shell ---------------------------------------------------- */
.ugtm-article .entry-content > .ugtm-gallery{margin-top:1.8em;}
.ugtm-gallery{position:relative;min-width:0;}
@media (min-width:960px){
  /* Same 860px width as the featured image above the text. */
  .ugtm-article .entry-content > .ugtm-gallery{margin-inline:-90px;}
}

.ugtm-article .entry-content .ugtm-gallery-track{
  display:flex;gap:12px;margin:0;padding:0;list-style:none;
  overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;
  scroll-snap-type:x mandatory;scrollbar-width:none;
  -webkit-overflow-scrolling:touch;border-radius:var(--radius-md);
}
.ugtm-gallery-track::-webkit-scrollbar{display:none;}
.ugtm-gallery-track:focus-visible{outline:3px solid var(--color-brand-pink-text);outline-offset:3px;}

.ugtm-article .entry-content .ugtm-gallery-track > li{
  flex:0 0 100%;min-width:0;margin:0;
  scroll-snap-align:start;scroll-snap-stop:always;
}
/* Phones: a glimpse of the next photo says "swipe" without words. */
@media (max-width:600px){
  .ugtm-article .entry-content .ugtm-gallery:not(.ugtm-gallery--docs) .ugtm-gallery-track > li{flex-basis:88%;}
}

.ugtm-gallery-slide{margin:0;}
.ugtm-article .entry-content .ugtm-gallery-frame{
  position:relative;display:block;width:100%;aspect-ratio:4/3;max-height:78vh;
  overflow:hidden;background:var(--color-surface-soft);
  border:1px solid var(--color-border);border-radius:var(--radius-md);
  text-decoration:none;cursor:zoom-in;
}
.ugtm-article .entry-content .ugtm-gallery--r32 .ugtm-gallery-frame{aspect-ratio:3/2;}
.ugtm-article .entry-content .ugtm-gallery--r169 .ugtm-gallery-frame{aspect-ratio:16/9;}
.ugtm-article .entry-content .ugtm-gallery--r21 .ugtm-gallery-frame{aspect-ratio:2/1;}
.ugtm-article .entry-content .ugtm-gallery--rport .ugtm-gallery-frame{aspect-ratio:5/7;}

/* contain = the whole photo is always shown: never cropped, never stretched. */
.ugtm-article .entry-content .ugtm-gallery-frame img{
  position:absolute;inset:0;width:100%;height:100%;max-width:none;
  object-fit:contain;border-radius:0;
}
.ugtm-gallery-slide figcaption{
  margin-top:8px;text-align:center;font-size:var(--fs-small);
  line-height:1.6;color:var(--color-muted);
}

/* --- controls (built by the script) ---------------------------------- */
.ugtm-gallery-bar{display:flex;align-items:center;justify-content:space-between;
  gap:12px;margin-top:12px;}
.ugtm-gallery-status{display:flex;flex-direction:column;align-items:center;gap:2px;
  min-width:0;text-align:center;}
.ugtm-gallery-count{margin:0;font-size:var(--fs-small);font-weight:700;
  color:var(--color-muted);font-variant-numeric:tabular-nums;}
.ugtm-gallery-hint{margin:0;font-size:12px;color:var(--color-muted);}
.ugtm-gallery-btn,.ugtm-lightbox-btn{
  flex:none;display:inline-flex;align-items:center;justify-content:center;
  width:44px;height:44px;padding:0;border-radius:var(--radius-pill);
  font:inherit;line-height:1;cursor:pointer;
}
.ugtm-gallery-btn{background:var(--color-surface);color:var(--color-ink);
  border:1px solid var(--color-border);box-shadow:var(--shadow-resting);}
.ugtm-gallery-btn:hover{border-color:var(--color-brand-gold);}
.ugtm-gallery-btn[disabled]{opacity:.35;cursor:default;box-shadow:none;}
.ugtm-gallery-btn[disabled]:hover{border-color:var(--color-border);}
.ugtm-gallery-btn svg,.ugtm-lightbox-btn svg{width:20px;height:20px;}

/* --- explanatory image that opens in the viewer (#23 examples) -------- */
.ugtm-article .entry-content a[data-ugtm-lightbox]{display:block;cursor:zoom-in;}

/* --- image viewer ------------------------------------------------------ */
html.ugtm-lb-open{overflow:hidden;}
.ugtm-lightbox{
  position:fixed;inset:0;width:auto;height:auto;max-width:none;max-height:none;
  margin:0;padding:0;border:0;background:rgba(16,16,0,.94);color:#fff;
  font-family:var(--font-body);
}
.ugtm-lightbox::backdrop{background:rgba(16,16,0,.94);}
.ugtm-lightbox-inner{display:grid;grid-template-rows:auto minmax(0,1fr) auto;height:100%;}
.ugtm-lightbox-top,.ugtm-lightbox-bottom{display:flex;align-items:center;
  justify-content:space-between;gap:12px;padding:10px 14px;}
.ugtm-lightbox-bottom{padding-bottom:max(14px,env(safe-area-inset-bottom));}
.ugtm-lightbox-stage{display:flex;align-items:center;justify-content:center;
  min-height:0;padding:0 10px;touch-action:pan-y pinch-zoom;}
.ugtm-lightbox-stage img{display:block;max-width:100%;max-height:100%;
  width:auto;height:auto;object-fit:contain;border-radius:6px;}
.ugtm-lightbox-count{margin:0;font-size:var(--fs-small);font-weight:700;
  font-variant-numeric:tabular-nums;}
.ugtm-lightbox-cap{margin:0;flex:1;min-width:0;text-align:center;
  font-size:var(--fs-small);line-height:1.6;}
.ugtm-lightbox-orig{color:#fff;font-size:var(--fs-small);font-weight:700;
  text-decoration:underline;text-underline-offset:3px;}
.ugtm-lightbox-tools{display:flex;align-items:center;gap:14px;}
.ugtm-lightbox-btn{background:rgba(255,255,255,.08);color:#fff;
  border:1px solid rgba(255,255,255,.4);}
.ugtm-lightbox-btn:hover{background:rgba(255,255,255,.18);}
.ugtm-lightbox-btn[disabled]{opacity:.3;cursor:default;}
.ugtm-lightbox-btn[hidden]{display:none;}
.ugtm-lightbox :focus-visible{outline:3px solid var(--color-brand-pink);outline-offset:2px;}

/* --- discreet Facebook link ------------------------------------------ */
.ugtm-article .entry-content > .ugtm-fb-link{margin-top:2em;}
.ugtm-article .entry-content .ugtm-fb-link a{
  display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:0 16px;
  border:1px solid var(--color-border);border-radius:var(--radius-pill);
  background:var(--color-surface);color:var(--color-ink);
  font-size:var(--fs-small);font-weight:700;text-decoration:none;
}
.ugtm-article .entry-content .ugtm-fb-link a:hover{border-color:var(--color-brand-gold);}
/* External-link glyph drawn in CSS, so the post content stays plain text. */
.ugtm-article .entry-content .ugtm-fb-link a::after{
  content:"";flex:none;width:14px;height:14px;background:var(--color-brand-gold-text);
  -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6'/%3E%3Cpath d='M20 4 10 14'/%3E%3Cpath d='M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") center/contain no-repeat;
          mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6'/%3E%3Cpath d='M20 4 10 14'/%3E%3Cpath d='M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") center/contain no-repeat;
}
/* The arrow points up-and-out in both directions; mirror it in RTL so it
   points away from the text it follows. */
[dir="rtl"] .ugtm-article .entry-content .ugtm-fb-link a::after{transform:scaleX(-1);}

@media (prefers-reduced-motion:reduce){
  .ugtm-gallery-track{scroll-behavior:auto;}
}
