/* ============================================================
   gallery.css — the photo wall.
   Loaded only by gallery.php, after style.css. Every rule is
   scoped under body.gal so no other page is affected.

   The idea: what a family actually takes home from a visit is a
   framed print. So each photo is matted and framed in the same
   cream-and-gold treatment as the portrait on the homepage,
   hung on the paper wall rather than dropped in a bare grid.
   ============================================================ */

body.gal .gal {
  background: var(--cream) url('/assets/images/decor/paper-texture.jpg?v=2') center / 600px auto repeat;
  padding-top: 76px;
}

body.gal .gal__divider {
  display: block;
  width: 300px;
  max-width: 62%;
  height: auto;
  margin: 0 auto 28px;
  opacity: 0.9;
}

body.gal .sec__head { margin-bottom: 56px; }

/* ── The wall ──────────────────────────────────────────────*/
body.gal .gal__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px 34px;
  max-width: 1120px;
  margin: 0 auto;
}

/* ── A framed print ────────────────────────────────────────
   Mat, gold keyline, and a cast shadow, matching the hero
   portrait on the homepage. */
body.gal .gal__frame {
  display: block;
  width: 100%;
  padding: 13px 13px 15px;
  background: linear-gradient(160deg, #F6EFDF 0%, #E6D8B8 100%);
  border: 1px solid rgba(201,162,76,0.9);
  border-radius: 3px;
  box-shadow: 0 16px 34px rgba(61,40,23,0.20);
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1), box-shadow 0.35s;
}
body.gal .gal__frame img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 2px;
  /* Reads as glass sitting inside the mat rather than a flat crop. */
  box-shadow: inset 0 0 0 1px rgba(61,40,23,0.22);
}

/* Hung by hand, so they do not all sit perfectly square. The tilt is
   static decoration, not motion — only the straightening is animated. */
body.gal .gal__frame:nth-child(3n+1) { transform: rotate(-0.8deg); }
body.gal .gal__frame:nth-child(3n+2) { transform: rotate(0.5deg); }
body.gal .gal__frame:nth-child(3n)   { transform: rotate(-0.35deg); }

body.gal .gal__frame:hover,
body.gal .gal__frame:focus-visible {
  transform: rotate(0deg) translateY(-8px);
  box-shadow: 0 26px 50px rgba(61,40,23,0.30);
}
body.gal .gal__frame:focus-visible {
  outline: 2px solid var(--evergreen);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  body.gal .gal__frame { transition: none; }
}

body.gal .gallery-empty {
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  color: var(--ash);
  padding: 48px 16px 32px;
}

/* ── Lightbox ──────────────────────────────────────────────
   The enlarged photo gets the same mat, and the alt text becomes
   a caption so the description is visible, not just announced. */
body.gal .lightbox__figure {
  /* Column-centred, so a caption wider or narrower than the photo still
     leaves an even mat on both sides. */
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 92vw;
  padding: 16px 16px 14px;
  background: linear-gradient(160deg, #F6EFDF 0%, #E6D8B8 100%);
  border: 1px solid rgba(201,162,76,0.9);
  border-radius: 3px;
  box-shadow: 0 40px 90px rgba(0,0,0,0.6);
}
body.gal .lightbox__img {
  max-width: 100%;
  max-height: 76vh;
  object-fit: contain;
  border-radius: 2px;
}
body.gal .lightbox__cap {
  max-width: 44ch;
  margin: 13px 0 2px;
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.5;
  text-align: center;
  color: #5C3F2A;
}
body.gal .lightbox__cap:empty { display: none; }

/* ── Narrower screens ──────────────────────────────────────*/
@media (max-width: 900px) {
  body.gal .gal__grid { grid-template-columns: repeat(2, 1fr); gap: 30px 24px; }
  /* Two columns, so the tilt has to repeat on a 2-cycle to stay alternating. */
  body.gal .gal__frame:nth-child(3n+1),
  body.gal .gal__frame:nth-child(3n+2),
  body.gal .gal__frame:nth-child(3n) { transform: rotate(0deg); }
  body.gal .gal__frame:nth-child(odd)  { transform: rotate(-0.6deg); }
  body.gal .gal__frame:nth-child(even) { transform: rotate(0.5deg); }
}

@media (max-width: 640px) {
  body.gal .gal { padding-top: 60px; }
  body.gal .sec__head { margin-bottom: 40px; }
  body.gal .gal__grid { gap: 22px 16px; }
  body.gal .gal__frame { padding: 8px 8px 10px; }
  body.gal .gal__divider { width: 220px; }
  body.gal .lightbox__figure { padding: 10px 10px 8px; }
  body.gal .lightbox__cap { font-size: 13px; }
}
