/* ============================================
   GALLERY (Horizontal Carousel)
   3D perspective with depth scaling
   ============================================ */

/* ---------- GALLERY SECTION ---------- */
#gallery {
  padding: var(--space-section) 0;
  background-color: var(--color-black);
  overflow: hidden;
}

/* ---------- GALLERY TITLE ---------- */
.gallery-title {
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: var(--weight-black);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-white);
  text-align: center;
  margin-bottom: var(--space-12);
}

/* ---------- GALLERY CONTAINER ---------- */
.gallery-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  position: relative;
  height: 800px;
  overflow: hidden;
  margin: 0 auto;
}

/* Vignette overlay that sits behind arrows */
.gallery-container::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(
    to right,
    var(--color-black) 0%,
    transparent 5%,
    transparent 95%,
    var(--color-black) 100%
  );
}

/* ---------- GALLERY WRAPPER ---------- */
.gallery-wrapper {
  display: flex;
  align-items: flex-end;
  transition: transform 0.6s var(--ease-out);
  position: relative;
  width: 100%;
  height: 100%;
}

/* ---------- GALLERY CELLS ---------- */
.gallery-cell {
  flex-shrink: 0;
  width: 600px;
  height: 800px;
  opacity: 0;
  transition:
    transform 0.6s var(--ease-out),
    opacity 0.4s var(--ease-out),
    filter 0.4s var(--ease-out);
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  transform-origin: bottom center;
  border-radius: var(--radius-lg);
  object-fit: cover;

  /* Subtle border */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    var(--shadow-xl);
}

/* Main (center) image */
.gallery-cell.main {
  width: 600px;
  height: 800px;
  opacity: 1;
  z-index: 3;
  transform: translateX(-50%) scale(1);
  filter: grayscale(0%);
  cursor: default;
}

/* Previous image */
.gallery-cell.prev {
  width: 530px;
  height: 780px;
  opacity: 0.7;
  z-index: 2;
  transform: translateX(calc(-50% - 580px)) scale(0.8);
  filter: grayscale(30%);
  cursor: pointer;
}

.gallery-cell.prev:hover {
  opacity: 0.85;
  filter: grayscale(15%);
}

/* Next image */
.gallery-cell.next {
  width: 530px;
  height: 780px;
  opacity: 0.7;
  z-index: 2;
  transform: translateX(calc(-50% + 580px)) scale(0.8);
  filter: grayscale(30%);
  cursor: pointer;
}

.gallery-cell.next:hover {
  opacity: 0.85;
  filter: grayscale(15%);
}

/* Far images (optional - for 5-image carousel) */
.gallery-cell.far-prev {
  opacity: 0.3;
  z-index: 1;
  transform: translateX(calc(-50% - 1000px)) scale(0.6);
  filter: grayscale(50%);
}

.gallery-cell.far-next {
  opacity: 0.3;
  z-index: 1;
  transform: translateX(calc(-50% + 1000px)) scale(0.6);
  filter: grayscale(50%);
}

/* ---------- GALLERY CAPTION ---------- */
.gallery-caption {
  width: 100%;
  max-width: 500px;
  margin: var(--space-10) auto 0;
  padding: 0 var(--space-4);
  color: var(--color-white);
  font-size: var(--text-lg);
  text-align: center;
  line-height: 1.5;
  min-height: 1.5em;
  word-wrap: break-word;
  overflow-wrap: break-word;
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
}

.gallery-caption.visible {
  opacity: 1;
}

/* ---------- GALLERY ARROWS ---------- */
/* Gallery uses unified .nav-arrow from style.css */
/* Legacy arrow support */
.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-white);
  cursor: pointer;
  z-index: 10;
  transition: var(--transition-base);
}

.gallery-arrow:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: translateY(-50%) scale(1.05);
}

.gallery-arrow.left {
  left: var(--space-6);
}

.gallery-arrow.right {
  right: var(--space-6);
}

.gallery-arrow img {
  width: 24px;
  height: 24px;
  filter: brightness(0) invert(1);
}

/* ---------- GALLERY INDICATORS (optional) ---------- */
.gallery-indicators {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-8);
}

.gallery-indicator {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.3);
  transition: var(--transition-base);
  cursor: pointer;
}

.gallery-indicator:hover {
  background: rgba(255, 255, 255, 0.5);
}

.gallery-indicator.active {
  width: 24px;
  background: var(--color-white);
}

/* ---------- SWIPE HINT (Mobile only) ---------- */
.swipe-hint {
  display: none;
  position: absolute;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-gray-400);
  font-family: var(--font-body);
  font-size: var(--text-small);
  z-index: 10;
  animation: swipeHint 2s ease-in-out infinite;
}

.swipe-hint svg {
  opacity: 0.7;
}

@keyframes swipeHint {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* ---------- RESPONSIVE ---------- */

/* Large desktop */
@media (min-width: 1800px) {
  .gallery-container {
    height: 900px;
  }

  .gallery-cell.main {
    width: 700px;
    height: 900px;
  }

  .gallery-cell.prev,
  .gallery-cell.next {
    width: 600px;
    height: 850px;
    transform: translateX(calc(-50% - 680px)) scale(0.8);
  }

  .gallery-cell.next {
    transform: translateX(calc(-50% + 680px)) scale(0.8);
  }
}

/* Desktop */
@media (max-width: 1800px) {
  .gallery-container {
    height: 700px;
  }

  .gallery-cell.main {
    width: 500px;
    height: 700px;
  }

  .gallery-cell.prev {
    width: 430px;
    height: 650px;
    transform: translateX(calc(-50% - 480px)) scale(0.8);
  }

  .gallery-cell.next {
    width: 430px;
    height: 650px;
    transform: translateX(calc(-50% + 480px)) scale(0.8);
  }
}

/* Medium desktop */
@media (max-width: 1500px) {
  .gallery-cell.main {
    width: 450px;
    height: 600px;
  }

  .gallery-cell.prev {
    width: 380px;
    height: 550px;
    transform: translateX(calc(-50% - 420px)) scale(0.8);
  }

  .gallery-cell.next {
    width: 380px;
    height: 550px;
    transform: translateX(calc(-50% + 420px)) scale(0.8);
  }
}

/* Small desktop */
@media (max-width: 1250px) {
  .gallery-container {
    height: 600px;
  }

  .gallery-cell.prev {
    transform: translateX(calc(-50% - 380px)) scale(0.75);
  }

  .gallery-cell.next {
    transform: translateX(calc(-50% + 380px)) scale(0.75);
  }
}

/* Tablet - hide side images */
@media (max-width: 1024px) {
  #gallery {
    padding: var(--space-section-sm) 0;
  }

  .gallery-container {
    height: 550px;
  }

  .gallery-container::before {
    display: none;
  }

  .gallery-wrapper {
    transition: transform 0.4s var(--ease-out);
  }

  .gallery-cell.main {
    width: 400px;
    height: 550px;
  }

  .gallery-cell.prev,
  .gallery-cell.next {
    opacity: 0;
    pointer-events: none;
  }

  .gallery-caption {
    max-width: 380px;
    font-size: var(--text-base);
    margin-top: var(--space-8);
  }
}

/* Mobile */
@media (max-width: 640px) {
  .gallery-container {
    height: 500px;
  }

  .gallery-cell.main {
    width: 320px;
    height: 450px;
    border-radius: var(--radius-md);
  }

  /* Position arrows at bottom on mobile */
  .gallery-arrow,
  .gallery-container .nav-arrow {
    top: auto;
    bottom: var(--space-4);
    transform: none;
    width: 48px;
    height: 48px;
  }

  .gallery-arrow:hover,
  .gallery-container .nav-arrow:hover {
    transform: scale(1.05);
  }

  .gallery-arrow.left,
  .gallery-container .nav-arrow--left {
    left: calc(50% - 80px);
  }

  .gallery-arrow.right,
  .gallery-container .nav-arrow--right {
    right: calc(50% - 80px);
  }

  .gallery-caption {
    max-width: 300px;
    font-size: var(--text-sm);
    margin-top: var(--space-6);
  }
}

/* Small mobile */
@media (max-width: 400px) {
  .gallery-container {
    height: 450px;
  }

  .gallery-cell.main {
    width: 280px;
    height: 400px;
  }

  .gallery-arrow.left,
  .gallery-container .nav-arrow--left {
    left: calc(50% - 70px);
  }

  .gallery-arrow.right,
  .gallery-container .nav-arrow--right {
    right: calc(50% - 70px);
  }

  .gallery-caption {
    max-width: 280px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .gallery-wrapper {
    transition: none;
  }

  .gallery-cell {
    transition: opacity 0.2s ease;
  }

  .gallery-arrow:hover,
  .gallery-container .nav-arrow:hover {
    transform: translateY(-50%);
  }
}
