/* ==================== GALLERY GRID ==================== */
.gallery__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.gallery__item {
  position: relative;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 4 / 3;
}

.gallery__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.gallery__item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.3), transparent);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.gallery__item:hover img {
  transform: scale(1.08);
}

.gallery__item:hover::after {
  opacity: 1;
}

.gallery__item--large {
  grid-column: span 2;
  grid-row: span 2;
}

/* ==================== LIGHTBOX ==================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox__overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.92);
}

.lightbox__content {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__image {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--border-radius);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.lightbox__image.loaded {
  opacity: 1;
}

.lightbox__close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--color-white);
  font-size: 28px;
  transition: background-color var(--transition-fast);
}

.lightbox__close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--color-white);
  font-size: 24px;
  transition: background-color var(--transition-fast);
}

.lightbox__nav:hover {
  background-color: rgba(255, 255, 255, 0.25);
}

.lightbox__prev {
  left: 20px;
}

.lightbox__next {
  right: 20px;
}

.lightbox__counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: var(--color-white);
  font-size: var(--text-sm);
  background-color: rgba(0, 0, 0, 0.5);
  padding: var(--space-2) var(--space-4);
  border-radius: 50px;
}

/* Prevent body scroll when lightbox open */
body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 768px) {
  .gallery__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
  }

  .gallery__item--large {
    grid-column: span 2;
    grid-row: span 1;
  }

  .lightbox__nav {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .lightbox__prev { left: 10px; }
  .lightbox__next { right: 10px; }
}

/* Mozaik 3 ve uzeri gorselde anlamli. 1-2 gorselde buyuk karo yaninda olu
   alan ve ortada bos hucre birakiyordu; bu durumlarda duz izgaraya donulur. */
.gallery__grid--tek {
  grid-template-columns: 1fr;
}

.gallery__grid--iki {
  grid-template-columns: repeat(2, 1fr);
}

.gallery__grid--tek .gallery__item--large,
.gallery__grid--iki .gallery__item--large {
  grid-column: auto;
  grid-row: auto;
}
