/* ------------------------------------------------------------
   GALLERY — plain grid of a journey's photos. Hovering a photo
   slides a title/description panel in from the side.
------------------------------------------------------------- */

.gallery-hero {
  padding: clamp(140px, 22vh, 220px) clamp(24px, 8vw, 100px) clamp(50px, 8vh, 90px);
  max-width: 820px;
}

.gallery-hero__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 1;
  margin-top: 14px;
}

.gallery-hero__desc {
  margin-top: 20px;
  color: var(--fg-dim);
  font-weight: 300;
  line-height: 1.7;
  max-width: 560px;
}

.gallery-hero__back {
  display: inline-block;
  margin-top: 26px;
}

.section-head {
  padding: clamp(50px, 9vh, 100px) clamp(24px, 8vw, 100px) clamp(24px, 4vh, 40px);
  max-width: 760px;
}

.section-head__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.8rem, 4.5vw, 3rem);
  margin-top: 12px;
}

/* Every photo in this gallery is exactly 3:2 (landscape) or 2:3
   (portrait) — trying to make both share one grid's row tracks (via
   spans on a shared base unit) turned out to still leave occasional
   gaps, because packing two different tile footprints into a strict
   row/column grid is a bin-packing problem CSS Grid's `dense` flow
   doesn't fully solve. Masonry-style CSS columns sidestep the problem
   entirely: each item just stacks directly under the previous one in
   whichever column it lands in, at its own natural aspect ratio, so
   there's never a gap to fill — landscape and portrait photos don't
   need to match footprints, columns just end up different heights. */
.gallery-grid {
  columns: 3;
  column-gap: 2px;
  background: var(--bg);
}

.gallery-item {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: #050505;
  break-inside: avoid;
  margin-bottom: 2px;
}

/* Every gallery item opens a lightbox on click (see lightbox.js) —
   rendered as a <button>, so this resets it back to look like the
   plain tile it visually is. */
.gallery-item--clickable {
  cursor: pointer;
  display: block;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  font: inherit;
  color: inherit;
  border: 0;
  padding: 0;
  text-align: left;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s var(--ease);
}

/* render-gallery.js disperses portrait photos through the list so
   the taller cells don't cluster into the same column back-to-back. */
.gallery-item--portrait {
  aspect-ratio: 2 / 3;
}

/* Gate the hover reveal to devices that actually have hover (a mouse)
   — on touch devices this rule combined with the JS-driven .is-open
   toggle (gallery.js) could leave two panels visibly open at once,
   because mobile browsers can get "stuck" applying :hover after a tap
   with no real mouseleave to clear it. Touch devices rely solely on
   .is-open, which gallery.js keeps mutually exclusive. */
@media (hover: hover) {
  .gallery-item:hover img {
    transform: scale(1.06);
  }

  .gallery-item:hover .gallery-item__panel {
    transform: translateX(0);
  }
}

.gallery-item.is-open img {
  transform: scale(1.06);
}

.gallery-item__panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 68%;
  background: rgba(9, 9, 9, 0.88);
  backdrop-filter: blur(6px);
  border-left: 1px solid var(--line);
  padding: 22px 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transform: translateX(100%);
  transition: transform 0.55s var(--ease-soft);
}

.gallery-item.is-open .gallery-item__panel {
  transform: translateX(0);
}

.gallery-item__index {
  font-size: 0.66rem;
  letter-spacing: 0.25em;
  color: var(--accent);
  margin-bottom: 10px;
}

.gallery-item__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.25rem;
  line-height: 1.15;
  margin-bottom: 10px;
}

.gallery-item__desc {
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--fg-dim);
  font-weight: 300;
}

@media (max-width: 900px) {
  .gallery-grid { columns: 2; }
  .gallery-item__panel { width: 80%; }
}

@media (max-width: 560px) {
  .gallery-grid { columns: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-item img, .gallery-item__panel { transition: none !important; }
}

/* ------------------------------------------------------------
   LIGHTBOX — full-gallery only. Clicking a photo opens this instead
   of navigating directly, darkening the page and showing the photo
   enlarged alongside its title/description and a link to the trip.
------------------------------------------------------------- */

body.no-scroll {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 56px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s var(--ease), visibility 0s linear 0.35s;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s var(--ease);
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 5, 0.92);
  backdrop-filter: blur(4px);
}

.lightbox__panel {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  max-width: 1100px;
  max-height: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  box-shadow: 0 60px 140px rgba(0, 0, 0, 0.6);
  transform: scale(0.96);
  transition: transform 0.35s var(--ease-soft);
}

.lightbox.is-open .lightbox__panel {
  transform: scale(1);
}

.lightbox__media {
  position: relative;
  flex: 1 1 65%;
  min-width: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__media img {
  width: 100%;
  height: 100%;
  max-height: 82vh;
  object-fit: contain;
}

.lightbox__info {
  flex: 0 0 320px;
  padding: clamp(28px, 4vw, 44px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-left: 1px solid var(--line);
}

.lightbox__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.3rem, 2.5vw, 1.7rem);
  margin-bottom: 14px;
}

.lightbox__meta {
  color: var(--fg-dim);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.lightbox__cta {
  align-self: flex-start;
}

.lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 5, 0.6);
  border: 1px solid var(--line);
  color: var(--fg);
  cursor: pointer;
  transition: background 0.3s var(--ease);
}

.lightbox__close:hover {
  background: rgba(5, 5, 5, 0.9);
}

.lightbox__close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

@media (max-width: 720px) {
  .lightbox__panel {
    flex-direction: column;
    overflow-y: auto;
    max-height: 92vh;
  }
  .lightbox__media img { max-height: 46vh; }
  .lightbox__info {
    border-left: none;
    border-top: 1px solid var(--line);
    flex: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox, .lightbox__panel { transition: none !important; }
}
