/* ==========================================================================
   NS Tiling Group - Gallery media add-on
   Loaded ONLY by gallery.html. Nothing in this file affects any other page.
   Scope: video thumbnails in the existing gallery grid + the lightbox
          close/next/prev controls. No changes to gallery layout, colours,
          typography, header, footer or navigation.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Video thumbnails
   Reuses the existing .project-item / .project-image card exactly as-is and
   only lays a play badge on top, so video cards sit in the same grid,
   at the same aspect ratio, with the same hover zoom, as photo cards.
   -------------------------------------------------------------------------- */

.our-projects .project-image .project-video-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
  transition: all 0.3s ease-out;
}

.our-projects .project-image .project-video-badge img {
  /* Override the card's aspect-ratio/object-fit rule for the small icon only */
  width: 26px;
  height: 26px;
  aspect-ratio: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
  transform: none;
  margin-left: 2px;
}

.our-projects .project-item:hover .project-image .project-video-badge {
  background: rgba(0, 0, 0, 0.75);
}

.our-projects .project-item:hover .project-image .project-video-badge img {
  transform: none; /* cancel the card's scale(1.2) hover on the icon */
}

/* --------------------------------------------------------------------------
   2. Lightbox close button
   The gallery previously had no lightbox at all, so clicking a photo simply
   navigated the browser to the raw image file - which is why a Back press was
   needed to get out. Now that Magnific Popup handles the click, this styles
   its close control into an obvious, easy-to-tap "X Close" button.
   Scoped with .mfp-ns-gallery so the popup used elsewhere is untouched.
   -------------------------------------------------------------------------- */

.mfp-ns-gallery .mfp-close,
.mfp-ns-gallery .mfp-image-holder .mfp-close,
.mfp-ns-gallery .mfp-iframe-holder .mfp-close,
.mfp-ns-gallery .mfp-inline-holder .mfp-close {
  position: fixed;
  top: 16px;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: 16px;
  right: calc(16px + env(safe-area-inset-right, 0px));
  width: auto;
  min-width: 48px;
  height: 48px;
  line-height: 1;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  opacity: 1;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  text-decoration: none;
  z-index: 1046;
  transition: background 0.2s ease-out, transform 0.2s ease-out;
}

.mfp-ns-gallery .mfp-close:hover,
.mfp-ns-gallery .mfp-close:focus {
  background: rgba(0, 0, 0, 0.95);
  border-color: #fff;
  opacity: 1;
  transform: scale(1.04);
}

.mfp-ns-gallery .mfp-close:active {
  top: 16px;
  top: calc(16px + env(safe-area-inset-top, 0px));
  transform: scale(0.97);
}

.mfp-ns-gallery .mfp-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.mfp-ns-gallery .mfp-close .ns-close-x {
  font-size: 19px;
  line-height: 1;
  font-weight: 400;
}

/* --------------------------------------------------------------------------
   3. Previous / next arrows and counter
   Magnific already provides these; this only makes them easier to see and tap.
   -------------------------------------------------------------------------- */

.mfp-ns-gallery .mfp-arrow {
  opacity: 0.85;
}

.mfp-ns-gallery .mfp-arrow:hover,
.mfp-ns-gallery .mfp-arrow:focus {
  opacity: 1;
}

/* The counter sits in Magnific's bottom bar alongside the caption. Left in
   place; only the colour is lifted so it reads against the dark backdrop. */
.mfp-ns-gallery .mfp-counter {
  color: #fff;
  font-size: 13px;
  opacity: 0.8;
}

/* Darker backdrop so the media is the focus and the white controls read
   clearly. Scoped to this gallery's popup only. */
.mfp-bg.mfp-ns-gallery {
  background: #0b0b0b;
  opacity: 0.94;
}

/* --------------------------------------------------------------------------
   4. Inline video player inside the lightbox
   -------------------------------------------------------------------------- */

/* Magnific sizes an inline holder to the full container width. Shrink-wrap it
   to the video so a portrait clip is not framed by a huge black panel. */
.mfp-ns-gallery .mfp-inline-holder .mfp-content {
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  text-align: center;
}

.ns-video-popup {
  position: relative;
  display: inline-block;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

.ns-video-popup video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 82vh;
  max-height: 82svh;
  margin: 0 auto;
  background: #000;
  outline: none;
}

/* --------------------------------------------------------------------------
   5. Small screens
   Nothing here redesigns the gallery - it only guarantees the viewer fits and
   that no element can push the page sideways.
   -------------------------------------------------------------------------- */

@media only screen and (max-width: 767px) {
  .our-projects .project-image .project-video-badge {
    width: 52px;
    height: 52px;
  }

  .our-projects .project-image .project-video-badge img {
    width: 21px;
    height: 21px;
  }

  .mfp-ns-gallery .mfp-close,
  .mfp-ns-gallery .mfp-image-holder .mfp-close,
  .mfp-ns-gallery .mfp-iframe-holder .mfp-close,
  .mfp-ns-gallery .mfp-inline-holder .mfp-close {
    top: 12px;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
    right: calc(12px + env(safe-area-inset-right, 0px));
    height: 46px;
    padding: 0 16px;
    font-size: 14px;
  }

  .mfp-ns-gallery .mfp-close:active {
    top: 12px;
    top: calc(12px + env(safe-area-inset-top, 0px));
  }

  /* Arrows sit low so they never overlap the close button */
  .mfp-ns-gallery .mfp-arrow {
    width: 60px;
    height: 88px;
    margin-top: -44px;
    transform: scale(0.72);
  }

  .mfp-ns-gallery .mfp-arrow-left {
    transform-origin: left center;
  }

  .mfp-ns-gallery .mfp-arrow-right {
    transform-origin: right center;
  }

  .mfp-ns-gallery .mfp-counter {
    font-size: 12px;
  }

  .mfp-ns-gallery img.mfp-img {
    padding: 62px 0 40px;
  }

  .ns-video-popup {
    border-radius: 8px;
  }

  .ns-video-popup video {
    max-height: 74vh;
    max-height: 74svh;
  }
}

/* Overflow guard: the lightbox is appended to <body>, so on some Android
   browsers a wide popup can create horizontal scroll. This pins it. */
.mfp-ns-gallery.mfp-wrap,
.mfp-ns-gallery .mfp-container {
  max-width: 100vw;
  overflow-x: hidden;
}
