/* ============================================================
   GALMAVECA — Gallery page stylesheet
   Loaded after styles.css. Sections:
     1. Masonry grid (CSS columns)
     2. Thumbnails
     3. Lightbox

   Behaviour (entrance stagger, lightbox) lives in
   assets/js/gallery.js. Without it the grid is still a plain,
   readable list of photos.
   ============================================================ */


/* ============================================================
   1. MASONRY GRID
   ============================================================ */
.gal-grid {
  column-count: 2;
  column-gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.gal-item {
  break-inside: avoid;
  margin-bottom: var(--space-4);

  /* Resting state for the scroll-in; JS adds .is-in in groups */
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 500ms ease, transform 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.gal-item.is-in {
  opacity: 1;
  transform: none;
}

@media (min-width: 768px) {
  .gal-grid { column-count: 3; }
}

@media (min-width: 1024px) {
  .gal-grid { column-count: 4; }
}


/* ============================================================
   2. THUMBNAILS
   ============================================================ */
.gal-thumb {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--color-bg-soft-surface);
  cursor: pointer;
  line-height: 0;
}

.gal-thumb img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 400ms ease;
}

.gal-thumb:hover img,
.gal-thumb:focus-visible img {
  transform: scale(1.03);
}

/* Dim + magnifier on hover */
.gal-thumb__zoom {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  background-color: rgba(10, 31, 51, 0.35);
  opacity: 0;
  transition: opacity 400ms ease;
}

.gal-thumb:hover .gal-thumb__zoom,
.gal-thumb:focus-visible .gal-thumb__zoom {
  opacity: 1;
}

.gal-thumb__zoom svg {
  width: 30px;
  height: 30px;
}

.gal-thumb:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}


/* ============================================================
   3. LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background-color: rgba(10, 31, 51, 0.95);
  animation: lightboxIn 220ms ease;
}

.lightbox[hidden] {
  display: none !important;
}

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

.lightbox__figure {
  margin: 0;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__img {
  max-width: 90vw;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.lightbox__btn {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  color: var(--color-white);
  background-color: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast),
              color var(--transition-fast);
}

.lightbox__btn:hover,
.lightbox__btn:focus-visible {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-white);
}

.lightbox__btn svg {
  width: 22px;
  height: 22px;
}

.lightbox__btn--close {
  top: var(--space-5);
  right: var(--space-5);
}

.lightbox__btn--prev { left: var(--space-5); }
.lightbox__btn--next { right: var(--space-5); }

.lightbox__counter {
  position: absolute;
  left: 50%;
  bottom: var(--space-6);
  transform: translateX(-50%);
  margin: 0;
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-wide);
  color: rgba(255, 255, 255, 0.6);
}

/* Phones — arrows drop to the bottom corners so they never sit
   on top of the photo */
@media (max-width: 767px) {
  .lightbox__btn {
    width: 44px;
    height: 44px;
  }

  .lightbox__btn--prev {
    left: var(--space-5);
    bottom: var(--space-12);
    top: auto;
  }

  .lightbox__btn--next {
    right: var(--space-5);
    bottom: var(--space-12);
    top: auto;
  }

  .lightbox__counter {
    bottom: var(--space-4);
  }
}


/* ============================================================
   4. REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .gal-item {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .gal-thumb img,
  .gal-thumb__zoom,
  .lightbox__btn {
    transition: none !important;
  }

  .gal-thumb:hover img,
  .gal-thumb:focus-visible img {
    transform: none;
  }

  .lightbox {
    animation: none;
  }
}
