/* CONNEXUS 2026 photo gallery (gallery.html, en/gallery.html).
   Layout, type and colours follow the photographer's own gallery
   (visionimpress.gallery.photo) 1:1; the site nav/footer sit around it.
   Measurements taken from that page:
   - page #F9F8F6, headings #30363B, photo placeholder #E7E5E0, bar border #DBD9D4
   - titles Jost 300 (cover 80px / 47px phone, scenes 44px / 24px phone)
   - grid: 30px side padding (8px under 1024px), 2px inset per tile = 4px gaps
   - 4 photos per row from 1440px, 3 from 1024px, justified rows below that
   - lightbox on the page colour, image 58px from top/bottom */

.cx-gal-page {
  --g-bg: #F9F8F6;
  --g-ink: #30363B;
  --g-black: #000;
  --g-ph: #E7E5E0;
  --g-line: #DBD9D4;
  --g-font: 'Jost', 'Helvetica Neue', Arial, sans-serif;
  --g-nav-h: 72px;
  --g-bar-h: 64px;
  background: var(--g-bg);
}

.cx-gal-page main {
  background: var(--g-bg);
  font-family: var(--g-font);
  color: var(--g-ink);
}

/* ---------- Cover ---------- */
.cx-gal-hero {
  position: relative;
  margin-top: var(--g-nav-h);
  height: calc(100vh - var(--g-nav-h));
  height: calc(100svh - var(--g-nav-h));
  min-height: 420px;
  overflow: hidden;
  background: #1b1b1b;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  padding: 0 24px 190px;
}

.cx-gal-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
}

.cx-gal-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #00000033;
}

.cx-gal-hero-title,
.cx-gal-hero-date,
.cx-gal-hero-down {
  position: relative;
  z-index: 1;
}

.cx-gal-hero-title {
  font-family: var(--g-font);
  font-size: 80px;
  font-weight: 300;
  line-height: 84px;
  letter-spacing: normal;
  color: #fff;
  margin: 0;
}

.cx-gal-hero-date {
  margin-top: 28px;
  font-family: var(--g-font);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
}

.cx-gal-hero-down {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0.9;
}

.cx-gal-hero-down:hover { opacity: 1; }

/* ---------- Sticky category bar ---------- */
.cx-gal-bar {
  position: sticky;
  top: var(--g-nav-h);
  z-index: 150;
  background: var(--g-bg);
  border-bottom: 1px solid var(--g-line);
  font-family: var(--g-font);
}

.cx-gal-bar-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  height: var(--g-bar-h);
  padding: 0 32px;
}

.cx-gal-credit {
  flex: none;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--g-ink);
  opacity: 0.7;
  white-space: nowrap;
}

.cx-gal-credit a { text-decoration: underline; text-underline-offset: 3px; }
.cx-gal-credit a:hover { opacity: 1; color: var(--g-black); }

.cx-gal-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 32px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.cx-gal-tabs::-webkit-scrollbar { display: none; }

/* centred while it fits, but still scrollable from the first tab when it
   doesn't (justify-content:center would clip the overflow on the left) */
.cx-gal-tab:first-child { margin-left: auto; }
.cx-gal-tab:last-child { margin-right: auto; }

.cx-gal-tab {
  flex: none;
  position: relative;
  padding: 8px 0;
  font-family: var(--g-font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--g-black);
  white-space: nowrap;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

.cx-gal-tab:hover,
.cx-gal-tab.active { opacity: 1; }

.cx-gal-tab.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  height: 1px;
  background: currentColor;
}

.cx-gal-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cx-gal-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--g-black);
  border-radius: 50%;
  transition: background 0.2s ease;
}

.cx-gal-icon-btn:hover { background: rgba(0, 0, 0, 0.05); }
.cx-gal-icon-btn.on { color: var(--g-black); }
.cx-gal-icon-btn.on svg path { fill: currentColor; }

.cx-gal-count {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--g-ink);
  color: #fff;
  font-size: 9px;
  font-weight: 500;
  line-height: 15px;
  text-align: center;
}

.cx-gal-count[hidden] { display: none; }

.cx-gal-icon-btn:focus-visible,
.cx-gal-tab:focus-visible,
.cx-gal-tile:focus-visible,
.cx-gal-lb button:focus-visible,
.cx-gal-lb a:focus-visible,
.cx-gal-pill button:focus-visible,
.cx-gal-pill a:focus-visible {
  outline: 2px solid var(--g-ink);
  outline-offset: 2px;
}

/* ---------- Scenes + grid ---------- */
.cx-gal-scene {
  padding-top: 85px;
  scroll-margin-top: calc(var(--g-nav-h) + var(--g-bar-h));
}


.cx-gal-title {
  font-family: var(--g-font);
  font-size: 44px;
  font-weight: 300;
  line-height: 50px;
  letter-spacing: normal;
  color: var(--g-ink);
  text-align: center;
  margin: 0 0 55px;
  padding: 0 24px;
}

.cx-gal-grid {
  position: relative;
  margin: 0 30px;
}

.cx-gal-tile {
  position: absolute;
  display: block;
  padding: 2px;
  cursor: pointer;
}

.cx-gal-tile-inner {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--g-ph);
}

.cx-gal-tile img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.22s ease-in;
}

.cx-gal-tile img.loaded { opacity: 1; }

/* Hover action bar: download / share / favourite, bottom-right */
.cx-gal-tile-actions {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 2px;
  padding: 0 18px 16px;
  height: 63px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0));
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.cx-gal-tile:hover .cx-gal-tile-actions,
.cx-gal-tile:focus-within .cx-gal-tile-actions {
  opacity: 1;
  pointer-events: auto;
}

.cx-gal-tile-actions > * {
  width: 34px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0.6;
  transition: opacity 0.3s 0.12s;
}

.cx-gal-tile-actions > *:hover { opacity: 1; }
.cx-gal-tile-actions .on { opacity: 1; }
.cx-gal-tile-actions .on svg path { fill: currentColor; }

/* Persistent heart on favourited photos */
.cx-gal-tile.fav::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 16px;
  height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 16'%3E%3Cpath d='M9 15.2 2.2 8.6A4.1 4.1 0 0 1 9 3.3a4.1 4.1 0 0 1 6.8 5.3Z' fill='%23fff'/%3E%3C/svg%3E") no-repeat center / contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  transition: opacity 0.3s;
}

.cx-gal-tile.fav:hover::after { opacity: 0; }

.cx-gal-empty {
  text-align: center;
  font-size: 16px;
  color: var(--g-ink);
  opacity: 0.7;
  padding: 0 24px;
}

/* Photographer credit + Drive link under the last scene (the bar's own
   credit only fits on very wide screens) */
.cx-gal-outro {
  padding: 85px 24px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--g-ink);
}

.cx-gal-outro a { text-decoration: underline; text-underline-offset: 3px; }
.cx-gal-outro a:hover { color: var(--g-black); }
.cx-gal-outro-sep { margin: 0 10px; opacity: 0.5; }

@media (max-width: 1599px) {
  .cx-gal-credit { display: none; }
}

/* ---------- Phone floating action pill (replaces the bar's icons) ---------- */
.cx-gal-pill {
  display: none;
}

/* ---------- Lightbox ---------- */
.cx-gal-lb {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--g-bg);
  font-family: var(--g-font);
  color: var(--g-ink);
  display: none;
}

.cx-gal-lb.open { display: block; }

.cx-gal-lb-stage {
  position: absolute;
  top: 58px;
  bottom: 59px;
  left: 64px;
  right: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
}

.cx-gal-lb-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.cx-gal-lb-top {
  position: absolute;
  top: 10px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
}

.cx-gal-lb-top > * {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--g-ink);
  border-radius: 50%;
  transition: background 0.2s ease;
}

.cx-gal-lb-top > *:hover { background: rgba(0, 0, 0, 0.05); }
.cx-gal-lb-top .on svg path { fill: currentColor; }

.cx-gal-lb-prev,
.cx-gal-lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--g-ink);
  z-index: 2;
}

.cx-gal-lb-prev { left: 4px; }
.cx-gal-lb-next { right: 4px; }
.cx-gal-lb-prev[disabled],
.cx-gal-lb-next[disabled] { opacity: 0.2; cursor: default; }

.cx-gal-lb-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  text-align: center;
  font-size: 12px;
  line-height: 18px;
  color: var(--g-ink);
}

.cx-gal-lb-count {
  position: absolute;
  top: 21px;
  left: 24px;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--g-ink);
  opacity: 0.7;
}

.cx-gal-toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 400;
  transform: translate(-50%, 20px);
  background: var(--g-ink);
  color: #fff;
  font-family: var(--g-font);
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.cx-gal-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.cx-gal-lock { overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .cx-gal-grid { margin: 0 8px; }
}

@media (max-width: 768px) {
  .cx-gal-page { --g-bar-h: 52px; }

  .cx-gal-hero { padding-bottom: 150px; }
  .cx-gal-hero-title { font-size: 47px; line-height: 52px; }
  .cx-gal-hero-date { margin-top: 20px; font-size: 14px; }
  .cx-gal-hero-down { bottom: 28px; }

  .cx-gal-bar-inner { padding: 0 16px; gap: 0; }
  .cx-gal-tabs { gap: 24px; }
  .cx-gal-actions { display: none; }

  .cx-gal-scene { padding-top: 48px; }
  .cx-gal-outro { padding: 48px 16px 120px; font-size: 11px; line-height: 2; }
  .cx-gal-title { font-size: 24px; line-height: 30px; margin-bottom: 32px; }

  /* touch screens have no hover: show favourites only via the heart badge */
  .cx-gal-tile-actions { display: none; }

  .cx-gal-pill {
    display: flex;
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 160;
    gap: 6px;
    padding: 8px 22px;
    border-radius: 40px;
    background: rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    font-family: var(--g-font);
  }

  .cx-gal-pill > * {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 64px;
    padding: 2px 6px;
    font-size: 11px;
    color: var(--g-ink);
  }

  .cx-gal-pill .cx-gal-count { top: -2px; right: 10px; }
  .cx-gal-pill .on svg path { fill: currentColor; }

  .cx-gal-lb-stage { left: 0; right: 0; top: 60px; bottom: 60px; }
  .cx-gal-lb-prev,
  .cx-gal-lb-next { top: auto; bottom: 6px; transform: none; height: 48px; }
  .cx-gal-lb-caption { bottom: 21px; padding: 0 64px; }
  .cx-gal-lb-count { left: 16px; }
  .cx-gal-lb-top { right: 6px; gap: 2px; }

  .cx-gal-page #bstf-btt { bottom: 6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cx-gal-tile img,
  .cx-gal-tile-actions,
  .cx-gal-toast { transition: none; }
}
