/* Adapted from Driftzine's original gallery-stage, natural-fit and lightbox code.
   Inline: natural image proportions, slim edge handles, clean cross-fade transitions.
   Viewer: dark backdrop, centred thumbnails, 180ms out / 300ms in motion. */
.publication-gallery-section.has-lp-gallery {
  width: 100%; max-width: 1040px; margin: 0 auto 40px; padding: 0; border: 0; transform: none;
}
.lp-gallery {
  width: 100%; min-width: 0; margin: 36px 0; color: #171917;
  font-family: Manrope, sans-serif; line-height: 1.4; text-align: left;
}
.has-lp-gallery > .lp-gallery { margin: 0; }
.lp-gallery *, .lp-gallery *::before, .lp-gallery *::after { box-sizing: border-box; }
.lp-gallery [hidden] { display: none !important; }
.lp-gallery :focus-visible { outline: 2px solid #2494c5; outline-offset: 4px; }
.lp-gallery button {
  appearance: none; -webkit-appearance: none; border: 0; margin: 0; cursor: pointer;
  color: inherit; font: inherit; letter-spacing: normal; text-transform: none;
  -webkit-tap-highlight-color: transparent;
}
.lp-gallery__stage {
  position: relative; width: 100%; overflow: hidden; isolation: isolate;
  border: 1px solid #d4d3ce; border-radius: 12px; background: #fff;
  transition: none !important;
}
.lp-gallery__viewport {
  position: absolute; inset: 0; overflow: hidden; touch-action: pan-y pinch-zoom;
}
.lp-gallery .lp-gallery__image {
  display: block; width: 100%; height: 100%; max-width: none; margin: 0; border: 0;
  border-radius: 0; object-fit: contain; object-position: center; user-select: none;
  -webkit-user-drag: none; backface-visibility: hidden; transform: none !important;
  transition: none !important;
}
.lp-gallery .lp-gallery__open-photo {
  position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%;
  padding: 0; background: transparent; border-radius: inherit; cursor: zoom-in;
}
.lp-gallery .lp-gallery__open-photo:focus-visible { outline-offset: -5px; }
.lp-gallery__arrow {
  position: absolute; z-index: 3; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 44px; height: 56px; padding: 0;
  border-radius: 999px; background: transparent;
}
.lp-gallery__arrow--previous { left: 0; }
.lp-gallery__arrow--next { right: 0; }
.lp-gallery__arrow::before {
  content: ""; position: absolute; width: 26px; height: 46px; border-radius: 999px;
  background: rgb(12 12 12 / 46%); backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
  box-shadow: 0 8px 24px rgb(0 0 0 / 14%); transition: background .2s;
}
.lp-gallery__arrow::after {
  content: ""; position: absolute; width: 2px; height: 16px; border-radius: 999px;
  background: rgb(255 255 255 / 92%); transition: height .22s cubic-bezier(.22,1,.36,1);
}
.lp-gallery__arrow svg { display: none; }
.lp-gallery__toolbar, .lp-gallery__thumbnails { display: none; }
.lp-gallery .lp-gallery__caption { margin: 12px 0 0; color: #636762; font-size: 13px; line-height: 1.5; }
.lp-gallery__count { font: 12px 'DM Mono', monospace; white-space: nowrap; letter-spacing: .06em; }
.lp-gallery__actions { display: flex; gap: 4px; align-items: center; }
.lp-gallery__action {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-width: 44px; min-height: 44px; padding: 8px 12px; border-radius: 24px;
  background: transparent; font-size: 12px !important; font-weight: 600 !important;
}
.lp-gallery__loading {
  display: none; position: absolute; z-index: 4; top: 18px; left: 50%;
  transform: translateX(-50%); padding: 8px 12px; border-radius: 20px;
  color: #171917; background: rgb(255 255 255 / 95%); font-size: 12px; white-space: nowrap;
}
.lp-gallery.is-loading .lp-gallery__loading { display: block; }
.lp-gallery__error {
  position: absolute; z-index: 2; inset: 0 54px; display: flex; flex-direction: column;
  gap: 14px; align-items: center; justify-content: center; font-size: 14px; text-align: center;
}
.lp-gallery__error button { min-height: 44px; padding: 10px 18px; border-radius: 24px; background: #edf4f7; color: #171917; }
.lp-gallery__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.lp-gallery-open { overflow: hidden; }
.lp-gallery-dialog {
  position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; height: 100dvh;
  max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: #fff; overflow: hidden;
}
.lp-gallery-dialog::backdrop { background: rgb(0 0 0 / 85%); }
.lp-gallery.is-expanded { position: relative; width: 100%; height: 100%; margin: 0; color: #fff; }
.lp-gallery.is-expanded .lp-gallery__stage {
  position: absolute; inset: 64px clamp(24px,3vw,64px) 112px; width: auto; height: auto;
  min-height: 0; border: 0; border-radius: 0; background: transparent; transition: none;
}
.lp-gallery.is-expanded .lp-gallery__viewport { cursor: grab; }
.lp-gallery.is-expanded .lp-gallery__viewport:active { cursor: grabbing; }
.lp-gallery.is-expanded .lp-gallery__toolbar {
  position: absolute; top: max(12px,env(safe-area-inset-top)); right: 24px; left: 24px;
  z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.lp-gallery.is-expanded .lp-gallery__arrow {
  position: fixed; top: 50%; width: 50px; height: 80px; color: #fff; border-radius: 0;
}
.lp-gallery.is-expanded .lp-gallery__arrow--previous { left: 12px; }
.lp-gallery.is-expanded .lp-gallery__arrow--next { right: 12px; }
.lp-gallery.is-expanded .lp-gallery__arrow::before, .lp-gallery.is-expanded .lp-gallery__arrow::after { display: none; }
.lp-gallery.is-expanded .lp-gallery__arrow svg { display: block; width: 32px; height: 32px; }
.lp-gallery.is-expanded .lp-gallery__thumbnails {
  position: absolute; bottom: max(20px,env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); display: flex; width: max-content; max-width: 90%;
  gap: 10px; padding: 4px; overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: thin; scrollbar-color: #777 transparent;
}
.lp-gallery .lp-gallery__thumbnail {
  flex: 0 0 60px; width: 60px; height: 60px; padding: 0;
  border: 2px solid transparent; border-radius: 6px; background: transparent; opacity: .6;
}
.lp-gallery .lp-gallery__thumbnail[aria-pressed="true"] { opacity: 1; border-color: #fff; }
.lp-gallery .lp-gallery__thumbnail img {
  display: block; width: 100%; height: 100%; margin: 0; object-fit: cover; border-radius: 4px;
}
.lp-gallery.is-expanded .lp-gallery__caption {
  position: absolute; bottom: 92px; left: 50%; transform: translateX(-50%); margin: 0;
  width: min(80%,900px); max-height: 3em; overflow-y: auto; text-align: center; color: #eee; font-size: 12px;
}
.lp-gallery.is-expanded:has(.lp-gallery__caption:not([hidden])) .lp-gallery__stage { bottom: 142px; }
.lp-gallery.is-zoomed .lp-gallery__viewport { overflow: auto; touch-action: pan-x pan-y pinch-zoom; cursor: auto; }
.lp-gallery.is-zoomed .lp-gallery__image { width: 200%; height: 200%; }
.lp-gallery.is-expanded .lp-gallery__action[aria-pressed="true"] { background: rgb(255 255 255 / 16%); }
.lp-gallery.is-expanded :focus-visible { outline-color: #fff; }
@media (hover: hover) {
  .lp-gallery__arrow:hover::before { background: rgb(12 12 12 / 72%); }
  .lp-gallery__arrow:hover::after { height: 28px; }
  .lp-gallery.is-expanded .lp-gallery__action:hover { background: rgb(255 255 255 / 12%); }
  .lp-gallery__thumbnail:hover { opacity: 1; }
}
@media (max-width: 767px) {
  .publication-gallery-section.has-lp-gallery { margin-bottom: 30px; }
  .lp-gallery.is-expanded .lp-gallery__stage { inset: 64px 12px 108px; }
  .lp-gallery.is-expanded .lp-gallery__arrow--previous { left: 0; }
  .lp-gallery.is-expanded .lp-gallery__arrow--next { right: 0; }
  .lp-gallery.is-expanded .lp-gallery__arrow { width: 44px; height: 56px; border-radius: 999px; background: rgb(12 12 12 / 46%); }
  .lp-gallery.is-expanded .lp-gallery__arrow svg { width: 25px; height: 25px; }
  .lp-gallery.is-expanded .lp-gallery__toolbar { right: 12px; left: 12px; }
  .lp-gallery__action { padding: 8px; }
}
@media (max-width: 360px) { .lp-gallery__action span { display: none; } }
@media (max-height: 450px) and (orientation: landscape) {
  .lp-gallery.is-expanded .lp-gallery__stage { inset: 52px 50px 82px; }
  .lp-gallery.is-expanded .lp-gallery__thumbnails { bottom: 8px; }
  .lp-gallery .lp-gallery__thumbnail { flex-basis: 48px; width: 48px; height: 48px; }
  .lp-gallery.is-expanded .lp-gallery__caption { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .lp-gallery__stage, .lp-gallery__arrow::before, .lp-gallery__arrow::after { transition: none; }
}
