/* Modal de projetos adaptativa: cabe na viewport e mantém rolagem independente do conteúdo. */
:root { --project-modal-gutter: clamp(12px, 2vw, 24px); }

.project-gallery-modal {
  padding: var(--project-modal-gutter);
  overflow: hidden;
}

.project-gallery-dialog {
  width: min(1440px, calc(100vw - (var(--project-modal-gutter) * 2)));
  height: min(92dvh, 980px);
  max-height: calc(100dvh - (var(--project-modal-gutter) * 2));
  min-height: 0;
  overflow: hidden;
  display: block;
}

.project-gallery-layout {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
}

.project-gallery-viewer {
  min-width: 0;
  min-height: 0;
  height: 100%;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.project-gallery-stage {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.project-gallery-stage img,
.project-gallery-stage video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: none;
  object-fit: contain;
}

.project-gallery-thumbs {
  flex: 0 0 auto;
  max-width: 100%;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

.project-gallery-copy {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  justify-content: flex-start;
  justify-content: safe center;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.project-gallery-copy:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

.project-gallery-copy::-webkit-scrollbar { width: 8px; }
.project-gallery-copy::-webkit-scrollbar-track { background: transparent; }
.project-gallery-copy::-webkit-scrollbar-thumb {
  background: rgba(5, 5, 5, .18);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

@media (max-width: 1180px) and (min-width: 861px) {
  .project-gallery-layout {
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr);
  }
}

/* Alturas menores, como notebooks e janelas reduzidas. */
@media (max-height: 700px) and (min-width: 861px) {
  :root { --project-modal-gutter: 10px; }

  .project-gallery-dialog {
    height: calc(100dvh - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: 24px;
  }

  .project-gallery-copy {
    padding: 30px 58px 28px 34px;
  }

  .project-gallery-copy h3 {
    font-size: clamp(30px, 3.2vw, 50px);
    margin-top: 12px;
  }

  .project-gallery-summary {
    margin-top: 16px;
    font-size: 15px;
    line-height: 1.55;
  }

  .project-gallery-facts { margin-top: 22px; }
  .project-gallery-fact { padding: 12px 0; }
}

/* Tablet e mobile: a modal vira uma página interna rolável, sem cortar conteúdo. */
@media (max-width: 860px) {
  .project-gallery-modal {
    display: block;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: #0b0b0b;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .project-gallery-dialog {
    width: 100%;
    height: auto;
    max-height: none;
    min-height: 100dvh;
    border-radius: 0;
    overflow: visible;
  }

  .project-gallery-layout {
    grid-template-columns: 1fr;
    width: 100%;
    height: auto;
    min-height: 100dvh;
    max-height: none;
  }

  .project-gallery-viewer {
    width: 100%;
    height: min(66svh, 680px);
    min-height: 460px;
  }

  .project-gallery-stage {
    min-height: 0;
    height: 100%;
  }

  .project-gallery-stage img,
  .project-gallery-stage video {
    max-height: none;
  }

  .project-gallery-copy {
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
    justify-content: flex-start;
    padding: 40px 24px 52px;
  }

  .project-gallery-close {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    top: max(14px, env(safe-area-inset-top));
  }
}

@media (max-width: 640px) {
  .project-gallery-viewer {
    height: min(62svh, 580px);
    min-height: 400px;
  }

  .project-gallery-copy {
    padding: 34px 22px 46px;
  }

  .project-gallery-copy h3 {
    font-size: clamp(34px, 11vw, 50px);
  }
}

/* Celulares em landscape e telas extremamente baixas. */
@media (max-width: 860px) and (max-height: 560px) {
  .project-gallery-viewer {
    height: 78svh;
    min-height: 320px;
  }
}
