/* =========================================
   Forest Quest — Mobile Modal + Media Patch
   Add AFTER forest-quest.css
   Current purpose:
   - keep modal scrollable on mobile
   - preserve original image ratios
   - avoid cropped heads/faces
   - keep Sign 4 readable without cutting content
   ========================================= */

/* Make all modal media safe by default */
.modal-panel img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Desktop/modal image row: keep three images, preserve real ratios */
.image-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
  align-items: start;
}

.image-row img {
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
  object-position: center center;
  border-radius: 14px;
  border: 1px solid rgba(232, 242, 228, 0.12);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

/* Sign 4 image: preserve original landscape ratio */
.impact-project-image {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: none;
  aspect-ratio: auto;
  object-fit: contain;
  object-position: center center;
  border-radius: 16px;
  margin: 12px 0;
  border: 1px solid rgba(232, 242, 228, 0.12);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.26);
}

.impact-project-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(232, 242, 228, 0.14);
}

.project-kicker {
  color: var(--text);
}

/* Desktop/modal safety */
.modal-panel {
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-panel::-webkit-scrollbar {
  width: 8px;
}

.modal-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.modal-panel::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

/* Mobile: stack images, keep original ratios, no cropping */
@media (max-width: 768px) {
  .modal {
    padding: 12px;
    overflow-y: auto;
  }

  .modal-panel {
    width: min(100%, 560px);
    max-height: calc(100dvh - 24px);
    margin: 0 auto;
    padding: 20px 16px 18px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 22px;
  }

  .modal-panel h3 {
    font-size: 30px;
    line-height: 1.04;
    padding-right: 42px;
  }

  .modal-panel p {
    font-size: 16px;
    line-height: 1.5;
  }

  .modal-panel ul {
    font-size: 15px;
    line-height: 1.55;
    padding-left: 18px;
  }

  .modal-close {
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
    border-radius: 13px;
  }

  .image-row {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 12px 0;
  }

  .image-row img {
    width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: auto;
    object-fit: contain;
    object-position: center center;
    border-radius: 12px;
  }

  .impact-project-image {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: none;
    aspect-ratio: auto;
    object-fit: contain;
    object-position: center center;
    margin: 10px 0 12px;
  }

  .impact-project-block {
    margin-top: 12px;
    padding-top: 12px;
  }

  .modal-actions {
    position: sticky;
    bottom: -18px;
    margin-left: -16px;
    margin-right: -16px;
    padding: 12px 16px 0;
    background: linear-gradient(
      to top,
      rgba(9, 16, 10, 0.98) 0%,
      rgba(9, 16, 10, 0.88) 65%,
      rgba(9, 16, 10, 0) 100%
    );
  }

  .modal-actions .btn {
    flex: 1 1 140px;
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .modal-panel {
    padding: 18px 14px 16px;
  }

  .modal-panel h3 {
    font-size: 27px;
  }

  .modal-actions {
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .modal-actions .btn {
    flex: 1 1 100%;
    justify-content: center;
  }
}
