/* ============================================
   3D Scroll Gallery - Based on ekaterina-mizulina.ru
   Uses GSAP ScrollTrigger for scroll-driven animations
   ============================================ */

:root {
  --gallery-bg: #000;
  --gallery-text: #fff;
  --gallery-accent: var(--color-primary, #6B2737);
  --gallery-gold: var(--color-gold, #D4A574);
  --perspective: 1500px;
  --grid-item-ratio: 1.5;
  --grid-width: 105%;
  --grid-height: auto;
  --grid-gap: 2vw;
  --grid-columns: 4;
  --grid-inner-scale: 0.7;
}

/* Hide default elements on gallery page */
.gallery-3d-page .breadcrumb-wrapper,
.gallery-3d-page nav[aria-label="Navigare"] {
  display: none;
}

/* Page Loader */
.js .loading::before,
.js .loading::after {
  content: '';
  position: fixed;
  z-index: 1000;
}

.js .loading::before {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--gallery-bg);
}

.js .loading::after {
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  border-radius: 50%;
  opacity: 0.4;
  background: var(--gallery-accent);
  animation: loaderAnim 0.7s linear infinite alternate forwards;
}

@keyframes loaderAnim {
  to {
    opacity: 1;
    transform: scale3d(0.5, 0.5, 1);
  }
}

/* ============================================
   Main Gallery Container
   ============================================ */

.gallery-scroll {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background: var(--gallery-bg);
  color: var(--gallery-text);
  overflow-x: hidden;
}

/* ============================================
   Intro Section
   ============================================ */

.gallery-scroll__intro {
  height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  margin-bottom: 20vh;
  position: relative;
}

.gallery-scroll__title {
  font-family: 'Oswald', var(--font-heading);
  font-size: clamp(2rem, 8vw, 5rem);
  font-weight: 300;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gallery-text);
  margin: 0;
  line-height: 1;
}

.gallery-scroll__subtitle {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--gallery-gold);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 1.5rem;
}

.gallery-scroll__hint {
  position: absolute;
  bottom: 3rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.gallery-scroll__hint::after {
  content: '';
  width: 1px;
  height: 3rem;
  background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   Grid Section - Core 3D Gallery
   ============================================ */

.grid {
  display: grid;
  place-items: center;
  padding: 2rem;
  width: 100%;
  min-height: 200vh;
  perspective: var(--perspective);
}

.grid-wrap {
  height: 100%;
  width: var(--grid-width);
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), 1fr);
  gap: var(--grid-gap);
  transform-style: preserve-3d;
}

.grid__item {
  position: relative;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  will-change: transform;
  overflow: visible;
}

.grid__item-inner {
  position: relative;
  border-radius: 8px;
  will-change: transform;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.grid__item-inner img {
  display: block;
  max-width: 280px;
  max-height: 400px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

/* ============================================
   Header Navigation
   ============================================ */

.gallery-scroll__header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  pointer-events: none;
}

.gallery-scroll__header > * {
  pointer-events: auto;
}

.gallery-scroll__back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color 0.3s ease;
}

.gallery-scroll__back:hover {
  color: var(--gallery-gold);
}

.gallery-scroll__back svg {
  width: 18px;
  height: 18px;
}

.gallery-scroll__info {
  text-align: right;
}

.gallery-scroll__info-title {
  font-family: 'Oswald', var(--font-heading);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gallery-text);
  margin: 0;
}

.gallery-scroll__info-count {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 0.25rem;
}

/* ============================================
   Section Divider
   ============================================ */

.gallery-scroll__divider {
  min-height: 30vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
}

.gallery-scroll__divider-content {
  display: flex;
  align-items: center;
  gap: 2rem;
  max-width: 600px;
  width: 100%;
}

.gallery-scroll__divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.gallery-scroll__divider-text {
  font-family: 'Oswald', var(--font-heading);
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ============================================
   Outro / End Section
   ============================================ */

.gallery-scroll__outro {
  min-height: 50vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 4rem 2rem;
}

.gallery-scroll__outro-text {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.gallery-scroll__outro-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding: 1rem 2rem;
  background: var(--gallery-accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.gallery-scroll__outro-link:hover {
  background: var(--gallery-gold);
  transform: translateY(-2px);
}

/* ============================================
   Lightbox
   ============================================ */

.gallery-scroll__lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.gallery-scroll__lightbox.is-active {
  opacity: 1;
  visibility: visible;
}

.gallery-scroll__lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.gallery-scroll__lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  transform: scale(0.9);
  transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.gallery-scroll__lightbox.is-active .gallery-scroll__lightbox-content {
  transform: scale(1);
}

.gallery-scroll__lightbox-img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
}

.gallery-scroll__lightbox-close {
  position: absolute;
  top: -3rem;
  right: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.3s ease;
}

.gallery-scroll__lightbox-close:hover {
  background: var(--gallery-accent);
  border-color: var(--gallery-accent);
  color: #fff;
}

.gallery-scroll__lightbox-close svg {
  width: 18px;
  height: 18px;
}

.gallery-scroll__lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.3s ease;
}

.gallery-scroll__lightbox-nav:hover {
  background: var(--gallery-accent);
  border-color: var(--gallery-accent);
}

.gallery-scroll__lightbox-nav--prev {
  left: -4rem;
}

.gallery-scroll__lightbox-nav--next {
  right: -4rem;
}

.gallery-scroll__lightbox-nav svg {
  width: 20px;
  height: 20px;
}

.gallery-scroll__lightbox-counter {
  position: absolute;
  top: -3rem;
  left: 0;
  font-family: 'Oswald', var(--font-heading);
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.1em;
}

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

/* Tablet */
@media screen and (max-width: 1024px) {
  :root {
    --grid-columns: 3;
    --grid-gap: 3vw;
  }

  .grid__item-inner img {
    max-width: 220px;
    max-height: 320px;
  }
}

/* Mobile */
@media screen and (max-width: 768px) {
  :root {
    --grid-columns: 2;
    --grid-gap: 2vw;
    --perspective: 800px;
  }

  .gallery-scroll__header {
    padding: 1rem;
  }

  .gallery-scroll__back span {
    display: none;
  }

  .gallery-scroll__title {
    font-size: clamp(1.5rem, 10vw, 3rem);
  }

  .gallery-scroll__intro {
    height: 80vh;
    margin-bottom: 10vh;
  }

  .gallery-scroll__hint {
    bottom: 2rem;
  }

  .grid {
    padding: 0.5rem;
    min-height: 150vh;
  }

  .grid-wrap {
    width: 100% !important;
    gap: 2vw !important;
  }

  .grid__item-inner img {
    max-width: 200px;
    max-height: 280px;
  }

  .grid__item-inner {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
  }

  .gallery-scroll__divider {
    min-height: 20vh;
    padding: 2rem 1rem;
  }

  .gallery-scroll__divider-text {
    font-size: 0.75rem;
  }

  .gallery-scroll__outro {
    min-height: 40vh;
    padding: 3rem 1rem;
  }

  .gallery-scroll__lightbox-content {
    max-width: 95vw;
    max-height: 80vh;
  }

  .gallery-scroll__lightbox-img {
    max-height: 75vh;
  }

  .gallery-scroll__lightbox-nav {
    display: none;
  }

  .gallery-scroll__lightbox-close {
    top: -2.5rem;
    width: 40px;
    height: 40px;
  }

  .gallery-scroll__lightbox-counter {
    top: -2.5rem;
    font-size: 0.75rem;
  }
}

/* Small phones */
@media screen and (max-width: 480px) {
  :root {
    --grid-columns: 2;
  }

  .gallery-scroll__title {
    font-size: clamp(1.2rem, 8vw, 2rem);
    letter-spacing: 0.1em;
  }

  .gallery-scroll__subtitle {
    font-size: 0.75rem;
  }

  .grid__item-inner img {
    max-width: 160px;
    max-height: 220px;
  }

  .gallery-scroll__info-title {
    font-size: 0.875rem;
  }

  .gallery-scroll__info-count {
    font-size: 0.65rem;
  }
}

/* ============================================
   Smooth scroll body
   ============================================ */

html.lenis,
html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

.lenis.lenis-smooth iframe {
  pointer-events: none;
}
