/* ===========================
   gallery.css — Dual-mode gallery (mosaic + scroll)
   =========================== */

body { overflow: hidden; }

/* Fixed background */
.gallery-bg {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: -1;
}

/* ===========================
   Mosaic Mode (default)
   =========================== */

.mosaic-container {
  position: fixed;
  inset: 0;
  overflow: auto;
  padding: 6rem 2rem 4rem;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.mosaic {
  position: relative;
  /* width set dynamically by gallery.js based on image count */
  margin: 0 auto;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mosaic images */
.mosaic-image {
  position: absolute;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  object-fit: cover;
  opacity: 0;
  /* Initial transform set by JS for center-to-grid animation */
}

/* Emerged state: at final grid position */
.mosaic-image.emerged {
  opacity: 1;
  transform: scale(1) translate(0, 0);
}

.mosaic-image.emerged.viewport-hover {
  transform: scale(1.05) translate(0, 0);
}

/* ===========================
   Scroll Mode
   =========================== */

.mosaic-container.scroll-mode {
  top: 50%;
  transform: translateY(-50%);
  height: 60dvh;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  display: flex;
  align-items: center;
}

.mosaic-container.scroll-mode::-webkit-scrollbar {
  display: none;
}

.mosaic.scroll-mode {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10vw;
  height: 100% !important;
  max-width: none;
  margin: 0;
  padding: 0 calc(50vw - 30dvh); /* Center first and last images */
}

/* Scroll mode images */
.scroll-mode .mosaic-image {
  position: relative !important;
  flex: 0 0 auto;
  width: 60dvh !important;
  height: 60dvh !important;
  left: auto !important;
  top: auto !important;
  opacity: 1;
  transform: scale(1) translateY(0);
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
}

.scroll-mode .mosaic-image:hover,
.scroll-mode .mosaic-image.centered {
  transform: scale(1.02);
}

/* Image counter indicator */
body.scroll-mode::before {
  content: attr(data-current-index);
  position: fixed;
  bottom: 3dvh;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(1rem, 2.2vw, 1.8rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  pointer-events: none;
  z-index: 200;
  opacity: 0.9;
}

body[data-section="flashbook"].scroll-mode::before {
  left: auto;
  right: 2.5dvw;
  transform: rotate(135deg);
  transform-origin: center center;
}

body[data-section="tattoo"].scroll-mode::before {
  left: 2.5dvw;
  right: auto;
  transform: rotate(-135deg);
  transform-origin: center center;
}

/* Flashbook scrolls left (RTL), tattoo scrolls right (LTR) */
body[data-section="flashbook"] .mosaic-container.scroll-mode {
  direction: rtl;
}

body[data-section="flashbook"] .mosaic.scroll-mode {
  direction: ltr; /* Reset for children so images render normally */
}

/* ===========================
   Responsive
   =========================== */

@media (max-width: 768px) {
  .mosaic-container {
    padding: 4rem 1rem 3rem;
  }

  .mosaic-container.scroll-mode {
    height: 50dvh;
  }

  .scroll-mode .mosaic-image {
    width: 50dvh !important;
    height: 50dvh !important;
  }

  .mosaic.scroll-mode {
    padding: 0 calc(50vw - 25dvh);
  }
}
