/* ============================================================
   PIEDRASANTA.SPACE — Gallery
   ============================================================ */

/* ── Gallery Section ── */
.gallery {
  padding-block: var(--sp-24);
  background: var(--surface-base);
  min-height: 100svh;
}

.gallery__header {
  max-width: 640px;
  margin-bottom: var(--sp-16);
}

.gallery__title {
  font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl));
  margin-bottom: var(--sp-4);
}

.gallery__body {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ── Grid ── */
.gallery__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-6);
  transition: opacity var(--dur-slow) var(--ease-out);
}

/* Hover: dim all siblings when hovering the grid */
.gallery__grid--has-hover .gallery__item:not(:hover) {
  opacity: 0.3;
  filter: brightness(0.4) saturate(0.3);
}

.gallery__item {
  position: relative;
  cursor: pointer;
  transition: opacity var(--dur-base) var(--ease-out),
              filter var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
  transform: translateZ(0);
}

.gallery__item:hover {
  transform: translateY(-4px);
}

/* ── Image Wrapper (3:2 aspect ratio) ── */
.gallery__image-wrap {
  position: relative;
  aspect-ratio: 3/2;
  overflow: hidden;
  background: var(--surface-03);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--dur-base) var(--ease-out);
}

.gallery__item:hover .gallery__image-wrap {
  border-color: var(--accent-border);
}

.gallery__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-in-out),
              filter var(--dur-slow) var(--ease-out);
}

.gallery__item:hover .gallery__image {
  transform: scale(1.04);
}

/* ── Placeholder (when no real image) ── */
.gallery__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-03);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-align: center;
  padding: var(--sp-4);
}

.gallery__placeholder svg {
  width: 36px;
  height: 36px;
  color: var(--text-tertiary);
  opacity: 0.4;
  margin-bottom: var(--sp-2);
}

/* ── Caption ── */
.gallery__caption {
  padding-block: var(--sp-4);
}

.gallery__caption-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.gallery__caption-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease-out);
  padding: var(--sp-8);
}

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

.lightbox__content {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox__image {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--border-mid);
  background: var(--surface-base);
}

.lightbox__placeholder {
  width: 80vw;
  max-width: 900px;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-02);
  border: 1px solid var(--border-mid);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.1em;
}

.lightbox__caption {
  margin-top: var(--sp-6);
  text-align: center;
}

.lightbox__caption-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--text-primary);
}

.lightbox__caption-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: var(--sp-2);
}

/* ── Close Button ── */
.lightbox__close {
  position: fixed;
  top: var(--sp-8);
  right: var(--sp-8);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-mid);
  background: rgba(10, 10, 12, 0.6);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
  z-index: 210;
}

.lightbox__close:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: rgba(10, 10, 12, 0.9);
}

/* ── Body scroll lock ── */
body.lightbox-open {
  overflow: hidden;
}

/* ── Responsive ── */
@media (max-width: 767px) {
  .gallery {
    padding-block: var(--sp-16);
  }

  .gallery__grid {
    grid-template-columns: 1fr;
    gap: var(--sp-4);
  }

  .lightbox {
    padding: var(--sp-4);
  }

  .lightbox__content {
    max-width: 100vw;
    max-height: 80vh;
  }

  .lightbox__close {
    top: var(--sp-4);
    right: var(--sp-4);
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .gallery__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery__item,
  .gallery__image,
  .lightbox {
    transition: none;
  }

  .gallery__grid--has-hover .gallery__item:not(:hover) {
    opacity: 1;
    filter: none;
  }
}
