/* ─── Static background word ────────────────────────────────────── */
.gallery-bg-word {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-body);
  font-size: clamp(3.5rem, 8vw, 9rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  opacity: 0.12;
  pointer-events: none;
  user-select: none;
  z-index: 2;
  white-space: nowrap;
}

/* ─── Gallery page ───────────────────────────────────────────────── */
.page-gallery { background: var(--bg); }
.page-gallery .site-header { background: var(--bg); }
.page-gallery .site-header.is-scrolled { background: transparent; }

.gallery-page {
  position: relative;
  padding: calc(72px + 3rem) var(--gutter) 8rem;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ─── Project group ──────────────────────────────────────────────── */
.gallery-group {
  margin-bottom: 7rem;
}

.gallery-group-label {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.32;
  margin-bottom: 1.75rem;
  font-style: normal;
}

/* ─── Single scatter canvas ──────────────────────────────────────── */
.gallery-scatter-canvas {
  position: relative;
  width: 100%;
}

/* ─── Gallery item ───────────────────────────────────────────────── */
.gallery-item {
  /* position: absolute + size + animation set by JS */
  cursor: pointer;
  margin: 0;
  will-change: transform;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
  transition: opacity 0.22s ease;
}

.gallery-item:hover img { opacity: 0.82; }
.gallery-item:hover { animation-play-state: paused !important; }

.gallery-caption {
  display: block;
  font-family: var(--font-body);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.32;
  margin-top: 0.45rem;
}

/* ─── Float keyframes ────────────────────────────────────────────── */
@keyframes float-a {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  30%  { transform: translate(8px, -18px) rotate(0.6deg); }
  65%  { transform: translate(-5px, -10px) rotate(-0.4deg); }
}
@keyframes float-b {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  35%  { transform: translate(-10px, -14px) rotate(-0.8deg); }
  70%  { transform: translate(6px, -22px) rotate(0.5deg); }
}
@keyframes float-c {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  40%  { transform: translate(12px, -16px) rotate(0.9deg); }
  80%  { transform: translate(-8px, -20px) rotate(-0.6deg); }
}
@keyframes float-d {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25%  { transform: translate(-6px, -12px) rotate(-0.5deg); }
  55%  { transform: translate(10px, -26px) rotate(0.7deg); }
  80%  { transform: translate(-4px, -16px) rotate(-0.3deg); }
}
@keyframes float-e {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  20%  { transform: translate(-20px, -8px) rotate(-1.2deg); }
  55%  { transform: translate(16px, -18px) rotate(0.8deg); }
  80%  { transform: translate(-8px, -24px) rotate(-0.5deg); }
}
@keyframes float-f {
  0%, 100% { transform: translate(0, 0); }
  15%  { transform: translate(6px, -28px); }
  45%  { transform: translate(-12px, -18px); }
  75%  { transform: translate(8px, -32px); }
}
@keyframes float-g {
  0%, 100% { transform: translate(0, 0) rotate(0.4deg); }
  30%  { transform: translate(14px, -12px) rotate(-0.7deg); }
  60%  { transform: translate(-10px, -20px) rotate(0.5deg); }
  85%  { transform: translate(6px, -10px) rotate(-0.3deg); }
}
@keyframes float-h {
  0%, 100% { transform: translate(0, 0); }
  18%  { transform: translate(-16px, -7px); }
  42%  { transform: translate(10px, -22px); }
  65%  { transform: translate(-5px, -14px); }
  88%  { transform: translate(12px, -26px); }
}

/* ─── Lightbox ───────────────────────────────────────────────────── */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 8, 0.95);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.gallery-lightbox.visible {
  opacity: 1;
  pointer-events: auto;
}

.gallery-lightbox-img {
  max-width: 84vw;
  max-height: 84vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 3px;
  transition: opacity 0.16s ease;
}
.gallery-lightbox-img.fading { opacity: 0; }

.gallery-lb-close {
  position: absolute;
  top: 1.75rem; right: 2rem;
  color: rgba(255,255,255,0.45);
  font-size: 1.1rem;
  line-height: 1;
  background: none; border: none; cursor: pointer;
  transition: color 0.18s;
  padding: 0.35rem;
  font-family: var(--font-body);
}
.gallery-lb-close:hover { color: #fff; }

.gallery-lb-prev,
.gallery-lb-next {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  color: rgba(255,255,255,0.35);
  font-size: 1rem;
  background: none; border: none; cursor: pointer;
  padding: 1.5rem;
  transition: color 0.18s;
  font-family: var(--font-body);
}
.gallery-lb-prev:hover,
.gallery-lb-next:hover { color: rgba(255,255,255,0.8); }
.gallery-lb-prev { left: 0.5rem; }
.gallery-lb-next { right: 0.5rem; }

.gallery-lb-project {
  position: absolute;
  bottom: 1.75rem; left: 2rem;
  font-family: var(--font-body);
  font-size: 0.62rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.06em;
}

.gallery-lb-counter {
  position: absolute;
  bottom: 1.75rem; left: 50%; transform: translateX(-50%);
  font-family: var(--font-body);
  font-size: 0.62rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.05em;
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .gallery-page { padding-top: calc(64px + 3rem); }
  .gallery-group { margin-bottom: 4.5rem; }

  /* Bigger touch targets for lightbox */
  .gallery-lb-prev,
  .gallery-lb-next {
    padding: 1.75rem;
    font-size: 1.75rem;
  }
  .gallery-lb-close {
    top: 1rem;
    right: 1rem;
    padding: 0.75rem;
    font-size: 1.35rem;
  }

  .gallery-bg-word { display: none; }

  /* Gallery scatter → 1-column grid on mobile (JS also handles this) */
  .gallery-scatter-canvas {
    overflow-x: hidden;
  }
}

@media (max-width: 480px) {
  .gallery-group { margin-bottom: 3rem; }
}
