/* Photo galleries: the gallery on a page, and its focus mode (lightbox). Settings arrive as classes and CSS variables set by inc/photo-gallery.php.
   Colours follow the site's colour tokens (Settings → Soulimous colours); the fallbacks only matter in the admin preview. */

.pg {
	--pg-ink: var(--ink, #1e1c1a);
	--pg-soft: var(--ink-soft, #6b6257);
	--pg-accent: var(--accent, #8a6f45);
	--pg-line: var(--line, rgba(30, 28, 26, .22));
	--pg-ease: .45s cubic-bezier(.2, .6, .2, 1);
	margin: 2rem 0;
	color: var(--pg-ink);
}
.pg *, .pg *::before, .pg *::after { box-sizing: border-box; }
.pg__note { font: 12px/1.5 "IBM Plex Mono", monospace; color: var(--pg-soft); }

.pg__list { list-style: none; margin: 0; padding: 0; }
.pg__item { margin: 0; padding: 0; min-width: 0; }
.pg__item[hidden] { display: none !important; }
.pg__link { display: block; position: relative; color: inherit; text-decoration: none; outline-offset: 3px; }
.pg--click-none .pg__link { cursor: default; }
.pg__link:focus-visible { outline: 2px solid var(--pg-accent); }
.pg__img { display: block; position: relative; overflow: hidden; background: var(--pg-line); }
.pg__img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform var(--pg-ease), filter var(--pg-ease), opacity var(--pg-ease); }

/* ---- layouts ---- */
.pg--layout-grid .pg__list { display: grid; grid-template-columns: repeat(var(--pg-cols), minmax(0, 1fr)); gap: var(--pg-gap-y) var(--pg-gap-x); align-items: start; }
.pg--layout-grid .pg__img img { height: auto; }
.pg--layout-grid:not(.pg--shape-original) .pg__img img { height: 100%; }
.pg--shape-square .pg__img { aspect-ratio: 1 / 1; }
.pg--shape-4-5 .pg__img { aspect-ratio: 4 / 5; }
.pg--shape-2-3 .pg__img { aspect-ratio: 2 / 3; }
.pg--shape-3-2 .pg__img { aspect-ratio: 3 / 2; }
.pg--shape-16-9 .pg__img { aspect-ratio: 16 / 9; }

.pg--layout-masonry .pg__list { column-count: var(--pg-cols); column-gap: var(--pg-gap-x); }
.pg--layout-masonry .pg__item { break-inside: avoid; margin-bottom: var(--pg-gap-y); }
.pg--layout-masonry .pg__img img { height: auto; }

.pg--layout-justified .pg__list { display: flex; flex-wrap: wrap; gap: var(--pg-gap-y) var(--pg-gap-x); }
.pg--layout-justified .pg__list::after { content: ""; flex-grow: 1000000; }
.pg--layout-justified .pg__item { flex: calc(var(--ar) * 100) 1 calc(var(--ar) * var(--pg-row-h)); }
.pg--layout-justified .pg__img { aspect-ratio: var(--ar); }

/* film strip: thumbnails in a row under the big photo */
.pg--layout-filmstrip .pg__list { position: relative; display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 6px; scrollbar-width: thin; scroll-snap-type: x proximity; }
.pg--layout-filmstrip .pg__item { flex: none; scroll-snap-align: center; }
.pg--layout-filmstrip .pg__img { height: var(--pg-strip); width: calc(var(--pg-strip) * var(--ar)); opacity: .55; transition: opacity var(--pg-ease); }
.pg--layout-filmstrip .pg__item.is-current .pg__img,
.pg--layout-filmstrip .pg__link:hover .pg__img { opacity: 1; }
.pg--layout-filmstrip .pg__item.is-current .pg__img { outline: 2px solid var(--pg-accent); outline-offset: -2px; }
.pg--layout-filmstrip .pg__cap { display: none; }

/* slideshow: the list is only the source of the photos */
.pg--layout-slideshow .pg__list { display: none; }

/* ---- the big photo (film strip and slideshow) ---- */
.pg__stage { position: relative; height: var(--pg-stage-vh); min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
.pg__slide { margin: 0; flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity .35s ease; }
.pg__slide.is-out { opacity: 0; }
.pg__slide img { display: block; flex: 1 1 auto; min-height: 0; max-width: 100%; width: auto; height: auto; object-fit: contain; cursor: zoom-in; }
.pg--click-none .pg__slide img { cursor: default; }
.pg__slide figcaption { flex: none; padding-top: 10px; text-align: center; min-height: 2.6em; }
.pg__nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; color: var(--pg-ink); font-size: 26px; cursor: pointer; opacity: .55; transition: opacity .3s; }
.pg__nav:hover, .pg__nav:focus-visible { opacity: 1; }
.pg__nav:focus-visible { outline: 2px solid var(--pg-accent); }
.pg__nav--prev { left: 0; }
.pg__nav--next { right: 0; }
.pg__dots { display: flex; gap: 8px; justify-content: center; padding: 10px 0 0; flex: none; }
.pg__dot { width: 9px; height: 9px; padding: 0; border-radius: 50%; border: 1px solid var(--pg-ink); background: none; cursor: pointer; opacity: .5; }
.pg__dot.is-current { background: var(--pg-ink); opacity: 1; }
.pg--layout-filmstrip .pg__stage { margin-bottom: 4px; }

/* ---- captions ---- */
.pg__cap { display: block; }
.pg__title { display: block; font: 400 15px/1.35 Inter, system-ui, sans-serif; }
.pg__sub { display: block; margin-top: 2px; font: 400 11px/1.5 "IBM Plex Mono", monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--pg-soft); }
.pg--cap-below .pg__cap { padding-top: 8px; }
.pg--cap-overlay .pg__cap, .pg--cap-hover .pg__cap, .pg--hover-veil .pg__cap {
	position: absolute; left: 0; right: 0; bottom: 0; padding: 36px 14px 12px; color: #f4efe7;
	background: linear-gradient(to top, rgba(14, 12, 10, .72), rgba(14, 12, 10, 0));
}
.pg--cap-overlay .pg__sub, .pg--cap-hover .pg__sub, .pg--hover-veil .pg__sub { color: rgba(244, 239, 231, .78); }
.pg--cap-hover .pg__cap, .pg--hover-veil:not(.pg--cap-overlay) .pg__cap { opacity: 0; transition: opacity var(--pg-ease); }
.pg--cap-hover .pg__link:hover .pg__cap, .pg--cap-hover .pg__link:focus-visible .pg__cap,
.pg--hover-veil .pg__link:hover .pg__cap, .pg--hover-veil .pg__link:focus-visible .pg__cap { opacity: 1; }
.pg--hover-veil.pg--cap-none .pg__cap { display: none; }
.pg--layout-filmstrip .pg__cap, .pg--layout-slideshow .pg__cap { display: none; }

/* ---- hover effects ---- */
@media (hover: hover) {
	.pg--hover-zoom .pg__link:hover img { transform: scale(1.06); }
	.pg--hover-lift .pg__item { transition: transform var(--pg-ease), box-shadow var(--pg-ease); }
	.pg--hover-lift .pg__item:hover { transform: translateY(-5px); box-shadow: 0 14px 28px rgba(30, 24, 16, .22); position: relative; z-index: 1; }
	.pg--hover-dim .pg__list:hover .pg__item { opacity: .45; transition: opacity var(--pg-ease); }
	.pg--hover-dim .pg__list:hover .pg__item:hover { opacity: 1; }
	.pg--hover-outline .pg__link:hover .pg__img { outline: 2px solid var(--pg-accent); outline-offset: -2px; }
	.pg--hover-mono .pg__img img { filter: grayscale(1) contrast(1.05); }
	.pg--hover-mono .pg__link:hover img { filter: none; }
	.pg--hover-veil .pg__link:hover .pg__img img { filter: brightness(.82); }
}
.pg--hover-mono .pg__link:focus-visible img { filter: none; }
.pg--layout-filmstrip.pg--hover-zoom .pg__link:hover img { transform: scale(1.06); }

/* ---- tags ---- */
.pg__tags { display: flex; flex-wrap: wrap; gap: 8px 10px; margin: 0 0 1.4rem; }
.pg--tags-center .pg__tags { justify-content: center; }
.pg__tag { font: 400 12px/1 "IBM Plex Mono", monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--pg-soft); background: none; border: 1px solid transparent; padding: 9px 13px; cursor: pointer; transition: color .3s, border-color .3s, background .3s; }
.pg__tag sup { font-size: 9px; margin-left: 3px; opacity: .7; }
.pg__tag:hover { color: var(--pg-ink); }
.pg__tag:focus-visible { outline: 2px solid var(--pg-accent); outline-offset: 2px; }
.pg__tag.is-active { color: var(--pg-ink); }
.pg__tags--pills .pg__tag { border-color: var(--pg-line); border-radius: 999px; }
.pg__tags--pills .pg__tag.is-active { border-color: var(--pg-ink); background: var(--pg-ink); color: var(--backdrop, #e6dfd4); }
.pg__tags--text .pg__tag { padding-left: 4px; padding-right: 4px; border-bottom: 1px solid transparent; }
.pg__tags--text .pg__tag.is-active { border-bottom-color: var(--pg-accent); }

@media (max-width: 1000px) {
	.pg--layout-grid .pg__list { grid-template-columns: repeat(var(--pg-cols-md), minmax(0, 1fr)); }
	.pg--layout-masonry .pg__list { column-count: var(--pg-cols-md); }
}
@media (max-width: 640px) {
	.pg--layout-grid .pg__list { grid-template-columns: repeat(var(--pg-cols-sm), minmax(0, 1fr)); }
	.pg--layout-masonry .pg__list { column-count: var(--pg-cols-sm); }
	.pg--layout-justified .pg__item { flex-basis: calc(var(--ar) * var(--pg-row-h) * .6); }
	.pg__nav { width: 36px; height: 36px; }
	.pg--layout-filmstrip .pg__img { height: calc(var(--pg-strip) * .8); width: calc(var(--pg-strip) * .8 * var(--ar)); }
}

/* ---- focus mode (lightbox) ---- */
.pgl {
	position: fixed; inset: 0; z-index: 100000; display: flex; flex-direction: column;
	background: #0d0c0b; color: #ece6dc; opacity: 0; transition: opacity .35s ease;
	--pgl-soft: rgba(236, 230, 220, .65); --pgl-line: rgba(236, 230, 220, .28);
}
.pgl--light { background: var(--backdrop, #e6dfd4); color: var(--ink, #1e1c1a); --pgl-soft: var(--ink-soft, #6b6257); --pgl-line: rgba(30, 28, 26, .28); }
.pgl.is-open { opacity: 1; }
.pgl *, .pgl *::before, .pgl *::after { box-sizing: border-box; }
.pgl__bar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; font: 400 12px/1 "IBM Plex Mono", monospace; letter-spacing: .08em; color: var(--pgl-soft); min-height: 52px; }
.pgl__btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; color: inherit; font-size: 28px; line-height: 1; cursor: pointer; opacity: .75; transition: opacity .3s; }
.pgl__btn:hover, .pgl__btn:focus-visible { opacity: 1; }
.pgl__btn:focus-visible { outline: 2px solid var(--accent, #8a6f45); }
.pgl__main { position: relative; flex: 1; min-height: 0; display: flex; }
.pgl__slide { flex: 1; min-width: 0; min-height: 0; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 56px; transition: opacity .28s ease, transform .28s ease; }
.pgl__slide.is-leaving { opacity: 0; }
.pgl--slide .pgl__slide.is-leaving.dir-next { transform: translateX(-40px); }
.pgl--slide .pgl__slide.is-leaving.dir-prev { transform: translateX(40px); }
.pgl--slide .pgl__slide.is-entering.dir-next { transform: translateX(40px); opacity: 0; transition: none; }
.pgl--slide .pgl__slide.is-entering.dir-prev { transform: translateX(-40px); opacity: 0; transition: none; }
.pgl__slide img { flex: 1 1 auto; min-height: 0; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; user-select: none; -webkit-user-drag: none; touch-action: pan-y pinch-zoom; }
.pgl__cap { flex: none; padding: 12px 0 4px; text-align: center; max-width: 70ch; min-height: 3.2em; }
.pgl__cap .pg__title { font-size: 15px; }
.pgl__cap .pg__sub { color: var(--pgl-soft); }
.pgl--cap-overlay .pgl__slide { position: relative; }
.pgl--cap-overlay .pgl__cap { position: absolute; left: 0; right: 0; bottom: 0; max-width: none; padding: 40px 56px 16px; color: #f4efe7; background: linear-gradient(to top, rgba(14, 12, 10, .7), rgba(14, 12, 10, 0)); }
.pgl--cap-overlay .pgl__cap .pg__sub { color: rgba(244, 239, 231, .78); }
.pgl--cap-none .pgl__cap { display: none; }
.pgl__arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; }
.pgl__arrow--prev { left: 6px; }
.pgl__arrow--next { right: 6px; }
.pgl--noarrows .pgl__arrow { display: none; }
.pgl__thumbs { flex: none; display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px 14px; justify-content: safe center; scrollbar-width: thin; }
.pgl__thumb { flex: none; height: 56px; padding: 0; border: 0; background: none; cursor: pointer; opacity: .45; transition: opacity .3s; }
.pgl__thumb img { display: block; height: 100%; width: auto; }
.pgl__thumb:hover, .pgl__thumb.is-current { opacity: 1; }
.pgl__thumb.is-current { outline: 2px solid var(--accent, #8a6f45); outline-offset: 1px; }
.pgl__thumb:focus-visible { outline: 2px solid var(--accent, #8a6f45); opacity: 1; }
html.pgl-lock { overflow: hidden; }

@media (max-width: 640px) {
	.pgl__slide { padding: 0 8px; }
	.pgl--cap-overlay .pgl__cap { padding: 40px 12px 12px; }
	.pgl__arrow { display: none; }   /* phones swipe */
	.pgl__thumb { height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
	.pg *, .pgl, .pgl * { transition-duration: .01s !important; }
}
