/* Galeri: mobilde yatay kaydırmalı şerit, masaüstünde karışık (yatay/dikey) grid + lightbox */

.gallery {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--scroller-item-width);
  gap: var(--space-md);
  margin: 0 calc(-1 * var(--space-md));
  padding: 0 var(--space-md) var(--space-sm);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 var(--space-md);
  scrollbar-width: none;
  list-style: none;
}

.gallery::-webkit-scrollbar {
  display: none;
}

.gallery li {
  scroll-snap-align: start;
}

.gallery-item {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text-inverse);
  font: inherit;
  text-align: left;
  overflow: hidden;
  cursor: zoom-in;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  transition: transform 1.2s var(--ease-out);
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
  transform: scale(1.06);
}

.gallery-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--space-2xl) var(--space-md) var(--space-md);
  background: linear-gradient(to top, var(--color-overlay-strong), var(--color-transparent));
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
}

.gallery-zoom {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  display: grid;
  place-items: center;
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: var(--radius-full);
  background: var(--color-secondary);
  color: var(--color-on-accent);
  transform: scale(0.6);
  opacity: 0;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.gallery-zoom svg {
  width: var(--icon-size);
  height: var(--icon-size);
}

.gallery-item:hover .gallery-zoom,
.gallery-item:focus-visible .gallery-zoom {
  transform: none;
  opacity: 1;
}

@media (hover: none) {
  .gallery-zoom {
    transform: none;
    opacity: 1;
  }
}

@media (min-width: 768px) {
  .gallery {
    grid-auto-flow: row dense;
    grid-auto-columns: auto;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: var(--gallery-row);
    margin: 0;
    padding: 0;
    overflow: visible;
  }

  .gallery .is-landscape { grid-column: span 2; }
  .gallery .is-portrait { grid-row: span 2; }

  .gallery-item img {
    aspect-ratio: auto;
  }
}

/* ---------- Lightbox ---------- */
.lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--color-backdrop);
  color: var(--color-text);
}

.lightbox::backdrop {
  background: var(--color-transparent);
}

.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-figure {
  margin: 0;
  padding: var(--space-3xl) var(--space-md);
  text-align: center;
}

.lightbox-img {
  width: auto;
  max-width: 100%;
  max-height: 76dvh;
  margin: 0 auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.lightbox-img.is-in {
  animation: lightbox-in 0.45s var(--ease-out);
}

@keyframes lightbox-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}

.lightbox-caption {
  margin-top: var(--space-md);
  color: var(--color-text-muted);
}

.lightbox-counter {
  color: var(--color-secondary);
  font-weight: var(--font-weight-bold);
}

.lightbox-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: calc(var(--touch-target) + var(--space-xs));
  height: calc(var(--touch-target) + var(--space-xs));
  padding: 0;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.lightbox-btn:hover {
  background: var(--color-secondary);
  color: var(--color-on-accent);
}

.lightbox-btn svg {
  width: var(--icon-size);
  height: var(--icon-size);
}

.lightbox-close { top: var(--space-md); right: var(--space-md); }
.lightbox-prev { bottom: var(--space-lg); left: var(--space-md); }
.lightbox-next { bottom: var(--space-lg); right: var(--space-md); }

@media (min-width: 768px) {
  .lightbox-prev,
  .lightbox-next {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-img,
  .gallery-item img {
    animation: none;
    transition: none;
  }
}
