/* ─── Gallery Grid ─── */
.gallery {
  width: min(1120px, calc(100% - 96px));
  max-width: 1120px;
  margin: 48px auto 0;
  overflow: hidden;
  border-radius: var(--radius-xl);
}

.gallery__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(2, 1fr);
  height: min(56vh, 560px);
  gap: 8px;
  overflow: hidden;
  border-radius: var(--radius-xl);
}

.gallery__main {
  grid-row: span 2;
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
}
.gallery__main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.gallery__main:hover img { transform: scale(1.03); }

.gallery__side {
  grid-row: span 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  min-height: 0;
}

.gallery__thumb {
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
  min-height: 0;
}
.gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.gallery__thumb:hover img { transform: scale(1.05); }

/* Top-right corners for first/second thumbs */
.gallery__side > .gallery__thumb:nth-child(2) { border-top-right-radius: var(--radius-xl); }

/* ─── "Show all" button ─── */
.gallery__thumb--last { position: relative; }

.gallery__show-all {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: var(--color-primary);
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  z-index: 10;
  white-space: nowrap;
}
.gallery__show-all:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.gallery__show-all svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ─── Mobile carousel ─── */
.gallery__carousel {
  display: none;
  position: relative;
}

.gallery__carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.gallery__carousel-track::-webkit-scrollbar { display: none; }

.gallery__carousel-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  height: 280px;
  overflow: hidden;
  cursor: pointer;
}
.gallery__carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.gallery__carousel-counter {
  position: absolute;
  bottom: 16px;
  right: 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  pointer-events: none;
  z-index: 2;
  letter-spacing: 0.02em;
}

/* ─── Lightbox ─── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.lightbox.open { display: flex; }

.lightbox__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.88);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox__container {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 64px 80px;
}

.lightbox__close {
  position: absolute;
  top: 20px;
  left: 24px;
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background var(--transition);
  z-index: 2;
}
.lightbox__close:hover { background: rgba(255,255,255,0.2); }
.lightbox__close svg { width: 20px; height: 20px; fill: none; }

.lightbox__prev,
.lightbox__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow var(--transition);
  z-index: 2;
}
.lightbox__prev:hover,
.lightbox__next:hover {
  transform: translateY(-50%) scale(1.08);
  box-shadow: var(--shadow-lg);
}
.lightbox__prev { left: 24px; }
.lightbox__next { right: 24px; }
.lightbox__prev svg,
.lightbox__next svg {
  width: 16px;
  height: 16px;
  fill: none;
}

.lightbox__track {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 900px;
  max-height: 700px;
  width: 100%;
  animation: zoomIn 0.2s ease;
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.lightbox__img {
  max-width: 100%;
  max-height: 700px;
  object-fit: contain;
  border-radius: var(--radius-lg);
  user-select: none;
}

.lightbox__counter {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  background: rgba(0,0,0,0.4);
  padding: 4px 14px;
  border-radius: var(--radius-full);
}

/* ─── Mobile gallery ─── */
@media (max-width: 768px) {
  .gallery {
    border-radius: 0;
    margin-top: 0;
    width: 100%;
    max-width: none;
  }
  .gallery__grid { display: none; }
  .gallery__carousel { display: block; }
  .gallery__carousel-slide {
    height: min(72vw, 420px);
    border-radius: 0;
  }
  .gallery__carousel-counter { bottom: 20px; right: 20px; }
  .lightbox__container { padding: 56px 8px 48px; }
  .lightbox__prev { left: 8px; width: 40px; height: 40px; }
  .lightbox__next { right: 8px; width: 40px; height: 40px; }
}
