/* ============================================================
   TERRA MAX - REALIZACJE STYLES
   Extends: home.css
   ============================================================ */

/* Reuse Page Hero from previous files (common style) */
.page-hero {
  position: relative;
  height: 50vh;
  min-height: 400px;
  display: flex;
  align-items: center;
  overflow: hidden;
  margin-top: 0;
}
.page-hero__background {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.page-hero__background img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.page-hero__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(30, 30, 30, 0.9) 0%,
    rgba(30, 30, 30, 0.6) 100%
  );
}
.page-hero::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: var(--color-primary);
  clip-path: polygon(0 100%, 100% 100%, 100% 0, 0 100%);
  z-index: 2;
}
.page-hero__content {
  position: relative;
  z-index: 3;
  padding-top: 100px; /* Increased from 60px for better spacing from header when zoomed */
}
.page-hero__title {
  color: var(--color-white);
  font-size: clamp(2.5rem, 4vw, 4rem);
  margin-bottom: 15px;
}
.page-hero__subtitle {
  color: rgba(255, 255, 255, 0.8);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1.2rem;
  max-width: 600px;
  border-left: 4px solid var(--color-primary);
  padding-left: 20px;
}

/* ==================== GALLERY ==================== */
.gallery {
  padding: var(--section-padding) 0;
  background: #fff;
}

.gallery-wrapper {
  position: relative;
}

.gallery-filters {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 50px;
  flex-wrap: wrap;
}

.filter-btn {
  background: transparent;
  border: 1px solid #ddd;
  padding: 10px 25px;
  font-family: var(--font-heading);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s var(--ease-tech);
  position: relative;
  /* Cut corner */
  clip-path: polygon(
    10px 0,
    100% 0,
    100% calc(100% - 10px),
    calc(100% - 10px) 100%,
    0 100%,
    0 10px
  );
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--color-dark);
  color: var(--color-primary);
  border-color: var(--color-dark);
  box-shadow: var(--glow-text);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  grid-auto-rows: 300px;
  grid-auto-flow: dense;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  background: #000;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); /* Clean rect initially */
  cursor: pointer;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Special positioning for specific images */
/* realizacje3.webp - obniżone o 1/4 */
.gallery-item:nth-child(2) img {
  object-position: center 25%;
}

/* realizacje5.webp - lekko powyżej środka */
.gallery-item:nth-child(3) img {
  object-position: center 40%;
}

/* realizacje4.webp - podniesione do góry aby pokazać koparkę */
.gallery-item:nth-child(8) img {
  object-position: center top;
}

/* Hidden state during filtering - subtle */
.gallery-item.hiding {
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  pointer-events: none;
}

/* Show state during filtering - subtle */
.gallery-item.showing {
  animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Masonry Sizes */
.gallery-item--large {
  grid-row: span 2;
  grid-column: span 1;
}
.gallery-item--wide {
  grid-column: span 2;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition:
    transform 0.6s var(--ease-tech),
    opacity 0.4s;
  opacity: 0.9;
}

.gallery-item:hover img {
  transform: scale(1.08);
  opacity: 0.6;
}

/* Overlay with Icon */
.gallery-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: all 0.4s var(--ease-tech);
}

.gallery-item:hover .gallery-overlay {
  opacity: 1;
}

.gallery-overlay i {
  font-size: 3rem;
  color: var(--color-primary);
  transform: scale(0.5);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gallery-item:hover .gallery-overlay i {
  transform: scale(1);
}

/* ==================== RESPONSIVE ==================== */
@media (min-width: 1600px) {
  .gallery-grid {
    gap: 30px;
    grid-auto-rows: 350px;
  }

  .gallery-item--large {
    grid-auto-rows: 400px;
  }
}

@media (max-width: 992px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 280px;
  }

  .gallery-item--large {
    grid-row: span 2;
  }

  .gallery-item--wide {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .gallery-filters {
    gap: 10px;
    margin-bottom: 40px;
  }

  .filter-btn {
    font-size: 12px;
    padding: 8px 18px;
  }

  .gallery {
    padding: 60px 0;
  }

  /* Mobile Slider */
  .gallery-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: 15px;
    grid-auto-rows: auto;
    padding: 0 7.5vw;
    -webkit-overflow-scrolling: touch;
  }

  .gallery-grid::-webkit-scrollbar {
    display: none;
  }

  .gallery-item {
    flex: 0 0 85vw;
    height: 70vh;
    max-height: 500px;
    scroll-snap-align: center;
  }

  .gallery-item img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
  }

  .gallery-item--large,
  .gallery-item--wide {
    flex: 0 0 85vw;
    grid-row: span 1;
    grid-column: span 1;
  }

  .gallery-overlay {
    padding: 20px;
  }

  .gallery-title {
    font-size: 1.2rem;
  }

  /* Show overlay hint on mobile */
  .gallery-item .gallery-overlay {
    opacity: 0;
  }

  .gallery-item:active .gallery-overlay {
    opacity: 1;
  }
  .gallery-overlay {
    display: none; /* Hide overlay completely on mobile */
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    padding: 0 5vw;
  }

  .gallery-item {
    flex: 0 0 90vw;
  }
}

/* Mobile Navigation Dots */
.gallery-nav-dots {
  display: none;
  justify-content: center;
  gap: 8px;
  margin-top: 30px;
}

@media (max-width: 768px) {
  .gallery-nav-dots {
    display: flex;
  }
}

.gallery-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ddd;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.gallery-dot.active {
  background: var(--color-primary);
  transform: scale(1.3);
}

/* Mobile Navigation Arrows - Styled to match site */
.gallery-arrow {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  background: var(--color-primary);
  border: none;
  color: var(--color-dark);
  width: 45px;
  height: 45px;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: all 0.2s ease;
  align-items: center;
  justify-content: center;
}

.gallery-arrow:active {
  transform: translateY(-50%) scale(0.95);
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.gallery-arrow--left {
  left: 15px;
}

.gallery-arrow--right {
  right: 15px;
}

.gallery-arrow i {
  font-size: 1.2rem;
  -webkit-text-stroke: 0;
}

@media (max-width: 768px) {
  .gallery-arrow {
    display: flex;
  }
}

/* ==================== LIGHTBOX ==================== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  display: flex; /* Keep flex always, manage visibility with visibility/opacity */
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden; /* Start hidden */
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox__content {
  max-width: 90vw;
  max-height: 90vh;
  position: relative;
  width: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.lightbox__content img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  display: block;
  transition: opacity 0.3s ease;
  opacity: 1;
}

.lightbox__content img.fade-out {
  opacity: 0;
}

.lightbox__close,
.lightbox__prev,
.lightbox__next {
  position: fixed;
  background: var(--color-primary);
  color: var(--color-dark);
  border: none;
  width: 50px;
  height: 50px;
  /* border-radius: 50%; */ /* REMOVED: To allow for clip-path */
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px); /* Custom clipped shape */
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 10000;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2); /* Subtle shadow for depth */
}

.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover {
  background: #fff;
  color: var(--color-dark);
  transform: scale(1.1);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3); /* More pronounced shadow on hover */
}

.lightbox__close {
  top: 30px;
  right: 30px;
}

.lightbox__prev {
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__next {
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__prev:hover {
  transform: translateY(-50%) scale(1.1);
}

.lightbox__next:hover {
  transform: translateY(-50%) scale(1.1);
}

@media (max-width: 768px) {
  .lightbox__close,
  .lightbox__prev,
  .lightbox__next {
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
  }

  .lightbox__close {
    top: 20px;
    right: 20px;
  }

  .lightbox__prev {
    left: 15px;
  }

  .lightbox__next {
    right: 15px;
  }
}
