/* Section "gallery" – justified photo grid + lightbox. Prefix: .ga- */

.ga { overflow-x: clip; }
.ga-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem 2rem; flex-wrap: wrap; margin-bottom: clamp(1.4rem, 3vw, 2rem); }
.ga-head > div { max-width: var(--measure); }
.ga-lead { margin: 0; }
.ga-count { margin: 0; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------- Filter chips ---------- */
.ga-filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.ga-filters[hidden] { display: none; }
.ga-chip {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 2.5rem;
  padding: .45rem 1rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line2); background: var(--panel);
  font: 700 .85rem/1 var(--font); color: var(--muted);
  transition: background .2s, color .2s, border-color .2s, transform .15s;
}
.ga-chip:hover { color: var(--ink); border-color: rgb(var(--primary-rgb) / .45); }
.ga-chip:active { transform: scale(.96); }
.ga-chip small { font: 700 .7rem/1 var(--font-mono); opacity: .7; }
.ga-chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
@media (max-width: 720px) {
  .ga-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); }
  .ga-filters::-webkit-scrollbar { display: none; }
  .ga-chip { flex-shrink: 0; }
}

/* ---------- Justified grid (pure CSS: flex-grow by aspect ratio) ---------- */
.ga-grid { --row: 15rem; --gap: .5rem; display: flex; flex-wrap: wrap; gap: var(--gap); }
.ga-grid::after { content: ''; flex-grow: 999999; }
@media (max-width: 1080px) { .ga-grid { --row: 12rem; } }
@media (max-width: 720px) { .ga-grid { --row: 8.5rem; --gap: .35rem; } }

.ga-item {
  position: relative; display: block; overflow: hidden;
  flex-grow: calc(var(--ar) * 100); width: calc(var(--ar) * var(--row));
  border-radius: .7rem; background: var(--bg2) var(--ga-bg, none) center / cover;
  outline-offset: 3px; cursor: zoom-in; color: inherit;
}
.ga-item[hidden] { display: none; }
.ga-ratio { display: block; }
.ga-item img, .ga-item video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transition: transform .8s var(--ease), opacity .7s var(--ease), filter .9s var(--ease);
}
/* Blur-up / fade-in once JS is in charge (images stay visible without JS). */
.ga--js .ga-item:not(.is-loaded) img { opacity: 0; filter: blur(14px); transform: scale(1.06); }
.ga--js .ga-item::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .06) 50%, transparent 70%) 0 0 / 250% 100%;
  animation: ga-shimmer 1.6s linear infinite;
}
.ga--js .ga-item.is-loaded::before { display: none; }
@keyframes ga-shimmer { to { background-position: -250% 0; } }

.ga-item::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, rgb(var(--bg-rgb) / .65));
  opacity: 0; transition: opacity .35s;
}
.ga-time {
  position: absolute; left: .6rem; bottom: .5rem; z-index: 1;
  font-size: .68rem; letter-spacing: .08em; color: var(--ink);
  opacity: 0; transform: translateY(4px); transition: opacity .3s, transform .3s;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .7);
}
.ga-play {
  position: absolute; left: 50%; top: 50%; z-index: 1; transform: translate(-50%, -50%);
  display: grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 50%;
  background: rgb(var(--primary-rgb) / .92); color: var(--on-primary); box-shadow: 0 0 26px rgb(var(--primary-rgb) / .35);
}
.ga-play svg { width: 1.2rem; height: 1.2rem; margin-left: .15rem; fill: currentColor; }
@media (hover: hover) {
  .ga-item:hover img { transform: scale(1.05); }
  .ga-item:hover::after, .ga-item:hover .ga-time { opacity: 1; transform: none; }
}
.ga-item:focus-visible::after, .ga-item:focus-visible .ga-time { opacity: 1; transform: none; }
.ga-item.is-new { animation: ga-in .6s var(--ease) both; }
@keyframes ga-in { from { opacity: 0; transform: scale(.96); } }

.ga-more { margin: 1rem 0 0; font-size: .85rem; }
.ga--js .ga-more { display: none; }
.ga-empty { width: 100%; padding: 2rem; text-align: center; color: var(--muted); }

/* ---------- Lightbox ---------- */
.ga-lb {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; color: var(--ink);
  background: rgb(var(--bg-rgb) / .96);
  overscroll-behavior: contain;
}
.ga-lb::backdrop { background: rgba(0, 0, 0, .85); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.ga-lb[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; animation: ga-lb-in .35s var(--ease); }
@keyframes ga-lb-in { from { opacity: 0; } }
.ga-lb-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: max(.8rem, env(safe-area-inset-top)) clamp(.8rem, 3vw, 1.6rem) .6rem;
}
.ga-lb-count { font: 700 .8rem/1 var(--font-mono); letter-spacing: .14em; color: var(--muted); }
.ga-lb-count b { color: var(--ink); }
.ga-lb-btn {
  display: grid; place-items: center; width: 2.9rem; height: 2.9rem; padding: 0; cursor: pointer;
  border-radius: 50%; border: 1px solid var(--line2); background: rgba(255, 255, 255, .06); color: var(--ink);
  transition: background .2s, transform .15s;
}
.ga-lb-btn:hover { background: rgba(255, 255, 255, .14); }
.ga-lb-btn:active { transform: scale(.94); }
.ga-lb-btn svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.ga-lb-stage { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: pan-y pinch-zoom; user-select: none; }
.ga-lb-media {
  grid-area: 1 / 1; max-width: calc(100vw - clamp(1rem, 12vw, 9rem)); max-height: 100%;
  display: grid; place-items: center; transition: transform .35s var(--ease), opacity .35s;
}
.ga-lb-media img, .ga-lb-media video {
  max-width: 100%; max-height: calc(100dvh - 9.5rem); width: auto; height: auto;
  border-radius: .5rem; box-shadow: 0 30px 90px rgba(0, 0, 0, .6); background: var(--bg2);
}
.ga-lb-media.is-dragging { transition: none; }
.ga-lb-media.in-next { animation: ga-slide-l .4s var(--ease); }
.ga-lb-media.in-prev { animation: ga-slide-r .4s var(--ease); }
@keyframes ga-slide-l { from { opacity: 0; transform: translateX(40px); } }
@keyframes ga-slide-r { from { opacity: 0; transform: translateX(-40px); } }
.ga-lb-prev, .ga-lb-next { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; }
.ga-lb-prev { left: clamp(.5rem, 2vw, 1.5rem); }
.ga-lb-next { right: clamp(.5rem, 2vw, 1.5rem); }
.ga-lb-prev:active, .ga-lb-next:active { transform: translateY(-50%) scale(.94); }
.ga-lb-cap {
  display: flex; justify-content: center; align-items: baseline; gap: .4rem 1rem; flex-wrap: wrap;
  padding: .8rem clamp(1rem, 4vw, 2rem) max(1rem, env(safe-area-inset-bottom));
  text-align: center; font-size: .95rem; color: var(--text); min-height: 3.6rem;
}
.ga-lb-cap .mono { font-size: .75rem; letter-spacing: .1em; color: var(--primary); }
@media (max-width: 720px) {
  .ga-lb-prev, .ga-lb-next { top: auto; bottom: .5rem; transform: none; width: 2.6rem; height: 2.6rem; }
  .ga-lb-prev:active, .ga-lb-next:active { transform: scale(.94); }
  .ga-lb-media { max-width: 100vw; }
  .ga-lb-media img, .ga-lb-media video { border-radius: 0; max-height: calc(100dvh - 10.5rem); }
  .ga-lb-cap { padding-inline: 3.6rem; font-size: .88rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ga--js .ga-item:not(.is-loaded) img { filter: none; transform: none; }
  .ga-lb-media.in-next, .ga-lb-media.in-prev, .ga-item.is-new { animation: none; }
}
