/* JAS Cleaning /projects gallery — the photo grid, its full-screen viewer and the pagination.
   Linked through PageStyles (precedence jas-4-page), after site.css + animations.css. The
   `section.pg.*` qualifier is intentional: site.css's `section.pg` otherwise wins the spacing.
   Markup: src/app/projects/ProjectsContent.tsx + ProjectsGallery.tsx. */

section.pg.projects-gallery { padding-top: 56px; }

.projects-results-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto 24px;
}

.projects-results-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 400;
  letter-spacing: -.02em;
}

.projects-results-head p {
  margin: 0;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .06em;
}

/* Three to a row at EVERY width (owner spec) — the phone grid is the familiar photo-app grid. */
.projects-grid {
  list-style: none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.projects-grid li { margin: 0; }

.projects-tile {
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--paper);
  border: 1px solid var(--line-soft);
}

.projects-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s ease;
}

.projects-tile:hover img { transform: scale(1.03); }

.projects-tile:focus-visible {
  outline: 2px solid var(--leaf);
  outline-offset: 3px;
}

/* ── Full-screen viewer (a native <dialog>, opened with showModal) ──
   The dialog covers the whole viewport and is transparent, so the dark ::backdrop shows
   around the photo. The photo is sized to EXACTLY its own picture — width capped by both the
   free width and the free height × its aspect ratio (--ratio, set inline) — so there is no
   empty <img> box around it: any click whose target is the dialog itself is outside the photo,
   which is how a tap outside closes the viewer. */
.projects-lightbox {
  --lb-pad: 40px;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: var(--lb-pad);
  border: 0;
  background: transparent;
  color: #fff;
  overflow: hidden;
}

.projects-lightbox[open] {
  display: grid;
  place-items: center;
  animation: projects-lightbox-in .18s ease-out;
}

.projects-lightbox::backdrop { background: rgba(17, 20, 18, .92); }
.projects-lightbox[open]::backdrop { animation: projects-backdrop-in .18s ease-out; }

.projects-lightbox-img {
  display: block;
  width: min(100%, calc((100vh - 2 * var(--lb-pad)) * var(--ratio, 1.3333)));
  width: min(100%, calc((100dvh - 2 * var(--lb-pad)) * var(--ratio, 1.3333)));
  height: auto;
  border-radius: 6px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6);
}

.projects-lightbox-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 50%;
  background: rgba(0, 0, 0, .5);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.projects-lightbox-close:hover { background: rgba(0, 0, 0, .75); }

.projects-lightbox-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* The page must not scroll under the open viewer (Lenis is paused by the gallery island). */
html.projects-lightbox-open,
html.projects-lightbox-open body { overflow: hidden; }

@keyframes projects-lightbox-in {
  from { opacity: 0; transform: scale(.98); }
  to { opacity: 1; transform: none; }
}

@keyframes projects-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Pagination (the blog's numbered-page pattern) ── */
.projects-pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 1100px;
  margin: 44px auto 0;
}

.projects-pagination a {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  text-decoration: none;
}

.projects-pagination a:hover { border-color: var(--ink); }

.projects-pagination a[aria-current="page"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

@media (max-width: 699px) {
  section.pg.projects-gallery {
    padding-right: 12px;
    padding-left: 12px;
  }

  .projects-results-head {
    align-items: start;
    flex-direction: column;
    gap: 8px;
    padding: 0 12px;
  }

  .projects-grid { gap: 4px; }
  .projects-tile { border-radius: 4px; }
  .projects-lightbox { --lb-pad: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .projects-tile img { transition: none; }
  .projects-tile:hover img { transform: none; }
  .projects-lightbox[open],
  .projects-lightbox[open]::backdrop { animation: none; }
}
