/* Reusable photo gallery + lightbox.
   Markup: <ul class="sb-gallery" data-gallery>
             <li><figure>
               <button type="button"><img alt="..." width height loading="lazy"></button>
               <figcaption>Caption</figcaption>
             </figure></li>
           </ul>
   Script: assets/js/gallery.js (builds the dialog; one per page). */

.sb-gallery-wrap{margin:8px 0 32px}
/* Six tracks so a short last row can grow without a hole.
   Three across: each item spans 2. Two left over: each spans 3.
   One left over: it spans the row. Thumb height stays the 3:2
   height of a normal cell, so every row of photos is the same height. */
.sb-gallery{
  --sb-cols:3;
  --sb-gap:14px;
  container-type:inline-size;
  display:grid;
  grid-template-columns:repeat(6,minmax(0,1fr));
  gap:18px var(--sb-gap);
  list-style:none;
  margin:0;
  padding:0;
  align-items:start;
}
.sb-gallery > li{grid-column:span 2;min-width:0}
.sb-gallery > li:last-child:nth-child(3n + 1){grid-column:1 / -1}
.sb-gallery > li:nth-last-child(2):nth-child(3n + 1),
.sb-gallery > li:last-child:nth-child(3n + 2){grid-column:span 3}
.sb-gallery figure{margin:0}
.sb-gallery-thumb{
  display:block;
  width:100%;
  height:calc((100cqi - (var(--sb-cols) - 1) * var(--sb-gap)) / var(--sb-cols) * 2 / 3);
  padding:0;
  border:1px solid var(--border);
  background:var(--bg3);
  cursor:zoom-in;
  overflow:hidden;
  border-radius:2px;
}
.sb-gallery-thumb img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  filter:sepia(8%);
  transition:transform .35s ease,filter .35s ease;
}
.sb-gallery-thumb:hover img,
.sb-gallery-thumb:focus-visible img{transform:scale(1.03);filter:sepia(0%)}
.sb-gallery-thumb:focus-visible{outline:2px solid var(--gold);outline-offset:2px}
.sb-gallery figcaption{
  font-family:'Cormorant Garamond',serif;
  font-size:16px;
  font-style:italic;
  line-height:1.4;
  color:var(--cream3);
  margin-top:7px;
}
.sb-gallery-credit{
  font-size:12px;
  color:var(--cream3);
  margin:16px 0 0;
  letter-spacing:.02em;
}
.sb-gallery-credit i{color:var(--gold);margin-right:6px}

@media(max-width:900px){
  .sb-gallery{
    --sb-cols:2;
    --sb-gap:10px;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:14px var(--sb-gap);
  }
  .sb-gallery > li,
  .sb-gallery > li:last-child:nth-child(3n + 1),
  .sb-gallery > li:nth-last-child(2):nth-child(3n + 1),
  .sb-gallery > li:last-child:nth-child(3n + 2){grid-column:auto}
  .sb-gallery > li:last-child:nth-child(odd){grid-column:1 / -1}
}
@media(max-width:520px){
  .sb-gallery{--sb-gap:8px;gap:12px var(--sb-gap)}
  .sb-gallery figcaption{font-size:14px}
}

/* Lightbox. The dialog element is created by gallery.js. */
.sb-lb{
  border:0;
  padding:0;
  margin:0;
  width:100%;
  height:100%;
  max-width:none;
  max-height:none;
  background:transparent;
  color:#F5F0E6;
}
.sb-lb::backdrop{background:rgba(0,0,0,.9)}
.sb-lb-stage{
  height:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:64px 72px 28px;
  box-sizing:border-box;
  touch-action:pan-y;
}
.sb-lb-figure{margin:0;max-width:min(1100px,100%);text-align:center}
.sb-lb-figure img{
  max-width:100%;
  max-height:min(72vh,820px);
  width:auto;
  height:auto;
  margin:0 auto;
  object-fit:contain;
  background:#000;
}
.sb-lb-figure figcaption{
  font-family:'Cormorant Garamond',serif;
  font-style:italic;
  font-size:18px;
  line-height:1.45;
  margin-top:12px;
  color:rgba(245,240,230,.88);
}
.sb-lb-count{
  margin:10px 0 0;
  font-family:'Raleway',sans-serif;
  font-size:11px;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:rgba(245,240,230,.55);
}
.sb-lb-close,.sb-lb-prev,.sb-lb-next{
  position:absolute;
  border:1px solid rgba(212,175,55,.45);
  background:rgba(0,0,0,.55);
  color:#F5F0E6;
  cursor:pointer;
  font-family:'Raleway',sans-serif;
}
.sb-lb-close{
  top:16px;
  right:16px;
  width:40px;
  height:40px;
  border-radius:2px;
  font-size:22px;
  line-height:1;
}
.sb-lb-prev,.sb-lb-next{
  top:50%;
  transform:translateY(-50%);
  width:44px;
  height:64px;
  font-size:28px;
  line-height:1;
}
.sb-lb-prev{left:16px}
.sb-lb-next{right:16px}
.sb-lb-close:hover,.sb-lb-prev:hover,.sb-lb-next:hover,
.sb-lb-close:focus-visible,.sb-lb-prev:focus-visible,.sb-lb-next:focus-visible{
  border-color:#D4AF37;
  color:#D4AF37;
  outline:none;
}
@media(max-width:700px){
  .sb-lb-stage{padding:56px 12px 20px}
  .sb-lb-prev,.sb-lb-next{top:auto;bottom:16px;transform:none;width:48px;height:44px;font-size:22px}
  .sb-lb-prev{left:16px}
  .sb-lb-next{right:16px}
  .sb-lb-figure img{max-height:62vh}
  .sb-lb-figure figcaption{font-size:16px;padding-bottom:52px}
}
@media(prefers-reduced-motion:reduce){
  .sb-gallery-thumb img{transition:none}
}
