/* ─────────────────────────────────────────────────────────────────────────────
   gallery.css — Treehouse International
   Masonry grid + full-screen lightbox. Dark minimalist botanical medical brand.
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Gallery Page Hero ──────────────────────────────────────────────────────── */
.gallery-hero {
  padding-top: calc(var(--header-height) + 3.5rem);
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--border);
}

.gallery-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  font-weight: 300;
  letter-spacing: 0.03em;
  margin-top: 1.5rem;
  margin-bottom: 0;
  max-width: 65ch;
  line-height: 1.8;
  padding-left: 1.25rem;
  border-left: 2px solid rgba(255, 255, 255, 0.2);
}

.gallery-hero-eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 1.5rem;
}

.gallery-hero-title {
  font-size: clamp(36px, 7vw, 90px);
  font-weight: 200;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text-white);
  margin-bottom: 1.5rem;
}

.gallery-hero-meta {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.gallery-hero-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.gallery-hero-count strong {
  color: var(--text-white);
  font-weight: 500;
}

/* ── Masonry Grid ────────────────────────────────────────────────────────────── */
.gallery-section {
  padding: 5rem 0 8rem;
}

.gallery-grid {
  /* CSS-native masonry via columns */
  column-count: 2;
  column-gap: 1.5px;
}

/* Breakpoint: tablet → 3 columns */
@media (min-width: 640px) {
  .gallery-grid {
    column-count: 3;
  }
}

/* Breakpoint: desktop → 4 columns */
@media (min-width: 1024px) {
  .gallery-grid {
    column-count: 4;
  }
}

/* Breakpoint: wide → 5 columns */
@media (min-width: 1440px) {
  .gallery-grid {
    column-count: 5;
  }
}

/* ── Gallery Item ────────────────────────────────────────────────────────────── */
.gallery-item {
  break-inside: avoid;
  display: block;
  margin-bottom: 1.5px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background-color: #0a0b0e;

  /* Fade in on image load */
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.3s ease;
}

.gallery-item.loaded {
  opacity: 1;
  transform: translateY(0);
}

.gallery-item.error {
  opacity: 0.15;
}

.gallery-item-inner {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  filter: grayscale(15%) brightness(0.9);
  transition:
    transform 0.65s cubic-bezier(0.16, 1, 0.3, 1),
    filter 0.45s ease,
    opacity 0.35s ease;
}

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

/* ── Hover Overlay ───────────────────────────────────────────────────────────── */
.gallery-item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 50%,
    rgba(0, 0, 0, 0.72) 100%
  );
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  color: #fff;
}

.gallery-item:hover .gallery-item-overlay,
.gallery-item:focus-visible .gallery-item-overlay {
  opacity: 1;
}

.gallery-item:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.5);
  outline-offset: -1px;
}

/* ── Lightbox ────────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.4s;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

/* Image stage */
.lightbox-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 4rem 5rem;
}

@media (max-width: 640px) {
  .lightbox-stage {
    padding: 4rem 1rem;
  }
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  transition:
    opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Lightbox Loader ─────────────────────────────────────────────────────────── */
.lightbox-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border: 1.5px solid rgba(255,255,255,0.15);
  border-top-color: rgba(255,255,255,0.8);
  border-radius: 50%;
  animation: lb-spin 0.75s linear infinite;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

/* ── Lightbox Controls ───────────────────────────────────────────────────────── */
.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.75rem;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  z-index: 10;
  padding: 0;
}

.lightbox-close:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.5);
  color: #fff;
}

.lightbox-close:focus-visible {
  outline: 1px solid rgba(255,255,255,0.5);
  outline-offset: 2px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  z-index: 10;
  padding: 0;
}

.lightbox-nav:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.4);
  color: #fff;
}

.lightbox-nav:focus-visible {
  outline: 1px solid rgba(255,255,255,0.5);
  outline-offset: 2px;
}

.lightbox-prev {
  left: 1.25rem;
}

.lightbox-next {
  right: 1.25rem;
}

@media (max-width: 640px) {
  .lightbox-prev { left: 0.5rem; }
  .lightbox-next { right: 0.5rem; }
  .lightbox-nav  { width: 40px; height: 40px; }
}

/* ── Lightbox Caption Bar ────────────────────────────────────────────────────── */
.lightbox-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.lightbox-caption {
  font-family: var(--font-title);
  font-size: 0.75rem;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lightbox-brand {
  font-family: var(--font-title);
  font-size: 0.7rem;
  color: rgba(255,255,255,0.2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

/* ── Gallery Spacer ─────────────────────────────────────────────────────────── */
.gallery-spacer {
  height: 2.5rem;
}
