:root {
  --bg-color: #1a1a1a;
  --text-color: #e0e0e0;
  --primary-color: #ffffff;
  --secondary-color: #a0a0a0;
  --border-color: #333333;
  --overlay-bg: rgba(0, 0, 0, 0.9);
  --font-family: 'Inter', sans-serif;
  --header-height: 90px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  font-weight: 300;
  overflow-x: hidden; /* Zapobiega przewijaniu horyzontalnemu */
  scrollbar-width: thin;
  scrollbar-color: var(--secondary-color) var(--bg-color);
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--secondary-color);
}


.container {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 40px;
}

/* --- Header & Navigation --- */
header {
  padding: 20px 0;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-color);
  z-index: 100;
  position: fixed; /* Zmieniono na fixed dla zablokowania nagłówka */
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  display: flex;
  align-items: center;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--primary-color);
  cursor: pointer;
}

nav ul {
  list-style-type: none;
  display: flex;
  gap: 25px;
}

nav button {
  background: none;
  border: none;
  color: var(--secondary-color);
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 400;
  cursor: pointer;
  transition: color 0.3s ease;
  padding: 5px 0;
}

nav button:hover {
  color: var(--primary-color);
}

nav button.active {
  color: var(--primary-color);
  border-bottom: 1px solid var(--primary-color);
}

/* --- Main Content --- */
main {
  padding: 40px 0;
  margin-top: var(--header-height); /* Dodano margines, aby treść nie chowała się pod nagłówkiem */
}

.gallery-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 40px;
  align-items: flex-start; /* Aligns items to the top of the grid */
}

.gallery-main-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}


/* --- Filter Panel --- */
.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 30px;
  align-self: start;
  position: sticky;
  top: calc(var(--header-height) + 40px); /* Przyklejony, z uwzględnieniem wysokości nagłówka */
  max-height: calc(100vh - var(--header-height) - 80px); /* Max height with padding */
  overflow-y: auto; /* Scroll if content is too tall */
  padding-right: 10px; /* Add some space for scrollbar */
}

.filters-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 30px;
  width: 100%;
}

.toggle-filters-btn {
  display: none; /* Hidden on desktop */
  width: 100%;
  padding: 12px 15px;
  background-color: #2a2a2a;
  border: 1px solid var(--border-color);
  color: var(--primary-color);
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.toggle-filters-btn:hover {
  background-color: #333333;
}


.filter-group h3 {
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 15px;
  color: var(--primary-color);
}

.filter-group ul {
  list-style-type: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-group button {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--secondary-color);
  font-family: var(--font-family);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 5px 12px;
  border-radius: 4px;
}

.filter-group button:hover {
  color: var(--primary-color);
  border-color: var(--secondary-color);
}

.filter-group button.active {
  color: var(--bg-color);
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.search-input {
    width: 100%;
    background-color: #2a2a2a;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 10px;
    font-family: var(--font-family);
    font-size: 0.9rem;
    border-radius: 4px;
}
.search-input:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.clear-filters-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--secondary-color);
  padding: 10px 15px;
  width: 100%;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 10px;
  text-align: center;
  border-radius: 4px;
}

.clear-filters-btn:hover {
  color: var(--primary-color);
  border-color: var(--secondary-color);
}

/* --- Sort Controls (Moved into Filter Panel) --- */
.sort-controls-inner select {
    width: 100%;
    background-color: #2a2a2a;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 4px;
    font-family: var(--font-family);
    font-size: 0.9rem;
}

.sort-controls-inner select:focus {
    outline: none;
    border-color: var(--secondary-color);
}

/* --- Photo Grid (Masonry) --- */
.photo-grid {
  column-count: 1; /* Mobile-first default */
  column-gap: 20px;
}

.photo-item {
  cursor: pointer;
  overflow: hidden;
  break-inside: avoid; /* Prevents items from splitting across columns */
  margin-bottom: 20px; /* Vertical gap between items in a column */
  position: relative; /* Potrzebne do pozycjonowania nakładki z tytułem */
}

.photo-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.4s ease;
  max-height: 85vh; /* Prevents image from being taller than the viewport */
}

.photo-item:hover img {
  transform: scale(1.05);
}

.photo-title-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: var(--primary-color);
  padding: 12px;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none; /* Pozwala na kliknięcie "przez" nakładkę */
}

.photo-item:hover .photo-title-overlay {
  opacity: 1;
}


/* --- Lightbox --- */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--overlay-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
  padding: 20px;
}

.lightbox-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 40px;
}

.lightbox-content img {
  max-width: 65%;
  max-height: 95%;
  object-fit: contain;
  flex-shrink: 1;
}

.lightbox-details {
  flex-basis: 320px;
  flex-shrink: 0;
  color: var(--secondary-color);
  padding: 20px;
  max-height: 95%;
  overflow-y: auto;
}
.lightbox-details h3 {
  color: var(--primary-color);
  font-weight: 500;
  font-size: 1.8rem;
  margin-bottom: 20px;
}
.lightbox-details p {
  font-size: 0.95rem;
  margin-bottom: 12px;
  line-height: 1.7;
}
.lightbox-details strong {
  color: var(--text-color);
  font-weight: 500;
  display: block;
  margin-bottom: 4px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lightbox-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--secondary-color);
  font-size: 2.5rem;
  cursor: pointer;
  transition: color 0.3s ease;
  z-index: 1001;
  padding: 10px 20px;
  -webkit-user-select: none; /* Safari */
  -ms-user-select: none; /* IE 10+ */
  user-select: none;
}
.lightbox-btn:hover {
  color: var(--primary-color);
}

.lightbox-close {
  top: 15px;
  right: 15px;
  transform: none;
  font-size: 2rem;
}

.lightbox-prev {
  left: 0;
}

.lightbox-next {
  right: 0;
}


/* --- Content Page --- */
.content-page {
  max-width: 800px;
}

.content-page--full-width {
  max-width: none;
}

.content-page--full-width p {
  text-align: justify;
}

.content-page h2 {
  font-size: 2rem;
  font-weight: 500;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  color: var(--primary-color);
}

.content-page--exhibitions h2 {
  font-size: 1rem;
  font-weight: 400;
  border-bottom: none;
  padding-bottom: 0;
  color: var(--primary-color);
}

.content-page p, .content-page ul {
  margin-bottom: 15px;
}

.content-page li {
  margin-left: 20px;
}

.content-page a {
  color: var(--text-color);
  text-decoration: none;
  border-bottom: 1px dotted var(--secondary-color);
  transition: color 0.3s ease, border-color 0.3s ease;
}

.content-page a:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
}

/* --- Carousel --- */
.carousel-container {
  position: relative;
  width: 100%;
  max-width: 1000px;
  margin: 40px auto;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.carousel-slider {
  display: flex;
  transition: transform 0.7s ease-in-out;
  height: auto;
}

.carousel-slide {
  min-width: 100%;
  box-sizing: border-box;
}

.carousel-slide img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  max-height: 60vh;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(26, 26, 26, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
  z-index: 10;
  padding: 0;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.carousel-btn:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

.carousel-prev {
  left: 15px;
}

.carousel-next {
  right: 15px;
}

/* --- Footer --- */
footer {
  background-color: var(--bg-color);
  border-top: 1px solid var(--border-color);
  padding: 20px 0;
  margin-top: 40px; /* Dodatkowy odstęp od treści */
}

.footer-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-container p {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.social-links {
  display: flex;
  gap: 20px;
}

.social-links a {
  color: var(--secondary-color);
  text-decoration: none;
  font-weight: 400;
  transition: color 0.3s ease;
}

.social-links a:hover {
  color: var(--primary-color);
}


@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .lightbox-content img {
        max-width: 60%;
    }
}


@media (max-width: 1024px) {
  .gallery-layout {
    grid-template-columns: 1fr;
  }
  .filter-panel {
    position: static;
    max-height: none;
    overflow-y: visible;
    flex-direction: column;
    padding-right: 0;
    gap: 0;
  }
  
  .toggle-filters-btn {
    display: block;
  }

  .filters-content-wrapper {
    transition: max-height 0.4s ease-out, opacity 0.3s ease-out, margin-top 0.4s ease-out;
    overflow: hidden;
    max-height: 2000px; /* Arbitralnie duża wartość, by pomieścić filtry */
    opacity: 1;
    margin-top: 20px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 30px;
    align-items: flex-start;
  }

  .filter-panel.collapsed .filters-content-wrapper {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  .filter-group {
      flex-basis: 48%;
  }
  .filter-group:first-child, 
  .filter-group:nth-last-child(2) { /* Sortowanie */
      flex-basis: 100%;
  }

  .clear-filters-btn {
    flex-basis: 100%;
    margin-top: 0; /* Reset margin */
  }
}

@media (max-width: 900px) {
    .lightbox-content {
        flex-direction: column;
        justify-content: center;
        gap: 20px;
        text-align: center;
    }
    .lightbox-content img {
        max-width: 100%;
        max-height: 65vh;
    }
    .lightbox-details {
        flex-basis: auto;
        text-align: center;
        padding: 0;
        max-height: 25vh;
    }
    .lightbox-details strong {
      text-align: center;
    }
}


@media (max-width: 768px) {
  :root {
    --header-height: 140px; /* Zwiększona wysokość dla zawijającego się menu */
  }
  .container {
    padding: 0 20px;
  }
  main {
      padding: 20px 0;
      margin-top: var(--header-height);
  }
  header {
      height: auto;
      min-height: var(--header-height);
  }
  header .container {
    flex-direction: column;
    gap: 20px;
    padding-top: 15px;
    padding-bottom: 15px;
  }
  nav ul {
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
  }
  .footer-container {
      flex-direction: column;
      gap: 10px;
  }
}

@media (max-width: 600px) {
    .filter-group {
        flex-basis: 100%;
    }
    .carousel-btn {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }
}

/* --- Photo Grid Responsive Columns (Masonry) --- */
@media (min-width: 769px) {
    .photo-grid {
        column-count: 2;
    }
}

@media (min-width: 1025px) {
    .photo-grid {
        column-count: 3;
    }
}

@media (min-width: 1401px) {
    .photo-grid {
        column-count: 4;
    }
}

@media (min-width: 1801px) {
    .photo-grid {
        column-count: 5;
    }
}