/* SPM gallery: styles are scoped to the grid and its dedicated viewer. */
.container-fluid-gallery { padding: 20px; }
.container-fluid-gallery .img-w {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-bottom: 20px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  border-radius: 0;
}
.container-fluid-gallery .img-w img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .container-fluid-gallery .img-w:hover img { transform: scale(1.08); }
}
.container-fluid-gallery .img-w:focus-visible,
.spm-gallery-viewer button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -5px;
  box-shadow: 0 0 0 3px #111;
}
.spm-gallery-viewer {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 9999;
  overflow: hidden;
  isolation: isolate;
  background: #000;
  color: #fff;
  font-family: inherit;
  overscroll-behavior: contain;
}
.spm-gallery-viewer *, .spm-gallery-viewer *::before, .spm-gallery-viewer *::after { box-sizing: border-box; }
.spm-gallery-viewer [hidden] { display: none !important; }
.spm-gallery-surface { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.spm-gallery-surface img { position: absolute; left: 50%; top: 50%; max-width: none; max-height: none; pointer-events: none; }
.spm-gallery-viewer.is-exploring .spm-gallery-surface { cursor: grab; }
.spm-gallery-viewer.is-dragging .spm-gallery-surface { cursor: grabbing; }
.spm-gallery-toolbar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: none;
}
.spm-gallery-viewer button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 24px;
  background: rgba(0,0,0,.75);
  color: #fff;
  font: inherit;
  font-size: 24px;
  line-height: 0;
  padding: 0 12px;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  padding-bottom: 6px !important;
}
.spm-gallery-viewer button:hover { background: #222; }
.spm-gallery-viewer button:disabled { opacity: .45; cursor: default; }
.spm-gallery-viewer [data-action="reset"] { font-size: 14px; }
.spm-gallery-viewer [data-action="close"] { font-size: 28px; }
.spm-gallery-arrow { position: absolute; top: 50%; transform: translateY(-50%); }
.spm-gallery-viewer .spm-gallery-arrow { font-size: 32px; }
.spm-gallery-prev { left: max(10px, env(safe-area-inset-left)); }
.spm-gallery-next { right: max(10px, env(safe-area-inset-right)); }
.spm-gallery-caption {
  position: absolute;
  bottom: -20px;
  left: 0;
  width: 100%;
  max-height: 35%;
  overflow: hidden;
  padding: 20px max(20px, env(safe-area-inset-right)) max(42px, calc(env(safe-area-inset-bottom) + 32px)) max(20px, env(safe-area-inset-left));
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  pointer-events: none;
}
.spm-gallery-caption h2 { color: #fff; font-size: 1.25rem; margin: 0; }
.spm-gallery-caption p { color: #fff; font-size: .95rem; margin: 5px 0 0; }
.spm-gallery-viewer.is-exploring .spm-gallery-caption { visibility: hidden; }
.spm-gallery-status {
  position: absolute;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: max(20px, env(safe-area-inset-left));
  right: max(20px, env(safe-area-inset-right));
  margin: 0;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 3px #000, 0 0 5px #000;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .container-fluid-gallery .img-w img { transition: none; }
}

/* Optional source link; retain the original full-viewport image and overlay. */
.spm-gallery-caption.has-source {
  max-height: calc(100% - 80px);
  overflow-y: auto;
}
.spm-gallery-source a {
  display: inline-block;
  max-width: 100%;
  min-height: 44px;
  padding: 6px 0px;
  color: var(--spm-gallery-link-color);
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
  pointer-events: auto;
  touch-action: manipulation;
}
.spm-gallery-source a:hover { color: #ffd966; }
.spm-gallery-source a:focus-visible {
  outline: 3px solid #ffd966;
  outline-offset: 2px;
}
