/* ─── 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;
  min-height: 0;
}
.gallery__main .gallery__media,
.gallery__thumb .gallery__media {
  width: 100%;
  height: 100%;
}

.gallery__media {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg-light);
}

.gallery__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.4s ease;
}

.gallery__media:not(.gallery__media--loading) img {
  opacity: 1;
}

.gallery__main:hover .gallery__media:not(.gallery__media--loading) img,
.gallery__thumb:hover .gallery__media:not(.gallery__media--loading) img {
  transform: scale(1.03);
}

.gallery__thumb:hover .gallery__media:not(.gallery__media--loading) img {
  transform: scale(1.05);
}

.gallery__media--loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--color-bg-light) 0%,
    #ececec 45%,
    var(--color-bg-light) 90%
  );
  background-size: 200% 100%;
  animation: gallerySkeleton 1.2s ease-in-out infinite;
  pointer-events: none;
}

.gallery__skeleton {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 280px;
  background: var(--color-bg-light);
}

@keyframes gallerySkeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.gallery--loading .gallery__show-all {
  pointer-events: none;
  opacity: 0;
}

.gallery__main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.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 {
  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 .gallery__media {
  height: 100%;
}
.gallery__carousel-slide img {
  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(var(--color-dark-rgb), 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: 2200;
}
.lightbox.open { display: flex; }

.lightbox__overlay {
  position: absolute;
  inset: 0;
  background: rgba(var(--color-dark-rgb), 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__media {
  max-width: 900px;
  max-height: 700px;
  width: 100%;
  background: transparent;
}

.lightbox__media::after {
  border-radius: var(--radius-lg);
}

.lightbox__media img {
  object-fit: contain;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 700px;
}

.lightbox__counter {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90vw, 480px);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  background: rgba(var(--color-dark-rgb), 0.4);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  text-align: center;
}

/* ─── 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; }
}
