#gallery {
  min-height: calc(100vh - 141px);
  width: 72%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 30px;
  margin: 0 auto;
  background-color: rgba(0, 0, 0, 0.3);
  box-shadow: var(--gothic-glow);
  padding: 2%;
  border: var(--gothic-border);
  position: relative;
}

#gallery::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    45deg,
    transparent 48%,
    rgba(139, 0, 0, 0.1) 50%,
    transparent 52%
  );
  pointer-events: none;
}

.categoriesMobile {
  display: none;
}

.categoriesPC {
  width: 100%;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: var(--gothic-border);
}

.categoriesPC .options {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 50px;
}

.categoriesPC span {
  font-size: 3rem;
  font-family: var(--font-bold) !important;
  color: var(--text-color-highlight);
  text-transform: uppercase;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  letter-spacing: 2px;
}

.category-link {
  font-size: 2rem;
  text-decoration: none;
  color: var(--text-color-bold);
  transition: all var(--transition-speed) ease;
  padding: 12px 24px;
  background-color: rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
  letter-spacing: 1px;
  border: var(--gothic-border);
  text-transform: capitalize;
}

.category-link::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(139, 0, 0, 0.2),
    transparent
  );
  transition: 0.5s;
}

.category-link:hover::before {
  left: 100%;
}

.category-link:hover {
  background-color: rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
  color: var(--text-color-highlight);
  box-shadow: var(--gothic-glow);
}

#selected {
  background-color: rgba(0, 0, 0, 0.7);
  color: var(--text-color-highlight);
  text-decoration: none;
  box-shadow: var(--gothic-glow);
  border: 1px solid var(--text-color-highlight);
}

#selected:hover {
  background-color: rgba(0, 0, 0, 0.8);
  color: var(--text-color-highlight);
}

.categoriesMobile {
  display: none;
}

.modern-select {
  width: 200px;
  background-color: var(--header-color);
  color: var(--text-color-bold);
  border: 1px solid var(--text-color-highlight);
  border-radius: 4px;
  padding: 10px;
  font-size: 1.2rem;
  text-transform: capitalize;
}

.posts {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: flex-start;
  width: 100%;
  margin: 0 auto;
  min-height: 300px;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.posts.loading {
  opacity: 0.6;
}

.post {
  position: relative;
  width: calc((100% - 40px) / 3);
  margin-bottom: 0;
  aspect-ratio: 1/1;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  animation: fadeIn 0.3s ease-in;
  box-shadow: var(--gothic-glow);
  border: var(--gothic-border);
  cursor: pointer;
}

.post img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  opacity: 0;
  animation: fadeIn 0.3s ease-in forwards;
}

.post:hover {
  filter: brightness(0.9);
}

/* Loading animation */
.post::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  border: 3px solid rgba(247, 41, 64, 0.1);
  border-top-color: var(--text-color-highlight);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
}

.post.loaded::before {
  display: none;
}

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

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

.pageCount {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 15px;
  background-color: rgba(0, 0, 0, 0.8);
  border: var(--gothic-border);
}

.pageCount label {
  color: var(--text-color-bold);
  font-size: 1rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.pageCount svg {
  width: 20px;
  height: 20px;
  fill: var(--text-color-bold);
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.5));
}

.no-category {
  text-align: center;
  color: var(--text-color-light);
  font-size: 1.2rem;
  padding: 40px;
}

.lazy-load {
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
}

.lazy-load.loaded {
  opacity: 1;
}

@media (max-width: 900px) {
  #gallery {
    width: 95%;
    padding: 15px;
  }

  .categoriesPC {
    display: none;
  }

  .categoriesMobile {
    display: block;
    width: 100%;
    margin-bottom: 15px;
  }

  .posts {
    width: 100%;
    gap: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .post {
    width: calc((100% - 10px) / 2);
    margin-bottom: 0;
    aspect-ratio: 1;
  }

  .pageCount {
    padding: 5px 10px;
    bottom: 5px;
    right: 5px;
  }

  .pageCount label {
    font-size: 0.8rem;
  }

  .pageCount svg {
    width: 15px;
    height: 15px;
  }
}

@media (max-width: 400px) {
  #gallery {
    width: 100%;
    padding: 10px;
  }

  .posts {
    gap: 10px;
  }

  .post {
    width: calc((100% - 10px) / 2);
    margin-bottom: 0;
  }
}

#image-viewer {
  display: none;
  z-index: 999;
}

#image-viewer #display {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

#image-viewer #image-wrapper {
  display: block;
  width: 80%;
  height: 95%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
}

#image-viewer #image-wrapper {
  overflow: auto;
  scrollbar-width: none;
}

#image-viewer #image-wrapper::-webkit-scrollbar {
  display: none;
}

#image-viewer #image-wrapper img {
  animation: showImage 0.5s;
  width: 100%;
  flex-shrink: 0;
  object-fit: contain;
  min-height: unset;
}

@keyframes showImage {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

#closeViewer {
  position: absolute;
  top: 15px;
  right: 35px;
  cursor: pointer;
  color: var(--text-color-bold);
  font-size: 40px;
}

#closeViewer:hover,
#closeViewer:focus {
  opacity: 0.8;
}

#prev,
#next {
  position: absolute;
  top: calc(50% - 80px);
  width: 80px;
  height: 80px;
  transition: all 0.5;
}

#prev:hover,
#next:hover {
  cursor: pointer;
  filter: brightness(0.8);
}

#prev {
  left: 80px;
}

#next {
  right: 80px;
}

#prev img,
#next img {
  width: 100%;
  height: 100%;
}

#fullOverlay {
  visibility: hidden;
  position: fixed;
  z-index: 1000000;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader {
  width: 48px;
  height: 48px;
  border: 5px solid #fff;
  border-bottom-color: transparent;
  border-radius: 50%;
  display: inline-block;
  box-sizing: border-box;
  animation: rotation 1s linear infinite;
}

@keyframes rotation {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
