/* ==========================================================================
   Gallery page - portfolio grid + lightbox (dark premium theme)
   Design tokens (--bg, --ink, --muted, --accent, --line, --card, --radius…)
   are defined in :root of styles.css; this file only references them.
   ========================================================================== */

.gallery {
  padding-top: clamp(20px, 4vw, 44px);
}

/* --- Masonry-ish portfolio grid via CSS multi-columns ------------------- */
.gallery-grid {
  columns: 3 280px;
  column-gap: 24px;
}

.gallery-item {
  /* reset the <button> */
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  margin: 0 0 24px;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  transition:
    transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 0.35s,
    box-shadow 0.35s;
}

.gallery-item:hover,
.gallery-item:focus-visible {
  transform: translateY(-6px);
  border-color: rgba(255, 122, 51, 0.5);
  box-shadow: 0 40px 80px -40px rgba(255, 122, 51, 0.35);
}

.gallery-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  filter: brightness(0.92);
  transition:
    transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 0.5s;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
  transform: scale(1.045);
  filter: brightness(1);
}

/* Subtle inner ring on the accent glow */
.gallery-item::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

/* --- Empty state -------------------------------------------------------- */
.gallery-empty {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  padding-block: clamp(40px, 8vw, 80px);
}

/* --- Lightbox ----------------------------------------------------------- */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vw, 26px);
  padding: clamp(16px, 4vw, 52px);
  background: rgba(6, 4, 3, 0.84);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

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

.gallery-lightbox.is-open {
  opacity: 1;
}

.gallery-lightbox__figure {
  margin: 0;
  max-width: min(1120px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.gallery-lightbox__img {
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, 0.8);
}

.gallery-lightbox__caption {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.gallery-lightbox__nav,
.gallery-lightbox__close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  transition:
    background 0.25s,
    border-color 0.25s,
    transform 0.25s;
}

.gallery-lightbox__nav:hover,
.gallery-lightbox__close:hover,
.gallery-lightbox__nav:focus-visible,
.gallery-lightbox__close:focus-visible {
  background: rgba(255, 122, 51, 0.18);
  border-color: rgba(255, 122, 51, 0.5);
}

.gallery-lightbox__nav:focus-visible,
.gallery-lightbox__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.gallery-lightbox__close {
  position: absolute;
  top: clamp(16px, 3vw, 28px);
  right: clamp(16px, 3vw, 28px);
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 640px) {
  .gallery-grid {
    columns: 1;
  }
  .gallery-lightbox__nav {
    position: absolute;
    bottom: clamp(16px, 5vw, 28px);
  }
  .gallery-lightbox__nav--prev {
    left: clamp(16px, 5vw, 28px);
  }
  .gallery-lightbox__nav--next {
    right: clamp(16px, 5vw, 28px);
  }
  .gallery-lightbox__img {
    max-height: 68vh;
  }
}

/* --- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .gallery-item,
  .gallery-item img,
  .gallery-lightbox,
  .gallery-lightbox__nav,
  .gallery-lightbox__close {
    transition: none;
  }
  .gallery-item:hover,
  .gallery-item:focus-visible,
  .gallery-item:hover img,
  .gallery-item:focus-visible img {
    transform: none;
  }
}
