/* Style dla galerii Masonry */
.gallery {
  margin: 0 auto; /* centrowanie galerii */
  padding: 20px;
  box-sizing: border-box;
  will-change: transform; /* optymalizacja dla przeglądarek */
  contain: content; /* pomaga przeglądarce zoptymalizować renderowanie */
  min-height: 200px; /* zapewnia minimalną wysokość przy ładowaniu */
  position: relative; /* dla poprawnego układu elementów */
  width: 100%; /* pełna szerokość kontenera */
}

/* Responsywność dla galerii */
@media (max-width: 768px) {
  .gallery {
    padding: 15px;
  }
}

@media (max-width: 480px) {
  .gallery {
    padding: 10px;
  }
}

/* Elementy galerii */
.gallery-item {
  width: 200px; /* stała szerokość elementu */
  margin-bottom: 20px; /* odstęp dolny */
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  cursor: pointer;
  background: none;
  padding: 0;
  border: 2px solid transparent;
  opacity: 1; /* domyślnie widoczne */
  transform: none; /* bez transformacji początkowej */
  transition: box-shadow 0.3s ease;
  will-change: transform, opacity; /* optymalizacja renderowania */
  contain: layout style; /* pomaga przeglądarce zoptymalizować renderowanie */
  page-break-inside: avoid; /* dla lepszego zachowania układu */
  break-inside: avoid; /* nowoczesny odpowiednik dla CSS Grid */
  
  /* Placeholder dla obrazów przed załadowaniem */
  min-height: 150px;
  background: linear-gradient(135deg, rgba(240,240,240,0.4) 0%, rgba(255,255,255,0.4) 100%);
  
  /* Zapobieganie nakładaniu się */
  float: left; /* pomaga w układzie */
  clear: none; /* nie wymuszaj nowej linii */
  box-sizing: border-box; /* uwzględniaj padding i border w wymiarach */
  margin-right: 20px; /* stały odstęp z prawej strony */
}

/* Responsywność dla elementów galerii */
@media (max-width: 768px) {
  .gallery-item {
    width: 180px;
    margin-bottom: 15px;
    margin-right: 15px;
    min-height: 130px;
  }
}

@media (max-width: 480px) {
  .gallery-item {
    width: 140px;
    margin-bottom: 10px;
    margin-right: 10px;
    min-height: 110px;
    border-radius: 8px;
  }
}

/* Clearfix dla kontenera galerii - zapobiega problemom z układem */
.gallery::after {
  content: "";
  display: block;
  clear: both;
}

/* Dodatkowa klasa dla kontenera Masonry */
.masonry-container {
  margin: 0 auto;
  position: relative;
}

/* Klasa dla elementów, które zostały umieszczone przez Masonry */
.gallery-item.masonry-placed {
  position: absolute; /* pozycjonowanie absolutne dla elementów Masonry */
}

.gallery-item img {
  width: 100%;
  display: block;
  height: auto;
  border-radius: 8px;
  transition: filter 0.3s ease, opacity 0.3s ease;
  will-change: filter, opacity; /* optymalizacja renderowania */
  transform: translateZ(0); /* włącza przyspieszenie sprzętowe */
  backface-visibility: hidden; /* redukcja migotania */
  opacity: 0; /* startujemy z przeźroczystym obrazem */
  min-height: 50px; /* minimalna wysokość przed załadowaniem */
}

/* Gdy obraz się załaduje, staje się widoczny */
.gallery-item img.loaded,
.gallery-item img.error {
  opacity: 1;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 20px rgba(0,0,0,0.15);
  z-index: 1;
  border-color: rgba(216, 180, 160, 0.5);
}

/* Dostosowanie efektów hover dla urządzeń dotykowych */
@media (max-width: 768px) {
  .gallery-item:hover {
    transform: translateY(-3px);
  }
}

@media (max-width: 480px) {
  .gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.12);
  }
}

.gallery-item:hover img {
  filter: brightness(1.05);
}

.gallery-item-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(58, 50, 56, 0.7);
  color: white;
  padding: 12px;
  opacity: 0;
  transform: translateY(100%);
  transition: transform 0.3s ease, opacity 0.3s ease;
  border-radius: 0 0 8px 8px;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

@media (max-width: 768px) {
  .gallery-item-caption {
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .gallery-item-caption {
    padding: 8px;
  }
}

.gallery-item:hover .gallery-item-caption {
  opacity: 1;
  transform: translateY(0);
}

.author-name {
  font-weight: bold;
  margin-bottom: 5px;
  font-family: var(--font-ui);
  letter-spacing: 0.5px;
}

.photo-description {
  font-style: italic;
  font-size: 0.9em;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-body);
  letter-spacing: 0.5px;
}

@media (max-width: 480px) {
  .photo-description {
    font-size: 0.8em;
    margin-top: 2px;
  }
}

.mdc-card.gallery-card {
  padding: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
  border: none;
}

/* Style dla lightboxa */
.mdc-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

/* Responsywność dla lightboxa na urządzeniach mobilnych */
@media (max-width: 768px) {
  .mdc-lightbox {
    padding: 0;
  }
}

.mdc-lightbox--open {
  opacity: 1;
}

.lightbox-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

.lightbox-image-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: auto;
  max-height: 80%;
}

.mdc-lightbox__image {
  max-width: 90%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
  display: block;
}

@media (max-width: 768px) {
  .mdc-lightbox__image {
    max-width: 95%;
    max-height: 60vh;
  }
}

@media (max-width: 480px) {
  .mdc-lightbox__image {
    max-width: 98%;
    max-height: 50vh;
    border-radius: 6px;
  }
}

.mdc-lightbox__caption {
  background-color: rgba(0,0,0,0.7);
  padding: 15px;
  border-radius: 8px;
  margin-top: 15px;
  max-width: 80%;
  text-align: center;
  color: white;
  backdrop-filter: blur(5px);
}

.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  min-width: 0;
  padding: 0;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background-color: rgba(0,0,0,0.5);
  color: white;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  border: 2px solid rgba(255,255,255,0.5);
  z-index: 1100;
  cursor: pointer;
  opacity: 1;
}

.lightbox-nav-btn:hover {
  background-color: rgba(0,0,0,0.7);
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  border-color: rgba(255,255,255,0.8);
}

.lightbox-nav-btn .material-icons {
  font-size: 36px;
  color: white;
}

.lightbox-prev-btn {
  left: 20px;
}

.lightbox-next-btn {
  right: 20px;
}

.lightbox-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  min-width: 0;
  padding: 0;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background-color: rgba(0,0,0,0.5);
  color: white;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  border: 2px solid rgba(255,255,255,0.5);
  z-index: 1100;
  cursor: pointer;
  opacity: 1;
}

.lightbox-close-btn:hover {
  background-color: rgba(0,0,0,0.7);
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  border-color: rgba(255,255,255,0.8);
}

.lightbox-close-btn .material-icons {
  font-size: 28px;
  color: white;
}

/* Responsywność dla galerii */
@media (max-width: 600px) {
  /* Dostosowanie lightboxa dla urządzeń mobilnych */
  .lightbox-container {
    padding: 10px;
  }
  
  .lightbox-image-container {
    max-height: 75%;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .mdc-lightbox__image {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    margin: 0 auto;
  }
  
  .mdc-lightbox__caption {
    width: 95%;
    max-width: 95%;
    margin-top: 10px;
    padding: 10px;
    font-size: 14px;
    box-sizing: border-box;
  }
  
  .lightbox-nav-btn {
    width: 44px;
    height: 44px;
    background-color: rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.5);
    display: flex !important;
  }
  
  .lightbox-nav-btn .material-icons {
    font-size: 32px;
    color: white;
  }
  
  .lightbox-prev-btn {
    left: 10px;
  }
  
  .lightbox-next-btn {
    right: 10px;
  }
  
  .lightbox-close-btn {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background-color: rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.5);
    display: flex !important;
  }
  
  .lightbox-close-btn .material-icons {
    font-size: 24px;
    color: white;
  }
  
  /* Na urządzeniach mobilnych wyłączamy Masonry i używamy standardowego układu */
  .gallery {
    padding: 10px;
    display: block;
    width: 100%;
    box-sizing: border-box;
  }
  
  .gallery-item {
    width: 100%; /* pełna szerokość na mobilnych */
    max-width: 400px; /* maksymalna szerokość */
    margin: 0 auto 20px auto; /* centrowanie */
    transition: opacity 0.25s ease, transform 0.25s ease; /* szybsze animacje na mobile */
    box-sizing: border-box;
    display: block;
    float: none; /* wyłącz float na mobile */
    margin-right: 0; /* bez prawego marginesu na mobile */
  }
  
  /* Wyłącz animację hover na urządzeniach dotykowych */
  .gallery-item:hover {
    transform: translateY(0); /* bez unoszenia na mobile */
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); /* bez dodatkowego cienia */
  }
  
  /* Zapewniamy, że obrazy wypełniają całą szerokość elementu */
  .gallery-item img {
    width: 100%;
    height: auto;
    display: block;
  }
  
  /* Na urządzeniach mobilnych podpisy są widoczne pod obrazkiem */
  .gallery-item-caption {
    position: static; /* Wyłączamy pozycjonowanie absolutne */
    opacity: 1; /* Zawsze widoczne */
    transform: none; /* Bez transformacji */
    background: var(--primary-light); /* Kolor zgodny z motywem strony */
    color: var(--text-primary);
    padding: 15px;
    border-radius: 0 0 8px 8px;
    margin-top: -4px; /* Przysunięcie do obrazka */
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-top: 1px solid rgba(255,255,255,0.2);
  }
  
  /* Styl dla nazwy autora */
  .author-name {
    font-family: var(--font-heading);
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 16px;
    color: var(--primary-dark);
    letter-spacing: 0.5px;
  }
  
  /* Styl dla opisu zdjęcia */
  .photo-description {
    font-family: var(--font-ui);
    font-style: italic;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
  }
}

/* Dostosowanie dla orientacji poziomej (landscape) na urządzeniach mobilnych */
@media (max-width: 896px) and (orientation: landscape) {
  .lightbox-image-container {
    max-height: 85%;
  }
  
  .mdc-lightbox__image {
    max-height: 85vh;
  }
  
  .mdc-lightbox__caption {
    margin-top: 5px;
    padding: 5px;
    font-size: 12px;
  }
  
  .lightbox-close-btn {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    display: flex !important;
  }
  
  .lightbox-nav-btn {
    width: 40px;
    height: 40px;
    display: flex !important;
    background-color: rgba(0,0,0,0.5);
  }
  
  .lightbox-nav-btn .material-icons {
    font-size: 28px;
  }
  
  .lightbox-prev-btn {
    left: 10px;
  }
  
  .lightbox-next-btn {
    right: 10px;
  }
}

/* Animacja wczytywania obrazów */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.grid-item.show {
  animation: fadeIn 0.6s ease forwards;
}

/* Przyciski w stylu ślubnym */
.wedding-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 30px;
  background: var(--primary-color, #d8b4a0);
  color: white;
  border: none;
  border-radius: 50px;
  font-family: 'Montserrat', sans-serif;
  font-size: 15px;
  letter-spacing: 1.2px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(184, 139, 120, 0.3);
  text-decoration: none;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.wedding-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 18px rgba(184, 139, 120, 0.35);
  background-color: var(--primary-dark, #b68973);
}

.wedding-btn--outlined {
  background: transparent;
  color: var(--primary-dark, #b68973);
  border: 1px solid var(--primary-color, #d8b4a0);
  box-shadow: none;
}

.wedding-btn--outlined:hover {
  background: rgba(216, 180, 160, 0.12);
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(184, 139, 120, 0.15);
  border-color: var(--primary-dark, #b68973);
}

.wedding-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: white;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  border-radius: inherit;
}

.wedding-btn:active::after {
  opacity: 0.15;
}

/* Lightbox - podstawowe style */
.mdc-lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.92);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 30px;
  box-sizing: border-box;
}

.mdc-lightbox--open {
  display: flex !important;
  animation: fade-in 0.4s ease;
}

.mdc-lightbox__image {
  max-width: 90%;
  max-height: 90%;
  box-shadow: 0 5px 30px rgba(0, 0, 0, 0.5);
  border: 6px solid white;
  border-radius: 6px;
  transition: transform 0.3s ease;
}

.mdc-lightbox__caption {
  max-width: 600px;
  width: 90%;
  word-wrap: break-word;
  font-family: var(--font-ui);
  text-align: center;
  line-height: 1.6;
}

/* Keyframes dla animacji */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Redukcja animacji dla osób preferujących mniejszy ruch */
@media (prefers-reduced-motion: reduce) {
  .gallery-item {
    transition: opacity 0.1s ease;
    transform: none;
  }
  
  .gallery-item:hover {
    transform: none;
  }
  
  .gallery-item img {
    transition: none;
  }
}

/* Animacje wczytywania nowych elementów */
@keyframes fadeInUp {
  from {
    opacity: 0.7;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Klasa dla nowo dodanych elementów */
.gallery-item.new-item {
  animation: fadeInUp 0.5s ease forwards;
}

/* Styl dla ładowania kolejnych zdjęć */
#loading-more {
  margin-top: 20px;
  padding: 15px;
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

/* Animacja krętła ładowania */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Styl przycisku ładowania większej ilości zdjęć */
#load-more {
  margin: 20px auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

#load-more:hover {
  transform: translateY(-3px);
}

#load-more:active {
  transform: translateY(0);
}

/* Zapobieganie przeskakiwaniu layoutu */
#load-more-container {
  min-height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Dodatkowy kontener dla Masonry */
.masonry-layout {
  position: relative;
  width: 100%;
  margin: 0 auto;
}

/* Styl dla komunikatu braku zdjęć */
#no-photos {
  padding: 30px;
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  text-align: center;
}

/* Dodatkowy wskaźnik ładowania dla obrazów */
.gallery-item::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  border: 3px solid rgba(216, 180, 160, 0.2);
  border-top-color: rgba(216, 180, 160, 0.8);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: spin 0.8s linear infinite;
  opacity: 0.7;
  pointer-events: none;
}

/* Ukryj wskaźnik ładowania po załadowaniu obrazu */
.gallery-item.loaded::after {
  display: none;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Fallback w przypadku problemów z Masonry */
.no-js .gallery {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.no-js .gallery-item {
  margin: 10px;
  float: none;
}

/* Styl dla kontenera z przyciskiem "Załaduj więcej" */
#load-more-container {
  clear: both; /* zawsze poniżej galerii */
  width: 100%;
  text-align: center;
  padding: 20px 0;
} 