/* Photo gallery widget. Scoped to .ds-gallery; themable via --ds-* variables.
 * Layout adapts to the container (data-ds-size on the placeholder, set by embed.js);
 * only the full-screen lightbox uses viewport units. */
.ds-gallery { --ds-g-gap: 12px; --ds-g-cols: 3; font-family: var(--ds-font, inherit); color: var(--ds-text, inherit);
  box-sizing: border-box; max-width: 100%; }
.ds-gallery *, .ds-gallery *::before, .ds-gallery *::after { box-sizing: border-box; }
.ds-gallery:focus { outline: none; }
.ds-gallery ul.ds-gallery__grid, .ds-gallery ul.ds-gallery__masonry, .ds-gallery ul.ds-gallery__justified,
.ds-gallery ul.ds-gallery__albums { list-style: none; margin: 0; padding: 0; }
.ds-gallery__frame { position: relative; }
.ds-gallery__fig { margin: 0; }
.ds-gallery__inner { display: block; }
.ds-gallery__pic { display: block; width: 100%; height: 100%; }
.ds-gallery__pic img { display: block; width: 100%; height: 100%; object-fit: cover; border: 0;
  border-radius: var(--ds-radius, 10px); background: rgba(127, 127, 127, .12); }
.ds-gallery__open { display: block; width: 100%; height: 100%; padding: 0; margin: 0; border: 0; background: none;
  color: inherit; font: inherit; cursor: zoom-in; border-radius: var(--ds-radius, 10px); }
.ds-gallery__open:focus-visible, .ds-gallery__album:focus-visible, .ds-gallery__nav:focus-visible,
.ds-gallery__more:focus-visible, .ds-gallery__back:focus-visible, .ds-gallery__track:focus-visible,
.ds-gallery__strip:focus-visible, .ds-gallery__link:focus-visible {
  outline: 3px solid var(--ds-accent, #4f46e5); outline-offset: 2px; }
.ds-gallery__open .ds-gallery__pic img { transition: transform .35s ease, filter .35s ease; }
@media (hover: hover) {
  .ds-gallery__open:hover .ds-gallery__pic img { filter: brightness(1.04) saturate(1.04); }
}
.ds-gallery__cap { margin: 6px 2px 0; font-size: .92em; line-height: 1.4; opacity: .85; overflow-wrap: anywhere; }
.ds-gallery__empty { margin: 0; padding: 18px 0; opacity: .7; }
.ds-gallery__head[hidden], .ds-gallery__more[hidden] { display: none; }
.ds-gallery__title { margin: 8px 0 4px; font-size: 1.25em; }
.ds-gallery__title:focus { outline: none; }
.ds-gallery__desc { margin: 0 0 12px; opacity: .8; }

/* grid: even squares */
.ds-gallery__grid { display: grid; grid-template-columns: repeat(var(--ds-g-cols), minmax(0, 1fr)); gap: var(--ds-g-gap); }
.ds-gallery__grid .ds-gallery__open, .ds-gallery__grid .ds-gallery__pic { aspect-ratio: 1; height: auto; }
.ds-gallery__grid .ds-gallery__pic img { aspect-ratio: 1; }

/* masonry: natural shapes, row-major order (spans set by the script) */
.ds-gallery__masonry { display: grid; grid-template-columns: repeat(var(--ds-g-cols), minmax(0, 1fr));
  grid-auto-rows: 4px; column-gap: var(--ds-g-gap); row-gap: var(--ds-g-gap); align-items: start; }
.ds-gallery__masonry .ds-gallery__pic, .ds-gallery__masonry .ds-gallery__open { height: auto; }
.ds-gallery__masonry .ds-gallery__pic img { height: auto; aspect-ratio: var(--ds-g-ratio, auto); }

/* justified rows: widths/heights set by the script */
.ds-gallery__justified { display: flex; flex-wrap: wrap; gap: var(--ds-g-gap); }
.ds-gallery__justified > .ds-gallery__item { flex: 0 0 auto; min-width: 0; max-width: 100%; height: 190px; width: 260px; }
.ds-gallery__justified .ds-gallery__fig, .ds-gallery__justified .ds-gallery__inner { height: 100%; }
.ds-gallery__justified .ds-gallery__pic img { border-radius: calc(var(--ds-radius, 10px) * .6); }

/* carousel / slider */
.ds-gallery__track { --ds-g-slide: 100%; display: flex; gap: var(--ds-g-gap); overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; border-radius: var(--ds-radius, 10px); }
.ds-gallery__track::-webkit-scrollbar { display: none; }
.ds-gallery__track > .ds-gallery__item { flex: 0 0 var(--ds-g-slide); min-width: 0; scroll-snap-align: start; }
.ds-gallery__track .ds-gallery__pic, .ds-gallery__track .ds-gallery__open { aspect-ratio: 3 / 2; height: auto; }
.ds-gallery__nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 999px;
  border: 0; background: rgba(255, 255, 255, .92); color: #111; font-size: 26px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18); display: grid; place-items: center; padding: 0 0 3px; }
.ds-gallery__nav:disabled { opacity: 0; pointer-events: none; }
.ds-gallery__nav--prev { left: 10px; }
.ds-gallery__nav--next { right: 10px; }
.ds-gallery--carousel .ds-gallery__frame:has(.ds-gallery__cap) .ds-gallery__nav { top: calc(50% - 14px); }
.ds-gallery__count { margin: 8px 0 0; text-align: center; font-size: .9em; opacity: .75; font-variant-numeric: tabular-nums; }

/* featured strip: one scrolling row */
.ds-gallery__strip { --ds-g-strip: 180px; display: flex; gap: var(--ds-g-gap); overflow-x: auto; scroll-snap-type: x proximity;
  overscroll-behavior-x: contain; scrollbar-width: thin; padding-bottom: 6px; }
.ds-gallery__strip > .ds-gallery__item { flex: 0 0 auto; height: var(--ds-g-strip); width: 240px; scroll-snap-align: start; }
.ds-gallery__strip .ds-gallery__fig, .ds-gallery__strip .ds-gallery__inner { height: 100%; }

.ds-gallery__more, .ds-gallery__back { font: inherit; font-weight: 650; min-height: 44px; padding: 10px 20px; margin-top: 16px;
  border: 1px solid rgba(127, 127, 127, .35); border-radius: var(--ds-radius, 10px); background: var(--ds-bg, #fff);
  color: inherit; cursor: pointer; }
.ds-gallery__back { margin: 0 0 8px; padding: 8px 4px; border-color: transparent; background: none; color: var(--ds-accent, inherit); }
.ds-gallery__more:disabled { opacity: .6; cursor: progress; }
.ds-gallery__link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 10px; color: var(--ds-accent, inherit);
  font-weight: 650; text-decoration: none; }
.ds-gallery__link:hover { text-decoration: underline; }

/* album covers */
.ds-gallery__albums { display: grid; grid-template-columns: repeat(var(--ds-g-cols), minmax(0, 1fr)); gap: var(--ds-g-gap); }
.ds-gallery__album { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit;
  text-align: left; cursor: pointer; border-radius: var(--ds-radius, 10px); }
.ds-gallery__cover { display: block; aspect-ratio: 4 / 3; border-radius: var(--ds-radius, 10px); overflow: hidden;
  background: rgba(127, 127, 127, .14); }
.ds-gallery__cover .ds-gallery__pic img { border-radius: 0; transition: transform .4s ease; }
@media (hover: hover) { .ds-gallery__album:hover .ds-gallery__cover img { transform: scale(1.03); } }
.ds-gallery__aname { display: block; margin-top: 8px; font-weight: 700; overflow-wrap: anywhere; }
.ds-gallery__acount { display: block; font-size: .88em; opacity: .7; }

/* narrow containers */
[data-ds-size="xs"] .ds-gallery { --ds-g-gap: 6px; }
[data-ds-size="sm"] .ds-gallery { --ds-g-gap: 8px; }
[data-ds-size="xs"] .ds-gallery__cap { font-size: .85em; margin-top: 4px; }
[data-ds-size="xs"] .ds-gallery__nav { width: 44px; height: 44px; font-size: 22px; }
[data-ds-size="xs"] .ds-gallery__nav--prev { left: 6px; }
[data-ds-size="xs"] .ds-gallery__nav--next { right: 6px; }
[data-ds-size="xs"] .ds-gallery__aname { font-size: .95em; }

/* lightbox (fixed to the screen, so viewport units are right here) */
.ds-gallery__lb { position: fixed; inset: 0; z-index: 2147483000; display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh;
  background: rgba(10, 10, 12, .96); color: #f4f4f5;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  font-family: var(--ds-font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif); }
.ds-gallery__lb[hidden] { display: none; }
.ds-gallery__lb-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 0 16px; }
.ds-gallery__lb-count { margin: 0; font-size: 14px; font-variant-numeric: tabular-nums; opacity: .85; }
.ds-gallery__lb-stage { position: relative; min-height: 0; display: grid; place-items: center; padding: 8px 64px;
  touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; }
.ds-gallery__lb-stage .ds-gallery__pic { display: contents; }
.ds-gallery__lb-stage img { position: absolute; inset: 8px 64px; margin: auto; width: auto; height: auto;
  max-width: calc(100% - 128px); max-height: calc(100% - 16px); object-fit: contain;
  border-radius: 4px; background: none; -webkit-user-drag: none; }
.ds-gallery__lb-btn { width: 48px; height: 48px; border-radius: 999px; border: 0; background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 30px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0 0 4px; }
.ds-gallery__lb-btn:hover { background: rgba(255, 255, 255, .22); }
.ds-gallery__lb-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.ds-gallery__lb-btn[hidden] { display: none; }
.ds-gallery__lb-prev, .ds-gallery__lb-next { position: absolute; top: 50%; transform: translateY(-50%); }
.ds-gallery__lb-prev { left: max(8px, env(safe-area-inset-left, 0px)); }
.ds-gallery__lb-next { right: max(8px, env(safe-area-inset-right, 0px)); }
.ds-gallery__lb-cap { margin: 0; padding: 10px 20px 16px; text-align: center; font-size: 15px; line-height: 1.45;
  max-height: 28vh; overflow-y: auto; overflow-wrap: anywhere; }
.ds-gallery__lb-cap[hidden] { display: none; }
@media (max-width: 640px) {
  .ds-gallery__lb-stage { padding: 4px 0; }
  .ds-gallery__lb-stage img { inset: 4px 0; max-width: 100%; max-height: calc(100% - 8px); border-radius: 0; }
  .ds-gallery__lb-prev, .ds-gallery__lb-next { top: auto; bottom: 12px; transform: none; background: rgba(255, 255, 255, .16); }
  .ds-gallery__lb { grid-template-rows: auto minmax(0, 1fr) auto 72px; }
}
@media (prefers-reduced-motion: reduce) {
  .ds-gallery__open .ds-gallery__pic img, .ds-gallery__cover .ds-gallery__pic img { transition: none; }
  .ds-gallery__album:hover .ds-gallery__cover img { transform: none; }
  .ds-gallery__track, .ds-gallery__strip { scroll-behavior: auto; }
}
