/* ============================================================
Project Gallery: image strip, scroll buttons and lightbox
============================================================ */

/* Horizontal image strip (swipe on phones, buttons on desktop) */
.project-gallery {
  position: relative;
  /* Side space for the scroll buttons, so they don't cover the images,
     and space below the scrollbar, so it doesn't touch the border */
  padding: 0 56px 12px;
  background: #f8f9fa;
}

.gallery-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 16px;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 16px;
  scrollbar-width: thin;
}

.gallery-strip li {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

/* Centers the images when they all fit, scrolls when they don't */
.gallery-strip li:first-child {
  margin-left: auto;
}

.gallery-strip li:last-child {
  margin-right: auto;
}

.gallery-strip a {
  display: block;
  cursor: zoom-in;
}

/* Phone screenshots are limited by height, wide screenshots by width */
.gallery-strip img {
  display: block;
  width: auto;
  height: auto;
  max-height: 460px;
  max-width: min(85vw, 820px);
  border: 1px solid #dee2e6;
  border-radius: 8px;
  background: #fff;
  transition: transform 0.2s ease;
}

.gallery-strip a:hover img {
  transform: scale(1.02);
}

/* Scroll buttons (left / right) */
.gallery-scroll {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  transform: translateY(-50%);
}

.gallery-scroll:hover {
  background: #A93339;
}

.gallery-scroll[hidden] {
  display: none;
}

.gallery-scroll-prev {
  left: 10px;
}

.gallery-scroll-next {
  right: 10px;
}

/* Small space beside each arrow icon, so it looks centered in its circle */
.gallery-scroll-prev i {
  margin-right: 2px;
}

.gallery-scroll-next i {
  margin-left: 2px;
}

/* Lightbox (full-size image) */
.lightbox {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(8, 12, 20, 0.95);
}

.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox::backdrop {
  background: transparent;
}

/* Keep the page behind the lightbox from scrolling */
html:has(.lightbox[open]) {
  overflow: hidden;
}

.lightbox-img {
  width: auto;
  height: auto;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 112px);
  border-radius: 8px;
}

.lightbox button {
  position: absolute;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(55, 65, 81, 0.9);
  color: #fff;
  font-size: 1.25rem;
  touch-action: manipulation;
}

.lightbox button:hover {
  background: #A93339;
}

.lightbox button[hidden] {
  display: none;
}

/* Taps on the icon go to the button */
.lightbox button i {
  pointer-events: none;
}

.lightbox-close {
  top: 16px;
  right: 16px;
}

.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-prev {
  left: 16px;
}

.lightbox-next {
  right: 16px;
}

/* Small space beside each arrow icon, so it looks centered in its circle */
.lightbox-prev i {
  margin-right: 2px;
}

.lightbox-next i {
  margin-left: 2px;
}

.lightbox-count {
  position: absolute;
  bottom: 28px;
  left: 0;
  right: 0;
  margin: 0;
  color: #9ca3af;
  font-size: 0.875rem;
  text-align: center;
  /* Lets taps reach the arrow buttons below it */
  pointer-events: none;
}

/* ---------------------------------------------------
  MEDIA QUERIES
----------------------------------------------------- */
/* Extra small devices (phones, 575px and down) */
@media (max-width: 575.98px) {
  /* Project Gallery: smaller images and scroll buttons, lightbox arrows at the bottom */
  .project-gallery {
    padding: 0 0 12px;
  }

  .gallery-strip img {
    max-height: 380px;
  }

  .gallery-scroll {
    width: 34px;
    height: 34px;
  }

  .gallery-scroll-prev {
    left: 6px;
  }

  .gallery-scroll-next {
    right: 6px;
  }

  .lightbox-prev,
  .lightbox-next {
    top: auto;
    bottom: 12px;
    transform: none;
  }

  .lightbox-img {
    max-height: calc(100% - 160px);
  }
}

/* ---------------------------------------------------
  DARK THEME (set by the theme toggle)
----------------------------------------------------- */
[data-bs-theme="dark"] .project-gallery {
  background: #2b3035;
}

[data-bs-theme="dark"] .gallery-strip img {
  border-color: #495057;
  background: #212529;
}
