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

.back-link {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; font-weight: 600; font-size: .95rem; color: var(--sawdust-dim);
}
.back-link:hover { color: var(--sawdust); }
@media (max-width: 720px) { .topnav .back-link { display: none; } }

.gallery-intro { padding: clamp(44px, 7vw, 84px) 0 clamp(28px, 4vw, 44px); }
.gallery-intro h1 { color: var(--sawdust); }
.gallery-intro p { margin-top: 16px; font-size: 1.12rem; color: var(--sawdust-dim); max-width: 52ch; }

/* ---------- Category stacks ---------- */
.stack-grid {
  list-style: none; margin: 0; padding: 0 0 clamp(64px, 9vw, 110px);
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(34px, 4vw, 52px) clamp(28px, 3.5vw, 48px);
}
/* Piles sit like prints set down on a table: slight tilts, staggered heights */
.stack-grid > li:nth-child(4n+1) { --tilt: -1.4deg; }
.stack-grid > li:nth-child(4n+2) { --tilt: 1.1deg; }
.stack-grid > li:nth-child(4n+3) { --tilt: -.5deg; }
.stack-grid > li:nth-child(4n+4) { --tilt: 1.6deg; }
@media (min-width: 620px) {
  .stack-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stack-grid > li:nth-child(2n) { margin-top: 64px; }
}
@media (min-width: 1000px) {
  .stack-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stack-grid > li:nth-child(2n) { margin-top: 0; }
  .stack-grid > li:nth-child(3n+2) { margin-top: 72px; }
  .stack-grid > li:nth-child(3n+3) { margin-top: 28px; }
}
.stack-tile {
  display: block; width: 100%;
  padding: 0; margin: 0; border: 0; background: none;
  text-align: left; color: inherit; font: inherit; cursor: pointer;
}
.stack-tile:focus-visible { outline-offset: 8px; }

/* A pile of prints: the cover photo sits on two darker sheets,
   so each tile reads as "a set of photos", not a single image. */
.stack-art { position: relative; aspect-ratio: 4 / 3; margin: 12px 14px 0 0; transform: rotate(var(--tilt, 0deg)); }
.stack-art::before, .stack-art::after {
  content: ""; position: absolute; inset: 0;
  border-radius: var(--radius-photo);
  background: #5b412b;
  box-shadow: 0 10px 22px rgba(10, 6, 3, .45);
  transition: transform .35s cubic-bezier(.22, .8, .24, 1);
}
.stack-art::before { transform: translate(12px, -10px) rotate(3.5deg); background: #4a3422; }
.stack-art::after  { transform: translate(6px, -5px) rotate(1.6deg); background: #6a4c33; }
.stack-cover {
  position: absolute; inset: 0; z-index: 1;
  border-radius: var(--radius-photo); overflow: hidden;
  background: #4a3423;
  box-shadow: 0 1px 0 rgba(255, 235, 200, .18) inset, 0 16px 34px rgba(10, 6, 3, .5);
  transition: transform .35s cubic-bezier(.22, .8, .24, 1);
}
.stack-cover img, .stack-cover .img-missing { width: 100%; height: 100%; object-fit: cover; }

.stack-tile:hover .stack-art::before, .stack-tile:focus-visible .stack-art::before { transform: translate(20px, -14px) rotate(6deg); }
.stack-tile:hover .stack-art::after,  .stack-tile:focus-visible .stack-art::after  { transform: translate(10px, -7px) rotate(3deg); }
.stack-tile:hover .stack-cover,       .stack-tile:focus-visible .stack-cover       { transform: translate(-4px, 2px) rotate(-1.2deg); }

.stack-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 18px; padding-right: 14px; }
.stack-label h2 { font-size: 1.45rem; color: var(--sawdust); }
.stack-count { flex: none; font-size: .92rem; font-weight: 600; color: var(--sawdust-dim); }
.stack-blurb { margin: 6px 14px 0 0; font-size: .98rem; color: var(--sawdust-dim); }

.gallery-empty { padding: 40px 0 100px; color: var(--sawdust-dim); }

/* ---------- Call to action band ---------- */
.gallery-cta { padding: clamp(52px, 7vw, 84px) 0; }
.gallery-cta .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 22px; }
.gallery-cta h2 { color: var(--ink); max-width: 20ch; }
.gallery-cta p { margin: 10px 0 0; }
.gallery-cta .btn-primary { background: var(--ink); color: var(--maple-light); }
.gallery-cta .btn-primary:hover { background: var(--walnut); }

/* ---------- Lightbox ---------- */
body.lb-open { overflow: hidden; }
.lb {
  position: fixed; inset: 0; z-index: 200;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #110b07;
  color: var(--sawdust);
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility 0s linear .25s;
}
.lb.is-open { opacity: 1; visibility: visible; transition: opacity .25s ease; }

.lb-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; }
.lb-title { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; margin: 0; }
.lb-count { font-size: .95rem; color: var(--sawdust-dim); margin-left: 12px; font-family: var(--font-body); font-weight: 600; }

.lb-stage { position: relative; display: flex; align-items: center; justify-content: center; padding: 0 76px; min-height: 0; touch-action: pan-y; }
.lb-stage figure { margin: 0; height: 100%; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }
.lb-img {
  max-width: 100%; max-height: 100%; min-height: 0;
  object-fit: contain; border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
  transition: opacity .2s ease;
}
.lb-img.is-loading { opacity: .25; }
.lb-stage .img-missing { width: min(640px, 100%); aspect-ratio: 4 / 3; border-radius: 4px; }
.lb-caption { margin: 12px 0 0; text-align: center; color: var(--sawdust-dim); font-size: .98rem; }
.lb-caption:empty { display: none; }

.lb-btn {
  display: grid; place-items: center;
  width: 50px; height: 50px; border-radius: 50%;
  background: rgba(242, 228, 200, .1);
  border: 2px solid rgba(242, 228, 200, .35);
  color: var(--sawdust); cursor: pointer;
  transition: background-color .2s, border-color .2s;
}
.lb-btn:hover { background: rgba(242, 228, 200, .2); border-color: var(--sawdust); }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }

.lb-strip {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 14px 18px 18px;
  scrollbar-width: thin;
  justify-content: safe center;
}
.lb-thumb {
  flex: none; width: 76px; height: 58px; padding: 0;
  border-radius: 5px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: #3a281b;
  opacity: .55; transition: opacity .2s, border-color .2s;
}
.lb-thumb img, .lb-thumb .img-missing { width: 100%; height: 100%; object-fit: cover; font-size: 0; padding: 0; }
.lb-thumb:hover { opacity: .9; }
.lb-thumb[aria-current="true"] { opacity: 1; border-color: var(--tape); }

@media (max-width: 640px) {
  .lb-stage { padding: 0 10px; }
  .lb-prev, .lb-next { top: auto; bottom: 10px; transform: none; width: 44px; height: 44px; background: rgba(20, 13, 8, .75); }
  .lb-prev { left: 12px; }
  .lb-next { right: 12px; }
  .lb-title { font-size: 1.1rem; }
  .lb-thumb { width: 60px; height: 46px; }
}
