/* ============================================================
   Individual stills project pages (e.g. /stills/st-george-spirits/)
   Additive layer on top of styles.css.

   Sections:
     1. Page-level overrides (allow scrolling)
     2. Page wrapper + header
     3. Masonry grid (CSS columns)
     4. "More Projects" CTA
     5. Lightbox
     6. Active-nav indicator
   ============================================================ */


/* -------------------------------------------------------
   1. Page-level overrides
   ------------------------------------------------------- */
/* Allow the document to scroll naturally on these pages — base
   styles.css locks html/body to 100vh/overflow:hidden for the
   homepage, so we override with overflow:visible here. Nested
   overflow:auto on both html and body confuses iOS Safari and
   can leave scroll completely stuck. */
html {
  height: auto;
  width: auto;
  overflow: visible;
}
body {
  height: auto;
  min-height: 100vh;
  width: auto;
  overflow-x: hidden;
  overflow-y: visible;
}
body.page-stills-project { background: var(--bg); }


/* -------------------------------------------------------
   2. Page wrapper + header
   Page wrapper is full-bleed (no horizontal padding) so the
   masonry grid spans edge-to-edge like the Films/Stills index.
   The title and CTA sit inside their own indented containers.
   ------------------------------------------------------- */
.gallery-page {
  position: relative;
  z-index: 5;
  padding: 92px 0 4px;
}

.gallery-header {
  padding: 0 32px 28px;
  margin: 0 8px 8px;          /* match cell-gap on the sides + below */
}

.gallery-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(34px, 4.5vw, 60px);
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--fg);
  text-align: right;
}


/* -------------------------------------------------------
   3. Masonry grid
   Two-column flex layout where items are distributed round-robin
   into <div class="gallery-col"> by gallery.js, preserving
   row-major reading order (item 1 top-left, item 2 top-right,
   item 3 below #1, item 4 below #2, …).

   The CSS-columns rule below is a no-JS fallback so the gallery
   is at least visible if the script doesn't run.
   ------------------------------------------------------- */

/* No-JS fallback: CSS columns (column-major flow, but visible) */
.gallery {
  column-count: 2;
  column-gap: 8px;
}
.gallery-item {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  overflow: hidden;            /* clip the scaled image to its frame */
  cursor: zoom-in;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
}

/* JS-laid-out flex columns: visual order matches DOM order row-major */
.gallery.is-laid-out {
  display: flex;
  column-count: auto;
  column-gap: 0;
  gap: 8px;
}
.gallery.is-laid-out .gallery-item {
  margin: 0;
  break-inside: auto;
}
.gallery-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gallery-item img {
  display: block;
  width: 100%;
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.gallery-item:hover img {
  transform: scale(1.06);
}




/* -------------------------------------------------------
   4. "More Projects" CTA
   ------------------------------------------------------- */
.gallery-cta {
  padding: 52px 32px 16px;
  display: flex;
  justify-content: flex-end;
}

/* Ghost button — no border, just text + arrow with the same underline-grow
   animation as topnav links: scaleX(0)→scaleX(1) on hover with the
   transform-origin flipping right→left so the line draws in from the left
   on hover and retracts toward the right on un-hover. */
.more-projects {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  padding: 6px 2px;
  position: relative;
  transition: color 0.3s ease;
}
/* Underline lives on the inner label span so it only spans the words,
   not the trailing arrow. */
.more-projects-label {
  position: relative;
  padding: 4px 0;
}
.more-projects-label::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right center;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.more-projects::after {
  content: '→';
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.more-projects:hover { color: #fff; }
.more-projects:hover .more-projects-label::after {
  transform: scaleX(1);
  transform-origin: left center;
}
.more-projects:hover::after {
  transform: translateX(6px);
}




/* -------------------------------------------------------
   5. Lightbox
   ------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* Same fold-through animation as the hamburger menu's close button:
   on hover the two diagonals rotate +90° each, passing through a "+"
   so the strokes fold around each other before settling back into an X. */
.lightbox-close {
  position: absolute;
  top: 24px;
  right: 32px;
  width: 32px;
  height: 22px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  z-index: 1;
}
.lightbox-close::before,
.lightbox-close::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 1px;
  background: rgba(255, 255, 255, 0.85);
  transition:
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.3s ease;
}
.lightbox-close::before        { transform: translate(-50%, -50%) rotate(45deg); }
.lightbox-close::after         { transform: translate(-50%, -50%) rotate(-45deg); }
.lightbox-close:hover::before  { transform: translate(-50%, -50%) rotate(135deg); }
.lightbox-close:hover::after   { transform: translate(-50%, -50%) rotate(45deg);  }
.lightbox-close:hover::before,
.lightbox-close:hover::after   { background: var(--accent); }

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  padding: 20px 24px;
  line-height: 0;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.25s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.lightbox-prev svg,
.lightbox-next svg {
  display: block;
  width: 44px;
  height: 44px;
}
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }
.lightbox-prev:hover { color: #fff; transform: translateY(-50%) translateX(-4px); }
.lightbox-next:hover { color: #fff; transform: translateY(-50%) translateX(4px); }



/* -------------------------------------------------------
   6. Active-nav indicator
   ------------------------------------------------------- */
.topnav a.is-current {
  color: #fff;
}
.topnav a.is-current::after {
  transform: scaleX(1);
  transform-origin: left center;
}


/* -------------------------------------------------------
   Responsive
   ------------------------------------------------------- */
@media (max-width: 760px) {
  .gallery-page { padding: 92px 0 6px; }
  .gallery-header {
    padding: 0 24px 22px;
    margin: 0 6px 6px;
  }
  /* No-JS fallback: collapse columns to 1 */
  .gallery {
    column-count: 1;
    column-gap: 6px;
  }
  .gallery-item { margin-bottom: 6px; }
  /* JS-laid-out: tighter gap on mobile */
  .gallery.is-laid-out      { gap: 6px; }
  .gallery.is-laid-out .gallery-col { gap: 6px; }
  .gallery.is-laid-out .gallery-item { margin: 0; }

  .gallery-cta { padding: 40px 24px 16px; }
  .lightbox-close { right: 24px; }
  .lightbox-prev { left: 0;  padding: 16px 14px; }
  .lightbox-next { right: 0; padding: 16px 14px; }
  .lightbox-prev svg,
  .lightbox-next svg { width: 36px; height: 36px; }
}
