/* ============================================================
   CHRONOFALL — media gallery (#media) + lightbox
   ============================================================ */

/* ============ Track ============ */
.gallery {
  position: relative;
}

.gallery__track {
  display: flex;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: .25rem .25rem 1.4rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--purple-deep) transparent;
}
.gallery__track::-webkit-scrollbar { height: 6px; }
.gallery__track::-webkit-scrollbar-track { background: rgba(168, 85, 247, .08); }
.gallery__track::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, var(--purple-deep), var(--purple));
  border-radius: 3px;
}

.gallery__item {
  flex: 0 0 clamp(264px, 76vw, 560px);
  scroll-snap-align: center;
}

.gallery__card {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  background: linear-gradient(180deg, rgba(168, 85, 247, .08), rgba(13, 7, 22, .9));
  border: 1px solid rgba(168, 85, 247, .3);
  transition: border-color .3s, box-shadow .3s, transform .3s;
}
.gallery__card:hover,
.gallery__card:focus-visible {
  border-color: var(--purple);
  box-shadow: 0 0 34px rgba(168, 85, 247, .3), inset 0 0 24px rgba(168, 85, 247, .07);
}
.gallery__card:focus-visible {
  outline: 1px solid var(--pink);
  outline-offset: 3px;
}
.gallery__card:active { transform: scale(.985); }

.gallery__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--bg2, #0d0716);
}

.gallery__caption {
  display: block;
  padding: .85rem 1rem .95rem;
  font-size: .78rem;
  letter-spacing: .06em;
  line-height: 1.5;
  color: var(--text-dim);
  border-top: 1px solid rgba(168, 85, 247, .22);
}
.gallery__card:hover .gallery__caption { color: var(--purple-soft); }

/* ============ Arrows ============ */
.gallery__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-65%);
  z-index: 5;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--purple-soft);
  background: rgba(7, 4, 13, .72);
  border: 1px solid rgba(168, 85, 247, .5);
  border-radius: 50%;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 18px rgba(168, 85, 247, .3);
  transition: color .25s, border-color .25s, box-shadow .25s, background .25s;
}
.gallery__arrow svg { display: block; }
.gallery__arrow:hover,
.gallery__arrow:focus-visible {
  color: var(--pink);
  border-color: var(--purple);
  background: rgba(107, 33, 168, .45);
  box-shadow: 0 0 28px rgba(168, 85, 247, .6);
}
.gallery__arrow:active { transform: translateY(-65%) scale(.92); }
.gallery__arrow--prev { left: -10px; }
.gallery__arrow--next { right: -10px; }

@media (max-width: 760px) {
  .gallery__arrow {
    width: 40px;
    height: 40px;
    box-shadow: 0 0 12px rgba(168, 85, 247, .25);
  }
  .gallery__arrow--prev { left: -6px; }
  .gallery__arrow--next { right: -6px; }
}

/* ============ Lightbox ============ */
body.glb-lock { overflow: hidden; }

.glb {
  position: fixed;
  inset: 0;
  z-index: 9400; /* below cursor (10000), above nav (7000) */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility 0s linear .3s;
}
.glb.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity .3s ease;
}

.glb__backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 45%, rgba(107, 33, 168, .22), transparent 70%),
    rgba(4, 2, 8, .93);
  backdrop-filter: blur(8px);
}

.glb__figure {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: min(1100px, 100%);
  text-align: center;
  pointer-events: none; /* clicks fall through to backdrop... */
}
.glb__img {
  pointer-events: auto; /* ...except on the image itself */
  display: block;
  max-width: 100%;
  max-height: min(72vh, 72svh);
  width: auto;
  height: auto;
  margin: 0 auto;
  border: 1px solid rgba(168, 85, 247, .55);
  box-shadow:
    0 0 50px rgba(168, 85, 247, .35),
    0 0 130px rgba(107, 33, 168, .3);
  transform: scale(.96);
  transition: transform .35s cubic-bezier(.2, .7, .2, 1);
}
.glb.is-open .glb__img { transform: none; }

.glb__caption {
  margin-top: 1.1rem;
  font-size: .8rem;
  letter-spacing: .12em;
  line-height: 1.6;
  color: var(--text-dim);
}
.glb__caption::before {
  content: '';
  display: block;
  width: 44px;
  height: 1px;
  margin: 0 auto .8rem;
  background: linear-gradient(90deg, transparent, var(--purple), transparent);
  box-shadow: 0 0 8px var(--purple);
}

.glb__close {
  position: absolute;
  top: max(.9rem, env(safe-area-inset-top));
  right: max(.9rem, env(safe-area-inset-right));
  z-index: 2;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--purple-soft);
  background: rgba(7, 4, 13, .7);
  border: 1px solid rgba(168, 85, 247, .5);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(168, 85, 247, .35);
  transition: color .25s, border-color .25s, box-shadow .25s, transform .25s;
}
.glb__close:hover,
.glb__close:focus-visible {
  color: var(--pink);
  border-color: var(--purple);
  box-shadow: 0 0 30px rgba(168, 85, 247, .7);
  transform: rotate(90deg);
}
.glb__close:focus-visible {
  outline: 1px solid var(--pink);
  outline-offset: 3px;
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  .gallery__track { scroll-behavior: auto; }
  .glb, .glb__img, .glb__close, .gallery__card { transition: none; }
}
