/* ==========================================================================
   Gallery pages (templates/section/gallery.html.twig) + lightbox polish.
   Uses the tokens from header.css; cards/eyebrow come from home.css.
   ========================================================================== */

.gallery-page { padding: 56px 0 96px; background: var(--surface); }
/* Photos use most of the screen width (the heading stays narrow and centred). */
.gallery-wide { width: 100%; max-width: 1600px; margin: 0 auto; padding: 0 32px; }
/* On gallery pages the header uses the same width, so logo and photos line up. */
.is-gallery-page .site-header .container { --container: 1536px; --gutter: 32px; }

/* ---- Heading ------------------------------------------------------------ */
.gallery-head { max-width: 720px; margin: 0 auto 44px; text-align: center; }

.gallery-title {
  margin: 0 0 16px;
  font-family: Poppins, sans-serif;
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.015em;
  color: var(--ink);
}
.gallery-desc { font-size: 18px; line-height: 1.7; color: var(--ink-muted); }
.gallery-desc p { margin: 0 0 8px; font-size: inherit; line-height: inherit; color: inherit; }

.gallery-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}
.gallery-meta li {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--brand-tint);
  font-size: 14px;
  color: var(--ink-muted);
}
.gallery-meta strong { font-weight: 600; color: var(--ink); }

/* ---- Justified rows ----------------------------------------------------
   Each item gets --r (width / height). It grows in proportion to its ratio, so
   every row fills the width at one shared height; the ::after filler keeps the
   last row from stretching. */
.justified-gallery {
  --row-h: clamp(220px, 16vw, 290px);
  --gap: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}
.justified-gallery::after { content: ""; flex-grow: 999999; }

.jg-item {
  position: relative;
  display: block;
  flex-grow: var(--r);
  flex-basis: calc(var(--r) * var(--row-h));
  max-width: 100%;
  overflow: hidden;
  border-radius: 10px;
  background: var(--placeholder);
}
.jg-ratio { display: block; padding-bottom: calc(100% / var(--r)); }
.jg-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s ease, filter .3s ease;
}
.jg-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(16, 28, 25, 0) 55%, rgba(16, 28, 25, .35) 100%);
  opacity: 0;
  transition: opacity .3s ease;
}
.jg-item[href] { cursor: zoom-in; }
.jg-item[href]:hover img { transform: scale(1.035); }
.jg-item[href]:hover::after { opacity: 1; }
.jg-item:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.gallery-others { padding-top: 96px; }

@media (max-width: 991.98px) {
  .gallery-wide { padding: 0 16px; }
  .is-gallery-page .site-header .container { --gutter: 16px; }
  .justified-gallery { --row-h: 200px; --gap: 8px; }
  .gallery-others { padding-top: 72px; }
}
@media (max-width: 575.98px) {
  .gallery-wide { padding: 0 16px; }
  .gallery-page { padding: 32px 0 64px; }
  .gallery-head { margin-bottom: 28px; }
  /* Phones: one photo per row, full width, whole photo visible */
  .justified-gallery { --gap: 12px; }
  .jg-item { flex: 0 0 100%; border-radius: 10px; }
}

/* ---- Lightbox (<dialog>, built by app.js) ------------------------------- */
html.has-lightbox { overflow: hidden; }
.lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  overflow: hidden;
}
.lightbox::backdrop { background: #0b1210; }   /* opaque: the page behind must not show through */
.lightbox[open] { animation: lightbox-in .25s ease; }
@keyframes lightbox-in { from { opacity: 0; } }

.lightbox-figure {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  height: 100%;
  margin: 0;
  padding: 56px 72px 64px;
}
.lightbox-img {
  max-width: 100%;
  max-height: calc(100dvh - 140px);
  width: auto;
  border-radius: 4px;
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  transition: opacity .2s ease;
}
.lightbox.is-loading .lightbox-img { opacity: .35; }
.lightbox-caption { max-width: 720px; font-size: 15px; text-align: center; color: rgba(255, 255, 255, .85); }
.lightbox-counter {
  position: absolute;
  top: 18px;
  left: 24px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .7);
}

.lightbox-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  transition: background-color .15s ease;
}
.lightbox-btn:hover { background: rgba(255, 255, 255, .2); }
.lightbox-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lightbox-close { top: 8px; right: 12px; }
.lightbox-prev, .lightbox-next { top: 50%; translate: 0 -50%; }
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }
.lightbox-btn[hidden] { display: none; }

@media (max-width: 767.98px) {
  .lightbox-figure { padding: 56px 8px 72px; }
  .lightbox-prev, .lightbox-next { top: auto; bottom: 12px; translate: none; }
  .lightbox-prev { left: calc(50% - 60px); }
  .lightbox-next { right: calc(50% - 60px); }
}

@media (prefers-reduced-motion: reduce) {
  .jg-item img, .jg-item::after { transition: none; }
  .jg-item:hover img { transform: none; }
}
