/* Gallery — packed masonry, reserved image size */

.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 8px 0 28px;
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gallery-filters button {
  appearance: none;
  background: transparent;
  color: var(--paper-dim);
  border: 1px solid var(--line);
  padding: 8px 14px;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.gallery-filters button:hover,
.gallery-filters button.active {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--paper);
}

.gallery-grid {
  --cols: 4;
  --gap: 16px;
  position: relative;
}

.gallery-grid.is-packed .gallery-thumb {
  position: absolute;
  margin: 0;
}

.gallery-thumb {
  break-inside: avoid;
  margin: 0 0 16px;
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  text-align: left;
}

.gallery-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: var(--thumb-ratio, 3 / 4);
  object-fit: contain;
  object-position: center top;
  display: block;
  background: #050506;
  opacity: 0;
  transition: opacity 280ms ease, filter 280ms ease, transform 280ms var(--ease, ease);
}

.gallery-thumb img.loaded,
.gallery-thumb img:not(.lazy),
.gallery-thumb.is-eager img {
  opacity: 1;
}

.gallery-thumb.is-clear img {
  background: transparent;
}

.gallery-thumb.is-pixel img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: contain;
}

.gallery-thumb > div {
  padding: 10px 2px 4px;
}

.gallery-thumb h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.98rem;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.gallery-thumb time,
.gallery-thumb .thumb-project {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 2px;
}

.gallery-thumb .thumb-project {
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.65rem;
}

@media (hover: hover) and (pointer: fine) {
  .gallery-thumb img { filter: saturate(0.92); }
  .gallery-thumb:hover {
    z-index: 2;
  }
  .gallery-thumb:hover img {
    filter: saturate(1.05);
    transform: translateY(-4px);
  }
}

#load-more-wrap {
  display: flex;
  justify-content: center;
  margin: 12px 0 8px;
}

#load-more {
  appearance: none;
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line-strong);
  padding: 12px 22px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
}

#load-more:hover:not(:disabled) {
  background: var(--paper);
  color: var(--ink);
}

#load-more:disabled {
  opacity: 0.35;
  cursor: default;
}

.no-results {
  columns: unset;
  min-height: 30vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2rem;
}

@media (max-width: 1100px) {
  .gallery-grid { --cols: 3; }
}

@media (max-width: 760px) {
  .gallery-grid { --cols: 2; --gap: 12px; }
}

@media (max-width: 420px) {
  .gallery-grid { --cols: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-thumb img {
    opacity: 1;
    transform: none;
  }
}
