/* DLS Gallery — GPL-2.0-or-later.
 * Adapted from the selected DLS Gallery design: 24px gutters, 4px image corners,
 * 8px caption spacing. Host typography and colours remain inherited.
 */
.dls-gallery {
    --dls-gallery-column: 16rem;
    --dls-gallery-ratio: 3 / 2;
    display: grid;
    /* auto-fill keeps empty tracks, so one or two images are not stretched and blurred.
     * Columns end up between one and two times the minimum width (layout `sizes`). */
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--dls-gallery-column)), 1fr));
    gap: 2rem 1.5rem;
    margin-block: 1.5rem;
}
.dls-gallery--size-s { --dls-gallery-column: 12rem; gap: 1.5rem 1rem; }
.dls-gallery--size-l { --dls-gallery-column: 22rem; }
.dls-gallery--ratio-4-3 { --dls-gallery-ratio: 4 / 3; }
.dls-gallery--ratio-1-1 { --dls-gallery-ratio: 1 / 1; }
.dls-gallery--ratio-natural { align-items: start; }
.dls-gallery__item { min-width: 0; margin: 0; }
.dls-gallery__link { display: block; border-radius: var(--dls-radius, 4px); }
.dls-gallery__picture { display: block; }
.dls-gallery__link:focus-visible { outline: 3px solid currentColor; outline-offset: 5px; }
.dls-gallery__image {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: var(--dls-gallery-ratio);
    object-fit: cover;
    border-radius: var(--dls-radius, 4px);
    transition: opacity .2s ease;
}
.dls-gallery--ratio-natural .dls-gallery__image { aspect-ratio: auto; }
.dls-gallery__link:hover .dls-gallery__image { opacity: .85; }
@media (prefers-reduced-motion: reduce) { .dls-gallery__image { transition: none; } }
.dls-gallery__caption { margin-top: .5rem; font-size: .9em; overflow-wrap: anywhere; }
.pswp__dls-caption {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(85%, 42rem);
    padding: .5rem .875rem;
    color: #fff;
    background: rgb(0 0 0 / 75%);
    border-radius: 4px;
    font-size: 1rem;
    overflow-wrap: anywhere;
    text-align: center;
}
.pswp__dls-caption:empty { display: none; }
.dls-gallery__link--video { position: relative; }
/* Play symbol on video posters, drawn in CSS. */
.dls-gallery__link--video::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3.5rem;
    height: 3.5rem;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgb(0 0 0 / 60%) no-repeat 58% 50% / 40% url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12'%3E%3Cpath d='M0 0l10 6-10 6z' fill='%23fff'/%3E%3C/svg%3E");
    pointer-events: none;
}
.dls-gallery__placeholder { background: #2b2f33; }
.pswp__dls-video { display: flex; align-items: center; justify-content: center; }
.pswp__dls-video video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.dls-gallery--ratio-natural .dls-gallery__placeholder { aspect-ratio: 16 / 9; }
/* Layouts for mixed portrait and landscape items. */
.dls-gallery--layout-masonry {
    display: block;
    columns: var(--dls-gallery-column) auto;
    column-gap: 1.5rem;
}
.dls-gallery--layout-masonry .dls-gallery__item { break-inside: avoid; margin-bottom: 1.5rem; }
.dls-gallery--layout-justified {
    --dls-row: 14rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem .75rem;
}
.dls-gallery--layout-justified.dls-gallery--size-s { --dls-row: 10rem; }
.dls-gallery--layout-justified.dls-gallery--size-l { --dls-row: 20rem; }
/* Items grow in proportion to their aspect ratio, so every row has one height. */
.dls-gallery--layout-justified .dls-gallery__item { flex: var(--dls-ratio, 1.5) 1 calc(var(--dls-ratio, 1.5) * var(--dls-row)); }
/* Keeps a short last row from stretching. */
.dls-gallery--layout-justified::after { content: ""; flex: 999 1 0; }
.dls-gallery--layout-masonry .dls-gallery__image { aspect-ratio: auto; }
.dls-gallery--layout-justified .dls-gallery__image { aspect-ratio: var(--dls-ratio, 1.5); }
.dls-gallery--layout-masonry .dls-gallery__placeholder { aspect-ratio: 16 / 9; }
/* Video previews in the grid. */
.dls-gallery__preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--dls-radius, 4px);
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}
.dls-gallery__preview.is-playing { opacity: 1; }
.dls-gallery__link--video:has(.is-playing)::after { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .dls-gallery__preview { transition: none; } }
/* Configured gap between items (px); without it each layout keeps its own spacing. */
.dls-gallery--gap { gap: var(--dls-gap); }
.dls-gallery--gap.dls-gallery--layout-masonry { column-gap: var(--dls-gap); }
.dls-gallery--gap.dls-gallery--layout-masonry .dls-gallery__item { margin-bottom: var(--dls-gap); }
/* Page navigation below the gallery; colours follow the site. */
.dls-gallery__pager { margin-block: -.5rem 1.5rem; text-align: center; }
.dls-gallery__pager-list { display: flex; flex-wrap: wrap; justify-content: center; gap: .375rem; margin: 0; padding: 0; list-style: none; }
.dls-gallery__pager-button {
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: .375rem .75rem;
    color: inherit;
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 4px;
    font: inherit;
    cursor: pointer;
}
.dls-gallery__pager-button[aria-current="page"] { font-weight: 700; box-shadow: inset 0 0 0 1px currentColor; }
.dls-gallery__pager-button:disabled { opacity: .4; cursor: default; }
.dls-gallery__pager-button:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
.dls-gallery__pager-gap { display: inline-block; min-width: 1.5rem; line-height: 2.5rem; }
.dls-gallery__pager-status { margin: .5rem 0 0; font-size: .9em; opacity: .8; }
/* Still copy of the previous lightbox item while it leaves. */
.pswp__dls-ghost { position: absolute; z-index: 0; object-fit: contain; pointer-events: none; }
/* Caption appearance from the options (custom properties on the gallery). */
.dls-gallery__caption {
    font-family: var(--dls-caption-font, inherit);
    font-size: var(--dls-caption-size, .9em);
    color: var(--dls-caption-color, inherit);
    text-align: var(--dls-caption-align, start);
}
.dls-gallery--caption-below.dls-gallery--caption-bg .dls-gallery__caption { padding: .375rem .5rem; background: var(--dls-caption-bg); border-radius: 4px; }
.dls-gallery--caption-overlay-bottom .dls-gallery__item,
.dls-gallery--caption-overlay-center .dls-gallery__item,
.dls-gallery--caption-overlay-top .dls-gallery__item { position: relative; }
.dls-gallery--caption-overlay-bottom .dls-gallery__caption,
.dls-gallery--caption-overlay-center .dls-gallery__caption,
.dls-gallery--caption-overlay-top .dls-gallery__caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: .5rem .75rem;
    color: var(--dls-caption-color, #fff);
    background: var(--dls-caption-bg, rgb(0 0 0 / 60%));
    border-radius: 0 0 var(--dls-radius, 4px) var(--dls-radius, 4px);
    pointer-events: none;
}
.dls-gallery--caption-overlay-top .dls-gallery__caption { top: 0; bottom: auto; border-radius: var(--dls-radius, 4px) var(--dls-radius, 4px) 0 0; }
/* Centred: `translate` keeps the vertical centring while the hover animation uses `transform`. */
.dls-gallery--caption-overlay-center .dls-gallery__caption { top: 50%; bottom: auto; translate: 0 -50%; border-radius: 0; }
/* Show on hover only: fade in and move slightly into place; hiding is a little quicker. */
.dls-gallery--caption-hover .dls-gallery__caption {
    opacity: 0;
    transform: translateY(.5rem);
    transition: opacity .25s ease-in, transform .25s ease-in;
}
.dls-gallery--caption-hover.dls-gallery--caption-overlay-top .dls-gallery__caption { transform: translateY(-.5rem); }
.dls-gallery--caption-hover .dls-gallery__item:hover .dls-gallery__caption,
.dls-gallery--caption-hover .dls-gallery__item:focus-within .dls-gallery__caption {
    opacity: 1;
    transform: none;
    transition: opacity .4s cubic-bezier(.2, .7, .2, 1), transform .4s cubic-bezier(.2, .7, .2, 1);
}
@media (hover: none) { .dls-gallery--caption-hover .dls-gallery__caption { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .dls-gallery--caption-hover .dls-gallery__caption,
    .dls-gallery--caption-hover.dls-gallery--caption-overlay-top .dls-gallery__caption,
    .dls-gallery--caption-hover .dls-gallery__item:hover .dls-gallery__caption,
    .dls-gallery--caption-hover .dls-gallery__item:focus-within .dls-gallery__caption { transform: none; transition: opacity .2s linear; }
}
/* Fixed column count; narrow screens use at most two columns. Two classes, so the chosen
 * count wins over site rules for the grid (e.g. a template user.css). */
.dls-gallery.dls-gallery--columns { grid-template-columns: repeat(var(--dls-columns), minmax(0, 1fr)); }
.dls-gallery--columns.dls-gallery--layout-masonry { columns: var(--dls-columns); }
@media (max-width: 40rem) {
    .dls-gallery.dls-gallery--columns { grid-template-columns: repeat(var(--dls-columns-narrow), minmax(0, 1fr)); }
    .dls-gallery--columns.dls-gallery--layout-masonry { columns: var(--dls-columns-narrow); }
}
/* Designed captions: their own paragraphs without extra outer spacing; links stay usable over images. */
.dls-gallery__caption > :first-child, .pswp__dls-caption > :first-child { margin-top: 0; }
.dls-gallery__caption > :last-child, .pswp__dls-caption > :last-child { margin-bottom: 0; }
.dls-gallery__caption a { pointer-events: auto; }
/* Whole-image background: the caption covers the item; its text sits at the chosen position. */
.dls-gallery--caption-full .dls-gallery__caption {
    top: 0;
    bottom: 0;
    translate: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border-radius: var(--dls-radius, 4px);
}
.dls-gallery--caption-full.dls-gallery--caption-overlay-center .dls-gallery__caption { justify-content: center; }
.dls-gallery--caption-full.dls-gallery--caption-overlay-top .dls-gallery__caption { justify-content: flex-start; }
/* The whole area fades in on hover, without moving. */
.dls-gallery--caption-full.dls-gallery--caption-hover .dls-gallery__caption { transform: none; }
/* Lightbox corner radius (option); set on the PhotoSwipe root by gallery.js. */
.pswp__img, .pswp__dls-video video, .pswp__dls-ghost { border-radius: var(--dls-lightbox-radius, 0); }
