/* Article galleries (tools/editorial/escapese-fig.mjs) and the photo viewer (gallery.js). */

/* The article column must not grow with its content (long captions, photo rows). */
.article-layout > .prose { min-width: 0; }

/* Grid of photos inside the article */
.prose .pxb-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 28px 0 10px; }
.prose .pxb-gallery-item { display: flex; flex-direction: column; margin: 0; min-width: 0; }
.prose .pxb-gallery-item > a { position: relative; display: block; overflow: hidden; border-radius: 12px; background: var(--surface); aspect-ratio: 4 / 3; }
.prose .pxb-gallery-item img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .5s cubic-bezier(.2,.8,.2,1), filter .3s; }
.prose .pxb-gallery-item > a::after { content: ''; position: absolute; right: 10px; top: 10px; width: 30px; height: 30px; border-radius: 999px; background: rgba(20,12,10,.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5' fill='none' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") center / 16px no-repeat; opacity: 0; transform: scale(.85); transition: opacity .25s, transform .25s; }
.prose .pxb-gallery-item > a:hover img, .prose .pxb-gallery-item > a:focus-visible img { transform: scale(1.05); filter: brightness(1.05); }
.prose .pxb-gallery-item > a:hover::after, .prose .pxb-gallery-item > a:focus-visible::after { opacity: 1; transform: scale(1); }
.prose .pxb-gallery-item > a:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.prose .pxb-gallery-item figcaption { margin-top: 6px; font: 12px/1.35 var(--sans); color: var(--muted); }
.prose .pxb-gallery-item figcaption strong { display: block; color: var(--text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prose .pxb-gallery-item figcaption span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prose .pxb-gallery-item figcaption a { color: inherit; }
/* 3 photos: one big, two stacked. 5+: one big in a three-column grid. */
@media (min-width: 640px) {
  .prose .pxb-gallery[data-count="3"] { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .prose .pxb-gallery[data-count="3"] .pxb-gallery-item:first-child { grid-row: span 2; }
  .prose .pxb-gallery[data-count="3"] .pxb-gallery-item:first-child > a { flex: 1; aspect-ratio: auto; min-height: 0; }
  .prose .pxb-gallery:is([data-count="5"], [data-count="6"], [data-count="7"], [data-count="8"], [data-count="9"], [data-count="10"]) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .prose .pxb-gallery:is([data-count="5"], [data-count="7"], [data-count="9"], [data-count="10"]) .pxb-gallery-item:first-child { grid-column: span 2; grid-row: span 2; }
  .prose .pxb-gallery:is([data-count="5"], [data-count="7"], [data-count="9"], [data-count="10"]) .pxb-gallery-item:first-child > a { flex: 1; aspect-ratio: auto; min-height: 0; }
}
.prose .pxb-gallery-open { display: inline-flex; align-items: center; gap: 8px; margin: 2px 0 26px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font: 600 13px var(--sans); cursor: pointer; transition: border-color .2s, background .2s; }
.prose .pxb-gallery-open:hover, .prose .pxb-gallery-open:focus-visible { border-color: var(--red); background: var(--hover); outline: none; }
.prose .pxb-gallery-open svg { width: 16px; height: 16px; }
.prose .pxg-trigger { cursor: zoom-in; }

/* Album strip near the top (articles with 6+ photos) */
.prose .pxb-album { margin: 26px 0; padding: 14px; border-radius: 14px; background: var(--block); color: var(--on-dark); }
.prose .pxb-album-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; font: 13px var(--sans); }
.prose .pxb-album-head strong { font: 700 15px var(--display); letter-spacing: .02em; text-transform: uppercase; }
.prose .pxb-album-head span { opacity: .75; }
.prose .pxb-album-row { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.prose .pxb-album-row::-webkit-scrollbar { display: none; }
.prose .pxb-album-row button { flex: 0 0 auto; width: 92px; height: 92px; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: #000; cursor: zoom-in; scroll-snap-align: start; }
.prose .pxb-album-row button img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s, opacity .3s; }
.prose .pxb-album-row button:hover img { transform: scale(1.08); }
.prose .pxb-album-row button:focus-visible { outline: 3px solid var(--amber); outline-offset: -3px; }
.prose .pxb-album-row .pxb-album-all { background: var(--red); color: #fff; font: 700 13px/1.2 var(--sans); }
.prose .pxb-album-row .pxb-album-all:hover { background: var(--red-dark); }

/* Full-screen viewer */
html.pxg-lock { overflow: hidden; }
.pxg { position: fixed; inset: 0; z-index: 1000; display: grid; height: 100vh; height: 100dvh; grid-template-rows: auto minmax(0, 1fr) auto auto; background: rgba(10,8,7,.96); color: #fbf6ee; animation: pxg-fade .2s ease; }
.pxg[hidden] { display: none; }
.pxg-top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; font: 600 14px var(--sans); }
.pxg-close { width: 42px; height: 42px; border: 0; border-radius: 999px; background: rgba(255,255,255,.1); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; }
.pxg-close:hover, .pxg-close:focus-visible { background: var(--red); outline: none; }
.pxg-stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; height: 100%; overflow: hidden; padding: 0 64px; }
.pxg-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: 6px; user-select: none; }
.pxg-img.is-in { animation: pxg-in .3s cubic-bezier(.2,.8,.2,1); }
.pxg-nav { position: absolute; top: 50%; width: 48px; height: 48px; margin-top: -24px; border: 0; border-radius: 999px; background: rgba(255,255,255,.12); color: #fff; font-size: 34px; line-height: 1; cursor: pointer; transition: background .2s; }
.pxg-nav:hover, .pxg-nav:focus-visible { background: var(--red); outline: none; }
.pxg-nav.prev { left: 10px; }
.pxg-nav.next { right: 10px; }
.pxg-cap { max-width: 860px; width: 100%; margin: 0 auto; padding: 12px 16px 4px; font: 14px/1.45 var(--sans); text-align: center; color: rgba(251,246,238,.85); }
.pxg-cap strong { color: #fff; }
.pxg-cap a { color: var(--amber); }
.pxg-thumbs { display: flex; gap: 6px; padding: 10px 16px 16px; overflow-x: auto; scrollbar-width: thin; justify-content: safe center; }
.pxg-thumbs button { flex: 0 0 auto; width: 58px; height: 58px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: #000; opacity: .5; cursor: pointer; transition: opacity .2s, border-color .2s; }
.pxg-thumbs button img { width: 100%; height: 100%; object-fit: cover; }
.pxg-thumbs button:hover, .pxg-thumbs button.on { opacity: 1; }
.pxg-thumbs button.on { border-color: var(--amber); }
@media (max-width: 640px) {
  .pxg-stage { padding: 0 8px; }
  .pxg-nav { top: auto; bottom: 8px; margin: 0; width: 42px; height: 42px; }
  .pxg-thumbs button { width: 48px; height: 48px; }
}
@keyframes pxg-fade { from { opacity: 0; } }
@keyframes pxg-in { from { opacity: 0; transform: scale(.97); } }
@media (prefers-reduced-motion: reduce) {
  .pxg, .pxg-img.is-in { animation: none; }
  .prose .pxb-gallery-item img { transition: none; }
}
