/* Photo grid and photo viewer. Tokens come from theme.json; the fallbacks match it. */

/* Justified rows. Without script, flex-grow by aspect ratio gives the same look; justify.js then makes the rows exact. */
.jg { display: flex; flex-wrap: wrap; gap: 8px; }
.jg::after { content: ''; flex-grow: 1000000; }
.jg.jg-js::after { display: none; }
.jg > a { --row: 120px; position: relative; overflow: hidden; display: block; min-width: 0; margin: 0; flex-grow: calc(var(--ar, 1.5) * 100); flex-basis: calc(var(--ar, 1.5) * var(--row)); aspect-ratio: var(--ar, 1.5); border-radius: 12px; background: var(--wp--preset--color--canvas-subtle, #f5f5f7); }
.jg > a img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 400ms ease; }
.jg > a:hover img { transform: scale(1.03); }
.jg > a:focus-visible { outline: 2px solid var(--wp--preset--color--ink, #000); outline-offset: 3px; }
@media (min-width: 700px) { .jg > a { --row: 150px; } }
@media (min-width: 1100px) { .jg > a { --row: 190px; } }
@media (prefers-reduced-motion: reduce) { .jg > a img { transition: none; } .jg > a:hover img { transform: none; } }

/* Viewer. Opens from any link with data-lb, groups by the nearest [data-lbgroup]. */
[data-lb] { cursor: zoom-in; }
/* One column capped at the screen: without it the nowrap caption widened the auto column past a phone (491px at 390, shop review 15 Nov 2026). */
.lb { --lb-gutter: var(--wp--custom--gutter, clamp(16px, 4vw, 24px)); position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.97); display: none; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; color: #fff; }
.lb[data-open="true"] { display: grid; }
.lb__top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px var(--lb-gutter); font-size: var(--wp--preset--font-size--small, 0.875rem); }
.lb__count { font-family: var(--wp--preset--font-family--mono, ui-monospace, Menlo, monospace); font-weight: 600; opacity: .85; }
.lb__cap { opacity: .75; flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb__btn { width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; font-size: 1.125rem; line-height: 1; cursor: pointer; display: grid; place-items: center; transition: background 150ms ease; }
.lb__btn:hover { background: rgba(255,255,255,.22); }
.lb__btn:focus-visible, .lb__thumbs button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.lb__stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 0 clamp(8px, 6vw, 88px); touch-action: none; overflow: hidden; }
/* The photo fills the stage and is contained inside it, so the whole picture shows whatever its shape or size. */
.lb .lb__stage img { position: absolute; top: 0; bottom: 0; left: clamp(8px, 6vw, 88px); right: clamp(8px, 6vw, 88px); width: calc(100% - 2 * clamp(8px, 6vw, 88px)); height: 100%; max-width: none; max-height: none; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.lb__prev, .lb__next { position: absolute; top: 50%; transform: translateY(-50%); }
.lb__prev { left: clamp(8px, 1.5vw, 20px); }
.lb__next { right: clamp(8px, 1.5vw, 20px); }
.lb__thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 14px var(--lb-gutter) calc(14px + env(safe-area-inset-bottom)); scrollbar-width: none; }
.lb__thumbs::-webkit-scrollbar { display: none; }
.lb__thumbs[hidden], .lb__btn[hidden] { display: none; }
/* margin auto on the ends centres a short strip but keeps a long one scrollable from its first photo */
.lb__thumbs button:first-child { margin-left: auto; } .lb__thumbs button:last-child { margin-right: auto; }
.lb__thumbs button { flex: 0 0 auto; width: 64px; height: 48px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; opacity: .55; background: #222; cursor: pointer; transition: opacity 150ms ease, border-color 150ms ease; }
.lb__thumbs button:hover { opacity: .9; }
.lb__thumbs button[aria-current="true"] { opacity: 1; border-color: #fff; }
.lb__thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb__status { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (max-width: 640px) { .lb__prev, .lb__next { display: none; } .lb__thumbs button { width: 52px; height: 40px; } }

/* Zoom: the photo scales from its centre; dragging moves it while zoomed. */
.lb .lb__stage img { transform-origin: center; transition: transform 140ms ease-out; cursor: zoom-in; will-change: transform; }
.lb__stage.is-zoomed img { cursor: grab; }
.lb__stage.is-drag img { transition: none; cursor: grabbing; }
.lb__btn[disabled] { opacity: .35; cursor: default; }
.lb__top .lb__zout, .lb__top .lb__zin { margin-left: 8px; font-size: 1.375rem; }
@media (prefers-reduced-motion: reduce) { .lb .lb__stage img { transition: none; } }
.lb__prev, .lb__next { z-index: 3; }
/* Button icons are inline SVG drawn about their centre; block display drops the inline baseline gap. */
.lb__btn svg { display: block; width: 20px; height: 20px; pointer-events: none; }
