/* ── Gallery page hero ─────────────────────────────────────── */
.jrm-page-hero--gallery {
  min-height: clamp(380px, 52vw, 560px);
  display: flex;
  align-items: flex-end;
}

.jrm-page-hero--gallery .jrm-page-hero__content {
  padding-block: clamp(5rem, 14vw, 9rem) clamp(3rem, 7vw, 4.5rem);
}

/* ── Album nav strip ───────────────────────────────────────── */
.gallery-album-nav {
  background: #fff;
  border-bottom: 1px solid var(--jrm-color-border);
  position: sticky;
  top: 74px; /* matches header height */
  z-index: 100;
}

.gallery-album-nav__inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-block: 0.7rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.gallery-album-nav__inner::-webkit-scrollbar {
  display: none;
}

.gallery-album-nav__label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--jrm-color-muted-light);
  white-space: nowrap;
  flex-shrink: 0;
  margin: 0;
}

.gallery-album-nav__links {
  display: flex;
  gap: 0.45rem;
  flex-wrap: nowrap;
}

.gallery-album-nav__chip {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  min-height: 32px;
  padding: 0.28rem 0.72rem;
  border-radius: var(--jrm-radius-pill);
  border: 1px solid var(--jrm-color-border-strong);
  background: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--jrm-color-secondary);
  transition:
    background var(--jrm-transition-base),
    border-color var(--jrm-transition-base),
    color var(--jrm-transition-base);
}

.gallery-album-nav__chip:hover,
.gallery-album-nav__chip:focus-visible {
  background: color-mix(in srgb, var(--jrm-color-primary) 14%, #fff 86%);
  border-color: color-mix(in srgb, var(--jrm-color-primary-strong) 35%, #fff 65%);
  color: color-mix(in srgb, var(--jrm-color-secondary) 90%, #000 10%);
}

/* ── Album section ─────────────────────────────────────────── */
.gallery-album {
  padding-block: clamp(3.2rem, 7vw, 5.2rem);
  background: var(--jrm-color-surface);
  scroll-margin-top: calc(74px + 48px); /* header + nav strip */
}

.gallery-album--alt {
  background: color-mix(in srgb, var(--jrm-color-surface-alt) 65%, #fff 35%);
}

/* ── Album header ──────────────────────────────────────────── */
.gallery-album__header {
  margin-bottom: clamp(1.4rem, 3vw, 2rem);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.gallery-album__meta h2 {
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  margin-bottom: 0.2rem;
}

.gallery-album__count {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--jrm-color-muted-light);
  letter-spacing: 0.02em;
}

/* ── Photo grid — CSS columns masonry ─────────────────────── */
.gallery-grid {
  columns: 4;
  column-gap: 0.75rem;
}

.gallery-item {
  break-inside: avoid;
  margin-bottom: 0.75rem;
}

/* Featured first item spans full first column row */
.gallery-item--featured {
  /* columns doesn't support span, so we use a wider aspect-ratio approach */
}

/* ── Photo item ────────────────────────────────────────────── */
.gallery-item__trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border-radius: var(--jrm-radius-card);
  /* Clip the zoom effect */
}

.gallery-item__trigger img,
.gallery-item__placeholder {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--jrm-radius-card);
  transition: transform 0.38s ease;
  vertical-align: bottom;
}

.gallery-item__placeholder {
  aspect-ratio: 4 / 3;
  background: linear-gradient(
    130deg,
    rgba(244, 197, 66, 0.22),
    rgba(14, 42, 71, 0.18)
  );
}

/* Hover overlay with expand icon */
.gallery-item__overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--jrm-radius-card);
  background: rgba(8, 18, 34, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transition:
    background var(--jrm-transition-base),
    opacity var(--jrm-transition-base);
}

.gallery-item__overlay svg {
  transform: scale(0.72);
  transition: transform var(--jrm-transition-spring);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.gallery-item__trigger:hover .gallery-item__overlay,
.gallery-item__trigger:focus-visible .gallery-item__overlay {
  background: rgba(8, 18, 34, 0.52);
  opacity: 1;
}

.gallery-item__trigger:hover .gallery-item__overlay svg,
.gallery-item__trigger:focus-visible .gallery-item__overlay svg {
  transform: scale(1);
}

.gallery-item__trigger:hover img {
  transform: scale(1.04);
}

.gallery-item__trigger:focus-visible {
  outline: 2px solid var(--jrm-color-primary-strong);
  outline-offset: 2px;
}

/* ── Empty state ───────────────────────────────────────────── */
.gallery-empty-state {
  text-align: center;
  padding: clamp(3rem, 8vw, 5rem) 1rem;
  max-width: 480px;
  margin-inline: auto;
}

.gallery-empty-state__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 1px solid var(--jrm-color-border-strong);
  color: var(--jrm-color-muted-light);
  margin-bottom: 1.2rem;
}

.gallery-empty-state h2 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  margin-bottom: 0.55rem;
}

.gallery-empty-state p {
  color: var(--jrm-color-muted);
  font-size: 0.98rem;
  margin: 0;
}

/* ── CTA section ───────────────────────────────────────────── */
.gallery-cta-section {
  background: color-mix(in srgb, var(--jrm-color-surface-alt) 55%, #fff 45%);
}

.gallery-cta {
  text-align: center;
  max-width: 640px;
  margin-inline: auto;
}

.gallery-cta h2 {
  font-size: clamp(1.7rem, 3.4vw, 2.4rem);
  margin-bottom: 0.55rem;
}

.gallery-cta p {
  color: var(--jrm-color-muted-dark);
  max-width: 58ch;
  margin-inline: auto;
  margin-bottom: 0;
}

.gallery-cta__actions {
  margin-top: 1.3rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ── Lightbox overlay ──────────────────────────────────────── */
.jrm-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Hidden by default — JS adds .is-open */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.jrm-lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.jrm-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 18, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: zoom-out;
}

.jrm-lightbox__panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-areas:
    "close  close  close"
    "prev   stage  next"
    "footer footer footer";
  grid-template-columns: 56px 1fr 56px;
  grid-template-rows: 48px 1fr auto;
  width: min(92vw, 1100px);
  max-height: calc(100dvh - 3rem);
}

/* ── Lightbox close button ─────────────────────────────────── */
.jrm-lightbox__close {
  grid-area: close;
  justify-self: end;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.88);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background var(--jrm-transition-base),
    border-color var(--jrm-transition-base),
    color var(--jrm-transition-base);
}

.jrm-lightbox__close:hover,
.jrm-lightbox__close:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

/* ── Lightbox stage ────────────────────────────────────────── */
.jrm-lightbox__stage {
  grid-area: stage;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  max-height: calc(100dvh - 10rem);
}

.jrm-lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 10rem);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  transition: opacity 0.2s ease;
}

.jrm-lightbox__img.is-loading {
  opacity: 0;
}

/* Loading spinner */
.jrm-lightbox__loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.jrm-lightbox__loader.is-active {
  opacity: 1;
}

.jrm-lightbox__loader::after {
  content: "";
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--jrm-color-primary);
  animation: lb-spin 0.72s linear infinite;
}

@keyframes lb-spin {
  to { transform: rotate(360deg); }
}

/* ── Lightbox nav arrows ───────────────────────────────────── */
.jrm-lightbox__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  align-self: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  transition:
    background var(--jrm-transition-base),
    border-color var(--jrm-transition-base),
    color var(--jrm-transition-base),
    transform var(--jrm-transition-base);
}

.jrm-lightbox__nav--prev { grid-area: prev; }
.jrm-lightbox__nav--next { grid-area: next; }

.jrm-lightbox__nav:hover,
.jrm-lightbox__nav:focus-visible {
  background: rgba(244, 197, 66, 0.2);
  border-color: rgba(244, 197, 66, 0.5);
  color: var(--jrm-color-primary);
}

.jrm-lightbox__nav--prev:hover { transform: translateX(-2px); }
.jrm-lightbox__nav--next:hover { transform: translateX(2px); }

.jrm-lightbox__nav:disabled,
.jrm-lightbox__nav[aria-disabled="true"] {
  opacity: 0.28;
  cursor: default;
  pointer-events: none;
}

/* ── Lightbox footer ───────────────────────────────────────── */
.jrm-lightbox__footer {
  grid-area: footer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0 0;
  min-height: 2.2rem;
}

.jrm-lightbox__caption {
  margin: 0;
  font-size: 0.86rem;
  color: rgba(255, 255, 255, 0.65);
  font-style: italic;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jrm-lightbox__counter {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.42);
  white-space: nowrap;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .gallery-grid {
    columns: 3;
  }
}

@media (max-width: 760px) {
  .gallery-grid {
    columns: 2;
    column-gap: 0.55rem;
  }

  .gallery-item {
    margin-bottom: 0.55rem;
  }

  .gallery-album__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .gallery-cta__actions {
    display: grid;
    gap: 0.65rem;
  }

  .gallery-cta__actions .btn {
    width: 100%;
  }

  /* Lightbox full-screen on mobile */
  .jrm-lightbox__panel {
    width: 100vw;
    max-height: 100dvh;
    grid-template-columns: 44px 1fr 44px;
  }

  .jrm-lightbox__img {
    border-radius: 4px;
    max-height: calc(100dvh - 9rem);
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    columns: 1;
  }
}

/* ── Reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .gallery-item__trigger img,
  .gallery-item__overlay,
  .gallery-item__overlay svg,
  .jrm-lightbox,
  .jrm-lightbox__img,
  .jrm-lightbox__nav,
  .jrm-lightbox__close {
    transition: none;
    animation: none;
  }
}
