body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#navigacija,
#galerijacontainer,
body > footer,
body > script {
  position: relative;
}

#galerijacontainer {
  display: none;
}

.gallery-page {
  width: 100%;
  flex: 1;
}

.gallery-heading {
  width: min(94%, 1440px);
  display: flex;
  justify-content: center;
  align-items: end;
  margin: 0 auto;
  padding: 7rem 0 3.5rem;
  border-bottom: 1px solid var(--ink);
}

.gallery-heading p {
  margin: 0;
  color: #000;
  font-size: clamp(1.85rem, 4vw, 3.5rem);
  font-weight: 800;
  text-transform: uppercase;
}

.gallery-heading h1 {
  margin: 0;
  font-family: "Futura", "Montserrat", sans-serif;
  font-size: clamp(4.5rem, 8vw, 8.5rem);
  font-weight: 800;
  line-height: 0.82;
  letter-spacing: -0.065em;
}

.gallery-heading h1 em {
  color: var(--blue);
  font-family: "DM Serif Display", serif;
  font-weight: 400;
}

.gallery-grid {
  width: min(94%, 1440px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: start;
  column-gap: 1.25rem;
  row-gap: 3.5rem;
  margin: 0 auto;
  padding: 4.5rem 0 8rem;
}

.gallery-item {
  position: relative;
  grid-column: span 4;
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.gallery-item {
  grid-column: auto;
  margin-top: 0;
}

.gallery-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--ink);
  background: #ddd8cd;
}

.gallery-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  filter: none;
  transition: transform 0.4s ease;
}

.gallery-item:hover .gallery-media img {
  filter: grayscale(0) contrast(1);
  transform: scale(1.025);
}

.gallery-meta {
  position: static;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 1rem;
  margin-top: 0.85rem;
  border-top: 1px solid var(--ink);
  padding-top: 0.75rem;
  color: var(--ink);
  opacity: 1;
  transform: none;
}

.gallery-meta h1,
.gallery-meta h2 {
  margin: 0;
  color: var(--ink);
  font-family: "Futura", "Montserrat", sans-serif;
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.gallery-meta p {
  margin: 0.1rem 0 0;
  color: #77746d;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  text-align: right;
}
.project-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 2.25rem;
  background: var(--paper);
  animation: modalFade 0.14s ease-out;
}

.project-modal[hidden] {
  display: none;
}

.project-modal-content {
  width: fit-content;
  max-width: min(980px, 92vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--paper);
  animation: modalEnter 0.18s ease-out;
}

.project-modal-divider {
  width: 100%;
  height: 1px;
  flex: 0 0 1px;
  margin-top: 0.5rem;
  background: var(--ink);
}

.project-modal-image {
  width: fit-content;
  max-width: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-sizing: border-box;
  margin-inline: auto;
}

.project-modal-image img {
  width: auto;
  max-width: 100%;
  max-height: 68vh;
  display: block;
  object-fit: contain;
}

.project-modal-caption {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  align-items: start;
  gap: 2rem;
  box-sizing: border-box;
  border-top: 1px solid var(--ink);
  padding-top: 1.25rem;
  color: var(--ink);
}

.project-modal-caption > p:first-child {
  display: none;
}

.project-modal-caption h2 {
  margin: 0;
  color: var(--ink);
  font-family: "Futura", "Montserrat", sans-serif;
  font-size: clamp(2rem, 3.2vw, 3.2rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.045em;
}

.project-modal-description {
  margin: 0;
  color: #3e3c38;
  font-size: clamp(0.92rem, 1.2vw, 1.05rem);
  font-weight: 500;
  line-height: 1.65;
}

.project-modal-close {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 101;
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.project-modal-close:hover {
  color: var(--blue);
}

.project-modal-prev,
.project-modal-next {
  position: fixed;
  top: 50%;
  z-index: 101;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transform: translateY(-50%);
  transition: color 0.16s ease, transform 0.16s ease;
}

.project-modal-nav {
  display: contents;
}

.project-modal-prev { left: 1.5rem; }
.project-modal-next { right: 1.5rem; }

.project-modal-prev:hover {
  color: var(--blue);
  transform: translate(-3px, -50%);
}

.project-modal-next:hover {
  color: var(--blue);
  transform: translate(3px, -50%);
}

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

@keyframes modalEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 980px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    column-gap: 1.25rem;
    row-gap: 4rem;
  }

  .gallery-item,
  .gallery-item:nth-child(1),
  .gallery-item:nth-child(2),
  .gallery-item:nth-child(3),
  .gallery-item:nth-child(4),
  .gallery-item:nth-child(5),
  .gallery-item:nth-child(6) {
    grid-column: auto;
    margin-top: 0;
  }

}



@media (max-width: 980px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 4rem;
  }

  .gallery-item,
  .gallery-item:nth-child(n) {
    grid-column: auto;
    margin-top: 0;
  }

  .gallery-item:nth-child(even) {
    margin-top: 4rem;
  }

  .project-modal {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
  }

  .project-modal-content {
    max-width: calc(100vw - 4.5rem);
    align-self: center;
  }

  .project-modal-nav {
    display: flex;
    justify-content: space-between;
  }

  .project-modal-prev,
  .project-modal-next {
    position: static;
    flex: 0 0 44px;
    transform: none;
  }

  .project-modal-prev:hover,
  .project-modal-next:hover {
    transform: none;
  }
}

@media (max-width: 680px) {
  .gallery-grid {
    width: calc(100% - 2rem);
    max-width: 100%;
    grid-template-columns: 1fr;
    column-gap: 0;
    row-gap: 1.25rem;
    padding: 2.5rem 0 4.5rem;
  }

  .gallery-item,
  .gallery-item:nth-child(n) {
    width: 100%;
    grid-column: 1;
    margin-top: 0;
  }

  .gallery-media {
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    border: 0;
    background: transparent;
  }

  .gallery-media img {
    width: 100%;
    height: auto;
    object-fit: contain;
  }

  .gallery-heading {
    width: calc(100% - 2rem);
    gap: 1.5rem;
    padding: 5rem 0 2.5rem;
  }

  .gallery-heading h1 { font-size: clamp(3.8rem, 18vw, 5.5rem); }

  .gallery-grid {
    width: calc(100% - 2rem);
    grid-template-columns: 1fr;
    row-gap: 3.5rem;
    padding: 3rem 0 5.5rem;
  }

  .gallery-item:nth-child(even) {
    margin-top: 0;
  }


  .project-modal {
    padding: 1rem;
  }

  .project-modal-content {
    max-height: none;
    max-width: calc(100vw - 2rem);
  }

  .project-modal-image img {
    max-height: 58vh;
  }

  .project-modal-caption {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .gallery-item,
  .gallery-item:nth-child(1),
  .gallery-item:nth-child(6) {
    grid-column: auto;
  }

  .gallery-media img,
  .gallery-item:nth-child(1) .gallery-media img,
  .gallery-item:nth-child(6) .gallery-media img {
    height: auto;
  }
}
