/* =========================
   Gallery
   ========================= */

.gallery-container {
  width: min(100% - 40px, var(--max));
  padding: clamp(56px, 9vw, 96px) 0 10px;
  text-align: left;
}

.gallery-title {
  margin: 0;
  color: var(--text);
  font-size: clamp(2rem, 5.4vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.gallery-title::after {
  display: block;
  width: min(200px, 46vw);
  height: 2px;
  margin-top: 22px;
  content: "";
  background: linear-gradient(90deg, var(--accent), var(--accent-2), transparent);
}

.gallery-container > p {
  max-width: 680px;
  margin: 20px 0 34px;
  color: var(--muted);
  line-height: 1.8;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.gallery-item::after {
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  pointer-events: none;
  content: "";
  background: linear-gradient(to top, rgba(8, 10, 18, 0.62), transparent);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: calc(var(--radius) - 2px);
  object-fit: cover;
  transition: transform 0.35s ease;
}

.gallery-item:hover,
.gallery-item:focus-within {
  transform: translateY(-5px);
  border-color: rgba(105, 210, 231, 0.55);
}

.gallery-item:hover::after,
.gallery-item:focus-within::after {
  opacity: 1;
}

.gallery-item:hover img,
.gallery-item:focus-within img {
  transform: scale(1.04);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(3, 4, 8, 0.86);
  backdrop-filter: blur(16px);
  overflow: auto;
}

.modal.active {
  display: flex;
}

.modal-content {
  display: grid;
  gap: 16px;
  justify-items: center;
  width: min(94vw, 1120px);
}

.modal-content img {
  display: block;
  max-width: 100%;
  max-height: 76vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: contain;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.56);
}

#modal-comment {
  max-width: min(92vw, 760px);
  margin: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--soft);
  background: rgba(8, 10, 18, 0.76);
  font-size: 0.96rem;
  line-height: 1.8;
  text-align: center;
  backdrop-filter: blur(12px);
}

.gallery-container .back-btn {
  margin-top: 32px;
}

@media (max-width: 860px) {
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .gallery-container {
    width: min(100% - 28px, var(--max));
    padding-top: 40px;
  }

  .gallery {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .modal {
    align-items: stretch;
    padding: 14px;
  }

  .modal-content {
    width: 100%;
    min-height: calc(100dvh - 28px);
    align-content: center;
    gap: 12px;
  }

  .modal-content img {
    max-height: 58dvh;
  }

  #modal-comment {
    max-width: 100%;
    width: 100%;
    max-height: 26dvh;
    overflow: auto;
    padding: 12px 14px;
    color: var(--text);
    background: rgba(8, 10, 18, 0.88);
    font-size: 0.9rem;
    line-height: 1.75;
    text-align: left;
  }
}
