.gallery-section { overflow: hidden; }

.gallery-summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--olive-800);
  font-size: 13px;
  font-weight: 800;
}

.gallery-summary::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sand);
  content: "";
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.gallery-card {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #eceee4;
  box-shadow: 0 15px 38px rgba(44, 49, 28, 0.09);
  cursor: zoom-in;
}

.gallery-card::after {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  color: #fff;
  background: rgba(52, 59, 32, 0.72);
  backdrop-filter: blur(8px);
  content: "+";
  font-size: 25px;
  line-height: 1;
  transition: transform 160ms ease, background 160ms ease;
}

.gallery-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 260ms ease;
}

.gallery-card:hover img { transform: scale(1.035); }
.gallery-card:hover::after { transform: scale(1.08); background: rgba(79, 90, 46, 0.92); }
.gallery-card:focus-visible { outline: 3px solid var(--sand); outline-offset: 4px; }

.gallery-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}

.gallery-lightbox {
  width: min(1280px, calc(100% - 28px));
  height: min(900px, calc(100vh - 28px));
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 26px;
  color: #fff;
  background: #171913;
  box-shadow: 0 30px 100px rgba(18, 20, 12, 0.56);
}

.gallery-lightbox::backdrop {
  background: rgba(24, 27, 16, 0.76);
  backdrop-filter: blur(10px);
}

.gallery-lightbox-layout {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-columns: 74px minmax(0, 1fr) 74px;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
}

.gallery-lightbox-image-wrap {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-column: 2;
  grid-row: 1;
  place-items: center;
  padding: 34px 10px 12px;
  touch-action: pan-y;
}

.gallery-lightbox-image {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}

.gallery-lightbox-close,
.gallery-lightbox-arrow {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
  cursor: pointer;
  transition: border 160ms ease, background 160ms ease;
}

.gallery-lightbox-close:hover,
.gallery-lightbox-arrow:hover { border-color: rgba(255, 255, 255, 0.62); background: rgba(255, 255, 255, 0.17); }

.gallery-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 46px;
  height: 46px;
  font-size: 29px;
}

.gallery-lightbox-arrow {
  width: 48px;
  height: 48px;
  justify-self: center;
  font-size: 31px;
}

.gallery-lightbox-prev { grid-column: 1; grid-row: 1; }
.gallery-lightbox-next { grid-column: 3; grid-row: 1; }

.gallery-lightbox-meta {
  display: flex;
  grid-column: 1 / -1;
  grid-row: 2;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 17px 24px 20px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.gallery-lightbox-caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-lightbox-counter { flex: 0 0 auto; font-weight: 800; }

@media (max-width: 940px) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 660px) {
  .gallery-grid { grid-template-columns: 1fr; gap: 14px; }
  .gallery-card { border-radius: 18px; }
  .gallery-lightbox { width: calc(100% - 12px); height: calc(100vh - 12px); border-radius: 20px; }
  .gallery-lightbox-layout { grid-template-columns: 54px minmax(0, 1fr) 54px; }
  .gallery-lightbox-image-wrap { grid-column: 1 / -1; padding: 64px 8px 8px; }
  .gallery-lightbox-arrow { z-index: 1; width: 42px; height: 42px; background: rgba(23, 25, 19, 0.66); }
  .gallery-lightbox-close { top: 12px; right: 12px; }
  .gallery-lightbox-meta { padding: 14px 16px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-card img,
  .gallery-card::after { transition: none; }
}
