/* ==========================================================================
   RackTide landing page: project photo strip + lightbox
   Sits between the contact section and the footer. Depends on tokens in
   hero.css and contact.css.
   ========================================================================== */

.gallery {
  --tile-h: clamp(200px, 22vw, 300px);
  --tile-gap: 16px;
  --tile-radius: 24px;
  position: relative;
  /* Tucks 1px under the white contact section so the dark page background
     can't show through a sub-pixel gap as a faint line between them. */
  margin-top: -1px;
  padding: 1px 0 clamp(56px, 6vw, 88px);
  background: var(--paper);
  overflow: hidden;
}

.gallery__head {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(28px, 3.4vw, 44px);
  text-align: center;
}

.gallery__title {
  margin: 0;
  font: 700 clamp(28px, 3.2vw, 44px) / 1.05 var(--font-display);
  letter-spacing: var(--title-tracking);
  text-transform: uppercase;
  color: var(--ink);
}

.gallery__copy {
  margin: 14px auto 0;
  font: 400 15px / 1.6 var(--font-body);
  color: var(--ink-soft);
}

.gallery__viewport {
  overflow: hidden;
  touch-action: pan-y;          /* vertical page scroll stays native; we handle horizontal drags */
  user-select: none;
  -webkit-user-select: none;
}

.gallery__viewport.is-dragging { cursor: grabbing; }

.gallery__track {
  display: flex;
  gap: var(--tile-gap);
  width: max-content;
  will-change: transform;
}

.gallery__set {
  display: flex;
  gap: var(--tile-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery__tile {
  position: relative;
  display: block;
  height: var(--tile-h);
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 0;
  border-radius: var(--tile-radius);
  overflow: hidden;
  background: #e9edf0;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}

.gallery__tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Hairline edge so light photos don't dissolve into the white page */
.gallery__tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(20, 26, 33, 0.06);
  pointer-events: none;
}

.gallery__tile:hover img,
.gallery__tile:focus-visible img {
  transform: scale(1.045);
}

.gallery__tile:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: -3px;
}

/* Motion turned off: no auto-scroll, just a row people can scroll themselves */
.gallery.is-static .gallery__viewport {
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding: 0 var(--gutter) 8px;
  scrollbar-width: thin;
}

.gallery.is-static .gallery__tile { scroll-snap-align: start; }

/* --------------------------------------------------------------------------
   Lightbox (native <dialog>)
   -------------------------------------------------------------------------- */
html.is-lightbox-open { overflow: hidden; }

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  overflow: hidden;
}

.lightbox[open] {
  display: grid;
  place-items: center;
  animation: lightbox-in 0.28s ease both;
}

.lightbox::backdrop {
  background: rgba(6, 9, 14, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@keyframes lightbox-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox__figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: min(1200px, calc(100vw - 176px));
  margin: 0;
  touch-action: pan-y;
}

.lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 140px);
  width: auto;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
  transition: opacity 0.26s ease, transform 0.36s cubic-bezier(0.2, 0.7, 0.2, 1);
  -webkit-user-drag: none;
  user-select: none;
}

.lightbox__img.is-leaving {
  opacity: 0;
  transform: translateX(calc(var(--dir, 0) * -32px));
}

.lightbox__img.is-entering {
  opacity: 0;
  transform: translateX(calc(var(--dir, 0) * 32px)) scale(0.985);
  transition: none;
}

.lightbox__counter {
  font: 500 13px / 1 var(--font-body);
  letter-spacing: 0.06em;
  color: #b3bfcc;
}

.lightbox__btn {
  position: fixed;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.lightbox__btn svg { width: 20px; height: 20px; }

.lightbox__btn:hover {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--blue-ink);
}

.lightbox__btn:focus-visible {
  outline: 2px solid var(--blue-bright);
  outline-offset: 3px;
}

.lightbox__close { top: 20px; right: 20px; }
.lightbox__prev  { top: 50%; left: 24px;  transform: translateY(-50%); }
.lightbox__next  { top: 50%; right: 24px; transform: translateY(-50%); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 719px) {
  .gallery { --tile-gap: 12px; --tile-radius: 18px; }

  .lightbox__figure { max-width: calc(100vw - 24px); }
  .lightbox__img { max-height: calc(100dvh - 180px); border-radius: 10px; }

  /* Arrows move under the photo so they never cover it */
  .lightbox__prev,
  .lightbox__next { top: auto; bottom: 24px; transform: none; }
  .lightbox__prev { left: calc(50% - 64px); }
  .lightbox__next { right: calc(50% - 64px); }
}

@media (prefers-reduced-motion: reduce) {
  .gallery__tile img,
  .lightbox__img,
  .lightbox__btn { transition: none; }
  .lightbox[open] { animation: none; }
}
