/* phanta.cms Gallery plugin 1.0.0 — themes can set --gallery-gap, --gallery-accent, --gallery-radius */
.ph-gallery { --g: var(--gallery-gap, 10px); }
.ph-gallery-item { position: relative; display: block; overflow: hidden; border-radius: var(--gallery-radius, 2px); background: rgba(127,127,127,.12); cursor: zoom-in; }
.ph-gallery-item img { display: block; width: 100%; height: auto; transition: transform .8s cubic-bezier(.2,.7,.2,1), filter .4s; }
.ph-gallery-item::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .35s;
  background: linear-gradient(to top, rgba(0,0,0,.45), rgba(0,0,0,0) 55%);
  box-shadow: inset 0 0 0 2px var(--gallery-accent, #fff);
}
.ph-gallery-item:hover img, .ph-gallery-item:focus-visible img { transform: scale(1.05); }
.ph-gallery-item:hover::after, .ph-gallery-item:focus-visible::after { opacity: 1; }

/* category filter buttons */
.ph-gallery-filter { display: flex; flex-wrap: wrap; justify-content: var(--gallery-filter-align, center); gap: 8px; margin: 0 0 28px; }
.ph-gallery-filter button {
  padding: 10px 20px; border-radius: 999px; border: 1px solid var(--gallery-filter-line, rgba(127,127,127,.4)); background: transparent;
  color: inherit; font: inherit; font-size: 14px; letter-spacing: .04em; cursor: pointer; transition: background .25s, color .25s, border-color .25s;
}
.ph-gallery-filter button:hover { border-color: var(--gallery-accent, currentColor); }
.ph-gallery-filter button[aria-pressed="true"] { background: var(--gallery-accent, #222); border-color: var(--gallery-accent, #222); color: var(--gallery-accent-fg, #fff); }
.ph-gallery { transition: opacity .18s; }
.ph-gallery.is-filtering { opacity: 0; }
.ph-gallery-item[hidden] { display: none; }

/* masonry: CSS columns */
.ph-gallery--masonry { columns: var(--cols, 4); column-gap: var(--g); }
.ph-gallery--masonry .ph-gallery-item { break-inside: avoid; margin-bottom: var(--g); }
@media (max-width: 1220px) { .ph-gallery--masonry { columns: min(var(--cols, 4), 2); } }
@media (max-width: 560px) { .ph-gallery--masonry { columns: 1; } }

/* justified rows: each photo grows in proportion to its aspect ratio */
.ph-gallery--rows { display: flex; flex-wrap: wrap; gap: var(--g); }
.ph-gallery--rows .ph-gallery-item { flex: calc(var(--r) * 240) 1 calc(var(--r) * 240px); aspect-ratio: var(--r); }
.ph-gallery--rows .ph-gallery-item img { height: 100%; object-fit: cover; }
.ph-gallery--rows::after { content: ""; flex: 1000000 1 0; }   /* the last row keeps its natural height */
@media (max-width: 560px) { .ph-gallery--rows .ph-gallery-item { flex-basis: calc(var(--r) * 110px); } }

/* square grid */
.ph-gallery--grid { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: var(--g); }
.ph-gallery--grid .ph-gallery-item { aspect-ratio: 1; }
.ph-gallery--grid .ph-gallery-item img { height: 100%; object-fit: cover; }
@media (max-width: 900px) { .ph-gallery--grid { grid-template-columns: repeat(min(var(--cols, 4), 3), 1fr); } }
@media (max-width: 560px) { .ph-gallery--grid { grid-template-columns: repeat(2, 1fr); } }

/* lightbox */
.ph-lb { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; background: rgba(8,8,8,.96); opacity: 0; transition: opacity .3s; touch-action: none; }
.ph-lb.open { opacity: 1; }
.ph-lb[hidden] { display: none; }
.ph-lb-stage { position: relative; width: 100vw; height: 100vh; height: 100dvh; display: grid; place-items: center; overflow: hidden; }
.ph-lb-img { max-width: calc(100vw - 140px); max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px); width: auto; height: auto; object-fit: contain;
  box-shadow: 0 30px 80px rgba(0,0,0,.6); transition: opacity .25s, transform .3s cubic-bezier(.2,.7,.2,1); user-select: none; -webkit-user-drag: none; }
.ph-lb-img.loading { opacity: .25; }
.ph-lb-btn { position: absolute; z-index: 2; display: grid; place-items: center; width: 52px; height: 52px; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,.08); color: #fff; transition: background .2s, color .2s, transform .2s; }
.ph-lb-btn[hidden] { display: none; }
.ph-lb-btn:hover { background: var(--gallery-accent, #fff); color: #111; }
.ph-lb-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ph-lb-close { top: 18px; right: 18px; }
.ph-lb-prev { left: 18px; top: 50%; translate: 0 -50%; }
.ph-lb-next { right: 18px; top: 50%; translate: 0 -50%; }
.ph-lb-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; gap: 16px; padding: 16px 24px;
  color: rgba(255,255,255,.75); font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .06em; }
.ph-lb-count { font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  .ph-lb-img { max-width: 100vw; max-height: calc(100dvh - 140px); }
  .ph-lb-prev, .ph-lb-next { top: auto; bottom: 56px; translate: none; width: 46px; height: 46px; }
  .ph-lb-prev { left: calc(50% - 56px); } .ph-lb-next { right: calc(50% - 56px); }
}
html.ph-lb-lock { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .ph-lb, .ph-lb-img, .ph-gallery-item img { transition: none; } }
