/* =========================================
   GALLERY FILTERS
========================================= */

.page-hero-gallery {
  background-image:
    linear-gradient(to top, var(--color-curtain-black) 0%, transparent 40%),
    url("../assets/images/backgrounds/stage-theater.webp");

  background-position: center 50%;
}

.gallery-filters {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: var(--space-40) var(--section-padding-x);
  background-color: var(--color-surface-primary);
}

.gallery-filters .filter-btn {
  background: transparent;
  border: none;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid transparent;
  transition:
    color var(--transition-base),
    border-color var(--transition-base);
}

.gallery-filters .filter-btn:hover {
  color: var(--color-parchment);
}

.gallery-filters .filter-btn.is-active {
  color: var(--color-antique-gold);
  border-bottom-color: var(--color-antique-gold);
}

/* =========================================
   FILTER ANIMATION
========================================= */

/* Adds a smooth fade-in when images are injected via JS */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.gallery-item {
  animation: fadeInScale 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* =========================================
   EDITORIAL MASONRY LAYOUT
========================================= */

.gallery-section {
  background-color: var(--color-surface-alt);
  padding: 120px var(--section-padding-x) 300px;
  overflow: clip; /* Prevents horizontal scroll from parallax */
}

.gallery-container {
  max-width: var(--container-width-lg);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-40);
  align-items: start;
  
  /* Adds a 3D perspective to the entire container so tilts look realistic */
  perspective: 1000px; 
}

.gallery-col {
  display: flex;
  flex-direction: column;
  gap: 60px; /* Large breathing room between images */
  will-change: transform; /* Performance optimization for smooth parallax */
}

/* Push the middle column down initially so it has room to scroll up */
.col-inner {
  margin-top: 150px; 
}

/* =========================================
   THE MAGNETIC MESH EFFECT
========================================= */

.gallery-item {
  position: relative;
  width: 100%;
  
  /* Strip away any backgrounds or borders that might be inherited */
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  
  --intensity: 0; 
  --tilt-x: 0deg;
  --tilt-y: 0deg;

  transform-style: preserve-3d;
  transform: 
    scale(calc(1 + (var(--intensity) * 0.05))) 
    translateZ(calc(var(--intensity) * 40px))
    rotateX(var(--tilt-x)) 
    rotateY(var(--tilt-y));
    
  /* Shadow applied strictly to the item, but we'll remove borders */
  box-shadow: 0 calc(var(--intensity) * 30px) calc(var(--intensity) * 50px) rgba(0, 0, 0, calc(0.5 + var(--intensity) * 0.4));
  
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), 
              box-shadow 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.gallery-image-wrapper {
  width: 100%;
  border-radius: 4px; /* A sharper, more modern corner */
  overflow: hidden;
  
  border: none; 
  background-color: transparent;
}

.gallery-image-wrapper img,
.gallery-image-wrapper video {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  
  filter: grayscale(80%) contrast(1.1); 
  transform: scale(calc(1 + (var(--intensity) * 0.15)));
  transition: filter 0.5s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.gallery-item:hover .gallery-image-wrapper img,
.gallery-item:hover .gallery-image-wrapper video {
  filter: grayscale(0%) contrast(1);
}

/* =========================================
   EDITORIAL TYPOGRAPHY
========================================= */
.gallery-caption {
  /* Push the text further down from the image */
  margin-top: 24px; 
  
  font-family: var(--font-body);
  text-align: center;
  font-size: 0.95rem; 
  font-weight: 800;
  
  text-transform: uppercase;
  letter-spacing: 0.15em; 
  
  color: var(--color-text-primary);
  opacity: 0.5; 
  
  transition: opacity 0.3s ease, color 0.3s ease, transform 0.3s ease;
}

/* Highlight and slightly lift the caption when the cursor is near */
.gallery-item:hover .gallery-caption {
  opacity: 1;
  color: var(--color-antique-gold);
}

/* =========================================
   LIGHTBOX STYLES
========================================= */
.lightbox {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.lightbox.is-active {
  pointer-events: auto;
  opacity: 1;
}
.lightbox-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.lightbox-close {
  position: absolute;
  top: 24px; right: 24px;
  background: transparent; border: none;
  color: var(--color-parchment);
  font-size: 3rem;
  cursor: pointer;
  z-index: 2;
  line-height: 1;
}
.lightbox-content {
  position: relative;
  z-index: 1;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-content.is-switching .lightbox-img,
.lightbox-content.is-switching .lightbox-video {
  opacity: 0;
  transform: scale(0.98);
}

.lightbox-img,
.lightbox-video {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.8);

  transition: opacity 0.3s ease, transform 0.3s ease;
}
.lightbox-caption {
  margin-top: 16px;
  color: var(--color-antique-gold);
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  
  width: 60px;
  height: 60px;
  border-radius: 50%;
  
  background: rgba(10, 10, 10, 0.5);
  border: 1px solid var(--color-effect-gold-20);
  color: var(--color-antique-gold);
  
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  
  transition: all var(--transition-base);
}

.lightbox-nav:hover {
  background: var(--color-parchment-05);
  border-color: var(--color-antique-gold);
  color: var(--color-parchment);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-prev { left: 40px; }
.lightbox-next { right: 40px; }

.lightbox-counter {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  
  font-family: var(--font-body);
  font-size: 0.9rem;
  letter-spacing: 0.3em;
  color: var(--color-text-muted);
}

/* =========================================
   VIDEO INDICATOR (HOVER-TO-PLAY)
========================================= */

.video-indicator {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 24px;
  height: 24px;
  z-index: 5;
  pointer-events: none;
  
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  transition: transform var(--transition-base);
}

.video-indicator .svg-mask {
  width: 100%;
  height: 100%;
  background-color: var(--color-parchment);
  opacity: 0.85;
  transition: background-color var(--transition-base), opacity var(--transition-base);
}

.gallery-item:hover .video-indicator .svg-mask {
  background-color: var(--color-antique-gold);
  opacity: 1;
}

.gallery-item:hover .video-indicator {
  transform: scale(1.1);
}

/* =========================================
   MOBILE RESPONSIVENESS
========================================= */
@media (max-width: 992px) {
  /* 1. Swipeable Filter Menu */
  .gallery-filters {
    justify-content: flex-start;
    padding: var(--space-40) 16px;
    overflow-x: auto;
    white-space: nowrap;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .gallery-filters::-webkit-scrollbar { display: none; }
  .gallery-filters .filter-btn { scroll-snap-align: start; flex-shrink: 0; }

  /* 2. Edge-to-Edge Grid (Tight Gaps) */
  .gallery-section {
    /* Removes massive side padding, leaves just 8px */
    padding: 24px 8px 100px; 
  }
  
  .gallery-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px; /* Extremely tight gap between Left/Right column */
  }

  .gallery-col {
    gap: 8px; /* Extremely tight vertical gap between photos */
  }

  #colThree { display: none; }

  /* 3. Hide Captions (Now handled by Lightbox) */
  .gallery-caption {
    display: none !important;
  }

  /* 4. Strip Parallax Math */
  .col-inner { margin-top: 0; }
  .gallery-item { 
    transform: none !important; 
    box-shadow: none !important; 
    /* Add a subtle visual cue that images are tappable */
    cursor: pointer;
  }

  .lightbox-nav { display: none; } 
  .lightbox-counter { bottom: 24px; }
}

/* =========================================
   MOTION ARCHIVE (VIDEO LOOP)
========================================= */

.motion-archive-section {
  position: relative;
  width: 100%;
  height: 90vh; /* Takes up 80% of the screen height */
  min-height: 600px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-curtain-black);
}

.motion-video {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100vw;
  height: 100%;
  object-fit: cover; /* Ensures the video fills the space without stretching */
  transform: translate(-50%, -50%);
  z-index: 1;
  /* Optional: Desaturate slightly to match the moody photos above */
  filter: grayscale(30%) contrast(1.1); 
}

.motion-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  /* Creates a vignette: darker at the edges, slightly lighter in the middle */
  background: radial-gradient(circle, rgba(10,10,10,0.3) 0%, rgba(10,10,10,0.8) 100%);
}

.motion-content {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 0 var(--section-padding-x);
}

.motion-title {
  font-family: var(--font-heading);
  font-size: 4rem; /* Massive, dramatic typography */
  color: var(--color-parchment);
  margin-bottom: var(--space-md);
  letter-spacing: 0.05em;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.motion-subtitle {
  font-size: 1.2rem;
  color: var(--color-antique-gold);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .motion-archive-section {
    height: 60vh;
    min-height: 400px;
  }
  .motion-title {
    font-size: 2.5rem;
  }
  .motion-subtitle {
    font-size: 0.9rem;
  }
}