/* Gallery page: filter bar, masonry grid (CSS columns), tiles and lightbox. */

.gallery-intro {
  padding-block: clamp(2rem, 6vw, 3.5rem) 1.5rem;
}

.gallery-intro h1 {
  font-size: clamp(2.25rem, 7vw, 4rem);
}

.gallery-intro p {
  margin-top: 0.75rem;
  color: var(--muted);
  max-width: 48ch;
}

/* ---- Filters ---- */
.filters {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-block: 1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
}

.filter {
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.filter:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.filter[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* ---- Grid ----
   Row-major order (left to right, then next row). Without JS it is a plain
   grid (every tile fully visible). gallery.js adds `grid--masonry`, which sets
   a small row unit and per-tile row spans for a staggered masonry that keeps
   the horizontal reading order. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: clamp(1.75rem, 4vw, 3.5rem);
  align-items: start;
  padding-block: 2rem 5rem;
}

.grid--masonry {
  grid-auto-rows: 8px;
}

.tile {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  position: relative;
}

.tile[hidden] {
  display: none;
}

.tile__link {
  display: block;
}

.tile__img {
  width: 100%;
  height: auto;
  background-size: cover;
  background-position: center;
  transition: transform 0.4s ease;
}

.tile:hover .tile__img {
  transform: scale(1.04);
}

.tile__caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1.5rem 0.85rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
  opacity: 0;
  transition: opacity 0.25s;
}

.tile:hover .tile__caption,
.tile:focus-within .tile__caption {
  opacity: 1;
}

/* ---- Lightbox (native <dialog>) ---- */
.lightbox {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.lightbox::backdrop {
  background: rgba(18, 17, 12, 0.92);
}

.lightbox__stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 3rem);
}

.lightbox__stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox__caption {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.lightbox__btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius);
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.4rem;
  display: grid;
  place-items: center;
  transition: background 0.2s;
}

.lightbox__btn:hover {
  background: var(--accent);
}

.lightbox__btn--prev {
  left: clamp(0.5rem, 3vw, 2rem);
}

.lightbox__btn--next {
  right: clamp(0.5rem, 3vw, 2rem);
}

.lightbox__close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius);
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.3rem;
  transition: background 0.2s;
}

.lightbox__close:hover {
  background: var(--accent);
}

/* JS-only controls hidden when scripting is unavailable. */
.no-js .filters,
.no-js .lightbox {
  display: none;
}
